babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. */
  1129. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1130. /**
  1131. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1132. * @param data contains the texture data
  1133. * @param texture defines the BabylonJS internal texture
  1134. * @param callback defines the method to call once ready to upload
  1135. */
  1136. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/IPipelineContext" {
  1140. /**
  1141. * Class used to store and describe the pipeline context associated with an effect
  1142. */
  1143. export interface IPipelineContext {
  1144. /**
  1145. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1146. */
  1147. isAsync: boolean;
  1148. /**
  1149. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1150. */
  1151. isReady: boolean;
  1152. /** @hidden */
  1153. _getVertexShaderCode(): string | null;
  1154. /** @hidden */
  1155. _getFragmentShaderCode(): string | null;
  1156. /** @hidden */
  1157. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1158. }
  1159. }
  1160. declare module "babylonjs/Meshes/dataBuffer" {
  1161. /**
  1162. * Class used to store gfx data (like WebGLBuffer)
  1163. */
  1164. export class DataBuffer {
  1165. /**
  1166. * Gets or sets the number of objects referencing this buffer
  1167. */
  1168. references: number;
  1169. /** Gets or sets the size of the underlying buffer */
  1170. capacity: number;
  1171. /**
  1172. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1173. */
  1174. is32Bits: boolean;
  1175. /**
  1176. * Gets the underlying buffer
  1177. */
  1178. get underlyingResource(): any;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1182. /** @hidden */
  1183. export interface IShaderProcessor {
  1184. attributeProcessor?: (attribute: string) => string;
  1185. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1186. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1187. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1188. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1189. lineProcessor?: (line: string, isFragment: boolean) => string;
  1190. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1191. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1195. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1196. /** @hidden */
  1197. export interface ProcessingOptions {
  1198. defines: string[];
  1199. indexParameters: any;
  1200. isFragment: boolean;
  1201. shouldUseHighPrecisionShader: boolean;
  1202. supportsUniformBuffers: boolean;
  1203. shadersRepository: string;
  1204. includesShadersStore: {
  1205. [key: string]: string;
  1206. };
  1207. processor?: IShaderProcessor;
  1208. version: string;
  1209. platformName: string;
  1210. lookForClosingBracketForUniformBuffer?: boolean;
  1211. }
  1212. }
  1213. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1214. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1215. /** @hidden */
  1216. export class ShaderCodeNode {
  1217. line: string;
  1218. children: ShaderCodeNode[];
  1219. additionalDefineKey?: string;
  1220. additionalDefineValue?: string;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. process(preprocessors: {
  1225. [key: string]: string;
  1226. }, options: ProcessingOptions): string;
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1230. /** @hidden */
  1231. export class ShaderCodeCursor {
  1232. private _lines;
  1233. lineIndex: number;
  1234. get currentLine(): string;
  1235. get canRead(): boolean;
  1236. set lines(value: string[]);
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1240. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1241. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1242. /** @hidden */
  1243. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1244. process(preprocessors: {
  1245. [key: string]: string;
  1246. }, options: ProcessingOptions): string;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1250. /** @hidden */
  1251. export class ShaderDefineExpression {
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. private static _OperatorPriority;
  1256. private static _Stack;
  1257. static postfixToInfix(postfix: string[]): string;
  1258. static infixToPostfix(infix: string): string[];
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1262. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderCodeTestNode extends ShaderCodeNode {
  1266. testExpression: ShaderDefineExpression;
  1267. isValid(preprocessors: {
  1268. [key: string]: string;
  1269. }): boolean;
  1270. }
  1271. }
  1272. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1273. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1274. /** @hidden */
  1275. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1276. define: string;
  1277. not: boolean;
  1278. constructor(define: string, not?: boolean);
  1279. isTrue(preprocessors: {
  1280. [key: string]: string;
  1281. }): boolean;
  1282. }
  1283. }
  1284. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1285. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1286. /** @hidden */
  1287. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1288. leftOperand: ShaderDefineExpression;
  1289. rightOperand: ShaderDefineExpression;
  1290. isTrue(preprocessors: {
  1291. [key: string]: string;
  1292. }): boolean;
  1293. }
  1294. }
  1295. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1296. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1297. /** @hidden */
  1298. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1299. leftOperand: ShaderDefineExpression;
  1300. rightOperand: ShaderDefineExpression;
  1301. isTrue(preprocessors: {
  1302. [key: string]: string;
  1303. }): boolean;
  1304. }
  1305. }
  1306. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1307. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1308. /** @hidden */
  1309. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1310. define: string;
  1311. operand: string;
  1312. testValue: string;
  1313. constructor(define: string, operand: string, testValue: string);
  1314. isTrue(preprocessors: {
  1315. [key: string]: string;
  1316. }): boolean;
  1317. }
  1318. }
  1319. declare module "babylonjs/Offline/IOfflineProvider" {
  1320. /**
  1321. * Class used to enable access to offline support
  1322. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1323. */
  1324. export interface IOfflineProvider {
  1325. /**
  1326. * Gets a boolean indicating if scene must be saved in the database
  1327. */
  1328. enableSceneOffline: boolean;
  1329. /**
  1330. * Gets a boolean indicating if textures must be saved in the database
  1331. */
  1332. enableTexturesOffline: boolean;
  1333. /**
  1334. * Open the offline support and make it available
  1335. * @param successCallback defines the callback to call on success
  1336. * @param errorCallback defines the callback to call on error
  1337. */
  1338. open(successCallback: () => void, errorCallback: () => void): void;
  1339. /**
  1340. * Loads an image from the offline support
  1341. * @param url defines the url to load from
  1342. * @param image defines the target DOM image
  1343. */
  1344. loadImage(url: string, image: HTMLImageElement): void;
  1345. /**
  1346. * Loads a file from offline support
  1347. * @param url defines the URL to load from
  1348. * @param sceneLoaded defines a callback to call on success
  1349. * @param progressCallBack defines a callback to call when progress changed
  1350. * @param errorCallback defines a callback to call on error
  1351. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1352. */
  1353. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/filesInputStore" {
  1357. /**
  1358. * Class used to help managing file picking and drag'n'drop
  1359. * File Storage
  1360. */
  1361. export class FilesInputStore {
  1362. /**
  1363. * List of files ready to be loaded
  1364. */
  1365. static FilesToLoad: {
  1366. [key: string]: File;
  1367. };
  1368. }
  1369. }
  1370. declare module "babylonjs/Misc/retryStrategy" {
  1371. import { WebRequest } from "babylonjs/Misc/webRequest";
  1372. /**
  1373. * Class used to define a retry strategy when error happens while loading assets
  1374. */
  1375. export class RetryStrategy {
  1376. /**
  1377. * Function used to defines an exponential back off strategy
  1378. * @param maxRetries defines the maximum number of retries (3 by default)
  1379. * @param baseInterval defines the interval between retries
  1380. * @returns the strategy function to use
  1381. */
  1382. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1383. }
  1384. }
  1385. declare module "babylonjs/Misc/baseError" {
  1386. /**
  1387. * @ignore
  1388. * Application error to support additional information when loading a file
  1389. */
  1390. export abstract class BaseError extends Error {
  1391. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1392. }
  1393. }
  1394. declare module "babylonjs/Misc/fileTools" {
  1395. import { WebRequest } from "babylonjs/Misc/webRequest";
  1396. import { Nullable } from "babylonjs/types";
  1397. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1398. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1399. import { BaseError } from "babylonjs/Misc/baseError";
  1400. /** @ignore */
  1401. export class LoadFileError extends BaseError {
  1402. request?: WebRequest;
  1403. file?: File;
  1404. /**
  1405. * Creates a new LoadFileError
  1406. * @param message defines the message of the error
  1407. * @param request defines the optional web request
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, object?: WebRequest | File);
  1411. }
  1412. /** @ignore */
  1413. export class RequestFileError extends BaseError {
  1414. request: WebRequest;
  1415. /**
  1416. * Creates a new LoadFileError
  1417. * @param message defines the message of the error
  1418. * @param request defines the optional web request
  1419. */
  1420. constructor(message: string, request: WebRequest);
  1421. }
  1422. /** @ignore */
  1423. export class ReadFileError extends BaseError {
  1424. file: File;
  1425. /**
  1426. * Creates a new ReadFileError
  1427. * @param message defines the message of the error
  1428. * @param file defines the optional file
  1429. */
  1430. constructor(message: string, file: File);
  1431. }
  1432. /**
  1433. * @hidden
  1434. */
  1435. export class FileTools {
  1436. /**
  1437. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1438. */
  1439. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1440. /**
  1441. * Gets or sets the base URL to use to load assets
  1442. */
  1443. static BaseUrl: string;
  1444. /**
  1445. * Default behaviour for cors in the application.
  1446. * It can be a string if the expected behavior is identical in the entire app.
  1447. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1448. */
  1449. static CorsBehavior: string | ((url: string | string[]) => string);
  1450. /**
  1451. * Gets or sets a function used to pre-process url before using them to load assets
  1452. */
  1453. static PreprocessUrl: (url: string) => string;
  1454. /**
  1455. * Removes unwanted characters from an url
  1456. * @param url defines the url to clean
  1457. * @returns the cleaned url
  1458. */
  1459. private static _CleanUrl;
  1460. /**
  1461. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1462. * @param url define the url we are trying
  1463. * @param element define the dom element where to configure the cors policy
  1464. */
  1465. static SetCorsBehavior(url: string | string[], element: {
  1466. crossOrigin: string | null;
  1467. }): void;
  1468. /**
  1469. * Loads an image as an HTMLImageElement.
  1470. * @param input url string, ArrayBuffer, or Blob to load
  1471. * @param onLoad callback called when the image successfully loads
  1472. * @param onError callback called when the image fails to load
  1473. * @param offlineProvider offline provider for caching
  1474. * @param mimeType optional mime type
  1475. * @returns the HTMLImageElement of the loaded image
  1476. */
  1477. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1478. /**
  1479. * Reads a file from a File object
  1480. * @param file defines the file to load
  1481. * @param onSuccess defines the callback to call when data is loaded
  1482. * @param onProgress defines the callback to call during loading process
  1483. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1484. * @param onError defines the callback to call when an error occurs
  1485. * @returns a file request object
  1486. */
  1487. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1488. /**
  1489. * Loads a file from a url
  1490. * @param url url to load
  1491. * @param onSuccess callback called when the file successfully loads
  1492. * @param onProgress callback called while file is loading (if the server supports this mode)
  1493. * @param offlineProvider defines the offline provider for caching
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @returns a file request object
  1497. */
  1498. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1499. /**
  1500. * Loads a file
  1501. * @param url url to load
  1502. * @param onSuccess callback called when the file successfully loads
  1503. * @param onProgress callback called while file is loading (if the server supports this mode)
  1504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1505. * @param onError callback called when the file fails to load
  1506. * @param onOpened callback called when the web request is opened
  1507. * @returns a file request object
  1508. */
  1509. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1510. /**
  1511. * Checks if the loaded document was accessed via `file:`-Protocol.
  1512. * @returns boolean
  1513. */
  1514. static IsFileURL(): boolean;
  1515. }
  1516. }
  1517. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1518. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1519. import { WebRequest } from "babylonjs/Misc/webRequest";
  1520. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1521. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1522. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1523. /** @hidden */
  1524. export class ShaderProcessor {
  1525. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1526. private static _ProcessPrecision;
  1527. private static _ExtractOperation;
  1528. private static _BuildSubExpression;
  1529. private static _BuildExpression;
  1530. private static _MoveCursorWithinIf;
  1531. private static _MoveCursor;
  1532. private static _EvaluatePreProcessors;
  1533. private static _PreparePreProcessors;
  1534. private static _ProcessShaderConversion;
  1535. private static _ProcessIncludes;
  1536. /**
  1537. * Loads a file from a url
  1538. * @param url url to load
  1539. * @param onSuccess callback called when the file successfully loads
  1540. * @param onProgress callback called while file is loading (if the server supports this mode)
  1541. * @param offlineProvider defines the offline provider for caching
  1542. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1543. * @param onError callback called when the file fails to load
  1544. * @returns a file request object
  1545. * @hidden
  1546. */
  1547. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1548. }
  1549. }
  1550. declare module "babylonjs/Maths/math.like" {
  1551. import { float, int, DeepImmutable } from "babylonjs/types";
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IColor4Like {
  1556. r: float;
  1557. g: float;
  1558. b: float;
  1559. a: float;
  1560. }
  1561. /**
  1562. * @hidden
  1563. */
  1564. export interface IColor3Like {
  1565. r: float;
  1566. g: float;
  1567. b: float;
  1568. }
  1569. /**
  1570. * @hidden
  1571. */
  1572. export interface IVector4Like {
  1573. x: float;
  1574. y: float;
  1575. z: float;
  1576. w: float;
  1577. }
  1578. /**
  1579. * @hidden
  1580. */
  1581. export interface IVector3Like {
  1582. x: float;
  1583. y: float;
  1584. z: float;
  1585. }
  1586. /**
  1587. * @hidden
  1588. */
  1589. export interface IVector2Like {
  1590. x: float;
  1591. y: float;
  1592. }
  1593. /**
  1594. * @hidden
  1595. */
  1596. export interface IMatrixLike {
  1597. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1598. updateFlag: int;
  1599. }
  1600. /**
  1601. * @hidden
  1602. */
  1603. export interface IViewportLike {
  1604. x: float;
  1605. y: float;
  1606. width: float;
  1607. height: float;
  1608. }
  1609. /**
  1610. * @hidden
  1611. */
  1612. export interface IPlaneLike {
  1613. normal: IVector3Like;
  1614. d: float;
  1615. normalize(): void;
  1616. }
  1617. }
  1618. declare module "babylonjs/Materials/iEffectFallbacks" {
  1619. import { Effect } from "babylonjs/Materials/effect";
  1620. /**
  1621. * Interface used to define common properties for effect fallbacks
  1622. */
  1623. export interface IEffectFallbacks {
  1624. /**
  1625. * Removes the defines that should be removed when falling back.
  1626. * @param currentDefines defines the current define statements for the shader.
  1627. * @param effect defines the current effect we try to compile
  1628. * @returns The resulting defines with defines of the current rank removed.
  1629. */
  1630. reduce(currentDefines: string, effect: Effect): string;
  1631. /**
  1632. * Removes the fallback from the bound mesh.
  1633. */
  1634. unBindMesh(): void;
  1635. /**
  1636. * Checks to see if more fallbacks are still availible.
  1637. */
  1638. hasMoreFallbacks: boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1642. /**
  1643. * Class used to evalaute queries containing `and` and `or` operators
  1644. */
  1645. export class AndOrNotEvaluator {
  1646. /**
  1647. * Evaluate a query
  1648. * @param query defines the query to evaluate
  1649. * @param evaluateCallback defines the callback used to filter result
  1650. * @returns true if the query matches
  1651. */
  1652. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1653. private static _HandleParenthesisContent;
  1654. private static _SimplifyNegation;
  1655. }
  1656. }
  1657. declare module "babylonjs/Misc/tags" {
  1658. /**
  1659. * Class used to store custom tags
  1660. */
  1661. export class Tags {
  1662. /**
  1663. * Adds support for tags on the given object
  1664. * @param obj defines the object to use
  1665. */
  1666. static EnableFor(obj: any): void;
  1667. /**
  1668. * Removes tags support
  1669. * @param obj defines the object to use
  1670. */
  1671. static DisableFor(obj: any): void;
  1672. /**
  1673. * Gets a boolean indicating if the given object has tags
  1674. * @param obj defines the object to use
  1675. * @returns a boolean
  1676. */
  1677. static HasTags(obj: any): boolean;
  1678. /**
  1679. * Gets the tags available on a given object
  1680. * @param obj defines the object to use
  1681. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1682. * @returns the tags
  1683. */
  1684. static GetTags(obj: any, asString?: boolean): any;
  1685. /**
  1686. * Adds tags to an object
  1687. * @param obj defines the object to use
  1688. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1689. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1690. */
  1691. static AddTagsTo(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _AddTagTo(obj: any, tag: string): void;
  1696. /**
  1697. * Removes specific tags from a specific object
  1698. * @param obj defines the object to use
  1699. * @param tagsString defines the tags to remove
  1700. */
  1701. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1702. /**
  1703. * @hidden
  1704. */
  1705. static _RemoveTagFrom(obj: any, tag: string): void;
  1706. /**
  1707. * Defines if tags hosted on an object match a given query
  1708. * @param obj defines the object to use
  1709. * @param tagsQuery defines the tag query
  1710. * @returns a boolean
  1711. */
  1712. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1713. }
  1714. }
  1715. declare module "babylonjs/Maths/math.scalar" {
  1716. /**
  1717. * Scalar computation library
  1718. */
  1719. export class Scalar {
  1720. /**
  1721. * Two pi constants convenient for computation.
  1722. */
  1723. static TwoPi: number;
  1724. /**
  1725. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1726. * @param a number
  1727. * @param b number
  1728. * @param epsilon (default = 1.401298E-45)
  1729. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. */
  1731. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1732. /**
  1733. * Returns a string : the upper case translation of the number i to hexadecimal.
  1734. * @param i number
  1735. * @returns the upper case translation of the number i to hexadecimal.
  1736. */
  1737. static ToHex(i: number): string;
  1738. /**
  1739. * Returns -1 if value is negative and +1 is value is positive.
  1740. * @param value the value
  1741. * @returns the value itself if it's equal to zero.
  1742. */
  1743. static Sign(value: number): number;
  1744. /**
  1745. * Returns the value itself if it's between min and max.
  1746. * Returns min if the value is lower than min.
  1747. * Returns max if the value is greater than max.
  1748. * @param value the value to clmap
  1749. * @param min the min value to clamp to (default: 0)
  1750. * @param max the max value to clamp to (default: 1)
  1751. * @returns the clamped value
  1752. */
  1753. static Clamp(value: number, min?: number, max?: number): number;
  1754. /**
  1755. * the log2 of value.
  1756. * @param value the value to compute log2 of
  1757. * @returns the log2 of value.
  1758. */
  1759. static Log2(value: number): number;
  1760. /**
  1761. * Loops the value, so that it is never larger than length and never smaller than 0.
  1762. *
  1763. * This is similar to the modulo operator but it works with floating point numbers.
  1764. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1765. * With t = 5 and length = 2.5, the result would be 0.0.
  1766. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1767. * @param value the value
  1768. * @param length the length
  1769. * @returns the looped value
  1770. */
  1771. static Repeat(value: number, length: number): number;
  1772. /**
  1773. * Normalize the value between 0.0 and 1.0 using min and max values
  1774. * @param value value to normalize
  1775. * @param min max to normalize between
  1776. * @param max min to normalize between
  1777. * @returns the normalized value
  1778. */
  1779. static Normalize(value: number, min: number, max: number): number;
  1780. /**
  1781. * Denormalize the value from 0.0 and 1.0 using min and max values
  1782. * @param normalized value to denormalize
  1783. * @param min max to denormalize between
  1784. * @param max min to denormalize between
  1785. * @returns the denormalized value
  1786. */
  1787. static Denormalize(normalized: number, min: number, max: number): number;
  1788. /**
  1789. * Calculates the shortest difference between two given angles given in degrees.
  1790. * @param current current angle in degrees
  1791. * @param target target angle in degrees
  1792. * @returns the delta
  1793. */
  1794. static DeltaAngle(current: number, target: number): number;
  1795. /**
  1796. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1797. * @param tx value
  1798. * @param length length
  1799. * @returns The returned value will move back and forth between 0 and length
  1800. */
  1801. static PingPong(tx: number, length: number): number;
  1802. /**
  1803. * Interpolates between min and max with smoothing at the limits.
  1804. *
  1805. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1806. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1807. * @param from from
  1808. * @param to to
  1809. * @param tx value
  1810. * @returns the smooth stepped value
  1811. */
  1812. static SmoothStep(from: number, to: number, tx: number): number;
  1813. /**
  1814. * Moves a value current towards target.
  1815. *
  1816. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1817. * Negative values of maxDelta pushes the value away from target.
  1818. * @param current current value
  1819. * @param target target value
  1820. * @param maxDelta max distance to move
  1821. * @returns resulting value
  1822. */
  1823. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1824. /**
  1825. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1826. *
  1827. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1828. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1829. * @param current current value
  1830. * @param target target value
  1831. * @param maxDelta max distance to move
  1832. * @returns resulting angle
  1833. */
  1834. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1835. /**
  1836. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1837. * @param start start value
  1838. * @param end target value
  1839. * @param amount amount to lerp between
  1840. * @returns the lerped value
  1841. */
  1842. static Lerp(start: number, end: number, amount: number): number;
  1843. /**
  1844. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1845. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1846. * @param start start value
  1847. * @param end target value
  1848. * @param amount amount to lerp between
  1849. * @returns the lerped value
  1850. */
  1851. static LerpAngle(start: number, end: number, amount: number): number;
  1852. /**
  1853. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1854. * @param a start value
  1855. * @param b target value
  1856. * @param value value between a and b
  1857. * @returns the inverseLerp value
  1858. */
  1859. static InverseLerp(a: number, b: number, value: number): number;
  1860. /**
  1861. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1862. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1863. * @param value1 spline value
  1864. * @param tangent1 spline value
  1865. * @param value2 spline value
  1866. * @param tangent2 spline value
  1867. * @param amount input value
  1868. * @returns hermite result
  1869. */
  1870. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1871. /**
  1872. * Returns a random float number between and min and max values
  1873. * @param min min value of random
  1874. * @param max max value of random
  1875. * @returns random value
  1876. */
  1877. static RandomRange(min: number, max: number): number;
  1878. /**
  1879. * This function returns percentage of a number in a given range.
  1880. *
  1881. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1882. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1883. * @param number to convert to percentage
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the percentage
  1887. */
  1888. static RangeToPercent(number: number, min: number, max: number): number;
  1889. /**
  1890. * This function returns number that corresponds to the percentage in a given range.
  1891. *
  1892. * PercentToRange(0.34,0,100) will return 34.
  1893. * @param percent to convert to number
  1894. * @param min min range
  1895. * @param max max range
  1896. * @returns the number
  1897. */
  1898. static PercentToRange(percent: number, min: number, max: number): number;
  1899. /**
  1900. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1901. * @param angle The angle to normalize in radian.
  1902. * @return The converted angle.
  1903. */
  1904. static NormalizeRadians(angle: number): number;
  1905. }
  1906. }
  1907. declare module "babylonjs/Maths/math.constants" {
  1908. /**
  1909. * Constant used to convert a value to gamma space
  1910. * @ignorenaming
  1911. */
  1912. export const ToGammaSpace: number;
  1913. /**
  1914. * Constant used to convert a value to linear space
  1915. * @ignorenaming
  1916. */
  1917. export const ToLinearSpace = 2.2;
  1918. /**
  1919. * Constant used to define the minimal number value in Babylon.js
  1920. * @ignorenaming
  1921. */
  1922. let Epsilon: number;
  1923. export { Epsilon };
  1924. }
  1925. declare module "babylonjs/Maths/math.viewport" {
  1926. /**
  1927. * Class used to represent a viewport on screen
  1928. */
  1929. export class Viewport {
  1930. /** viewport left coordinate */
  1931. x: number;
  1932. /** viewport top coordinate */
  1933. y: number;
  1934. /**viewport width */
  1935. width: number;
  1936. /** viewport height */
  1937. height: number;
  1938. /**
  1939. * Creates a Viewport object located at (x, y) and sized (width, height)
  1940. * @param x defines viewport left coordinate
  1941. * @param y defines viewport top coordinate
  1942. * @param width defines the viewport width
  1943. * @param height defines the viewport height
  1944. */
  1945. constructor(
  1946. /** viewport left coordinate */
  1947. x: number,
  1948. /** viewport top coordinate */
  1949. y: number,
  1950. /**viewport width */
  1951. width: number,
  1952. /** viewport height */
  1953. height: number);
  1954. /**
  1955. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1956. * @param renderWidth defines the rendering width
  1957. * @param renderHeight defines the rendering height
  1958. * @returns a new Viewport
  1959. */
  1960. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1961. /**
  1962. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1963. * @param renderWidth defines the rendering width
  1964. * @param renderHeight defines the rendering height
  1965. * @param ref defines the target viewport
  1966. * @returns the current viewport
  1967. */
  1968. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1969. /**
  1970. * Returns a new Viewport copied from the current one
  1971. * @returns a new Viewport
  1972. */
  1973. clone(): Viewport;
  1974. }
  1975. }
  1976. declare module "babylonjs/Misc/arrayTools" {
  1977. /**
  1978. * Class containing a set of static utilities functions for arrays.
  1979. */
  1980. export class ArrayTools {
  1981. /**
  1982. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1983. * @param size the number of element to construct and put in the array
  1984. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1985. * @returns a new array filled with new objects
  1986. */
  1987. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1988. }
  1989. }
  1990. declare module "babylonjs/Maths/math.plane" {
  1991. import { DeepImmutable } from "babylonjs/types";
  1992. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1993. /**
  1994. * Represents a plane by the equation ax + by + cz + d = 0
  1995. */
  1996. export class Plane {
  1997. private static _TmpMatrix;
  1998. /**
  1999. * Normal of the plane (a,b,c)
  2000. */
  2001. normal: Vector3;
  2002. /**
  2003. * d component of the plane
  2004. */
  2005. d: number;
  2006. /**
  2007. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2008. * @param a a component of the plane
  2009. * @param b b component of the plane
  2010. * @param c c component of the plane
  2011. * @param d d component of the plane
  2012. */
  2013. constructor(a: number, b: number, c: number, d: number);
  2014. /**
  2015. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2016. */
  2017. asArray(): number[];
  2018. /**
  2019. * @returns a new plane copied from the current Plane.
  2020. */
  2021. clone(): Plane;
  2022. /**
  2023. * @returns the string "Plane".
  2024. */
  2025. getClassName(): string;
  2026. /**
  2027. * @returns the Plane hash code.
  2028. */
  2029. getHashCode(): number;
  2030. /**
  2031. * Normalize the current Plane in place.
  2032. * @returns the updated Plane.
  2033. */
  2034. normalize(): Plane;
  2035. /**
  2036. * Applies a transformation the plane and returns the result
  2037. * @param transformation the transformation matrix to be applied to the plane
  2038. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2039. */
  2040. transform(transformation: DeepImmutable<Matrix>): Plane;
  2041. /**
  2042. * Compute the dot product between the point and the plane normal
  2043. * @param point point to calculate the dot product with
  2044. * @returns the dot product (float) of the point coordinates and the plane normal.
  2045. */
  2046. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2047. /**
  2048. * Updates the current Plane from the plane defined by the three given points.
  2049. * @param point1 one of the points used to contruct the plane
  2050. * @param point2 one of the points used to contruct the plane
  2051. * @param point3 one of the points used to contruct the plane
  2052. * @returns the updated Plane.
  2053. */
  2054. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2055. /**
  2056. * Checks if the plane is facing a given direction
  2057. * @param direction the direction to check if the plane is facing
  2058. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2059. * @returns True is the vector "direction" is the same side than the plane normal.
  2060. */
  2061. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2062. /**
  2063. * Calculates the distance to a point
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance (float) from the given point to the Plane.
  2066. */
  2067. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2068. /**
  2069. * Creates a plane from an array
  2070. * @param array the array to create a plane from
  2071. * @returns a new Plane from the given array.
  2072. */
  2073. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2074. /**
  2075. * Creates a plane from three points
  2076. * @param point1 point used to create the plane
  2077. * @param point2 point used to create the plane
  2078. * @param point3 point used to create the plane
  2079. * @returns a new Plane defined by the three given points.
  2080. */
  2081. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2082. /**
  2083. * Creates a plane from an origin point and a normal
  2084. * @param origin origin of the plane to be constructed
  2085. * @param normal normal of the plane to be constructed
  2086. * @returns a new Plane the normal vector to this plane at the given origin point.
  2087. * Note : the vector "normal" is updated because normalized.
  2088. */
  2089. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2090. /**
  2091. * Calculates the distance from a plane and a point
  2092. * @param origin origin of the plane to be constructed
  2093. * @param normal normal of the plane to be constructed
  2094. * @param point point to calculate distance to
  2095. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2096. */
  2097. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2098. }
  2099. }
  2100. declare module "babylonjs/Engines/performanceConfigurator" {
  2101. /** @hidden */
  2102. export class PerformanceConfigurator {
  2103. /** @hidden */
  2104. static MatrixUse64Bits: boolean;
  2105. /** @hidden */
  2106. static MatrixTrackPrecisionChange: boolean;
  2107. /** @hidden */
  2108. static MatrixCurrentType: any;
  2109. /** @hidden */
  2110. static MatrixTrackedMatrices: Array<any> | null;
  2111. /** @hidden */
  2112. static SetMatrixPrecision(use64bits: boolean): void;
  2113. }
  2114. }
  2115. declare module "babylonjs/Maths/math.vector" {
  2116. import { Viewport } from "babylonjs/Maths/math.viewport";
  2117. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2118. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2119. import { Plane } from "babylonjs/Maths/math.plane";
  2120. /**
  2121. * Class representing a vector containing 2 coordinates
  2122. */
  2123. export class Vector2 {
  2124. /** defines the first coordinate */
  2125. x: number;
  2126. /** defines the second coordinate */
  2127. y: number;
  2128. /**
  2129. * Creates a new Vector2 from the given x and y coordinates
  2130. * @param x defines the first coordinate
  2131. * @param y defines the second coordinate
  2132. */
  2133. constructor(
  2134. /** defines the first coordinate */
  2135. x?: number,
  2136. /** defines the second coordinate */
  2137. y?: number);
  2138. /**
  2139. * Gets a string with the Vector2 coordinates
  2140. * @returns a string with the Vector2 coordinates
  2141. */
  2142. toString(): string;
  2143. /**
  2144. * Gets class name
  2145. * @returns the string "Vector2"
  2146. */
  2147. getClassName(): string;
  2148. /**
  2149. * Gets current vector hash code
  2150. * @returns the Vector2 hash code as a number
  2151. */
  2152. getHashCode(): number;
  2153. /**
  2154. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2155. * @param array defines the source array
  2156. * @param index defines the offset in source array
  2157. * @returns the current Vector2
  2158. */
  2159. toArray(array: FloatArray, index?: number): Vector2;
  2160. /**
  2161. * Update the current vector from an array
  2162. * @param array defines the destination array
  2163. * @param index defines the offset in the destination array
  2164. * @returns the current Vector3
  2165. */
  2166. fromArray(array: FloatArray, index?: number): Vector2;
  2167. /**
  2168. * Copy the current vector to an array
  2169. * @returns a new array with 2 elements: the Vector2 coordinates.
  2170. */
  2171. asArray(): number[];
  2172. /**
  2173. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2174. * @param source defines the source Vector2
  2175. * @returns the current updated Vector2
  2176. */
  2177. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2178. /**
  2179. * Sets the Vector2 coordinates with the given floats
  2180. * @param x defines the first coordinate
  2181. * @param y defines the second coordinate
  2182. * @returns the current updated Vector2
  2183. */
  2184. copyFromFloats(x: number, y: number): Vector2;
  2185. /**
  2186. * Sets the Vector2 coordinates with the given floats
  2187. * @param x defines the first coordinate
  2188. * @param y defines the second coordinate
  2189. * @returns the current updated Vector2
  2190. */
  2191. set(x: number, y: number): Vector2;
  2192. /**
  2193. * Add another vector with the current one
  2194. * @param otherVector defines the other vector
  2195. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2196. */
  2197. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2198. /**
  2199. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2200. * @param otherVector defines the other vector
  2201. * @param result defines the target vector
  2202. * @returns the unmodified current Vector2
  2203. */
  2204. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2205. /**
  2206. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns the current updated Vector2
  2209. */
  2210. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2211. /**
  2212. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. addVector3(otherVector: Vector3): Vector2;
  2217. /**
  2218. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2219. * @param otherVector defines the other vector
  2220. * @returns a new Vector2
  2221. */
  2222. subtract(otherVector: Vector2): Vector2;
  2223. /**
  2224. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2225. * @param otherVector defines the other vector
  2226. * @param result defines the target vector
  2227. * @returns the unmodified current Vector2
  2228. */
  2229. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2230. /**
  2231. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Multiplies in place the current Vector2 coordinates by the given ones
  2238. * @param otherVector defines the other vector
  2239. * @returns the current updated Vector2
  2240. */
  2241. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @returns a new Vector2
  2246. */
  2247. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2250. * @param otherVector defines the other vector
  2251. * @param result defines the target vector
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2257. * @param x defines the first coordinate
  2258. * @param y defines the second coordinate
  2259. * @returns a new Vector2
  2260. */
  2261. multiplyByFloats(x: number, y: number): Vector2;
  2262. /**
  2263. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @returns a new Vector2
  2266. */
  2267. divide(otherVector: Vector2): Vector2;
  2268. /**
  2269. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2270. * @param otherVector defines the other vector
  2271. * @param result defines the target vector
  2272. * @returns the unmodified current Vector2
  2273. */
  2274. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2275. /**
  2276. * Divides the current Vector2 coordinates by the given ones
  2277. * @param otherVector defines the other vector
  2278. * @returns the current updated Vector2
  2279. */
  2280. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2281. /**
  2282. * Gets a new Vector2 with current Vector2 negated coordinates
  2283. * @returns a new Vector2
  2284. */
  2285. negate(): Vector2;
  2286. /**
  2287. * Negate this vector in place
  2288. * @returns this
  2289. */
  2290. negateInPlace(): Vector2;
  2291. /**
  2292. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2293. * @param result defines the Vector3 object where to store the result
  2294. * @returns the current Vector2
  2295. */
  2296. negateToRef(result: Vector2): Vector2;
  2297. /**
  2298. * Multiply the Vector2 coordinates by scale
  2299. * @param scale defines the scaling factor
  2300. * @returns the current updated Vector2
  2301. */
  2302. scaleInPlace(scale: number): Vector2;
  2303. /**
  2304. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2305. * @param scale defines the scaling factor
  2306. * @returns a new Vector2
  2307. */
  2308. scale(scale: number): Vector2;
  2309. /**
  2310. * Scale the current Vector2 values by a factor to a given Vector2
  2311. * @param scale defines the scale factor
  2312. * @param result defines the Vector2 object where to store the result
  2313. * @returns the unmodified current Vector2
  2314. */
  2315. scaleToRef(scale: number, result: Vector2): Vector2;
  2316. /**
  2317. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2318. * @param scale defines the scale factor
  2319. * @param result defines the Vector2 object where to store the result
  2320. * @returns the unmodified current Vector2
  2321. */
  2322. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2323. /**
  2324. * Gets a boolean if two vectors are equals
  2325. * @param otherVector defines the other vector
  2326. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2327. */
  2328. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2329. /**
  2330. * Gets a boolean if two vectors are equals (using an epsilon value)
  2331. * @param otherVector defines the other vector
  2332. * @param epsilon defines the minimal distance to consider equality
  2333. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2334. */
  2335. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2336. /**
  2337. * Gets a new Vector2 from current Vector2 floored values
  2338. * @returns a new Vector2
  2339. */
  2340. floor(): Vector2;
  2341. /**
  2342. * Gets a new Vector2 from current Vector2 floored values
  2343. * @returns a new Vector2
  2344. */
  2345. fract(): Vector2;
  2346. /**
  2347. * Gets the length of the vector
  2348. * @returns the vector length (float)
  2349. */
  2350. length(): number;
  2351. /**
  2352. * Gets the vector squared length
  2353. * @returns the vector squared length (float)
  2354. */
  2355. lengthSquared(): number;
  2356. /**
  2357. * Normalize the vector
  2358. * @returns the current updated Vector2
  2359. */
  2360. normalize(): Vector2;
  2361. /**
  2362. * Gets a new Vector2 copied from the Vector2
  2363. * @returns a new Vector2
  2364. */
  2365. clone(): Vector2;
  2366. /**
  2367. * Gets a new Vector2(0, 0)
  2368. * @returns a new Vector2
  2369. */
  2370. static Zero(): Vector2;
  2371. /**
  2372. * Gets a new Vector2(1, 1)
  2373. * @returns a new Vector2
  2374. */
  2375. static One(): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set from the given index element of the given array
  2378. * @param array defines the data source
  2379. * @param offset defines the offset in the data source
  2380. * @returns a new Vector2
  2381. */
  2382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2383. /**
  2384. * Sets "result" from the given index element of the given array
  2385. * @param array defines the data source
  2386. * @param offset defines the offset in the data source
  2387. * @param result defines the target vector
  2388. */
  2389. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2390. /**
  2391. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2392. * @param value1 defines 1st point of control
  2393. * @param value2 defines 2nd point of control
  2394. * @param value3 defines 3rd point of control
  2395. * @param value4 defines 4th point of control
  2396. * @param amount defines the interpolation factor
  2397. * @returns a new Vector2
  2398. */
  2399. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2400. /**
  2401. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2402. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2403. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2404. * @param value defines the value to clamp
  2405. * @param min defines the lower limit
  2406. * @param max defines the upper limit
  2407. * @returns a new Vector2
  2408. */
  2409. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2412. * @param value1 defines the 1st control point
  2413. * @param tangent1 defines the outgoing tangent
  2414. * @param value2 defines the 2nd control point
  2415. * @param tangent2 defines the incoming tangent
  2416. * @param amount defines the interpolation factor
  2417. * @returns a new Vector2
  2418. */
  2419. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2420. /**
  2421. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2422. * @param start defines the start vector
  2423. * @param end defines the end vector
  2424. * @param amount defines the interpolation factor
  2425. * @returns a new Vector2
  2426. */
  2427. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2428. /**
  2429. * Gets the dot product of the vector "left" and the vector "right"
  2430. * @param left defines first vector
  2431. * @param right defines second vector
  2432. * @returns the dot product (float)
  2433. */
  2434. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2435. /**
  2436. * Returns a new Vector2 equal to the normalized given vector
  2437. * @param vector defines the vector to normalize
  2438. * @returns a new Vector2
  2439. */
  2440. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2441. /**
  2442. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2443. * @param left defines 1st vector
  2444. * @param right defines 2nd vector
  2445. * @returns a new Vector2
  2446. */
  2447. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2448. /**
  2449. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2450. * @param left defines 1st vector
  2451. * @param right defines 2nd vector
  2452. * @returns a new Vector2
  2453. */
  2454. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2455. /**
  2456. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2457. * @param vector defines the vector to transform
  2458. * @param transformation defines the matrix to apply
  2459. * @returns a new Vector2
  2460. */
  2461. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2462. /**
  2463. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2464. * @param vector defines the vector to transform
  2465. * @param transformation defines the matrix to apply
  2466. * @param result defines the target vector
  2467. */
  2468. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2469. /**
  2470. * Determines if a given vector is included in a triangle
  2471. * @param p defines the vector to test
  2472. * @param p0 defines 1st triangle point
  2473. * @param p1 defines 2nd triangle point
  2474. * @param p2 defines 3rd triangle point
  2475. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2476. */
  2477. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2478. /**
  2479. * Gets the distance between the vectors "value1" and "value2"
  2480. * @param value1 defines first vector
  2481. * @param value2 defines second vector
  2482. * @returns the distance between vectors
  2483. */
  2484. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2485. /**
  2486. * Returns the squared distance between the vectors "value1" and "value2"
  2487. * @param value1 defines first vector
  2488. * @param value2 defines second vector
  2489. * @returns the squared distance between vectors
  2490. */
  2491. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2492. /**
  2493. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2494. * @param value1 defines first vector
  2495. * @param value2 defines second vector
  2496. * @returns a new Vector2
  2497. */
  2498. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2499. /**
  2500. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2501. * @param p defines the middle point
  2502. * @param segA defines one point of the segment
  2503. * @param segB defines the other point of the segment
  2504. * @returns the shortest distance
  2505. */
  2506. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2507. }
  2508. /**
  2509. * Class used to store (x,y,z) vector representation
  2510. * A Vector3 is the main object used in 3D geometry
  2511. * It can represent etiher the coordinates of a point the space, either a direction
  2512. * Reminder: js uses a left handed forward facing system
  2513. */
  2514. export class Vector3 {
  2515. private static _UpReadOnly;
  2516. private static _ZeroReadOnly;
  2517. /** @hidden */
  2518. _x: number;
  2519. /** @hidden */
  2520. _y: number;
  2521. /** @hidden */
  2522. _z: number;
  2523. /** @hidden */
  2524. _isDirty: boolean;
  2525. /** Gets or sets the x coordinate */
  2526. get x(): number;
  2527. set x(value: number);
  2528. /** Gets or sets the y coordinate */
  2529. get y(): number;
  2530. set y(value: number);
  2531. /** Gets or sets the z coordinate */
  2532. get z(): number;
  2533. set z(value: number);
  2534. /**
  2535. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2536. * @param x defines the first coordinates (on X axis)
  2537. * @param y defines the second coordinates (on Y axis)
  2538. * @param z defines the third coordinates (on Z axis)
  2539. */
  2540. constructor(x?: number, y?: number, z?: number);
  2541. /**
  2542. * Creates a string representation of the Vector3
  2543. * @returns a string with the Vector3 coordinates.
  2544. */
  2545. toString(): string;
  2546. /**
  2547. * Gets the class name
  2548. * @returns the string "Vector3"
  2549. */
  2550. getClassName(): string;
  2551. /**
  2552. * Creates the Vector3 hash code
  2553. * @returns a number which tends to be unique between Vector3 instances
  2554. */
  2555. getHashCode(): number;
  2556. /**
  2557. * Creates an array containing three elements : the coordinates of the Vector3
  2558. * @returns a new array of numbers
  2559. */
  2560. asArray(): number[];
  2561. /**
  2562. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2563. * @param array defines the destination array
  2564. * @param index defines the offset in the destination array
  2565. * @returns the current Vector3
  2566. */
  2567. toArray(array: FloatArray, index?: number): Vector3;
  2568. /**
  2569. * Update the current vector from an array
  2570. * @param array defines the destination array
  2571. * @param index defines the offset in the destination array
  2572. * @returns the current Vector3
  2573. */
  2574. fromArray(array: FloatArray, index?: number): Vector3;
  2575. /**
  2576. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2577. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2578. */
  2579. toQuaternion(): Quaternion;
  2580. /**
  2581. * Adds the given vector to the current Vector3
  2582. * @param otherVector defines the second operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2586. /**
  2587. * Adds the given coordinates to the current Vector3
  2588. * @param x defines the x coordinate of the operand
  2589. * @param y defines the y coordinate of the operand
  2590. * @param z defines the z coordinate of the operand
  2591. * @returns the current updated Vector3
  2592. */
  2593. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2594. /**
  2595. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2596. * @param otherVector defines the second operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2600. /**
  2601. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2602. * @param otherVector defines the second operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2607. /**
  2608. * Subtract the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the current updated Vector3
  2611. */
  2612. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2615. * @param otherVector defines the second operand
  2616. * @returns the resulting Vector3
  2617. */
  2618. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2619. /**
  2620. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2621. * @param otherVector defines the second operand
  2622. * @param result defines the Vector3 object where to store the result
  2623. * @returns the current Vector3
  2624. */
  2625. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2626. /**
  2627. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2628. * @param x defines the x coordinate of the operand
  2629. * @param y defines the y coordinate of the operand
  2630. * @param z defines the z coordinate of the operand
  2631. * @returns the resulting Vector3
  2632. */
  2633. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2634. /**
  2635. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @param result defines the Vector3 object where to store the result
  2640. * @returns the current Vector3
  2641. */
  2642. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2643. /**
  2644. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2645. * @returns a new Vector3
  2646. */
  2647. negate(): Vector3;
  2648. /**
  2649. * Negate this vector in place
  2650. * @returns this
  2651. */
  2652. negateInPlace(): Vector3;
  2653. /**
  2654. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2655. * @param result defines the Vector3 object where to store the result
  2656. * @returns the current Vector3
  2657. */
  2658. negateToRef(result: Vector3): Vector3;
  2659. /**
  2660. * Multiplies the Vector3 coordinates by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns the current updated Vector3
  2663. */
  2664. scaleInPlace(scale: number): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2667. * @param scale defines the multiplier factor
  2668. * @returns a new Vector3
  2669. */
  2670. scale(scale: number): Vector3;
  2671. /**
  2672. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2673. * @param scale defines the multiplier factor
  2674. * @param result defines the Vector3 object where to store the result
  2675. * @returns the current Vector3
  2676. */
  2677. scaleToRef(scale: number, result: Vector3): Vector3;
  2678. /**
  2679. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2680. * @param scale defines the scale factor
  2681. * @param result defines the Vector3 object where to store the result
  2682. * @returns the unmodified current Vector3
  2683. */
  2684. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2685. /**
  2686. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2687. * @param origin defines the origin of the projection ray
  2688. * @param plane defines the plane to project to
  2689. * @returns the projected vector3
  2690. */
  2691. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2692. /**
  2693. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2694. * @param origin defines the origin of the projection ray
  2695. * @param plane defines the plane to project to
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2701. * @param otherVector defines the second operand
  2702. * @returns true if both vectors are equals
  2703. */
  2704. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2705. /**
  2706. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2707. * @param otherVector defines the second operand
  2708. * @param epsilon defines the minimal distance to define values as equals
  2709. * @returns true if both vectors are distant less than epsilon
  2710. */
  2711. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2712. /**
  2713. * Returns true if the current Vector3 coordinates equals the given floats
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns true if both vectors are equals
  2718. */
  2719. equalsToFloats(x: number, y: number, z: number): boolean;
  2720. /**
  2721. * Multiplies the current Vector3 coordinates by the given ones
  2722. * @param otherVector defines the second operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2728. * @param otherVector defines the second operand
  2729. * @returns the new Vector3
  2730. */
  2731. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2732. /**
  2733. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2734. * @param otherVector defines the second operand
  2735. * @param result defines the Vector3 object where to store the result
  2736. * @returns the current Vector3
  2737. */
  2738. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2741. * @param x defines the x coordinate of the operand
  2742. * @param y defines the y coordinate of the operand
  2743. * @param z defines the z coordinate of the operand
  2744. * @returns the new Vector3
  2745. */
  2746. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2749. * @param otherVector defines the second operand
  2750. * @returns the new Vector3
  2751. */
  2752. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2753. /**
  2754. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2755. * @param otherVector defines the second operand
  2756. * @param result defines the Vector3 object where to store the result
  2757. * @returns the current Vector3
  2758. */
  2759. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2760. /**
  2761. * Divides the current Vector3 coordinates by the given ones.
  2762. * @param otherVector defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. divideInPlace(otherVector: Vector3): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2774. * @param other defines the second operand
  2775. * @returns the current updated Vector3
  2776. */
  2777. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2778. /**
  2779. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2780. * @param x defines the x coordinate of the operand
  2781. * @param y defines the y coordinate of the operand
  2782. * @param z defines the z coordinate of the operand
  2783. * @returns the current updated Vector3
  2784. */
  2785. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2786. /**
  2787. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2788. * @param x defines the x coordinate of the operand
  2789. * @param y defines the y coordinate of the operand
  2790. * @param z defines the z coordinate of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2794. /**
  2795. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2796. * Check if is non uniform within a certain amount of decimal places to account for this
  2797. * @param epsilon the amount the values can differ
  2798. * @returns if the the vector is non uniform to a certain number of decimal places
  2799. */
  2800. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2801. /**
  2802. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2803. */
  2804. get isNonUniform(): boolean;
  2805. /**
  2806. * Gets a new Vector3 from current Vector3 floored values
  2807. * @returns a new Vector3
  2808. */
  2809. floor(): Vector3;
  2810. /**
  2811. * Gets a new Vector3 from current Vector3 floored values
  2812. * @returns a new Vector3
  2813. */
  2814. fract(): Vector3;
  2815. /**
  2816. * Gets the length of the Vector3
  2817. * @returns the length of the Vector3
  2818. */
  2819. length(): number;
  2820. /**
  2821. * Gets the squared length of the Vector3
  2822. * @returns squared length of the Vector3
  2823. */
  2824. lengthSquared(): number;
  2825. /**
  2826. * Normalize the current Vector3.
  2827. * Please note that this is an in place operation.
  2828. * @returns the current updated Vector3
  2829. */
  2830. normalize(): Vector3;
  2831. /**
  2832. * Reorders the x y z properties of the vector in place
  2833. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2834. * @returns the current updated vector
  2835. */
  2836. reorderInPlace(order: string): this;
  2837. /**
  2838. * Rotates the vector around 0,0,0 by a quaternion
  2839. * @param quaternion the rotation quaternion
  2840. * @param result vector to store the result
  2841. * @returns the resulting vector
  2842. */
  2843. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2844. /**
  2845. * Rotates a vector around a given point
  2846. * @param quaternion the rotation quaternion
  2847. * @param point the point to rotate around
  2848. * @param result vector to store the result
  2849. * @returns the resulting vector
  2850. */
  2851. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2852. /**
  2853. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2854. * The cross product is then orthogonal to both current and "other"
  2855. * @param other defines the right operand
  2856. * @returns the cross product
  2857. */
  2858. cross(other: Vector3): Vector3;
  2859. /**
  2860. * Normalize the current Vector3 with the given input length.
  2861. * Please note that this is an in place operation.
  2862. * @param len the length of the vector
  2863. * @returns the current updated Vector3
  2864. */
  2865. normalizeFromLength(len: number): Vector3;
  2866. /**
  2867. * Normalize the current Vector3 to a new vector
  2868. * @returns the new Vector3
  2869. */
  2870. normalizeToNew(): Vector3;
  2871. /**
  2872. * Normalize the current Vector3 to the reference
  2873. * @param reference define the Vector3 to update
  2874. * @returns the updated Vector3
  2875. */
  2876. normalizeToRef(reference: Vector3): Vector3;
  2877. /**
  2878. * Creates a new Vector3 copied from the current Vector3
  2879. * @returns the new Vector3
  2880. */
  2881. clone(): Vector3;
  2882. /**
  2883. * Copies the given vector coordinates to the current Vector3 ones
  2884. * @param source defines the source Vector3
  2885. * @returns the current updated Vector3
  2886. */
  2887. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2888. /**
  2889. * Copies the given floats to the current Vector3 coordinates
  2890. * @param x defines the x coordinate of the operand
  2891. * @param y defines the y coordinate of the operand
  2892. * @param z defines the z coordinate of the operand
  2893. * @returns the current updated Vector3
  2894. */
  2895. copyFromFloats(x: number, y: number, z: number): Vector3;
  2896. /**
  2897. * Copies the given floats to the current Vector3 coordinates
  2898. * @param x defines the x coordinate of the operand
  2899. * @param y defines the y coordinate of the operand
  2900. * @param z defines the z coordinate of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. set(x: number, y: number, z: number): Vector3;
  2904. /**
  2905. * Copies the given float to the current Vector3 coordinates
  2906. * @param v defines the x, y and z coordinates of the operand
  2907. * @returns the current updated Vector3
  2908. */
  2909. setAll(v: number): Vector3;
  2910. /**
  2911. * Get the clip factor between two vectors
  2912. * @param vector0 defines the first operand
  2913. * @param vector1 defines the second operand
  2914. * @param axis defines the axis to use
  2915. * @param size defines the size along the axis
  2916. * @returns the clip factor
  2917. */
  2918. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2919. /**
  2920. * Get angle between two vectors
  2921. * @param vector0 angle between vector0 and vector1
  2922. * @param vector1 angle between vector0 and vector1
  2923. * @param normal direction of the normal
  2924. * @return the angle between vector0 and vector1
  2925. */
  2926. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 set from the index "offset" of the given array
  2929. * @param array defines the source array
  2930. * @param offset defines the offset in the source array
  2931. * @returns the new Vector3
  2932. */
  2933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2936. * @param array defines the source array
  2937. * @param offset defines the offset in the source array
  2938. * @returns the new Vector3
  2939. * @deprecated Please use FromArray instead.
  2940. */
  2941. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2942. /**
  2943. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2944. * @param array defines the source array
  2945. * @param offset defines the offset in the source array
  2946. * @param result defines the Vector3 where to store the result
  2947. */
  2948. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2949. /**
  2950. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2951. * @param array defines the source array
  2952. * @param offset defines the offset in the source array
  2953. * @param result defines the Vector3 where to store the result
  2954. * @deprecated Please use FromArrayToRef instead.
  2955. */
  2956. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" with the given floats.
  2959. * @param x defines the x coordinate of the source
  2960. * @param y defines the y coordinate of the source
  2961. * @param z defines the z coordinate of the source
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2967. * @returns a new empty Vector3
  2968. */
  2969. static Zero(): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2972. * @returns a new unit Vector3
  2973. */
  2974. static One(): Vector3;
  2975. /**
  2976. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2977. * @returns a new up Vector3
  2978. */
  2979. static Up(): Vector3;
  2980. /**
  2981. * Gets a up Vector3 that must not be updated
  2982. */
  2983. static get UpReadOnly(): DeepImmutable<Vector3>;
  2984. /**
  2985. * Gets a zero Vector3 that must not be updated
  2986. */
  2987. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2990. * @returns a new down Vector3
  2991. */
  2992. static Down(): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Forward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3001. * @param rightHandedSystem is the scene right-handed (negative-z)
  3002. * @returns a new forward Vector3
  3003. */
  3004. static Backward(rightHandedSystem?: boolean): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3007. * @returns a new right Vector3
  3008. */
  3009. static Right(): Vector3;
  3010. /**
  3011. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3012. * @returns a new left Vector3
  3013. */
  3014. static Left(): Vector3;
  3015. /**
  3016. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3017. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @returns the transformed Vector3
  3021. */
  3022. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3023. /**
  3024. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3025. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3026. * @param vector defines the Vector3 to transform
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3033. * This method computes tranformed coordinates only, not transformed direction vectors
  3034. * @param x define the x coordinate of the source vector
  3035. * @param y define the y coordinate of the source vector
  3036. * @param z define the z coordinate of the source vector
  3037. * @param transformation defines the transformation matrix
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3043. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3044. * @param vector defines the Vector3 to transform
  3045. * @param transformation defines the transformation matrix
  3046. * @returns the new Vector3
  3047. */
  3048. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3049. /**
  3050. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3051. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3052. * @param vector defines the Vector3 to transform
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3059. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3060. * @param x define the x coordinate of the source vector
  3061. * @param y define the y coordinate of the source vector
  3062. * @param z define the z coordinate of the source vector
  3063. * @param transformation defines the transformation matrix
  3064. * @param result defines the Vector3 where to store the result
  3065. */
  3066. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3067. /**
  3068. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3069. * @param value1 defines the first control point
  3070. * @param value2 defines the second control point
  3071. * @param value3 defines the third control point
  3072. * @param value4 defines the fourth control point
  3073. * @param amount defines the amount on the spline to use
  3074. * @returns the new Vector3
  3075. */
  3076. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3077. /**
  3078. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @returns the new Vector3
  3085. */
  3086. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3087. /**
  3088. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3089. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3090. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3091. * @param value defines the current value
  3092. * @param min defines the lower range value
  3093. * @param max defines the upper range value
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Checks if a given vector is inside a specific range
  3099. * @param v defines the vector to test
  3100. * @param min defines the minimum range
  3101. * @param max defines the maximum range
  3102. */
  3103. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3106. * @param value1 defines the first control point
  3107. * @param tangent1 defines the first tangent vector
  3108. * @param value2 defines the second control point
  3109. * @param tangent2 defines the second tangent vector
  3110. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3111. * @returns the new Vector3
  3112. */
  3113. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3114. /**
  3115. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3116. * @param start defines the start value
  3117. * @param end defines the end value
  3118. * @param amount max defines amount between both (between 0 and 1)
  3119. * @returns the new Vector3
  3120. */
  3121. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3122. /**
  3123. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3124. * @param start defines the start value
  3125. * @param end defines the end value
  3126. * @param amount max defines amount between both (between 0 and 1)
  3127. * @param result defines the Vector3 where to store the result
  3128. */
  3129. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3130. /**
  3131. * Returns the dot product (float) between the vectors "left" and "right"
  3132. * @param left defines the left operand
  3133. * @param right defines the right operand
  3134. * @returns the dot product
  3135. */
  3136. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3139. * The cross product is then orthogonal to both "left" and "right"
  3140. * @param left defines the left operand
  3141. * @param right defines the right operand
  3142. * @returns the cross product
  3143. */
  3144. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Sets the given vector "result" with the cross product of "left" and "right"
  3147. * The cross product is then orthogonal to both "left" and "right"
  3148. * @param left defines the left operand
  3149. * @param right defines the right operand
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3153. /**
  3154. * Returns a new Vector3 as the normalization of the given vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @returns the new Vector3
  3157. */
  3158. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Sets the given vector "result" with the normalization of the given first vector
  3161. * @param vector defines the Vector3 to normalize
  3162. * @param result defines the Vector3 where to store the result
  3163. */
  3164. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3165. /**
  3166. * Project a Vector3 onto screen space
  3167. * @param vector defines the Vector3 to project
  3168. * @param world defines the world matrix to use
  3169. * @param transform defines the transform (view x projection) matrix to use
  3170. * @param viewport defines the screen viewport to use
  3171. * @returns the new Vector3
  3172. */
  3173. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3174. /**
  3175. * Project a Vector3 onto screen space to reference
  3176. * @param vector defines the Vector3 to project
  3177. * @param world defines the world matrix to use
  3178. * @param transform defines the transform (view x projection) matrix to use
  3179. * @param viewport defines the screen viewport to use
  3180. * @param result the vector in which the screen space will be stored
  3181. * @returns the new Vector3
  3182. */
  3183. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3184. /** @hidden */
  3185. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3186. /**
  3187. * Unproject from screen space to object space
  3188. * @param source defines the screen space Vector3 to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param transform defines the transform (view x projection) matrix to use
  3193. * @returns the new Vector3
  3194. */
  3195. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3196. /**
  3197. * Unproject from screen space to object space
  3198. * @param source defines the screen space Vector3 to use
  3199. * @param viewportWidth defines the current width of the viewport
  3200. * @param viewportHeight defines the current height of the viewport
  3201. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3202. * @param view defines the view matrix to use
  3203. * @param projection defines the projection matrix to use
  3204. * @returns the new Vector3
  3205. */
  3206. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3207. /**
  3208. * Unproject from screen space to object space
  3209. * @param source defines the screen space Vector3 to use
  3210. * @param viewportWidth defines the current width of the viewport
  3211. * @param viewportHeight defines the current height of the viewport
  3212. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3213. * @param view defines the view matrix to use
  3214. * @param projection defines the projection matrix to use
  3215. * @param result defines the Vector3 where to store the result
  3216. */
  3217. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3218. /**
  3219. * Unproject from screen space to object space
  3220. * @param sourceX defines the screen space x coordinate to use
  3221. * @param sourceY defines the screen space y coordinate to use
  3222. * @param sourceZ defines the screen space z coordinate to use
  3223. * @param viewportWidth defines the current width of the viewport
  3224. * @param viewportHeight defines the current height of the viewport
  3225. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3226. * @param view defines the view matrix to use
  3227. * @param projection defines the projection matrix to use
  3228. * @param result defines the Vector3 where to store the result
  3229. */
  3230. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3231. /**
  3232. * Gets the minimal coordinate values between two Vector3
  3233. * @param left defines the first operand
  3234. * @param right defines the second operand
  3235. * @returns the new Vector3
  3236. */
  3237. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * Gets the maximal coordinate values between two Vector3
  3240. * @param left defines the first operand
  3241. * @param right defines the second operand
  3242. * @returns the new Vector3
  3243. */
  3244. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3245. /**
  3246. * Returns the distance between the vectors "value1" and "value2"
  3247. * @param value1 defines the first operand
  3248. * @param value2 defines the second operand
  3249. * @returns the distance
  3250. */
  3251. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3252. /**
  3253. * Returns the squared distance between the vectors "value1" and "value2"
  3254. * @param value1 defines the first operand
  3255. * @param value2 defines the second operand
  3256. * @returns the squared distance
  3257. */
  3258. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3259. /**
  3260. * Returns a new Vector3 located at the center between "value1" and "value2"
  3261. * @param value1 defines the first operand
  3262. * @param value2 defines the second operand
  3263. * @returns the new Vector3
  3264. */
  3265. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3266. /**
  3267. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3268. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3269. * to something in order to rotate it from its local system to the given target system
  3270. * Note: axis1, axis2 and axis3 are normalized during this operation
  3271. * @param axis1 defines the first axis
  3272. * @param axis2 defines the second axis
  3273. * @param axis3 defines the third axis
  3274. * @returns a new Vector3
  3275. */
  3276. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3277. /**
  3278. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3279. * @param axis1 defines the first axis
  3280. * @param axis2 defines the second axis
  3281. * @param axis3 defines the third axis
  3282. * @param ref defines the Vector3 where to store the result
  3283. */
  3284. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3285. }
  3286. /**
  3287. * Vector4 class created for EulerAngle class conversion to Quaternion
  3288. */
  3289. export class Vector4 {
  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. * Creates a Vector4 object from the given floats.
  3300. * @param x x value of the vector
  3301. * @param y y value of the vector
  3302. * @param z z value of the vector
  3303. * @param w w value of the vector
  3304. */
  3305. constructor(
  3306. /** x value of the vector */
  3307. x: number,
  3308. /** y value of the vector */
  3309. y: number,
  3310. /** z value of the vector */
  3311. z: number,
  3312. /** w value of the vector */
  3313. w: number);
  3314. /**
  3315. * Returns the string with the Vector4 coordinates.
  3316. * @returns a string containing all the vector values
  3317. */
  3318. toString(): string;
  3319. /**
  3320. * Returns the string "Vector4".
  3321. * @returns "Vector4"
  3322. */
  3323. getClassName(): string;
  3324. /**
  3325. * Returns the Vector4 hash code.
  3326. * @returns a unique hash code
  3327. */
  3328. getHashCode(): number;
  3329. /**
  3330. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3331. * @returns the resulting array
  3332. */
  3333. asArray(): number[];
  3334. /**
  3335. * Populates the given array from the given index with the Vector4 coordinates.
  3336. * @param array array to populate
  3337. * @param index index of the array to start at (default: 0)
  3338. * @returns the Vector4.
  3339. */
  3340. toArray(array: FloatArray, index?: number): Vector4;
  3341. /**
  3342. * Update the current vector from an array
  3343. * @param array defines the destination array
  3344. * @param index defines the offset in the destination array
  3345. * @returns the current Vector3
  3346. */
  3347. fromArray(array: FloatArray, index?: number): Vector4;
  3348. /**
  3349. * Adds the given vector to the current Vector4.
  3350. * @param otherVector the vector to add
  3351. * @returns the updated Vector4.
  3352. */
  3353. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3354. /**
  3355. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3356. * @param otherVector the vector to add
  3357. * @returns the resulting vector
  3358. */
  3359. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3360. /**
  3361. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3362. * @param otherVector the vector to add
  3363. * @param result the vector to store the result
  3364. * @returns the current Vector4.
  3365. */
  3366. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3367. /**
  3368. * Subtract in place the given vector from the current Vector4.
  3369. * @param otherVector the vector to subtract
  3370. * @returns the updated Vector4.
  3371. */
  3372. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3375. * @param otherVector the vector to add
  3376. * @returns the new vector with the result
  3377. */
  3378. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3379. /**
  3380. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3381. * @param otherVector the vector to subtract
  3382. * @param result the vector to store the result
  3383. * @returns the current Vector4.
  3384. */
  3385. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3386. /**
  3387. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3388. */
  3389. /**
  3390. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3391. * @param x value to subtract
  3392. * @param y value to subtract
  3393. * @param z value to subtract
  3394. * @param w value to subtract
  3395. * @returns new vector containing the result
  3396. */
  3397. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3398. /**
  3399. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3400. * @param x value to subtract
  3401. * @param y value to subtract
  3402. * @param z value to subtract
  3403. * @param w value to subtract
  3404. * @param result the vector to store the result in
  3405. * @returns the current Vector4.
  3406. */
  3407. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3408. /**
  3409. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3410. * @returns a new vector with the negated values
  3411. */
  3412. negate(): Vector4;
  3413. /**
  3414. * Negate this vector in place
  3415. * @returns this
  3416. */
  3417. negateInPlace(): Vector4;
  3418. /**
  3419. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3420. * @param result defines the Vector3 object where to store the result
  3421. * @returns the current Vector4
  3422. */
  3423. negateToRef(result: Vector4): Vector4;
  3424. /**
  3425. * Multiplies the current Vector4 coordinates by scale (float).
  3426. * @param scale the number to scale with
  3427. * @returns the updated Vector4.
  3428. */
  3429. scaleInPlace(scale: number): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3432. * @param scale the number to scale with
  3433. * @returns a new vector with the result
  3434. */
  3435. scale(scale: number): Vector4;
  3436. /**
  3437. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3438. * @param scale the number to scale with
  3439. * @param result a vector to store the result in
  3440. * @returns the current Vector4.
  3441. */
  3442. scaleToRef(scale: number, result: Vector4): Vector4;
  3443. /**
  3444. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3445. * @param scale defines the scale factor
  3446. * @param result defines the Vector4 object where to store the result
  3447. * @returns the unmodified current Vector4
  3448. */
  3449. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3450. /**
  3451. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3452. * @param otherVector the vector to compare against
  3453. * @returns true if they are equal
  3454. */
  3455. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3456. /**
  3457. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3458. * @param otherVector vector to compare against
  3459. * @param epsilon (Default: very small number)
  3460. * @returns true if they are equal
  3461. */
  3462. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3463. /**
  3464. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3465. * @param x x value to compare against
  3466. * @param y y value to compare against
  3467. * @param z z value to compare against
  3468. * @param w w value to compare against
  3469. * @returns true if equal
  3470. */
  3471. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3472. /**
  3473. * Multiplies in place the current Vector4 by the given one.
  3474. * @param otherVector vector to multiple with
  3475. * @returns the updated Vector4.
  3476. */
  3477. multiplyInPlace(otherVector: Vector4): Vector4;
  3478. /**
  3479. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3480. * @param otherVector vector to multiple with
  3481. * @returns resulting new vector
  3482. */
  3483. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3484. /**
  3485. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3486. * @param otherVector vector to multiple with
  3487. * @param result vector to store the result
  3488. * @returns the current Vector4.
  3489. */
  3490. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3491. /**
  3492. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3493. * @param x x value multiply with
  3494. * @param y y value multiply with
  3495. * @param z z value multiply with
  3496. * @param w w value multiply with
  3497. * @returns resulting new vector
  3498. */
  3499. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3500. /**
  3501. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3502. * @param otherVector vector to devide with
  3503. * @returns resulting new vector
  3504. */
  3505. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3506. /**
  3507. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3508. * @param otherVector vector to devide with
  3509. * @param result vector to store the result
  3510. * @returns the current Vector4.
  3511. */
  3512. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3513. /**
  3514. * Divides the current Vector3 coordinates by the given ones.
  3515. * @param otherVector vector to devide with
  3516. * @returns the updated Vector3.
  3517. */
  3518. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3519. /**
  3520. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3521. * @param other defines the second operand
  3522. * @returns the current updated Vector4
  3523. */
  3524. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3525. /**
  3526. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3527. * @param other defines the second operand
  3528. * @returns the current updated Vector4
  3529. */
  3530. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3531. /**
  3532. * Gets a new Vector4 from current Vector4 floored values
  3533. * @returns a new Vector4
  3534. */
  3535. floor(): Vector4;
  3536. /**
  3537. * Gets a new Vector4 from current Vector3 floored values
  3538. * @returns a new Vector4
  3539. */
  3540. fract(): Vector4;
  3541. /**
  3542. * Returns the Vector4 length (float).
  3543. * @returns the length
  3544. */
  3545. length(): number;
  3546. /**
  3547. * Returns the Vector4 squared length (float).
  3548. * @returns the length squared
  3549. */
  3550. lengthSquared(): number;
  3551. /**
  3552. * Normalizes in place the Vector4.
  3553. * @returns the updated Vector4.
  3554. */
  3555. normalize(): Vector4;
  3556. /**
  3557. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3558. * @returns this converted to a new vector3
  3559. */
  3560. toVector3(): Vector3;
  3561. /**
  3562. * Returns a new Vector4 copied from the current one.
  3563. * @returns the new cloned vector
  3564. */
  3565. clone(): Vector4;
  3566. /**
  3567. * Updates the current Vector4 with the given one coordinates.
  3568. * @param source the source vector to copy from
  3569. * @returns the updated Vector4.
  3570. */
  3571. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3572. /**
  3573. * Updates the current Vector4 coordinates with the given floats.
  3574. * @param x float to copy from
  3575. * @param y float to copy from
  3576. * @param z float to copy from
  3577. * @param w float to copy from
  3578. * @returns the updated Vector4.
  3579. */
  3580. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3581. /**
  3582. * Updates the current Vector4 coordinates with the given floats.
  3583. * @param x float to set from
  3584. * @param y float to set from
  3585. * @param z float to set from
  3586. * @param w float to set from
  3587. * @returns the updated Vector4.
  3588. */
  3589. set(x: number, y: number, z: number, w: number): Vector4;
  3590. /**
  3591. * Copies the given float to the current Vector3 coordinates
  3592. * @param v defines the x, y, z and w coordinates of the operand
  3593. * @returns the current updated Vector3
  3594. */
  3595. setAll(v: number): Vector4;
  3596. /**
  3597. * Returns a new Vector4 set from the starting index of the given array.
  3598. * @param array the array to pull values from
  3599. * @param offset the offset into the array to start at
  3600. * @returns the new vector
  3601. */
  3602. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the starting index of the given array.
  3605. * @param array the array to pull values from
  3606. * @param offset the offset into the array to start at
  3607. * @param result the vector to store the result in
  3608. */
  3609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3610. /**
  3611. * Updates the given vector "result" from the starting index of the given Float32Array.
  3612. * @param array the array to pull values from
  3613. * @param offset the offset into the array to start at
  3614. * @param result the vector to store the result in
  3615. */
  3616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3617. /**
  3618. * Updates the given vector "result" coordinates from the given floats.
  3619. * @param x float to set from
  3620. * @param y float to set from
  3621. * @param z float to set from
  3622. * @param w float to set from
  3623. * @param result the vector to the floats in
  3624. */
  3625. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3626. /**
  3627. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3628. * @returns the new vector
  3629. */
  3630. static Zero(): Vector4;
  3631. /**
  3632. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3633. * @returns the new vector
  3634. */
  3635. static One(): Vector4;
  3636. /**
  3637. * Returns a new normalized Vector4 from the given one.
  3638. * @param vector the vector to normalize
  3639. * @returns the vector
  3640. */
  3641. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Updates the given vector "result" from the normalization of the given one.
  3644. * @param vector the vector to normalize
  3645. * @param result the vector to store the result in
  3646. */
  3647. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3648. /**
  3649. * Returns a vector with the minimum values from the left and right vectors
  3650. * @param left left vector to minimize
  3651. * @param right right vector to minimize
  3652. * @returns a new vector with the minimum of the left and right vector values
  3653. */
  3654. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3655. /**
  3656. * Returns a vector with the maximum values from the left and right vectors
  3657. * @param left left vector to maximize
  3658. * @param right right vector to maximize
  3659. * @returns a new vector with the maximum of the left and right vector values
  3660. */
  3661. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3662. /**
  3663. * Returns the distance (float) between the vectors "value1" and "value2".
  3664. * @param value1 value to calulate the distance between
  3665. * @param value2 value to calulate the distance between
  3666. * @return the distance between the two vectors
  3667. */
  3668. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3669. /**
  3670. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3671. * @param value1 value to calulate the distance between
  3672. * @param value2 value to calulate the distance between
  3673. * @return the distance between the two vectors squared
  3674. */
  3675. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3676. /**
  3677. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3678. * @param value1 value to calulate the center between
  3679. * @param value2 value to calulate the center between
  3680. * @return the center between the two vectors
  3681. */
  3682. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3683. /**
  3684. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3685. * This methods computes transformed normalized direction vectors only.
  3686. * @param vector the vector to transform
  3687. * @param transformation the transformation matrix to apply
  3688. * @returns the new vector
  3689. */
  3690. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3691. /**
  3692. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3693. * This methods computes transformed normalized direction vectors only.
  3694. * @param vector the vector to transform
  3695. * @param transformation the transformation matrix to apply
  3696. * @param result the vector to store the result in
  3697. */
  3698. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3699. /**
  3700. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3701. * This methods computes transformed normalized direction vectors only.
  3702. * @param x value to transform
  3703. * @param y value to transform
  3704. * @param z value to transform
  3705. * @param w value to transform
  3706. * @param transformation the transformation matrix to apply
  3707. * @param result the vector to store the results in
  3708. */
  3709. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3710. /**
  3711. * Creates a new Vector4 from a Vector3
  3712. * @param source defines the source data
  3713. * @param w defines the 4th component (default is 0)
  3714. * @returns a new Vector4
  3715. */
  3716. static FromVector3(source: Vector3, w?: number): Vector4;
  3717. }
  3718. /**
  3719. * Class used to store quaternion data
  3720. * @see https://en.wikipedia.org/wiki/Quaternion
  3721. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3722. */
  3723. export class Quaternion {
  3724. /** @hidden */
  3725. _x: number;
  3726. /** @hidden */
  3727. _y: number;
  3728. /** @hidden */
  3729. _z: number;
  3730. /** @hidden */
  3731. _w: number;
  3732. /** @hidden */
  3733. _isDirty: boolean;
  3734. /** Gets or sets the x coordinate */
  3735. get x(): number;
  3736. set x(value: number);
  3737. /** Gets or sets the y coordinate */
  3738. get y(): number;
  3739. set y(value: number);
  3740. /** Gets or sets the z coordinate */
  3741. get z(): number;
  3742. set z(value: number);
  3743. /** Gets or sets the w coordinate */
  3744. get w(): number;
  3745. set w(value: number);
  3746. /**
  3747. * Creates a new Quaternion from the given floats
  3748. * @param x defines the first component (0 by default)
  3749. * @param y defines the second component (0 by default)
  3750. * @param z defines the third component (0 by default)
  3751. * @param w defines the fourth component (1.0 by default)
  3752. */
  3753. constructor(x?: number, y?: number, z?: number, w?: number);
  3754. /**
  3755. * Gets a string representation for the current quaternion
  3756. * @returns a string with the Quaternion coordinates
  3757. */
  3758. toString(): string;
  3759. /**
  3760. * Gets the class name of the quaternion
  3761. * @returns the string "Quaternion"
  3762. */
  3763. getClassName(): string;
  3764. /**
  3765. * Gets a hash code for this quaternion
  3766. * @returns the quaternion hash code
  3767. */
  3768. getHashCode(): number;
  3769. /**
  3770. * Copy the quaternion to an array
  3771. * @returns a new array populated with 4 elements from the quaternion coordinates
  3772. */
  3773. asArray(): number[];
  3774. /**
  3775. * Check if two quaternions are equals
  3776. * @param otherQuaternion defines the second operand
  3777. * @return true if the current quaternion and the given one coordinates are strictly equals
  3778. */
  3779. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3780. /**
  3781. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3782. * @param otherQuaternion defines the other quaternion
  3783. * @param epsilon defines the minimal distance to consider equality
  3784. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3785. */
  3786. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3787. /**
  3788. * Clone the current quaternion
  3789. * @returns a new quaternion copied from the current one
  3790. */
  3791. clone(): Quaternion;
  3792. /**
  3793. * Copy a quaternion to the current one
  3794. * @param other defines the other quaternion
  3795. * @returns the updated current quaternion
  3796. */
  3797. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the given float coordinates
  3800. * @param x defines the x coordinate
  3801. * @param y defines the y coordinate
  3802. * @param z defines the z coordinate
  3803. * @param w defines the w coordinate
  3804. * @returns the updated current quaternion
  3805. */
  3806. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3807. /**
  3808. * Updates the current quaternion from the given float coordinates
  3809. * @param x defines the x coordinate
  3810. * @param y defines the y coordinate
  3811. * @param z defines the z coordinate
  3812. * @param w defines the w coordinate
  3813. * @returns the updated current quaternion
  3814. */
  3815. set(x: number, y: number, z: number, w: number): Quaternion;
  3816. /**
  3817. * Adds two quaternions
  3818. * @param other defines the second operand
  3819. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3820. */
  3821. add(other: DeepImmutable<Quaternion>): Quaternion;
  3822. /**
  3823. * Add a quaternion to the current one
  3824. * @param other defines the quaternion to add
  3825. * @returns the current quaternion
  3826. */
  3827. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3828. /**
  3829. * Subtract two quaternions
  3830. * @param other defines the second operand
  3831. * @returns a new quaternion as the subtraction result of the given one from the current one
  3832. */
  3833. subtract(other: Quaternion): Quaternion;
  3834. /**
  3835. * Multiplies the current quaternion by a scale factor
  3836. * @param value defines the scale factor
  3837. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3838. */
  3839. scale(value: number): Quaternion;
  3840. /**
  3841. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3842. * @param scale defines the scale factor
  3843. * @param result defines the Quaternion object where to store the result
  3844. * @returns the unmodified current quaternion
  3845. */
  3846. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3847. /**
  3848. * Multiplies in place the current quaternion by a scale factor
  3849. * @param value defines the scale factor
  3850. * @returns the current modified quaternion
  3851. */
  3852. scaleInPlace(value: number): Quaternion;
  3853. /**
  3854. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3855. * @param scale defines the scale factor
  3856. * @param result defines the Quaternion object where to store the result
  3857. * @returns the unmodified current quaternion
  3858. */
  3859. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3860. /**
  3861. * Multiplies two quaternions
  3862. * @param q1 defines the second operand
  3863. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3864. */
  3865. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3866. /**
  3867. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3868. * @param q1 defines the second operand
  3869. * @param result defines the target quaternion
  3870. * @returns the current quaternion
  3871. */
  3872. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3873. /**
  3874. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3875. * @param q1 defines the second operand
  3876. * @returns the currentupdated quaternion
  3877. */
  3878. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3879. /**
  3880. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3881. * @param ref defines the target quaternion
  3882. * @returns the current quaternion
  3883. */
  3884. conjugateToRef(ref: Quaternion): Quaternion;
  3885. /**
  3886. * Conjugates in place (1-q) the current quaternion
  3887. * @returns the current updated quaternion
  3888. */
  3889. conjugateInPlace(): Quaternion;
  3890. /**
  3891. * Conjugates in place (1-q) the current quaternion
  3892. * @returns a new quaternion
  3893. */
  3894. conjugate(): Quaternion;
  3895. /**
  3896. * Gets length of current quaternion
  3897. * @returns the quaternion length (float)
  3898. */
  3899. length(): number;
  3900. /**
  3901. * Normalize in place the current quaternion
  3902. * @returns the current updated quaternion
  3903. */
  3904. normalize(): Quaternion;
  3905. /**
  3906. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3907. * @param order is a reserved parameter and is ignored for now
  3908. * @returns a new Vector3 containing the Euler angles
  3909. */
  3910. toEulerAngles(order?: string): Vector3;
  3911. /**
  3912. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3913. * @param result defines the vector which will be filled with the Euler angles
  3914. * @returns the current unchanged quaternion
  3915. */
  3916. toEulerAnglesToRef(result: Vector3): Quaternion;
  3917. /**
  3918. * Updates the given rotation matrix with the current quaternion values
  3919. * @param result defines the target matrix
  3920. * @returns the current unchanged quaternion
  3921. */
  3922. toRotationMatrix(result: Matrix): Quaternion;
  3923. /**
  3924. * Updates the current quaternion from the given rotation matrix values
  3925. * @param matrix defines the source matrix
  3926. * @returns the current updated quaternion
  3927. */
  3928. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3929. /**
  3930. * Creates a new quaternion from a rotation matrix
  3931. * @param matrix defines the source matrix
  3932. * @returns a new quaternion created from the given rotation matrix values
  3933. */
  3934. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3935. /**
  3936. * Updates the given quaternion with the given rotation matrix values
  3937. * @param matrix defines the source matrix
  3938. * @param result defines the target quaternion
  3939. */
  3940. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3941. /**
  3942. * Returns the dot product (float) between the quaternions "left" and "right"
  3943. * @param left defines the left operand
  3944. * @param right defines the right operand
  3945. * @returns the dot product
  3946. */
  3947. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3948. /**
  3949. * Checks if the two quaternions are close to each other
  3950. * @param quat0 defines the first quaternion to check
  3951. * @param quat1 defines the second quaternion to check
  3952. * @returns true if the two quaternions are close to each other
  3953. */
  3954. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3955. /**
  3956. * Creates an empty quaternion
  3957. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3958. */
  3959. static Zero(): Quaternion;
  3960. /**
  3961. * Inverse a given quaternion
  3962. * @param q defines the source quaternion
  3963. * @returns a new quaternion as the inverted current quaternion
  3964. */
  3965. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3966. /**
  3967. * Inverse a given quaternion
  3968. * @param q defines the source quaternion
  3969. * @param result the quaternion the result will be stored in
  3970. * @returns the result quaternion
  3971. */
  3972. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3973. /**
  3974. * Creates an identity quaternion
  3975. * @returns the identity quaternion
  3976. */
  3977. static Identity(): Quaternion;
  3978. /**
  3979. * Gets a boolean indicating if the given quaternion is identity
  3980. * @param quaternion defines the quaternion to check
  3981. * @returns true if the quaternion is identity
  3982. */
  3983. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3984. /**
  3985. * Creates a quaternion from a rotation around an axis
  3986. * @param axis defines the axis to use
  3987. * @param angle defines the angle to use
  3988. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3989. */
  3990. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3991. /**
  3992. * Creates a rotation around an axis and stores it into the given quaternion
  3993. * @param axis defines the axis to use
  3994. * @param angle defines the angle to use
  3995. * @param result defines the target quaternion
  3996. * @returns the target quaternion
  3997. */
  3998. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3999. /**
  4000. * Creates a new quaternion from data stored into an array
  4001. * @param array defines the data source
  4002. * @param offset defines the offset in the source array where the data starts
  4003. * @returns a new quaternion
  4004. */
  4005. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4006. /**
  4007. * Updates the given quaternion "result" from the starting index of the given array.
  4008. * @param array the array to pull values from
  4009. * @param offset the offset into the array to start at
  4010. * @param result the quaternion to store the result in
  4011. */
  4012. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4013. /**
  4014. * Create a quaternion from Euler rotation angles
  4015. * @param x Pitch
  4016. * @param y Yaw
  4017. * @param z Roll
  4018. * @returns the new Quaternion
  4019. */
  4020. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4021. /**
  4022. * Updates a quaternion from Euler rotation angles
  4023. * @param x Pitch
  4024. * @param y Yaw
  4025. * @param z Roll
  4026. * @param result the quaternion to store the result
  4027. * @returns the updated quaternion
  4028. */
  4029. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4030. /**
  4031. * Create a quaternion from Euler rotation vector
  4032. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4033. * @returns the new Quaternion
  4034. */
  4035. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4036. /**
  4037. * Updates a quaternion from Euler rotation vector
  4038. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4039. * @param result the quaternion to store the result
  4040. * @returns the updated quaternion
  4041. */
  4042. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4043. /**
  4044. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4045. * @param yaw defines the rotation around Y axis
  4046. * @param pitch defines the rotation around X axis
  4047. * @param roll defines the rotation around Z axis
  4048. * @returns the new quaternion
  4049. */
  4050. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4051. /**
  4052. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4053. * @param yaw defines the rotation around Y axis
  4054. * @param pitch defines the rotation around X axis
  4055. * @param roll defines the rotation around Z axis
  4056. * @param result defines the target quaternion
  4057. */
  4058. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4059. /**
  4060. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4061. * @param alpha defines the rotation around first axis
  4062. * @param beta defines the rotation around second axis
  4063. * @param gamma defines the rotation around third axis
  4064. * @returns the new quaternion
  4065. */
  4066. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4067. /**
  4068. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4069. * @param alpha defines the rotation around first axis
  4070. * @param beta defines the rotation around second axis
  4071. * @param gamma defines the rotation around third axis
  4072. * @param result defines the target quaternion
  4073. */
  4074. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4075. /**
  4076. * 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)
  4077. * @param axis1 defines the first axis
  4078. * @param axis2 defines the second axis
  4079. * @param axis3 defines the third axis
  4080. * @returns the new quaternion
  4081. */
  4082. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4083. /**
  4084. * 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
  4085. * @param axis1 defines the first axis
  4086. * @param axis2 defines the second axis
  4087. * @param axis3 defines the third axis
  4088. * @param ref defines the target quaternion
  4089. */
  4090. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4091. /**
  4092. * Interpolates between two quaternions
  4093. * @param left defines first quaternion
  4094. * @param right defines second quaternion
  4095. * @param amount defines the gradient to use
  4096. * @returns the new interpolated quaternion
  4097. */
  4098. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4099. /**
  4100. * Interpolates between two quaternions and stores it into a target quaternion
  4101. * @param left defines first quaternion
  4102. * @param right defines second quaternion
  4103. * @param amount defines the gradient to use
  4104. * @param result defines the target quaternion
  4105. */
  4106. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4107. /**
  4108. * Interpolate between two quaternions using Hermite interpolation
  4109. * @param value1 defines first quaternion
  4110. * @param tangent1 defines the incoming tangent
  4111. * @param value2 defines second quaternion
  4112. * @param tangent2 defines the outgoing tangent
  4113. * @param amount defines the target quaternion
  4114. * @returns the new interpolated quaternion
  4115. */
  4116. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4117. }
  4118. /**
  4119. * Class used to store matrix data (4x4)
  4120. */
  4121. export class Matrix {
  4122. /**
  4123. * Gets the precision of matrix computations
  4124. */
  4125. static get Use64Bits(): boolean;
  4126. private static _updateFlagSeed;
  4127. private static _identityReadOnly;
  4128. private _isIdentity;
  4129. private _isIdentityDirty;
  4130. private _isIdentity3x2;
  4131. private _isIdentity3x2Dirty;
  4132. /**
  4133. * Gets the update flag of the matrix which is an unique number for the matrix.
  4134. * It will be incremented every time the matrix data change.
  4135. * You can use it to speed the comparison between two versions of the same matrix.
  4136. */
  4137. updateFlag: number;
  4138. private readonly _m;
  4139. /**
  4140. * Gets the internal data of the matrix
  4141. */
  4142. get m(): DeepImmutable<Float32Array | Array<number>>;
  4143. /** @hidden */
  4144. _markAsUpdated(): void;
  4145. /** @hidden */
  4146. private _updateIdentityStatus;
  4147. /**
  4148. * Creates an empty matrix (filled with zeros)
  4149. */
  4150. constructor();
  4151. /**
  4152. * Check if the current matrix is identity
  4153. * @returns true is the matrix is the identity matrix
  4154. */
  4155. isIdentity(): boolean;
  4156. /**
  4157. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4158. * @returns true is the matrix is the identity matrix
  4159. */
  4160. isIdentityAs3x2(): boolean;
  4161. /**
  4162. * Gets the determinant of the matrix
  4163. * @returns the matrix determinant
  4164. */
  4165. determinant(): number;
  4166. /**
  4167. * Returns the matrix as a Float32Array or Array<number>
  4168. * @returns the matrix underlying array
  4169. */
  4170. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4171. /**
  4172. * Returns the matrix as a Float32Array or Array<number>
  4173. * @returns the matrix underlying array.
  4174. */
  4175. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4176. /**
  4177. * Inverts the current matrix in place
  4178. * @returns the current inverted matrix
  4179. */
  4180. invert(): Matrix;
  4181. /**
  4182. * Sets all the matrix elements to zero
  4183. * @returns the current matrix
  4184. */
  4185. reset(): Matrix;
  4186. /**
  4187. * Adds the current matrix with a second one
  4188. * @param other defines the matrix to add
  4189. * @returns a new matrix as the addition of the current matrix and the given one
  4190. */
  4191. add(other: DeepImmutable<Matrix>): Matrix;
  4192. /**
  4193. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4194. * @param other defines the matrix to add
  4195. * @param result defines the target matrix
  4196. * @returns the current matrix
  4197. */
  4198. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4199. /**
  4200. * Adds in place the given matrix to the current matrix
  4201. * @param other defines the second operand
  4202. * @returns the current updated matrix
  4203. */
  4204. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4205. /**
  4206. * Sets the given matrix to the current inverted Matrix
  4207. * @param other defines the target matrix
  4208. * @returns the unmodified current matrix
  4209. */
  4210. invertToRef(other: Matrix): Matrix;
  4211. /**
  4212. * add a value at the specified position in the current Matrix
  4213. * @param index the index of the value within the matrix. between 0 and 15.
  4214. * @param value the value to be added
  4215. * @returns the current updated matrix
  4216. */
  4217. addAtIndex(index: number, value: number): Matrix;
  4218. /**
  4219. * mutiply the specified position in the current Matrix by a value
  4220. * @param index the index of the value within the matrix. between 0 and 15.
  4221. * @param value the value to be added
  4222. * @returns the current updated matrix
  4223. */
  4224. multiplyAtIndex(index: number, value: number): Matrix;
  4225. /**
  4226. * Inserts the translation vector (using 3 floats) in the current matrix
  4227. * @param x defines the 1st component of the translation
  4228. * @param y defines the 2nd component of the translation
  4229. * @param z defines the 3rd component of the translation
  4230. * @returns the current updated matrix
  4231. */
  4232. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4233. /**
  4234. * Adds the translation vector (using 3 floats) in the current matrix
  4235. * @param x defines the 1st component of the translation
  4236. * @param y defines the 2nd component of the translation
  4237. * @param z defines the 3rd component of the translation
  4238. * @returns the current updated matrix
  4239. */
  4240. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4241. /**
  4242. * Inserts the translation vector in the current matrix
  4243. * @param vector3 defines the translation to insert
  4244. * @returns the current updated matrix
  4245. */
  4246. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4247. /**
  4248. * Gets the translation value of the current matrix
  4249. * @returns a new Vector3 as the extracted translation from the matrix
  4250. */
  4251. getTranslation(): Vector3;
  4252. /**
  4253. * Fill a Vector3 with the extracted translation from the matrix
  4254. * @param result defines the Vector3 where to store the translation
  4255. * @returns the current matrix
  4256. */
  4257. getTranslationToRef(result: Vector3): Matrix;
  4258. /**
  4259. * Remove rotation and scaling part from the matrix
  4260. * @returns the updated matrix
  4261. */
  4262. removeRotationAndScaling(): Matrix;
  4263. /**
  4264. * Multiply two matrices
  4265. * @param other defines the second operand
  4266. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4267. */
  4268. multiply(other: DeepImmutable<Matrix>): Matrix;
  4269. /**
  4270. * Copy the current matrix from the given one
  4271. * @param other defines the source matrix
  4272. * @returns the current updated matrix
  4273. */
  4274. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4275. /**
  4276. * Populates the given array from the starting index with the current matrix values
  4277. * @param array defines the target array
  4278. * @param offset defines the offset in the target array where to start storing values
  4279. * @returns the current matrix
  4280. */
  4281. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4282. /**
  4283. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4284. * @param other defines the second operand
  4285. * @param result defines the matrix where to store the multiplication
  4286. * @returns the current matrix
  4287. */
  4288. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4289. /**
  4290. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4291. * @param other defines the second operand
  4292. * @param result defines the array where to store the multiplication
  4293. * @param offset defines the offset in the target array where to start storing values
  4294. * @returns the current matrix
  4295. */
  4296. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4297. /**
  4298. * Check equality between this matrix and a second one
  4299. * @param value defines the second matrix to compare
  4300. * @returns true is the current matrix and the given one values are strictly equal
  4301. */
  4302. equals(value: DeepImmutable<Matrix>): boolean;
  4303. /**
  4304. * Clone the current matrix
  4305. * @returns a new matrix from the current matrix
  4306. */
  4307. clone(): Matrix;
  4308. /**
  4309. * Returns the name of the current matrix class
  4310. * @returns the string "Matrix"
  4311. */
  4312. getClassName(): string;
  4313. /**
  4314. * Gets the hash code of the current matrix
  4315. * @returns the hash code
  4316. */
  4317. getHashCode(): number;
  4318. /**
  4319. * Decomposes the current Matrix into a translation, rotation and scaling components
  4320. * @param scale defines the scale vector3 given as a reference to update
  4321. * @param rotation defines the rotation quaternion given as a reference to update
  4322. * @param translation defines the translation vector3 given as a reference to update
  4323. * @returns true if operation was successful
  4324. */
  4325. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4326. /**
  4327. * Gets specific row of the matrix
  4328. * @param index defines the number of the row to get
  4329. * @returns the index-th row of the current matrix as a new Vector4
  4330. */
  4331. getRow(index: number): Nullable<Vector4>;
  4332. /**
  4333. * Sets the index-th row of the current matrix to the vector4 values
  4334. * @param index defines the number of the row to set
  4335. * @param row defines the target vector4
  4336. * @returns the updated current matrix
  4337. */
  4338. setRow(index: number, row: Vector4): Matrix;
  4339. /**
  4340. * Compute the transpose of the matrix
  4341. * @returns the new transposed matrix
  4342. */
  4343. transpose(): Matrix;
  4344. /**
  4345. * Compute the transpose of the matrix and store it in a given matrix
  4346. * @param result defines the target matrix
  4347. * @returns the current matrix
  4348. */
  4349. transposeToRef(result: Matrix): Matrix;
  4350. /**
  4351. * Sets the index-th row of the current matrix with the given 4 x float values
  4352. * @param index defines the row index
  4353. * @param x defines the x component to set
  4354. * @param y defines the y component to set
  4355. * @param z defines the z component to set
  4356. * @param w defines the w component to set
  4357. * @returns the updated current matrix
  4358. */
  4359. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4360. /**
  4361. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4362. * @param scale defines the scale factor
  4363. * @returns a new matrix
  4364. */
  4365. scale(scale: number): Matrix;
  4366. /**
  4367. * Scale the current matrix values by a factor to a given result matrix
  4368. * @param scale defines the scale factor
  4369. * @param result defines the matrix to store the result
  4370. * @returns the current matrix
  4371. */
  4372. scaleToRef(scale: number, result: Matrix): Matrix;
  4373. /**
  4374. * Scale the current matrix values by a factor and add the result to a given matrix
  4375. * @param scale defines the scale factor
  4376. * @param result defines the Matrix to store the result
  4377. * @returns the current matrix
  4378. */
  4379. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4380. /**
  4381. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4382. * @param ref matrix to store the result
  4383. */
  4384. toNormalMatrix(ref: Matrix): void;
  4385. /**
  4386. * Gets only rotation part of the current matrix
  4387. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4388. */
  4389. getRotationMatrix(): Matrix;
  4390. /**
  4391. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4392. * @param result defines the target matrix to store data to
  4393. * @returns the current matrix
  4394. */
  4395. getRotationMatrixToRef(result: Matrix): Matrix;
  4396. /**
  4397. * Toggles model matrix from being right handed to left handed in place and vice versa
  4398. */
  4399. toggleModelMatrixHandInPlace(): void;
  4400. /**
  4401. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4402. */
  4403. toggleProjectionMatrixHandInPlace(): void;
  4404. /**
  4405. * Creates a matrix from an array
  4406. * @param array defines the source array
  4407. * @param offset defines an offset in the source array
  4408. * @returns a new Matrix set from the starting index of the given array
  4409. */
  4410. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4411. /**
  4412. * Copy the content of an array into a given matrix
  4413. * @param array defines the source array
  4414. * @param offset defines an offset in the source array
  4415. * @param result defines the target matrix
  4416. */
  4417. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4418. /**
  4419. * Stores an array into a matrix after having multiplied each component by a given factor
  4420. * @param array defines the source array
  4421. * @param offset defines the offset in the source array
  4422. * @param scale defines the scaling factor
  4423. * @param result defines the target matrix
  4424. */
  4425. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4426. /**
  4427. * Gets an identity matrix that must not be updated
  4428. */
  4429. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4430. /**
  4431. * Stores a list of values (16) inside a given matrix
  4432. * @param initialM11 defines 1st value of 1st row
  4433. * @param initialM12 defines 2nd value of 1st row
  4434. * @param initialM13 defines 3rd value of 1st row
  4435. * @param initialM14 defines 4th value of 1st row
  4436. * @param initialM21 defines 1st value of 2nd row
  4437. * @param initialM22 defines 2nd value of 2nd row
  4438. * @param initialM23 defines 3rd value of 2nd row
  4439. * @param initialM24 defines 4th value of 2nd row
  4440. * @param initialM31 defines 1st value of 3rd row
  4441. * @param initialM32 defines 2nd value of 3rd row
  4442. * @param initialM33 defines 3rd value of 3rd row
  4443. * @param initialM34 defines 4th value of 3rd row
  4444. * @param initialM41 defines 1st value of 4th row
  4445. * @param initialM42 defines 2nd value of 4th row
  4446. * @param initialM43 defines 3rd value of 4th row
  4447. * @param initialM44 defines 4th value of 4th row
  4448. * @param result defines the target matrix
  4449. */
  4450. 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;
  4451. /**
  4452. * Creates new matrix from a list of values (16)
  4453. * @param initialM11 defines 1st value of 1st row
  4454. * @param initialM12 defines 2nd value of 1st row
  4455. * @param initialM13 defines 3rd value of 1st row
  4456. * @param initialM14 defines 4th value of 1st row
  4457. * @param initialM21 defines 1st value of 2nd row
  4458. * @param initialM22 defines 2nd value of 2nd row
  4459. * @param initialM23 defines 3rd value of 2nd row
  4460. * @param initialM24 defines 4th value of 2nd row
  4461. * @param initialM31 defines 1st value of 3rd row
  4462. * @param initialM32 defines 2nd value of 3rd row
  4463. * @param initialM33 defines 3rd value of 3rd row
  4464. * @param initialM34 defines 4th value of 3rd row
  4465. * @param initialM41 defines 1st value of 4th row
  4466. * @param initialM42 defines 2nd value of 4th row
  4467. * @param initialM43 defines 3rd value of 4th row
  4468. * @param initialM44 defines 4th value of 4th row
  4469. * @returns the new matrix
  4470. */
  4471. 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;
  4472. /**
  4473. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4474. * @param scale defines the scale vector3
  4475. * @param rotation defines the rotation quaternion
  4476. * @param translation defines the translation vector3
  4477. * @returns a new matrix
  4478. */
  4479. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4480. /**
  4481. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4482. * @param scale defines the scale vector3
  4483. * @param rotation defines the rotation quaternion
  4484. * @param translation defines the translation vector3
  4485. * @param result defines the target matrix
  4486. */
  4487. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4488. /**
  4489. * Creates a new identity matrix
  4490. * @returns a new identity matrix
  4491. */
  4492. static Identity(): Matrix;
  4493. /**
  4494. * Creates a new identity matrix and stores the result in a given matrix
  4495. * @param result defines the target matrix
  4496. */
  4497. static IdentityToRef(result: Matrix): void;
  4498. /**
  4499. * Creates a new zero matrix
  4500. * @returns a new zero matrix
  4501. */
  4502. static Zero(): Matrix;
  4503. /**
  4504. * Creates a new rotation matrix for "angle" radians around the X axis
  4505. * @param angle defines the angle (in radians) to use
  4506. * @return the new matrix
  4507. */
  4508. static RotationX(angle: number): Matrix;
  4509. /**
  4510. * Creates a new matrix as the invert of a given matrix
  4511. * @param source defines the source matrix
  4512. * @returns the new matrix
  4513. */
  4514. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4515. /**
  4516. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationXToRef(angle: number, result: Matrix): void;
  4521. /**
  4522. * Creates a new rotation matrix for "angle" radians around the Y axis
  4523. * @param angle defines the angle (in radians) to use
  4524. * @return the new matrix
  4525. */
  4526. static RotationY(angle: number): Matrix;
  4527. /**
  4528. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4529. * @param angle defines the angle (in radians) to use
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationYToRef(angle: number, result: Matrix): void;
  4533. /**
  4534. * Creates a new rotation matrix for "angle" radians around the Z axis
  4535. * @param angle defines the angle (in radians) to use
  4536. * @return the new matrix
  4537. */
  4538. static RotationZ(angle: number): Matrix;
  4539. /**
  4540. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4541. * @param angle defines the angle (in radians) to use
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationZToRef(angle: number, result: Matrix): void;
  4545. /**
  4546. * Creates a new rotation matrix for "angle" radians around the given axis
  4547. * @param axis defines the axis to use
  4548. * @param angle defines the angle (in radians) to use
  4549. * @return the new matrix
  4550. */
  4551. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4552. /**
  4553. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4554. * @param axis defines the axis to use
  4555. * @param angle defines the angle (in radians) to use
  4556. * @param result defines the target matrix
  4557. */
  4558. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4559. /**
  4560. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4561. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4562. * @param from defines the vector to align
  4563. * @param to defines the vector to align to
  4564. * @param result defines the target matrix
  4565. */
  4566. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4567. /**
  4568. * Creates a rotation matrix
  4569. * @param yaw defines the yaw angle in radians (Y axis)
  4570. * @param pitch defines the pitch angle in radians (X axis)
  4571. * @param roll defines the roll angle in radians (Z axis)
  4572. * @returns the new rotation matrix
  4573. */
  4574. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4575. /**
  4576. * Creates a rotation matrix and stores it in a given matrix
  4577. * @param yaw defines the yaw angle in radians (Y axis)
  4578. * @param pitch defines the pitch angle in radians (X axis)
  4579. * @param roll defines the roll angle in radians (Z axis)
  4580. * @param result defines the target matrix
  4581. */
  4582. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4583. /**
  4584. * Creates a scaling matrix
  4585. * @param x defines the scale factor on X axis
  4586. * @param y defines the scale factor on Y axis
  4587. * @param z defines the scale factor on Z axis
  4588. * @returns the new matrix
  4589. */
  4590. static Scaling(x: number, y: number, z: number): Matrix;
  4591. /**
  4592. * Creates a scaling matrix and stores it in a given matrix
  4593. * @param x defines the scale factor on X axis
  4594. * @param y defines the scale factor on Y axis
  4595. * @param z defines the scale factor on Z axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4599. /**
  4600. * Creates a translation matrix
  4601. * @param x defines the translation on X axis
  4602. * @param y defines the translation on Y axis
  4603. * @param z defines the translationon Z axis
  4604. * @returns the new matrix
  4605. */
  4606. static Translation(x: number, y: number, z: number): Matrix;
  4607. /**
  4608. * Creates a translation matrix and stores it in a given matrix
  4609. * @param x defines the translation on X axis
  4610. * @param y defines the translation on Y axis
  4611. * @param z defines the translationon Z axis
  4612. * @param result defines the target matrix
  4613. */
  4614. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4615. /**
  4616. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4617. * @param startValue defines the start value
  4618. * @param endValue defines the end value
  4619. * @param gradient defines the gradient factor
  4620. * @returns the new matrix
  4621. */
  4622. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4623. /**
  4624. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4625. * @param startValue defines the start value
  4626. * @param endValue defines the end value
  4627. * @param gradient defines the gradient factor
  4628. * @param result defines the Matrix object where to store data
  4629. */
  4630. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4631. /**
  4632. * Builds a new matrix whose values are computed by:
  4633. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4634. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4635. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4636. * @param startValue defines the first matrix
  4637. * @param endValue defines the second matrix
  4638. * @param gradient defines the gradient between the two matrices
  4639. * @returns the new matrix
  4640. */
  4641. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4642. /**
  4643. * Update a matrix to values which are computed by:
  4644. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4645. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4646. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4647. * @param startValue defines the first matrix
  4648. * @param endValue defines the second matrix
  4649. * @param gradient defines the gradient between the two matrices
  4650. * @param result defines the target matrix
  4651. */
  4652. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4653. /**
  4654. * 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"
  4655. * This function works in left handed mode
  4656. * @param eye defines the final position of the entity
  4657. * @param target defines where the entity should look at
  4658. * @param up defines the up vector for the entity
  4659. * @returns the new matrix
  4660. */
  4661. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4662. /**
  4663. * 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".
  4664. * This function works in left handed mode
  4665. * @param eye defines the final position of the entity
  4666. * @param target defines where the entity should look at
  4667. * @param up defines the up vector for the entity
  4668. * @param result defines the target matrix
  4669. */
  4670. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4671. /**
  4672. * 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"
  4673. * This function works in right handed mode
  4674. * @param eye defines the final position of the entity
  4675. * @param target defines where the entity should look at
  4676. * @param up defines the up vector for the entity
  4677. * @returns the new matrix
  4678. */
  4679. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4680. /**
  4681. * 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".
  4682. * This function works in right handed mode
  4683. * @param eye defines the final position of the entity
  4684. * @param target defines where the entity should look at
  4685. * @param up defines the up vector for the entity
  4686. * @param result defines the target matrix
  4687. */
  4688. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4689. /**
  4690. * Create a left-handed orthographic projection matrix
  4691. * @param width defines the viewport width
  4692. * @param height defines the viewport height
  4693. * @param znear defines the near clip plane
  4694. * @param zfar defines the far clip plane
  4695. * @returns a new matrix as a left-handed orthographic projection matrix
  4696. */
  4697. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4698. /**
  4699. * Store a left-handed orthographic projection to a given matrix
  4700. * @param width defines the viewport width
  4701. * @param height defines the viewport height
  4702. * @param znear defines the near clip plane
  4703. * @param zfar defines the far clip plane
  4704. * @param result defines the target matrix
  4705. */
  4706. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4707. /**
  4708. * Create a left-handed orthographic projection matrix
  4709. * @param left defines the viewport left coordinate
  4710. * @param right defines the viewport right coordinate
  4711. * @param bottom defines the viewport bottom coordinate
  4712. * @param top defines the viewport top coordinate
  4713. * @param znear defines the near clip plane
  4714. * @param zfar defines the far clip plane
  4715. * @returns a new matrix as a left-handed orthographic projection matrix
  4716. */
  4717. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4718. /**
  4719. * Stores a left-handed orthographic projection into a given matrix
  4720. * @param left defines the viewport left coordinate
  4721. * @param right defines the viewport right coordinate
  4722. * @param bottom defines the viewport bottom coordinate
  4723. * @param top defines the viewport top coordinate
  4724. * @param znear defines the near clip plane
  4725. * @param zfar defines the far clip plane
  4726. * @param result defines the target matrix
  4727. */
  4728. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4729. /**
  4730. * Creates a right-handed orthographic projection matrix
  4731. * @param left defines the viewport left coordinate
  4732. * @param right defines the viewport right coordinate
  4733. * @param bottom defines the viewport bottom coordinate
  4734. * @param top defines the viewport top coordinate
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @returns a new matrix as a right-handed orthographic projection matrix
  4738. */
  4739. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4740. /**
  4741. * Stores a right-handed orthographic projection into a given matrix
  4742. * @param left defines the viewport left coordinate
  4743. * @param right defines the viewport right coordinate
  4744. * @param bottom defines the viewport bottom coordinate
  4745. * @param top defines the viewport top coordinate
  4746. * @param znear defines the near clip plane
  4747. * @param zfar defines the far clip plane
  4748. * @param result defines the target matrix
  4749. */
  4750. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4751. /**
  4752. * Creates a left-handed perspective projection matrix
  4753. * @param width defines the viewport width
  4754. * @param height defines the viewport height
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a left-handed perspective projection matrix
  4758. */
  4759. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Creates a left-handed perspective projection matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @returns a new matrix as a left-handed perspective projection matrix
  4767. */
  4768. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4769. /**
  4770. * Stores a left-handed perspective projection into a given matrix
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar defines the far clip plane
  4775. * @param result defines the target matrix
  4776. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4777. */
  4778. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4779. /**
  4780. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4781. * @param fov defines the horizontal field of view
  4782. * @param aspect defines the aspect ratio
  4783. * @param znear defines the near clip plane
  4784. * @param zfar not used as infinity is used as far clip
  4785. * @param result defines the target matrix
  4786. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4787. */
  4788. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4789. /**
  4790. * Creates a right-handed perspective projection matrix
  4791. * @param fov defines the horizontal field of view
  4792. * @param aspect defines the aspect ratio
  4793. * @param znear defines the near clip plane
  4794. * @param zfar defines the far clip plane
  4795. * @returns a new matrix as a right-handed perspective projection matrix
  4796. */
  4797. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4798. /**
  4799. * Stores a right-handed perspective projection into a given matrix
  4800. * @param fov defines the horizontal field of view
  4801. * @param aspect defines the aspect ratio
  4802. * @param znear defines the near clip plane
  4803. * @param zfar defines the far clip plane
  4804. * @param result defines the target matrix
  4805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4806. */
  4807. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4808. /**
  4809. * Stores a right-handed perspective projection into a given matrix
  4810. * @param fov defines the horizontal field of view
  4811. * @param aspect defines the aspect ratio
  4812. * @param znear defines the near clip plane
  4813. * @param zfar not used as infinity is used as far clip
  4814. * @param result defines the target matrix
  4815. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4816. */
  4817. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4818. /**
  4819. * Stores a perspective projection for WebVR info a given matrix
  4820. * @param fov defines the field of view
  4821. * @param znear defines the near clip plane
  4822. * @param zfar defines the far clip plane
  4823. * @param result defines the target matrix
  4824. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4825. */
  4826. static PerspectiveFovWebVRToRef(fov: {
  4827. upDegrees: number;
  4828. downDegrees: number;
  4829. leftDegrees: number;
  4830. rightDegrees: number;
  4831. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4832. /**
  4833. * Computes a complete transformation matrix
  4834. * @param viewport defines the viewport to use
  4835. * @param world defines the world matrix
  4836. * @param view defines the view matrix
  4837. * @param projection defines the projection matrix
  4838. * @param zmin defines the near clip plane
  4839. * @param zmax defines the far clip plane
  4840. * @returns the transformation matrix
  4841. */
  4842. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4843. /**
  4844. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4845. * @param matrix defines the matrix to use
  4846. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4847. */
  4848. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4849. /**
  4850. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4851. * @param matrix defines the matrix to use
  4852. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4853. */
  4854. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4855. /**
  4856. * Compute the transpose of a given matrix
  4857. * @param matrix defines the matrix to transpose
  4858. * @returns the new matrix
  4859. */
  4860. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4861. /**
  4862. * Compute the transpose of a matrix and store it in a target matrix
  4863. * @param matrix defines the matrix to transpose
  4864. * @param result defines the target matrix
  4865. */
  4866. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4867. /**
  4868. * Computes a reflection matrix from a plane
  4869. * @param plane defines the reflection plane
  4870. * @returns a new matrix
  4871. */
  4872. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4873. /**
  4874. * Computes a reflection matrix from a plane
  4875. * @param plane defines the reflection plane
  4876. * @param result defines the target matrix
  4877. */
  4878. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4879. /**
  4880. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4881. * @param xaxis defines the value of the 1st axis
  4882. * @param yaxis defines the value of the 2nd axis
  4883. * @param zaxis defines the value of the 3rd axis
  4884. * @param result defines the target matrix
  4885. */
  4886. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4887. /**
  4888. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4889. * @param quat defines the quaternion to use
  4890. * @param result defines the target matrix
  4891. */
  4892. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4893. }
  4894. /**
  4895. * @hidden
  4896. */
  4897. export class TmpVectors {
  4898. static Vector2: Vector2[];
  4899. static Vector3: Vector3[];
  4900. static Vector4: Vector4[];
  4901. static Quaternion: Quaternion[];
  4902. static Matrix: Matrix[];
  4903. }
  4904. }
  4905. declare module "babylonjs/Maths/math.path" {
  4906. import { DeepImmutable, Nullable } from "babylonjs/types";
  4907. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4908. /**
  4909. * Defines potential orientation for back face culling
  4910. */
  4911. export enum Orientation {
  4912. /**
  4913. * Clockwise
  4914. */
  4915. CW = 0,
  4916. /** Counter clockwise */
  4917. CCW = 1
  4918. }
  4919. /** Class used to represent a Bezier curve */
  4920. export class BezierCurve {
  4921. /**
  4922. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4923. * @param t defines the time
  4924. * @param x1 defines the left coordinate on X axis
  4925. * @param y1 defines the left coordinate on Y axis
  4926. * @param x2 defines the right coordinate on X axis
  4927. * @param y2 defines the right coordinate on Y axis
  4928. * @returns the interpolated value
  4929. */
  4930. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4931. }
  4932. /**
  4933. * Defines angle representation
  4934. */
  4935. export class Angle {
  4936. private _radians;
  4937. /**
  4938. * Creates an Angle object of "radians" radians (float).
  4939. * @param radians the angle in radians
  4940. */
  4941. constructor(radians: number);
  4942. /**
  4943. * Get value in degrees
  4944. * @returns the Angle value in degrees (float)
  4945. */
  4946. degrees(): number;
  4947. /**
  4948. * Get value in radians
  4949. * @returns the Angle value in radians (float)
  4950. */
  4951. radians(): number;
  4952. /**
  4953. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4954. * @param a defines first point as the origin
  4955. * @param b defines point
  4956. * @returns a new Angle
  4957. */
  4958. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4959. /**
  4960. * Gets a new Angle object from the given float in radians
  4961. * @param radians defines the angle value in radians
  4962. * @returns a new Angle
  4963. */
  4964. static FromRadians(radians: number): Angle;
  4965. /**
  4966. * Gets a new Angle object from the given float in degrees
  4967. * @param degrees defines the angle value in degrees
  4968. * @returns a new Angle
  4969. */
  4970. static FromDegrees(degrees: number): Angle;
  4971. }
  4972. /**
  4973. * This represents an arc in a 2d space.
  4974. */
  4975. export class Arc2 {
  4976. /** Defines the start point of the arc */
  4977. startPoint: Vector2;
  4978. /** Defines the mid point of the arc */
  4979. midPoint: Vector2;
  4980. /** Defines the end point of the arc */
  4981. endPoint: Vector2;
  4982. /**
  4983. * Defines the center point of the arc.
  4984. */
  4985. centerPoint: Vector2;
  4986. /**
  4987. * Defines the radius of the arc.
  4988. */
  4989. radius: number;
  4990. /**
  4991. * Defines the angle of the arc (from mid point to end point).
  4992. */
  4993. angle: Angle;
  4994. /**
  4995. * Defines the start angle of the arc (from start point to middle point).
  4996. */
  4997. startAngle: Angle;
  4998. /**
  4999. * Defines the orientation of the arc (clock wise/counter clock wise).
  5000. */
  5001. orientation: Orientation;
  5002. /**
  5003. * Creates an Arc object from the three given points : start, middle and end.
  5004. * @param startPoint Defines the start point of the arc
  5005. * @param midPoint Defines the midlle point of the arc
  5006. * @param endPoint Defines the end point of the arc
  5007. */
  5008. constructor(
  5009. /** Defines the start point of the arc */
  5010. startPoint: Vector2,
  5011. /** Defines the mid point of the arc */
  5012. midPoint: Vector2,
  5013. /** Defines the end point of the arc */
  5014. endPoint: Vector2);
  5015. }
  5016. /**
  5017. * Represents a 2D path made up of multiple 2D points
  5018. */
  5019. export class Path2 {
  5020. private _points;
  5021. private _length;
  5022. /**
  5023. * If the path start and end point are the same
  5024. */
  5025. closed: boolean;
  5026. /**
  5027. * Creates a Path2 object from the starting 2D coordinates x and y.
  5028. * @param x the starting points x value
  5029. * @param y the starting points y value
  5030. */
  5031. constructor(x: number, y: number);
  5032. /**
  5033. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5034. * @param x the added points x value
  5035. * @param y the added points y value
  5036. * @returns the updated Path2.
  5037. */
  5038. addLineTo(x: number, y: number): Path2;
  5039. /**
  5040. * 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.
  5041. * @param midX middle point x value
  5042. * @param midY middle point y value
  5043. * @param endX end point x value
  5044. * @param endY end point y value
  5045. * @param numberOfSegments (default: 36)
  5046. * @returns the updated Path2.
  5047. */
  5048. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5049. /**
  5050. * Closes the Path2.
  5051. * @returns the Path2.
  5052. */
  5053. close(): Path2;
  5054. /**
  5055. * Gets the sum of the distance between each sequential point in the path
  5056. * @returns the Path2 total length (float).
  5057. */
  5058. length(): number;
  5059. /**
  5060. * Gets the points which construct the path
  5061. * @returns the Path2 internal array of points.
  5062. */
  5063. getPoints(): Vector2[];
  5064. /**
  5065. * Retreives the point at the distance aways from the starting point
  5066. * @param normalizedLengthPosition the length along the path to retreive the point from
  5067. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5068. */
  5069. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5070. /**
  5071. * Creates a new path starting from an x and y position
  5072. * @param x starting x value
  5073. * @param y starting y value
  5074. * @returns a new Path2 starting at the coordinates (x, y).
  5075. */
  5076. static StartingAt(x: number, y: number): Path2;
  5077. }
  5078. /**
  5079. * Represents a 3D path made up of multiple 3D points
  5080. */
  5081. export class Path3D {
  5082. /**
  5083. * an array of Vector3, the curve axis of the Path3D
  5084. */
  5085. path: Vector3[];
  5086. private _curve;
  5087. private _distances;
  5088. private _tangents;
  5089. private _normals;
  5090. private _binormals;
  5091. private _raw;
  5092. private _alignTangentsWithPath;
  5093. private readonly _pointAtData;
  5094. /**
  5095. * new Path3D(path, normal, raw)
  5096. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5097. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5098. * @param path an array of Vector3, the curve axis of the Path3D
  5099. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5100. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5101. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5102. */
  5103. constructor(
  5104. /**
  5105. * an array of Vector3, the curve axis of the Path3D
  5106. */
  5107. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5108. /**
  5109. * Returns the Path3D array of successive Vector3 designing its curve.
  5110. * @returns the Path3D array of successive Vector3 designing its curve.
  5111. */
  5112. getCurve(): Vector3[];
  5113. /**
  5114. * Returns the Path3D array of successive Vector3 designing its curve.
  5115. * @returns the Path3D array of successive Vector3 designing its curve.
  5116. */
  5117. getPoints(): Vector3[];
  5118. /**
  5119. * @returns the computed length (float) of the path.
  5120. */
  5121. length(): number;
  5122. /**
  5123. * Returns an array populated with tangent vectors on each Path3D curve point.
  5124. * @returns an array populated with tangent vectors on each Path3D curve point.
  5125. */
  5126. getTangents(): Vector3[];
  5127. /**
  5128. * Returns an array populated with normal vectors on each Path3D curve point.
  5129. * @returns an array populated with normal vectors on each Path3D curve point.
  5130. */
  5131. getNormals(): Vector3[];
  5132. /**
  5133. * Returns an array populated with binormal vectors on each Path3D curve point.
  5134. * @returns an array populated with binormal vectors on each Path3D curve point.
  5135. */
  5136. getBinormals(): Vector3[];
  5137. /**
  5138. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5139. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5140. */
  5141. getDistances(): number[];
  5142. /**
  5143. * Returns an interpolated point along this path
  5144. * @param position the position of the point along this path, from 0.0 to 1.0
  5145. * @returns a new Vector3 as the point
  5146. */
  5147. getPointAt(position: number): Vector3;
  5148. /**
  5149. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5150. * @param position the position of the point along this path, from 0.0 to 1.0
  5151. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5152. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5153. */
  5154. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5155. /**
  5156. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5157. * @param position the position of the point along this path, from 0.0 to 1.0
  5158. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5159. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5160. */
  5161. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5162. /**
  5163. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5164. * @param position the position of the point along this path, from 0.0 to 1.0
  5165. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5166. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5167. */
  5168. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5169. /**
  5170. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5171. * @param position the position of the point along this path, from 0.0 to 1.0
  5172. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5173. */
  5174. getDistanceAt(position: number): number;
  5175. /**
  5176. * Returns the array index of the previous point of an interpolated point along this path
  5177. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5178. * @returns the array index
  5179. */
  5180. getPreviousPointIndexAt(position: number): number;
  5181. /**
  5182. * 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)
  5183. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5184. * @returns the sub position
  5185. */
  5186. getSubPositionAt(position: number): number;
  5187. /**
  5188. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5189. * @param target the vector of which to get the closest position to
  5190. * @returns the position of the closest virtual point on this path to the target vector
  5191. */
  5192. getClosestPositionTo(target: Vector3): number;
  5193. /**
  5194. * Returns a sub path (slice) of this path
  5195. * @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
  5196. * @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
  5197. * @returns a sub path (slice) of this path
  5198. */
  5199. slice(start?: number, end?: number): Path3D;
  5200. /**
  5201. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5202. * @param path path which all values are copied into the curves points
  5203. * @param firstNormal which should be projected onto the curve
  5204. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5205. * @returns the same object updated.
  5206. */
  5207. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5208. private _compute;
  5209. private _getFirstNonNullVector;
  5210. private _getLastNonNullVector;
  5211. private _normalVector;
  5212. /**
  5213. * Updates the point at data for an interpolated point along this curve
  5214. * @param position the position of the point along this curve, from 0.0 to 1.0
  5215. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5216. * @returns the (updated) point at data
  5217. */
  5218. private _updatePointAtData;
  5219. /**
  5220. * Updates the point at data from the specified parameters
  5221. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5222. * @param point the interpolated point
  5223. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5224. */
  5225. private _setPointAtData;
  5226. /**
  5227. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5228. */
  5229. private _updateInterpolationMatrix;
  5230. }
  5231. /**
  5232. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5233. * A Curve3 is designed from a series of successive Vector3.
  5234. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5235. */
  5236. export class Curve3 {
  5237. private _points;
  5238. private _length;
  5239. /**
  5240. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5241. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5242. * @param v1 (Vector3) the control point
  5243. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5250. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5251. * @param v1 (Vector3) the first control point
  5252. * @param v2 (Vector3) the second control point
  5253. * @param v3 (Vector3) the end point of the Cubic Bezier
  5254. * @param nbPoints (integer) the wanted number of points in the curve
  5255. * @returns the created Curve3
  5256. */
  5257. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5258. /**
  5259. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5260. * @param p1 (Vector3) the origin point of the Hermite Spline
  5261. * @param t1 (Vector3) the tangent vector at the origin point
  5262. * @param p2 (Vector3) the end point of the Hermite Spline
  5263. * @param t2 (Vector3) the tangent vector at the end point
  5264. * @param nbPoints (integer) the wanted number of points in the curve
  5265. * @returns the created Curve3
  5266. */
  5267. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5268. /**
  5269. * Returns a Curve3 object along a CatmullRom Spline curve :
  5270. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5271. * @param nbPoints (integer) the wanted number of points between each curve control points
  5272. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5273. * @returns the created Curve3
  5274. */
  5275. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5276. /**
  5277. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5278. * A Curve3 is designed from a series of successive Vector3.
  5279. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5280. * @param points points which make up the curve
  5281. */
  5282. constructor(points: Vector3[]);
  5283. /**
  5284. * @returns the Curve3 stored array of successive Vector3
  5285. */
  5286. getPoints(): Vector3[];
  5287. /**
  5288. * @returns the computed length (float) of the curve.
  5289. */
  5290. length(): number;
  5291. /**
  5292. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5293. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5294. * curveA and curveB keep unchanged.
  5295. * @param curve the curve to continue from this curve
  5296. * @returns the newly constructed curve
  5297. */
  5298. continue(curve: DeepImmutable<Curve3>): Curve3;
  5299. private _computeLength;
  5300. }
  5301. }
  5302. declare module "babylonjs/Animations/easing" {
  5303. /**
  5304. * This represents the main contract an easing function should follow.
  5305. * Easing functions are used throughout the animation system.
  5306. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5307. */
  5308. export interface IEasingFunction {
  5309. /**
  5310. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5311. * of the easing function.
  5312. * The link below provides some of the most common examples of easing functions.
  5313. * @see https://easings.net/
  5314. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5315. * @returns the corresponding value on the curve defined by the easing function
  5316. */
  5317. ease(gradient: number): number;
  5318. }
  5319. /**
  5320. * Base class used for every default easing function.
  5321. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5322. */
  5323. export class EasingFunction implements IEasingFunction {
  5324. /**
  5325. * Interpolation follows the mathematical formula associated with the easing function.
  5326. */
  5327. static readonly EASINGMODE_EASEIN: number;
  5328. /**
  5329. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5330. */
  5331. static readonly EASINGMODE_EASEOUT: number;
  5332. /**
  5333. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5334. */
  5335. static readonly EASINGMODE_EASEINOUT: number;
  5336. private _easingMode;
  5337. /**
  5338. * Sets the easing mode of the current function.
  5339. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5340. */
  5341. setEasingMode(easingMode: number): void;
  5342. /**
  5343. * Gets the current easing mode.
  5344. * @returns the easing mode
  5345. */
  5346. getEasingMode(): number;
  5347. /**
  5348. * @hidden
  5349. */
  5350. easeInCore(gradient: number): number;
  5351. /**
  5352. * Given an input gradient between 0 and 1, this returns the corresponding value
  5353. * of the easing function.
  5354. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5355. * @returns the corresponding value on the curve defined by the easing function
  5356. */
  5357. ease(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a circle shape (see link below).
  5361. * @see https://easings.net/#easeInCirc
  5362. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class CircleEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a ease back shape (see link below).
  5370. * @see https://easings.net/#easeInBack
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class BackEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the amplitude of the function */
  5375. amplitude: number;
  5376. /**
  5377. * Instantiates a back ease easing
  5378. * @see https://easings.net/#easeInBack
  5379. * @param amplitude Defines the amplitude of the function
  5380. */
  5381. constructor(
  5382. /** Defines the amplitude of the function */
  5383. amplitude?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a bouncing shape (see link below).
  5389. * @see https://easings.net/#easeInBounce
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class BounceEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the number of bounces */
  5394. bounces: number;
  5395. /** Defines the amplitude of the bounce */
  5396. bounciness: number;
  5397. /**
  5398. * Instantiates a bounce easing
  5399. * @see https://easings.net/#easeInBounce
  5400. * @param bounces Defines the number of bounces
  5401. * @param bounciness Defines the amplitude of the bounce
  5402. */
  5403. constructor(
  5404. /** Defines the number of bounces */
  5405. bounces?: number,
  5406. /** Defines the amplitude of the bounce */
  5407. bounciness?: number);
  5408. /** @hidden */
  5409. easeInCore(gradient: number): number;
  5410. }
  5411. /**
  5412. * Easing function with a power of 3 shape (see link below).
  5413. * @see https://easings.net/#easeInCubic
  5414. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5415. */
  5416. export class CubicEase extends EasingFunction implements IEasingFunction {
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. /**
  5421. * Easing function with an elastic shape (see link below).
  5422. * @see https://easings.net/#easeInElastic
  5423. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5424. */
  5425. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5426. /** Defines the number of oscillations*/
  5427. oscillations: number;
  5428. /** Defines the amplitude of the oscillations*/
  5429. springiness: number;
  5430. /**
  5431. * Instantiates an elastic easing function
  5432. * @see https://easings.net/#easeInElastic
  5433. * @param oscillations Defines the number of oscillations
  5434. * @param springiness Defines the amplitude of the oscillations
  5435. */
  5436. constructor(
  5437. /** Defines the number of oscillations*/
  5438. oscillations?: number,
  5439. /** Defines the amplitude of the oscillations*/
  5440. springiness?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with an exponential shape (see link below).
  5446. * @see https://easings.net/#easeInExpo
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5450. /** Defines the exponent of the function */
  5451. exponent: number;
  5452. /**
  5453. * Instantiates an exponential easing function
  5454. * @see https://easings.net/#easeInExpo
  5455. * @param exponent Defines the exponent of the function
  5456. */
  5457. constructor(
  5458. /** Defines the exponent of the function */
  5459. exponent?: number);
  5460. /** @hidden */
  5461. easeInCore(gradient: number): number;
  5462. }
  5463. /**
  5464. * Easing function with a power shape (see link below).
  5465. * @see https://easings.net/#easeInQuad
  5466. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5467. */
  5468. export class PowerEase extends EasingFunction implements IEasingFunction {
  5469. /** Defines the power of the function */
  5470. power: number;
  5471. /**
  5472. * Instantiates an power base easing function
  5473. * @see https://easings.net/#easeInQuad
  5474. * @param power Defines the power of the function
  5475. */
  5476. constructor(
  5477. /** Defines the power of the function */
  5478. power?: number);
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a power of 2 shape (see link below).
  5484. * @see https://easings.net/#easeInQuad
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5488. /** @hidden */
  5489. easeInCore(gradient: number): number;
  5490. }
  5491. /**
  5492. * Easing function with a power of 4 shape (see link below).
  5493. * @see https://easings.net/#easeInQuart
  5494. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5495. */
  5496. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5497. /** @hidden */
  5498. easeInCore(gradient: number): number;
  5499. }
  5500. /**
  5501. * Easing function with a power of 5 shape (see link below).
  5502. * @see https://easings.net/#easeInQuint
  5503. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5504. */
  5505. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5506. /** @hidden */
  5507. easeInCore(gradient: number): number;
  5508. }
  5509. /**
  5510. * Easing function with a sin shape (see link below).
  5511. * @see https://easings.net/#easeInSine
  5512. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5513. */
  5514. export class SineEase extends EasingFunction implements IEasingFunction {
  5515. /** @hidden */
  5516. easeInCore(gradient: number): number;
  5517. }
  5518. /**
  5519. * Easing function with a bezier shape (see link below).
  5520. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5521. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5522. */
  5523. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5524. /** Defines the x component of the start tangent in the bezier curve */
  5525. x1: number;
  5526. /** Defines the y component of the start tangent in the bezier curve */
  5527. y1: number;
  5528. /** Defines the x component of the end tangent in the bezier curve */
  5529. x2: number;
  5530. /** Defines the y component of the end tangent in the bezier curve */
  5531. y2: number;
  5532. /**
  5533. * Instantiates a bezier function
  5534. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5535. * @param x1 Defines the x component of the start tangent in the bezier curve
  5536. * @param y1 Defines the y component of the start tangent in the bezier curve
  5537. * @param x2 Defines the x component of the end tangent in the bezier curve
  5538. * @param y2 Defines the y component of the end tangent in the bezier curve
  5539. */
  5540. constructor(
  5541. /** Defines the x component of the start tangent in the bezier curve */
  5542. x1?: number,
  5543. /** Defines the y component of the start tangent in the bezier curve */
  5544. y1?: number,
  5545. /** Defines the x component of the end tangent in the bezier curve */
  5546. x2?: number,
  5547. /** Defines the y component of the end tangent in the bezier curve */
  5548. y2?: number);
  5549. /** @hidden */
  5550. easeInCore(gradient: number): number;
  5551. }
  5552. }
  5553. declare module "babylonjs/Maths/math.color" {
  5554. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5555. /**
  5556. * Class used to hold a RBG color
  5557. */
  5558. export class Color3 {
  5559. /**
  5560. * Defines the red component (between 0 and 1, default is 0)
  5561. */
  5562. r: number;
  5563. /**
  5564. * Defines the green component (between 0 and 1, default is 0)
  5565. */
  5566. g: number;
  5567. /**
  5568. * Defines the blue component (between 0 and 1, default is 0)
  5569. */
  5570. b: number;
  5571. /**
  5572. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5573. * @param r defines the red component (between 0 and 1, default is 0)
  5574. * @param g defines the green component (between 0 and 1, default is 0)
  5575. * @param b defines the blue component (between 0 and 1, default is 0)
  5576. */
  5577. constructor(
  5578. /**
  5579. * Defines the red component (between 0 and 1, default is 0)
  5580. */
  5581. r?: number,
  5582. /**
  5583. * Defines the green component (between 0 and 1, default is 0)
  5584. */
  5585. g?: number,
  5586. /**
  5587. * Defines the blue component (between 0 and 1, default is 0)
  5588. */
  5589. b?: number);
  5590. /**
  5591. * Creates a string with the Color3 current values
  5592. * @returns the string representation of the Color3 object
  5593. */
  5594. toString(): string;
  5595. /**
  5596. * Returns the string "Color3"
  5597. * @returns "Color3"
  5598. */
  5599. getClassName(): string;
  5600. /**
  5601. * Compute the Color3 hash code
  5602. * @returns an unique number that can be used to hash Color3 objects
  5603. */
  5604. getHashCode(): number;
  5605. /**
  5606. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5607. * @param array defines the array where to store the r,g,b components
  5608. * @param index defines an optional index in the target array to define where to start storing values
  5609. * @returns the current Color3 object
  5610. */
  5611. toArray(array: FloatArray, index?: number): Color3;
  5612. /**
  5613. * Update the current color with values stored in an array from the starting index of the given array
  5614. * @param array defines the source array
  5615. * @param offset defines an offset in the source array
  5616. * @returns the current Color3 object
  5617. */
  5618. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5619. /**
  5620. * Returns a new Color4 object from the current Color3 and the given alpha
  5621. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5622. * @returns a new Color4 object
  5623. */
  5624. toColor4(alpha?: number): Color4;
  5625. /**
  5626. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5627. * @returns the new array
  5628. */
  5629. asArray(): number[];
  5630. /**
  5631. * Returns the luminance value
  5632. * @returns a float value
  5633. */
  5634. toLuminance(): number;
  5635. /**
  5636. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5637. * @param otherColor defines the second operand
  5638. * @returns the new Color3 object
  5639. */
  5640. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5641. /**
  5642. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5643. * @param otherColor defines the second operand
  5644. * @param result defines the Color3 object where to store the result
  5645. * @returns the current Color3
  5646. */
  5647. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5648. /**
  5649. * Determines equality between Color3 objects
  5650. * @param otherColor defines the second operand
  5651. * @returns true if the rgb values are equal to the given ones
  5652. */
  5653. equals(otherColor: DeepImmutable<Color3>): boolean;
  5654. /**
  5655. * Determines equality between the current Color3 object and a set of r,b,g values
  5656. * @param r defines the red component to check
  5657. * @param g defines the green component to check
  5658. * @param b defines the blue component to check
  5659. * @returns true if the rgb values are equal to the given ones
  5660. */
  5661. equalsFloats(r: number, g: number, b: number): boolean;
  5662. /**
  5663. * Multiplies in place each rgb value by scale
  5664. * @param scale defines the scaling factor
  5665. * @returns the updated Color3
  5666. */
  5667. scale(scale: number): Color3;
  5668. /**
  5669. * Multiplies the rgb values by scale and stores the result into "result"
  5670. * @param scale defines the scaling factor
  5671. * @param result defines the Color3 object where to store the result
  5672. * @returns the unmodified current Color3
  5673. */
  5674. scaleToRef(scale: number, result: Color3): Color3;
  5675. /**
  5676. * Scale the current Color3 values by a factor and add the result to a given Color3
  5677. * @param scale defines the scale factor
  5678. * @param result defines color to store the result into
  5679. * @returns the unmodified current Color3
  5680. */
  5681. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5682. /**
  5683. * Clamps the rgb values by the min and max values and stores the result into "result"
  5684. * @param min defines minimum clamping value (default is 0)
  5685. * @param max defines maximum clamping value (default is 1)
  5686. * @param result defines color to store the result into
  5687. * @returns the original Color3
  5688. */
  5689. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5690. /**
  5691. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5692. * @param otherColor defines the second operand
  5693. * @returns the new Color3
  5694. */
  5695. add(otherColor: DeepImmutable<Color3>): Color3;
  5696. /**
  5697. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5698. * @param otherColor defines the second operand
  5699. * @param result defines Color3 object to store the result into
  5700. * @returns the unmodified current Color3
  5701. */
  5702. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5703. /**
  5704. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5705. * @param otherColor defines the second operand
  5706. * @returns the new Color3
  5707. */
  5708. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5709. /**
  5710. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5711. * @param otherColor defines the second operand
  5712. * @param result defines Color3 object to store the result into
  5713. * @returns the unmodified current Color3
  5714. */
  5715. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5716. /**
  5717. * Copy the current object
  5718. * @returns a new Color3 copied the current one
  5719. */
  5720. clone(): Color3;
  5721. /**
  5722. * Copies the rgb values from the source in the current Color3
  5723. * @param source defines the source Color3 object
  5724. * @returns the updated Color3 object
  5725. */
  5726. copyFrom(source: DeepImmutable<Color3>): Color3;
  5727. /**
  5728. * Updates the Color3 rgb values from the given floats
  5729. * @param r defines the red component to read from
  5730. * @param g defines the green component to read from
  5731. * @param b defines the blue component to read from
  5732. * @returns the current Color3 object
  5733. */
  5734. copyFromFloats(r: number, g: number, b: number): Color3;
  5735. /**
  5736. * Updates the Color3 rgb values from the given floats
  5737. * @param r defines the red component to read from
  5738. * @param g defines the green component to read from
  5739. * @param b defines the blue component to read from
  5740. * @returns the current Color3 object
  5741. */
  5742. set(r: number, g: number, b: number): Color3;
  5743. /**
  5744. * Compute the Color3 hexadecimal code as a string
  5745. * @returns a string containing the hexadecimal representation of the Color3 object
  5746. */
  5747. toHexString(): string;
  5748. /**
  5749. * Computes a new Color3 converted from the current one to linear space
  5750. * @returns a new Color3 object
  5751. */
  5752. toLinearSpace(): Color3;
  5753. /**
  5754. * Converts current color in rgb space to HSV values
  5755. * @returns a new color3 representing the HSV values
  5756. */
  5757. toHSV(): Color3;
  5758. /**
  5759. * Converts current color in rgb space to HSV values
  5760. * @param result defines the Color3 where to store the HSV values
  5761. */
  5762. toHSVToRef(result: Color3): void;
  5763. /**
  5764. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5765. * @param convertedColor defines the Color3 object where to store the linear space version
  5766. * @returns the unmodified Color3
  5767. */
  5768. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5769. /**
  5770. * Computes a new Color3 converted from the current one to gamma space
  5771. * @returns a new Color3 object
  5772. */
  5773. toGammaSpace(): Color3;
  5774. /**
  5775. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5776. * @param convertedColor defines the Color3 object where to store the gamma space version
  5777. * @returns the unmodified Color3
  5778. */
  5779. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5780. private static _BlackReadOnly;
  5781. /**
  5782. * Convert Hue, saturation and value to a Color3 (RGB)
  5783. * @param hue defines the hue
  5784. * @param saturation defines the saturation
  5785. * @param value defines the value
  5786. * @param result defines the Color3 where to store the RGB values
  5787. */
  5788. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5789. /**
  5790. * Creates a new Color3 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color3 object
  5793. */
  5794. static FromHexString(hex: string): Color3;
  5795. /**
  5796. * Creates a new Color3 from the starting index of the given array
  5797. * @param array defines the source array
  5798. * @param offset defines an offset in the source array
  5799. * @returns a new Color3 object
  5800. */
  5801. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5802. /**
  5803. * Creates a new Color3 from the starting index element of the given array
  5804. * @param array defines the source array to read from
  5805. * @param offset defines the offset in the source array
  5806. * @param result defines the target Color3 object
  5807. */
  5808. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5809. /**
  5810. * Creates a new Color3 from integer values (< 256)
  5811. * @param r defines the red component to read from (value between 0 and 255)
  5812. * @param g defines the green component to read from (value between 0 and 255)
  5813. * @param b defines the blue component to read from (value between 0 and 255)
  5814. * @returns a new Color3 object
  5815. */
  5816. static FromInts(r: number, g: number, b: number): Color3;
  5817. /**
  5818. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5819. * @param start defines the start Color3 value
  5820. * @param end defines the end Color3 value
  5821. * @param amount defines the gradient value between start and end
  5822. * @returns a new Color3 object
  5823. */
  5824. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5825. /**
  5826. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5827. * @param left defines the start value
  5828. * @param right defines the end value
  5829. * @param amount defines the gradient factor
  5830. * @param result defines the Color3 object where to store the result
  5831. */
  5832. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5833. /**
  5834. * Returns a Color3 value containing a red color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Red(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a green color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Green(): Color3;
  5843. /**
  5844. * Returns a Color3 value containing a blue color
  5845. * @returns a new Color3 object
  5846. */
  5847. static Blue(): Color3;
  5848. /**
  5849. * Returns a Color3 value containing a black color
  5850. * @returns a new Color3 object
  5851. */
  5852. static Black(): Color3;
  5853. /**
  5854. * Gets a Color3 value containing a black color that must not be updated
  5855. */
  5856. static get BlackReadOnly(): DeepImmutable<Color3>;
  5857. /**
  5858. * Returns a Color3 value containing a white color
  5859. * @returns a new Color3 object
  5860. */
  5861. static White(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a purple color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Purple(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a magenta color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Magenta(): Color3;
  5872. /**
  5873. * Returns a Color3 value containing a yellow color
  5874. * @returns a new Color3 object
  5875. */
  5876. static Yellow(): Color3;
  5877. /**
  5878. * Returns a Color3 value containing a gray color
  5879. * @returns a new Color3 object
  5880. */
  5881. static Gray(): Color3;
  5882. /**
  5883. * Returns a Color3 value containing a teal color
  5884. * @returns a new Color3 object
  5885. */
  5886. static Teal(): Color3;
  5887. /**
  5888. * Returns a Color3 value containing a random color
  5889. * @returns a new Color3 object
  5890. */
  5891. static Random(): Color3;
  5892. }
  5893. /**
  5894. * Class used to hold a RBGA color
  5895. */
  5896. export class Color4 {
  5897. /**
  5898. * Defines the red component (between 0 and 1, default is 0)
  5899. */
  5900. r: number;
  5901. /**
  5902. * Defines the green component (between 0 and 1, default is 0)
  5903. */
  5904. g: number;
  5905. /**
  5906. * Defines the blue component (between 0 and 1, default is 0)
  5907. */
  5908. b: number;
  5909. /**
  5910. * Defines the alpha component (between 0 and 1, default is 1)
  5911. */
  5912. a: number;
  5913. /**
  5914. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5915. * @param r defines the red component (between 0 and 1, default is 0)
  5916. * @param g defines the green component (between 0 and 1, default is 0)
  5917. * @param b defines the blue component (between 0 and 1, default is 0)
  5918. * @param a defines the alpha component (between 0 and 1, default is 1)
  5919. */
  5920. constructor(
  5921. /**
  5922. * Defines the red component (between 0 and 1, default is 0)
  5923. */
  5924. r?: number,
  5925. /**
  5926. * Defines the green component (between 0 and 1, default is 0)
  5927. */
  5928. g?: number,
  5929. /**
  5930. * Defines the blue component (between 0 and 1, default is 0)
  5931. */
  5932. b?: number,
  5933. /**
  5934. * Defines the alpha component (between 0 and 1, default is 1)
  5935. */
  5936. a?: number);
  5937. /**
  5938. * Adds in place the given Color4 values to the current Color4 object
  5939. * @param right defines the second operand
  5940. * @returns the current updated Color4 object
  5941. */
  5942. addInPlace(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5945. * @returns the new array
  5946. */
  5947. asArray(): number[];
  5948. /**
  5949. * Stores from the starting index in the given array the Color4 successive values
  5950. * @param array defines the array where to store the r,g,b components
  5951. * @param index defines an optional index in the target array to define where to start storing values
  5952. * @returns the current Color4 object
  5953. */
  5954. toArray(array: number[], index?: number): Color4;
  5955. /**
  5956. * Update the current color with values stored in an array from the starting index of the given array
  5957. * @param array defines the source array
  5958. * @param offset defines an offset in the source array
  5959. * @returns the current Color4 object
  5960. */
  5961. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5962. /**
  5963. * Determines equality between Color4 objects
  5964. * @param otherColor defines the second operand
  5965. * @returns true if the rgba values are equal to the given ones
  5966. */
  5967. equals(otherColor: DeepImmutable<Color4>): boolean;
  5968. /**
  5969. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5970. * @param right defines the second operand
  5971. * @returns a new Color4 object
  5972. */
  5973. add(right: DeepImmutable<Color4>): Color4;
  5974. /**
  5975. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5976. * @param right defines the second operand
  5977. * @returns a new Color4 object
  5978. */
  5979. subtract(right: DeepImmutable<Color4>): Color4;
  5980. /**
  5981. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5982. * @param right defines the second operand
  5983. * @param result defines the Color4 object where to store the result
  5984. * @returns the current Color4 object
  5985. */
  5986. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5987. /**
  5988. * Creates a new Color4 with the current Color4 values multiplied by scale
  5989. * @param scale defines the scaling factor to apply
  5990. * @returns a new Color4 object
  5991. */
  5992. scale(scale: number): Color4;
  5993. /**
  5994. * Multiplies the current Color4 values by scale and stores the result in "result"
  5995. * @param scale defines the scaling factor to apply
  5996. * @param result defines the Color4 object where to store the result
  5997. * @returns the current unmodified Color4
  5998. */
  5999. scaleToRef(scale: number, result: Color4): Color4;
  6000. /**
  6001. * Scale the current Color4 values by a factor and add the result to a given Color4
  6002. * @param scale defines the scale factor
  6003. * @param result defines the Color4 object where to store the result
  6004. * @returns the unmodified current Color4
  6005. */
  6006. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6007. /**
  6008. * Clamps the rgb values by the min and max values and stores the result into "result"
  6009. * @param min defines minimum clamping value (default is 0)
  6010. * @param max defines maximum clamping value (default is 1)
  6011. * @param result defines color to store the result into.
  6012. * @returns the cuurent Color4
  6013. */
  6014. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6015. /**
  6016. * Multipy an Color4 value by another and return a new Color4 object
  6017. * @param color defines the Color4 value to multiply by
  6018. * @returns a new Color4 object
  6019. */
  6020. multiply(color: Color4): Color4;
  6021. /**
  6022. * Multipy a Color4 value by another and push the result in a reference value
  6023. * @param color defines the Color4 value to multiply by
  6024. * @param result defines the Color4 to fill the result in
  6025. * @returns the result Color4
  6026. */
  6027. multiplyToRef(color: Color4, result: Color4): Color4;
  6028. /**
  6029. * Creates a string with the Color4 current values
  6030. * @returns the string representation of the Color4 object
  6031. */
  6032. toString(): string;
  6033. /**
  6034. * Returns the string "Color4"
  6035. * @returns "Color4"
  6036. */
  6037. getClassName(): string;
  6038. /**
  6039. * Compute the Color4 hash code
  6040. * @returns an unique number that can be used to hash Color4 objects
  6041. */
  6042. getHashCode(): number;
  6043. /**
  6044. * Creates a new Color4 copied from the current one
  6045. * @returns a new Color4 object
  6046. */
  6047. clone(): Color4;
  6048. /**
  6049. * Copies the given Color4 values into the current one
  6050. * @param source defines the source Color4 object
  6051. * @returns the current updated Color4 object
  6052. */
  6053. copyFrom(source: Color4): Color4;
  6054. /**
  6055. * Copies the given float values into the current one
  6056. * @param r defines the red component to read from
  6057. * @param g defines the green component to read from
  6058. * @param b defines the blue component to read from
  6059. * @param a defines the alpha component to read from
  6060. * @returns the current updated Color4 object
  6061. */
  6062. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6063. /**
  6064. * Copies the given float values into the current one
  6065. * @param r defines the red component to read from
  6066. * @param g defines the green component to read from
  6067. * @param b defines the blue component to read from
  6068. * @param a defines the alpha component to read from
  6069. * @returns the current updated Color4 object
  6070. */
  6071. set(r: number, g: number, b: number, a: number): Color4;
  6072. /**
  6073. * Compute the Color4 hexadecimal code as a string
  6074. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6075. * @returns a string containing the hexadecimal representation of the Color4 object
  6076. */
  6077. toHexString(returnAsColor3?: boolean): string;
  6078. /**
  6079. * Computes a new Color4 converted from the current one to linear space
  6080. * @returns a new Color4 object
  6081. */
  6082. toLinearSpace(): Color4;
  6083. /**
  6084. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6085. * @param convertedColor defines the Color4 object where to store the linear space version
  6086. * @returns the unmodified Color4
  6087. */
  6088. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6089. /**
  6090. * Computes a new Color4 converted from the current one to gamma space
  6091. * @returns a new Color4 object
  6092. */
  6093. toGammaSpace(): Color4;
  6094. /**
  6095. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6096. * @param convertedColor defines the Color4 object where to store the gamma space version
  6097. * @returns the unmodified Color4
  6098. */
  6099. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6100. /**
  6101. * Creates a new Color4 from the string containing valid hexadecimal values
  6102. * @param hex defines a string containing valid hexadecimal values
  6103. * @returns a new Color4 object
  6104. */
  6105. static FromHexString(hex: string): Color4;
  6106. /**
  6107. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6108. * @param left defines the start value
  6109. * @param right defines the end value
  6110. * @param amount defines the gradient factor
  6111. * @returns a new Color4 object
  6112. */
  6113. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6114. /**
  6115. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6116. * @param left defines the start value
  6117. * @param right defines the end value
  6118. * @param amount defines the gradient factor
  6119. * @param result defines the Color4 object where to store data
  6120. */
  6121. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6122. /**
  6123. * Creates a new Color4 from a Color3 and an alpha value
  6124. * @param color3 defines the source Color3 to read from
  6125. * @param alpha defines the alpha component (1.0 by default)
  6126. * @returns a new Color4 object
  6127. */
  6128. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6129. /**
  6130. * Creates a new Color4 from the starting index element of the given array
  6131. * @param array defines the source array to read from
  6132. * @param offset defines the offset in the source array
  6133. * @returns a new Color4 object
  6134. */
  6135. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6136. /**
  6137. * Creates a new Color4 from the starting index element of the given array
  6138. * @param array defines the source array to read from
  6139. * @param offset defines the offset in the source array
  6140. * @param result defines the target Color4 object
  6141. */
  6142. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6143. /**
  6144. * Creates a new Color3 from integer values (< 256)
  6145. * @param r defines the red component to read from (value between 0 and 255)
  6146. * @param g defines the green component to read from (value between 0 and 255)
  6147. * @param b defines the blue component to read from (value between 0 and 255)
  6148. * @param a defines the alpha component to read from (value between 0 and 255)
  6149. * @returns a new Color3 object
  6150. */
  6151. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6152. /**
  6153. * Check the content of a given array and convert it to an array containing RGBA data
  6154. * If the original array was already containing count * 4 values then it is returned directly
  6155. * @param colors defines the array to check
  6156. * @param count defines the number of RGBA data to expect
  6157. * @returns an array containing count * 4 values (RGBA)
  6158. */
  6159. static CheckColors4(colors: number[], count: number): number[];
  6160. }
  6161. /**
  6162. * @hidden
  6163. */
  6164. export class TmpColors {
  6165. static Color3: Color3[];
  6166. static Color4: Color4[];
  6167. }
  6168. }
  6169. declare module "babylonjs/Animations/animationKey" {
  6170. /**
  6171. * Defines an interface which represents an animation key frame
  6172. */
  6173. export interface IAnimationKey {
  6174. /**
  6175. * Frame of the key frame
  6176. */
  6177. frame: number;
  6178. /**
  6179. * Value at the specifies key frame
  6180. */
  6181. value: any;
  6182. /**
  6183. * The input tangent for the cubic hermite spline
  6184. */
  6185. inTangent?: any;
  6186. /**
  6187. * The output tangent for the cubic hermite spline
  6188. */
  6189. outTangent?: any;
  6190. /**
  6191. * The animation interpolation type
  6192. */
  6193. interpolation?: AnimationKeyInterpolation;
  6194. }
  6195. /**
  6196. * Enum for the animation key frame interpolation type
  6197. */
  6198. export enum AnimationKeyInterpolation {
  6199. /**
  6200. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6201. */
  6202. STEP = 1
  6203. }
  6204. }
  6205. declare module "babylonjs/Animations/animationRange" {
  6206. /**
  6207. * Represents the range of an animation
  6208. */
  6209. export class AnimationRange {
  6210. /**The name of the animation range**/
  6211. name: string;
  6212. /**The starting frame of the animation */
  6213. from: number;
  6214. /**The ending frame of the animation*/
  6215. to: number;
  6216. /**
  6217. * Initializes the range of an animation
  6218. * @param name The name of the animation range
  6219. * @param from The starting frame of the animation
  6220. * @param to The ending frame of the animation
  6221. */
  6222. constructor(
  6223. /**The name of the animation range**/
  6224. name: string,
  6225. /**The starting frame of the animation */
  6226. from: number,
  6227. /**The ending frame of the animation*/
  6228. to: number);
  6229. /**
  6230. * Makes a copy of the animation range
  6231. * @returns A copy of the animation range
  6232. */
  6233. clone(): AnimationRange;
  6234. }
  6235. }
  6236. declare module "babylonjs/Animations/animationEvent" {
  6237. /**
  6238. * Composed of a frame, and an action function
  6239. */
  6240. export class AnimationEvent {
  6241. /** The frame for which the event is triggered **/
  6242. frame: number;
  6243. /** The event to perform when triggered **/
  6244. action: (currentFrame: number) => void;
  6245. /** Specifies if the event should be triggered only once**/
  6246. onlyOnce?: boolean | undefined;
  6247. /**
  6248. * Specifies if the animation event is done
  6249. */
  6250. isDone: boolean;
  6251. /**
  6252. * Initializes the animation event
  6253. * @param frame The frame for which the event is triggered
  6254. * @param action The event to perform when triggered
  6255. * @param onlyOnce Specifies if the event should be triggered only once
  6256. */
  6257. constructor(
  6258. /** The frame for which the event is triggered **/
  6259. frame: number,
  6260. /** The event to perform when triggered **/
  6261. action: (currentFrame: number) => void,
  6262. /** Specifies if the event should be triggered only once**/
  6263. onlyOnce?: boolean | undefined);
  6264. /** @hidden */
  6265. _clone(): AnimationEvent;
  6266. }
  6267. }
  6268. declare module "babylonjs/Behaviors/behavior" {
  6269. import { Nullable } from "babylonjs/types";
  6270. /**
  6271. * Interface used to define a behavior
  6272. */
  6273. export interface Behavior<T> {
  6274. /** gets or sets behavior's name */
  6275. name: string;
  6276. /**
  6277. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6278. */
  6279. init(): void;
  6280. /**
  6281. * Called when the behavior is attached to a target
  6282. * @param target defines the target where the behavior is attached to
  6283. */
  6284. attach(target: T): void;
  6285. /**
  6286. * Called when the behavior is detached from its target
  6287. */
  6288. detach(): void;
  6289. }
  6290. /**
  6291. * Interface implemented by classes supporting behaviors
  6292. */
  6293. export interface IBehaviorAware<T> {
  6294. /**
  6295. * Attach a behavior
  6296. * @param behavior defines the behavior to attach
  6297. * @returns the current host
  6298. */
  6299. addBehavior(behavior: Behavior<T>): T;
  6300. /**
  6301. * Remove a behavior from the current object
  6302. * @param behavior defines the behavior to detach
  6303. * @returns the current host
  6304. */
  6305. removeBehavior(behavior: Behavior<T>): T;
  6306. /**
  6307. * Gets a behavior using its name to search
  6308. * @param name defines the name to search
  6309. * @returns the behavior or null if not found
  6310. */
  6311. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6312. }
  6313. }
  6314. declare module "babylonjs/Misc/smartArray" {
  6315. /**
  6316. * Defines an array and its length.
  6317. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6318. */
  6319. export interface ISmartArrayLike<T> {
  6320. /**
  6321. * The data of the array.
  6322. */
  6323. data: Array<T>;
  6324. /**
  6325. * The active length of the array.
  6326. */
  6327. length: number;
  6328. }
  6329. /**
  6330. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6331. */
  6332. export class SmartArray<T> implements ISmartArrayLike<T> {
  6333. /**
  6334. * The full set of data from the array.
  6335. */
  6336. data: Array<T>;
  6337. /**
  6338. * The active length of the array.
  6339. */
  6340. length: number;
  6341. protected _id: number;
  6342. /**
  6343. * Instantiates a Smart Array.
  6344. * @param capacity defines the default capacity of the array.
  6345. */
  6346. constructor(capacity: number);
  6347. /**
  6348. * Pushes a value at the end of the active data.
  6349. * @param value defines the object to push in the array.
  6350. */
  6351. push(value: T): void;
  6352. /**
  6353. * Iterates over the active data and apply the lambda to them.
  6354. * @param func defines the action to apply on each value.
  6355. */
  6356. forEach(func: (content: T) => void): void;
  6357. /**
  6358. * Sorts the full sets of data.
  6359. * @param compareFn defines the comparison function to apply.
  6360. */
  6361. sort(compareFn: (a: T, b: T) => number): void;
  6362. /**
  6363. * Resets the active data to an empty array.
  6364. */
  6365. reset(): void;
  6366. /**
  6367. * Releases all the data from the array as well as the array.
  6368. */
  6369. dispose(): void;
  6370. /**
  6371. * Concats the active data with a given array.
  6372. * @param array defines the data to concatenate with.
  6373. */
  6374. concat(array: any): void;
  6375. /**
  6376. * Returns the position of a value in the active data.
  6377. * @param value defines the value to find the index for
  6378. * @returns the index if found in the active data otherwise -1
  6379. */
  6380. indexOf(value: T): number;
  6381. /**
  6382. * Returns whether an element is part of the active data.
  6383. * @param value defines the value to look for
  6384. * @returns true if found in the active data otherwise false
  6385. */
  6386. contains(value: T): boolean;
  6387. private static _GlobalId;
  6388. }
  6389. /**
  6390. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6391. * The data in this array can only be present once
  6392. */
  6393. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6394. private _duplicateId;
  6395. /**
  6396. * Pushes a value at the end of the active data.
  6397. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6398. * @param value defines the object to push in the array.
  6399. */
  6400. push(value: T): void;
  6401. /**
  6402. * Pushes a value at the end of the active data.
  6403. * If the data is already present, it won t be added again
  6404. * @param value defines the object to push in the array.
  6405. * @returns true if added false if it was already present
  6406. */
  6407. pushNoDuplicate(value: T): boolean;
  6408. /**
  6409. * Resets the active data to an empty array.
  6410. */
  6411. reset(): void;
  6412. /**
  6413. * Concats the active data with a given array.
  6414. * This ensures no dupplicate will be present in the result.
  6415. * @param array defines the data to concatenate with.
  6416. */
  6417. concatWithNoDuplicate(array: any): void;
  6418. }
  6419. }
  6420. declare module "babylonjs/Cameras/cameraInputsManager" {
  6421. import { Nullable } from "babylonjs/types";
  6422. import { Camera } from "babylonjs/Cameras/camera";
  6423. /**
  6424. * @ignore
  6425. * This is a list of all the different input types that are available in the application.
  6426. * Fo instance: ArcRotateCameraGamepadInput...
  6427. */
  6428. export var CameraInputTypes: {};
  6429. /**
  6430. * This is the contract to implement in order to create a new input class.
  6431. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6432. */
  6433. export interface ICameraInput<TCamera extends Camera> {
  6434. /**
  6435. * Defines the camera the input is attached to.
  6436. */
  6437. camera: Nullable<TCamera>;
  6438. /**
  6439. * Gets the class name of the current intput.
  6440. * @returns the class name
  6441. */
  6442. getClassName(): string;
  6443. /**
  6444. * Get the friendly name associated with the input class.
  6445. * @returns the input friendly name
  6446. */
  6447. getSimpleName(): string;
  6448. /**
  6449. * Attach the input controls to a specific dom element to get the input from.
  6450. * @param element Defines the element the controls should be listened from
  6451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6452. */
  6453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6454. /**
  6455. * Detach the current controls from the specified dom element.
  6456. * @param element Defines the element to stop listening the inputs from
  6457. */
  6458. detachControl(element: Nullable<HTMLElement>): void;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs?: () => void;
  6464. }
  6465. /**
  6466. * Represents a map of input types to input instance or input index to input instance.
  6467. */
  6468. export interface CameraInputsMap<TCamera extends Camera> {
  6469. /**
  6470. * Accessor to the input by input type.
  6471. */
  6472. [name: string]: ICameraInput<TCamera>;
  6473. /**
  6474. * Accessor to the input by input index.
  6475. */
  6476. [idx: number]: ICameraInput<TCamera>;
  6477. }
  6478. /**
  6479. * This represents the input manager used within a camera.
  6480. * It helps dealing with all the different kind of input attached to a camera.
  6481. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6482. */
  6483. export class CameraInputsManager<TCamera extends Camera> {
  6484. /**
  6485. * Defines the list of inputs attahed to the camera.
  6486. */
  6487. attached: CameraInputsMap<TCamera>;
  6488. /**
  6489. * Defines the dom element the camera is collecting inputs from.
  6490. * This is null if the controls have not been attached.
  6491. */
  6492. attachedElement: Nullable<HTMLElement>;
  6493. /**
  6494. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6495. */
  6496. noPreventDefault: boolean;
  6497. /**
  6498. * Defined the camera the input manager belongs to.
  6499. */
  6500. camera: TCamera;
  6501. /**
  6502. * Update the current camera state depending on the inputs that have been used this frame.
  6503. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6504. */
  6505. checkInputs: () => void;
  6506. /**
  6507. * Instantiate a new Camera Input Manager.
  6508. * @param camera Defines the camera the input manager blongs to
  6509. */
  6510. constructor(camera: TCamera);
  6511. /**
  6512. * Add an input method to a camera
  6513. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6514. * @param input camera input method
  6515. */
  6516. add(input: ICameraInput<TCamera>): void;
  6517. /**
  6518. * Remove a specific input method from a camera
  6519. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6520. * @param inputToRemove camera input method
  6521. */
  6522. remove(inputToRemove: ICameraInput<TCamera>): void;
  6523. /**
  6524. * Remove a specific input type from a camera
  6525. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6526. * @param inputType the type of the input to remove
  6527. */
  6528. removeByType(inputType: string): void;
  6529. private _addCheckInputs;
  6530. /**
  6531. * Attach the input controls to the currently attached dom element to listen the events from.
  6532. * @param input Defines the input to attach
  6533. */
  6534. attachInput(input: ICameraInput<TCamera>): void;
  6535. /**
  6536. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6537. * @param element Defines the dom element to collect the events from
  6538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6539. */
  6540. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6541. /**
  6542. * Detach the current manager inputs controls from a specific dom element.
  6543. * @param element Defines the dom element to collect the events from
  6544. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6545. */
  6546. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6547. /**
  6548. * Rebuild the dynamic inputCheck function from the current list of
  6549. * defined inputs in the manager.
  6550. */
  6551. rebuildInputCheck(): void;
  6552. /**
  6553. * Remove all attached input methods from a camera
  6554. */
  6555. clear(): void;
  6556. /**
  6557. * Serialize the current input manager attached to a camera.
  6558. * This ensures than once parsed,
  6559. * the input associated to the camera will be identical to the current ones
  6560. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6561. */
  6562. serialize(serializedCamera: any): void;
  6563. /**
  6564. * Parses an input manager serialized JSON to restore the previous list of inputs
  6565. * and states associated to a camera.
  6566. * @param parsedCamera Defines the JSON to parse
  6567. */
  6568. parse(parsedCamera: any): void;
  6569. }
  6570. }
  6571. declare module "babylonjs/Meshes/buffer" {
  6572. import { Nullable, DataArray } from "babylonjs/types";
  6573. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6574. /**
  6575. * Class used to store data that will be store in GPU memory
  6576. */
  6577. export class Buffer {
  6578. private _engine;
  6579. private _buffer;
  6580. /** @hidden */
  6581. _data: Nullable<DataArray>;
  6582. private _updatable;
  6583. private _instanced;
  6584. private _divisor;
  6585. /**
  6586. * Gets the byte stride.
  6587. */
  6588. readonly byteStride: number;
  6589. /**
  6590. * Constructor
  6591. * @param engine the engine
  6592. * @param data the data to use for this buffer
  6593. * @param updatable whether the data is updatable
  6594. * @param stride the stride (optional)
  6595. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6596. * @param instanced whether the buffer is instanced (optional)
  6597. * @param useBytes set to true if the stride in in bytes (optional)
  6598. * @param divisor sets an optional divisor for instances (1 by default)
  6599. */
  6600. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6601. /**
  6602. * Create a new VertexBuffer based on the current buffer
  6603. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6604. * @param offset defines offset in the buffer (0 by default)
  6605. * @param size defines the size in floats of attributes (position is 3 for instance)
  6606. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6607. * @param instanced defines if the vertex buffer contains indexed data
  6608. * @param useBytes defines if the offset and stride are in bytes *
  6609. * @param divisor sets an optional divisor for instances (1 by default)
  6610. * @returns the new vertex buffer
  6611. */
  6612. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6613. /**
  6614. * Gets a boolean indicating if the Buffer is updatable?
  6615. * @returns true if the buffer is updatable
  6616. */
  6617. isUpdatable(): boolean;
  6618. /**
  6619. * Gets current buffer's data
  6620. * @returns a DataArray or null
  6621. */
  6622. getData(): Nullable<DataArray>;
  6623. /**
  6624. * Gets underlying native buffer
  6625. * @returns underlying native buffer
  6626. */
  6627. getBuffer(): Nullable<DataBuffer>;
  6628. /**
  6629. * Gets the stride in float32 units (i.e. byte stride / 4).
  6630. * May not be an integer if the byte stride is not divisible by 4.
  6631. * @returns the stride in float32 units
  6632. * @deprecated Please use byteStride instead.
  6633. */
  6634. getStrideSize(): number;
  6635. /**
  6636. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6637. * @param data defines the data to store
  6638. */
  6639. create(data?: Nullable<DataArray>): void;
  6640. /** @hidden */
  6641. _rebuild(): void;
  6642. /**
  6643. * Update current buffer data
  6644. * @param data defines the data to store
  6645. */
  6646. update(data: DataArray): void;
  6647. /**
  6648. * Updates the data directly.
  6649. * @param data the new data
  6650. * @param offset the new offset
  6651. * @param vertexCount the vertex count (optional)
  6652. * @param useBytes set to true if the offset is in bytes
  6653. */
  6654. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6655. /**
  6656. * Release all resources
  6657. */
  6658. dispose(): void;
  6659. }
  6660. /**
  6661. * Specialized buffer used to store vertex data
  6662. */
  6663. export class VertexBuffer {
  6664. /** @hidden */
  6665. _buffer: Buffer;
  6666. private _kind;
  6667. private _size;
  6668. private _ownsBuffer;
  6669. private _instanced;
  6670. private _instanceDivisor;
  6671. /**
  6672. * The byte type.
  6673. */
  6674. static readonly BYTE: number;
  6675. /**
  6676. * The unsigned byte type.
  6677. */
  6678. static readonly UNSIGNED_BYTE: number;
  6679. /**
  6680. * The short type.
  6681. */
  6682. static readonly SHORT: number;
  6683. /**
  6684. * The unsigned short type.
  6685. */
  6686. static readonly UNSIGNED_SHORT: number;
  6687. /**
  6688. * The integer type.
  6689. */
  6690. static readonly INT: number;
  6691. /**
  6692. * The unsigned integer type.
  6693. */
  6694. static readonly UNSIGNED_INT: number;
  6695. /**
  6696. * The float type.
  6697. */
  6698. static readonly FLOAT: number;
  6699. /**
  6700. * Gets or sets the instance divisor when in instanced mode
  6701. */
  6702. get instanceDivisor(): number;
  6703. set instanceDivisor(value: number);
  6704. /**
  6705. * Gets the byte stride.
  6706. */
  6707. readonly byteStride: number;
  6708. /**
  6709. * Gets the byte offset.
  6710. */
  6711. readonly byteOffset: number;
  6712. /**
  6713. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6714. */
  6715. readonly normalized: boolean;
  6716. /**
  6717. * Gets the data type of each component in the array.
  6718. */
  6719. readonly type: number;
  6720. /**
  6721. * Constructor
  6722. * @param engine the engine
  6723. * @param data the data to use for this vertex buffer
  6724. * @param kind the vertex buffer kind
  6725. * @param updatable whether the data is updatable
  6726. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6727. * @param stride the stride (optional)
  6728. * @param instanced whether the buffer is instanced (optional)
  6729. * @param offset the offset of the data (optional)
  6730. * @param size the number of components (optional)
  6731. * @param type the type of the component (optional)
  6732. * @param normalized whether the data contains normalized data (optional)
  6733. * @param useBytes set to true if stride and offset are in bytes (optional)
  6734. * @param divisor defines the instance divisor to use (1 by default)
  6735. */
  6736. 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);
  6737. /** @hidden */
  6738. _rebuild(): void;
  6739. /**
  6740. * Returns the kind of the VertexBuffer (string)
  6741. * @returns a string
  6742. */
  6743. getKind(): string;
  6744. /**
  6745. * Gets a boolean indicating if the VertexBuffer is updatable?
  6746. * @returns true if the buffer is updatable
  6747. */
  6748. isUpdatable(): boolean;
  6749. /**
  6750. * Gets current buffer's data
  6751. * @returns a DataArray or null
  6752. */
  6753. getData(): Nullable<DataArray>;
  6754. /**
  6755. * Gets underlying native buffer
  6756. * @returns underlying native buffer
  6757. */
  6758. getBuffer(): Nullable<DataBuffer>;
  6759. /**
  6760. * Gets the stride in float32 units (i.e. byte stride / 4).
  6761. * May not be an integer if the byte stride is not divisible by 4.
  6762. * @returns the stride in float32 units
  6763. * @deprecated Please use byteStride instead.
  6764. */
  6765. getStrideSize(): number;
  6766. /**
  6767. * Returns the offset as a multiple of the type byte length.
  6768. * @returns the offset in bytes
  6769. * @deprecated Please use byteOffset instead.
  6770. */
  6771. getOffset(): number;
  6772. /**
  6773. * Returns the number of components per vertex attribute (integer)
  6774. * @returns the size in float
  6775. */
  6776. getSize(): number;
  6777. /**
  6778. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6779. * @returns true if this buffer is instanced
  6780. */
  6781. getIsInstanced(): boolean;
  6782. /**
  6783. * Returns the instancing divisor, zero for non-instanced (integer).
  6784. * @returns a number
  6785. */
  6786. getInstanceDivisor(): number;
  6787. /**
  6788. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6789. * @param data defines the data to store
  6790. */
  6791. create(data?: DataArray): void;
  6792. /**
  6793. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6794. * This function will create a new buffer if the current one is not updatable
  6795. * @param data defines the data to store
  6796. */
  6797. update(data: DataArray): void;
  6798. /**
  6799. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6800. * Returns the directly updated WebGLBuffer.
  6801. * @param data the new data
  6802. * @param offset the new offset
  6803. * @param useBytes set to true if the offset is in bytes
  6804. */
  6805. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6806. /**
  6807. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6808. */
  6809. dispose(): void;
  6810. /**
  6811. * Enumerates each value of this vertex buffer as numbers.
  6812. * @param count the number of values to enumerate
  6813. * @param callback the callback function called for each value
  6814. */
  6815. forEach(count: number, callback: (value: number, index: number) => void): void;
  6816. /**
  6817. * Positions
  6818. */
  6819. static readonly PositionKind: string;
  6820. /**
  6821. * Normals
  6822. */
  6823. static readonly NormalKind: string;
  6824. /**
  6825. * Tangents
  6826. */
  6827. static readonly TangentKind: string;
  6828. /**
  6829. * Texture coordinates
  6830. */
  6831. static readonly UVKind: string;
  6832. /**
  6833. * Texture coordinates 2
  6834. */
  6835. static readonly UV2Kind: string;
  6836. /**
  6837. * Texture coordinates 3
  6838. */
  6839. static readonly UV3Kind: string;
  6840. /**
  6841. * Texture coordinates 4
  6842. */
  6843. static readonly UV4Kind: string;
  6844. /**
  6845. * Texture coordinates 5
  6846. */
  6847. static readonly UV5Kind: string;
  6848. /**
  6849. * Texture coordinates 6
  6850. */
  6851. static readonly UV6Kind: string;
  6852. /**
  6853. * Colors
  6854. */
  6855. static readonly ColorKind: string;
  6856. /**
  6857. * Matrix indices (for bones)
  6858. */
  6859. static readonly MatricesIndicesKind: string;
  6860. /**
  6861. * Matrix weights (for bones)
  6862. */
  6863. static readonly MatricesWeightsKind: string;
  6864. /**
  6865. * Additional matrix indices (for bones)
  6866. */
  6867. static readonly MatricesIndicesExtraKind: string;
  6868. /**
  6869. * Additional matrix weights (for bones)
  6870. */
  6871. static readonly MatricesWeightsExtraKind: string;
  6872. /**
  6873. * Deduces the stride given a kind.
  6874. * @param kind The kind string to deduce
  6875. * @returns The deduced stride
  6876. */
  6877. static DeduceStride(kind: string): number;
  6878. /**
  6879. * Gets the byte length of the given type.
  6880. * @param type the type
  6881. * @returns the number of bytes
  6882. */
  6883. static GetTypeByteLength(type: number): number;
  6884. /**
  6885. * Enumerates each value of the given parameters as numbers.
  6886. * @param data the data to enumerate
  6887. * @param byteOffset the byte offset of the data
  6888. * @param byteStride the byte stride of the data
  6889. * @param componentCount the number of components per element
  6890. * @param componentType the type of the component
  6891. * @param count the number of values to enumerate
  6892. * @param normalized whether the data is normalized
  6893. * @param callback the callback function called for each value
  6894. */
  6895. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6896. private static _GetFloatValue;
  6897. }
  6898. }
  6899. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6900. import { Vector3 } from "babylonjs/Maths/math.vector";
  6901. import { Mesh } from "babylonjs/Meshes/mesh";
  6902. /**
  6903. * The options Interface for creating a Capsule Mesh
  6904. */
  6905. export interface ICreateCapsuleOptions {
  6906. /** The Orientation of the capsule. Default : Vector3.Up() */
  6907. orientation?: Vector3;
  6908. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6909. subdivisions: number;
  6910. /** Number of cylindrical segments on the capsule. */
  6911. tessellation: number;
  6912. /** Height or Length of the capsule. */
  6913. height: number;
  6914. /** Radius of the capsule. */
  6915. radius: number;
  6916. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6917. capSubdivisions: number;
  6918. /** Overwrite for the top radius. */
  6919. radiusTop?: number;
  6920. /** Overwrite for the bottom radius. */
  6921. radiusBottom?: number;
  6922. /** Overwrite for the top capSubdivisions. */
  6923. topCapSubdivisions?: number;
  6924. /** Overwrite for the bottom capSubdivisions. */
  6925. bottomCapSubdivisions?: number;
  6926. }
  6927. /**
  6928. * Class containing static functions to help procedurally build meshes
  6929. */
  6930. export class CapsuleBuilder {
  6931. /**
  6932. * Creates a capsule or a pill mesh
  6933. * @param name defines the name of the mesh
  6934. * @param options The constructors options.
  6935. * @param scene The scene the mesh is scoped to.
  6936. * @returns Capsule Mesh
  6937. */
  6938. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6939. }
  6940. }
  6941. declare module "babylonjs/Collisions/intersectionInfo" {
  6942. import { Nullable } from "babylonjs/types";
  6943. /**
  6944. * @hidden
  6945. */
  6946. export class IntersectionInfo {
  6947. bu: Nullable<number>;
  6948. bv: Nullable<number>;
  6949. distance: number;
  6950. faceId: number;
  6951. subMeshId: number;
  6952. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6953. }
  6954. }
  6955. declare module "babylonjs/Culling/boundingSphere" {
  6956. import { DeepImmutable } from "babylonjs/types";
  6957. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6958. import { Plane } from "babylonjs/Maths/math.plane";
  6959. /**
  6960. * Class used to store bounding sphere information
  6961. */
  6962. export class BoundingSphere {
  6963. /**
  6964. * Gets the center of the bounding sphere in local space
  6965. */
  6966. readonly center: Vector3;
  6967. /**
  6968. * Radius of the bounding sphere in local space
  6969. */
  6970. radius: number;
  6971. /**
  6972. * Gets the center of the bounding sphere in world space
  6973. */
  6974. readonly centerWorld: Vector3;
  6975. /**
  6976. * Radius of the bounding sphere in world space
  6977. */
  6978. radiusWorld: number;
  6979. /**
  6980. * Gets the minimum vector in local space
  6981. */
  6982. readonly minimum: Vector3;
  6983. /**
  6984. * Gets the maximum vector in local space
  6985. */
  6986. readonly maximum: Vector3;
  6987. private _worldMatrix;
  6988. private static readonly TmpVector3;
  6989. /**
  6990. * Creates a new bounding sphere
  6991. * @param min defines the minimum vector (in local space)
  6992. * @param max defines the maximum vector (in local space)
  6993. * @param worldMatrix defines the new world matrix
  6994. */
  6995. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6996. /**
  6997. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6998. * @param min defines the new minimum vector (in local space)
  6999. * @param max defines the new maximum vector (in local space)
  7000. * @param worldMatrix defines the new world matrix
  7001. */
  7002. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7003. /**
  7004. * Scale the current bounding sphere by applying a scale factor
  7005. * @param factor defines the scale factor to apply
  7006. * @returns the current bounding box
  7007. */
  7008. scale(factor: number): BoundingSphere;
  7009. /**
  7010. * Gets the world matrix of the bounding box
  7011. * @returns a matrix
  7012. */
  7013. getWorldMatrix(): DeepImmutable<Matrix>;
  7014. /** @hidden */
  7015. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7016. /**
  7017. * Tests if the bounding sphere is intersecting the frustum planes
  7018. * @param frustumPlanes defines the frustum planes to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7022. /**
  7023. * Tests if the bounding sphere center is in between the frustum planes.
  7024. * Used for optimistic fast inclusion.
  7025. * @param frustumPlanes defines the frustum planes to test
  7026. * @returns true if the sphere center is in between the frustum planes
  7027. */
  7028. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7029. /**
  7030. * Tests if a point is inside the bounding sphere
  7031. * @param point defines the point to test
  7032. * @returns true if the point is inside the bounding sphere
  7033. */
  7034. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7035. /**
  7036. * Checks if two sphere intersct
  7037. * @param sphere0 sphere 0
  7038. * @param sphere1 sphere 1
  7039. * @returns true if the speres intersect
  7040. */
  7041. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingBox" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7048. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. /**
  7051. * Class used to store bounding box information
  7052. */
  7053. export class BoundingBox implements ICullable {
  7054. /**
  7055. * Gets the 8 vectors representing the bounding box in local space
  7056. */
  7057. readonly vectors: Vector3[];
  7058. /**
  7059. * Gets the center of the bounding box in local space
  7060. */
  7061. readonly center: Vector3;
  7062. /**
  7063. * Gets the center of the bounding box in world space
  7064. */
  7065. readonly centerWorld: Vector3;
  7066. /**
  7067. * Gets the extend size in local space
  7068. */
  7069. readonly extendSize: Vector3;
  7070. /**
  7071. * Gets the extend size in world space
  7072. */
  7073. readonly extendSizeWorld: Vector3;
  7074. /**
  7075. * Gets the OBB (object bounding box) directions
  7076. */
  7077. readonly directions: Vector3[];
  7078. /**
  7079. * Gets the 8 vectors representing the bounding box in world space
  7080. */
  7081. readonly vectorsWorld: Vector3[];
  7082. /**
  7083. * Gets the minimum vector in world space
  7084. */
  7085. readonly minimumWorld: Vector3;
  7086. /**
  7087. * Gets the maximum vector in world space
  7088. */
  7089. readonly maximumWorld: Vector3;
  7090. /**
  7091. * Gets the minimum vector in local space
  7092. */
  7093. readonly minimum: Vector3;
  7094. /**
  7095. * Gets the maximum vector in local space
  7096. */
  7097. readonly maximum: Vector3;
  7098. private _worldMatrix;
  7099. private static readonly TmpVector3;
  7100. /**
  7101. * @hidden
  7102. */
  7103. _tag: number;
  7104. /**
  7105. * Creates a new bounding box
  7106. * @param min defines the minimum vector (in local space)
  7107. * @param max defines the maximum vector (in local space)
  7108. * @param worldMatrix defines the new world matrix
  7109. */
  7110. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7111. /**
  7112. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7113. * @param min defines the new minimum vector (in local space)
  7114. * @param max defines the new maximum vector (in local space)
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Scale the current bounding box by applying a scale factor
  7120. * @param factor defines the scale factor to apply
  7121. * @returns the current bounding box
  7122. */
  7123. scale(factor: number): BoundingBox;
  7124. /**
  7125. * Gets the world matrix of the bounding box
  7126. * @returns a matrix
  7127. */
  7128. getWorldMatrix(): DeepImmutable<Matrix>;
  7129. /** @hidden */
  7130. _update(world: DeepImmutable<Matrix>): void;
  7131. /**
  7132. * Tests if the bounding box is intersecting the frustum planes
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @returns true if there is an intersection
  7135. */
  7136. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /**
  7138. * Tests if the bounding box is entirely inside the frustum planes
  7139. * @param frustumPlanes defines the frustum planes to test
  7140. * @returns true if there is an inclusion
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7143. /**
  7144. * Tests if a point is inside the bounding box
  7145. * @param point defines the point to test
  7146. * @returns true if the point is inside the bounding box
  7147. */
  7148. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7149. /**
  7150. * Tests if the bounding box intersects with a bounding sphere
  7151. * @param sphere defines the sphere to test
  7152. * @returns true if there is an intersection
  7153. */
  7154. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7155. /**
  7156. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7157. * @param min defines the min vector to use
  7158. * @param max defines the max vector to use
  7159. * @returns true if there is an intersection
  7160. */
  7161. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7162. /**
  7163. * Tests if two bounding boxes are intersections
  7164. * @param box0 defines the first box to test
  7165. * @param box1 defines the second box to test
  7166. * @returns true if there is an intersection
  7167. */
  7168. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7169. /**
  7170. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7171. * @param minPoint defines the minimum vector of the bounding box
  7172. * @param maxPoint defines the maximum vector of the bounding box
  7173. * @param sphereCenter defines the sphere center
  7174. * @param sphereRadius defines the sphere radius
  7175. * @returns true if there is an intersection
  7176. */
  7177. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7178. /**
  7179. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7180. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7181. * @param frustumPlanes defines the frustum planes to test
  7182. * @return true if there is an inclusion
  7183. */
  7184. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7185. /**
  7186. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7187. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7188. * @param frustumPlanes defines the frustum planes to test
  7189. * @return true if there is an intersection
  7190. */
  7191. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. }
  7193. }
  7194. declare module "babylonjs/Collisions/collider" {
  7195. import { Nullable, IndicesArray } from "babylonjs/types";
  7196. import { Vector3 } from "babylonjs/Maths/math.vector";
  7197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7198. import { Plane } from "babylonjs/Maths/math.plane";
  7199. /** @hidden */
  7200. export class Collider {
  7201. /** Define if a collision was found */
  7202. collisionFound: boolean;
  7203. /**
  7204. * Define last intersection point in local space
  7205. */
  7206. intersectionPoint: Vector3;
  7207. /**
  7208. * Define last collided mesh
  7209. */
  7210. collidedMesh: Nullable<AbstractMesh>;
  7211. private _collisionPoint;
  7212. private _planeIntersectionPoint;
  7213. private _tempVector;
  7214. private _tempVector2;
  7215. private _tempVector3;
  7216. private _tempVector4;
  7217. private _edge;
  7218. private _baseToVertex;
  7219. private _destinationPoint;
  7220. private _slidePlaneNormal;
  7221. private _displacementVector;
  7222. /** @hidden */
  7223. _radius: Vector3;
  7224. /** @hidden */
  7225. _retry: number;
  7226. private _velocity;
  7227. private _basePoint;
  7228. private _epsilon;
  7229. /** @hidden */
  7230. _velocityWorldLength: number;
  7231. /** @hidden */
  7232. _basePointWorld: Vector3;
  7233. private _velocityWorld;
  7234. private _normalizedVelocity;
  7235. /** @hidden */
  7236. _initialVelocity: Vector3;
  7237. /** @hidden */
  7238. _initialPosition: Vector3;
  7239. private _nearestDistance;
  7240. private _collisionMask;
  7241. get collisionMask(): number;
  7242. set collisionMask(mask: number);
  7243. /**
  7244. * Gets the plane normal used to compute the sliding response (in local space)
  7245. */
  7246. get slidePlaneNormal(): Vector3;
  7247. /** @hidden */
  7248. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7249. /** @hidden */
  7250. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7251. /** @hidden */
  7252. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7253. /** @hidden */
  7254. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7255. /** @hidden */
  7256. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7257. /** @hidden */
  7258. _getResponse(pos: Vector3, vel: Vector3): void;
  7259. }
  7260. }
  7261. declare module "babylonjs/Culling/boundingInfo" {
  7262. import { DeepImmutable } from "babylonjs/types";
  7263. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7264. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7265. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7266. import { Plane } from "babylonjs/Maths/math.plane";
  7267. import { Collider } from "babylonjs/Collisions/collider";
  7268. /**
  7269. * Interface for cullable objects
  7270. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7271. */
  7272. export interface ICullable {
  7273. /**
  7274. * Checks if the object or part of the object is in the frustum
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isInFrustum(frustumPlanes: Plane[]): boolean;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7286. }
  7287. /**
  7288. * Info for a bounding data of a mesh
  7289. */
  7290. export class BoundingInfo implements ICullable {
  7291. /**
  7292. * Bounding box for the mesh
  7293. */
  7294. readonly boundingBox: BoundingBox;
  7295. /**
  7296. * Bounding sphere for the mesh
  7297. */
  7298. readonly boundingSphere: BoundingSphere;
  7299. private _isLocked;
  7300. private static readonly TmpVector3;
  7301. /**
  7302. * Constructs bounding info
  7303. * @param minimum min vector of the bounding box/sphere
  7304. * @param maximum max vector of the bounding box/sphere
  7305. * @param worldMatrix defines the new world matrix
  7306. */
  7307. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7308. /**
  7309. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7310. * @param min defines the new minimum vector (in local space)
  7311. * @param max defines the new maximum vector (in local space)
  7312. * @param worldMatrix defines the new world matrix
  7313. */
  7314. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7315. /**
  7316. * min vector of the bounding box/sphere
  7317. */
  7318. get minimum(): Vector3;
  7319. /**
  7320. * max vector of the bounding box/sphere
  7321. */
  7322. get maximum(): Vector3;
  7323. /**
  7324. * If the info is locked and won't be updated to avoid perf overhead
  7325. */
  7326. get isLocked(): boolean;
  7327. set isLocked(value: boolean);
  7328. /**
  7329. * Updates the bounding sphere and box
  7330. * @param world world matrix to be used to update
  7331. */
  7332. update(world: DeepImmutable<Matrix>): void;
  7333. /**
  7334. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7335. * @param center New center of the bounding info
  7336. * @param extend New extend of the bounding info
  7337. * @returns the current bounding info
  7338. */
  7339. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7340. /**
  7341. * Scale the current bounding info by applying a scale factor
  7342. * @param factor defines the scale factor to apply
  7343. * @returns the current bounding info
  7344. */
  7345. scale(factor: number): BoundingInfo;
  7346. /**
  7347. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7348. * @param frustumPlanes defines the frustum to test
  7349. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7350. * @returns true if the bounding info is in the frustum planes
  7351. */
  7352. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7353. /**
  7354. * Gets the world distance between the min and max points of the bounding box
  7355. */
  7356. get diagonalLength(): number;
  7357. /**
  7358. * Checks if a cullable object (mesh...) is in the camera frustum
  7359. * Unlike isInFrustum this cheks the full bounding box
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7364. /** @hidden */
  7365. _checkCollision(collider: Collider): boolean;
  7366. /**
  7367. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7368. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7369. * @param point the point to check intersection with
  7370. * @returns if the point intersects
  7371. */
  7372. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7373. /**
  7374. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7375. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7376. * @param boundingInfo the bounding info to check intersection with
  7377. * @param precise if the intersection should be done using OBB
  7378. * @returns if the bounding info intersects
  7379. */
  7380. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7381. }
  7382. }
  7383. declare module "babylonjs/Maths/math.functions" {
  7384. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7385. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7386. /**
  7387. * Extracts minimum and maximum values from a list of indexed positions
  7388. * @param positions defines the positions to use
  7389. * @param indices defines the indices to the positions
  7390. * @param indexStart defines the start index
  7391. * @param indexCount defines the end index
  7392. * @param bias defines bias value to add to the result
  7393. * @return minimum and maximum values
  7394. */
  7395. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7396. minimum: Vector3;
  7397. maximum: Vector3;
  7398. };
  7399. /**
  7400. * Extracts minimum and maximum values from a list of positions
  7401. * @param positions defines the positions to use
  7402. * @param start defines the start index in the positions array
  7403. * @param count defines the number of positions to handle
  7404. * @param bias defines bias value to add to the result
  7405. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7406. * @return minimum and maximum values
  7407. */
  7408. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7409. minimum: Vector3;
  7410. maximum: Vector3;
  7411. };
  7412. }
  7413. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7414. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7415. /** @hidden */
  7416. export class WebGLDataBuffer extends DataBuffer {
  7417. private _buffer;
  7418. constructor(resource: WebGLBuffer);
  7419. get underlyingResource(): any;
  7420. }
  7421. }
  7422. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7423. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7424. import { Nullable } from "babylonjs/types";
  7425. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7426. /** @hidden */
  7427. export class WebGLPipelineContext implements IPipelineContext {
  7428. engine: ThinEngine;
  7429. program: Nullable<WebGLProgram>;
  7430. context?: WebGLRenderingContext;
  7431. vertexShader?: WebGLShader;
  7432. fragmentShader?: WebGLShader;
  7433. isParallelCompiled: boolean;
  7434. onCompiled?: () => void;
  7435. transformFeedback?: WebGLTransformFeedback | null;
  7436. vertexCompilationError: Nullable<string>;
  7437. fragmentCompilationError: Nullable<string>;
  7438. programLinkError: Nullable<string>;
  7439. programValidationError: Nullable<string>;
  7440. get isAsync(): boolean;
  7441. get isReady(): boolean;
  7442. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7443. _getVertexShaderCode(): string | null;
  7444. _getFragmentShaderCode(): string | null;
  7445. }
  7446. }
  7447. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7448. import { FloatArray, Nullable } from "babylonjs/types";
  7449. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7450. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7451. module "babylonjs/Engines/thinEngine" {
  7452. interface ThinEngine {
  7453. /**
  7454. * Create an uniform buffer
  7455. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7456. * @param elements defines the content of the uniform buffer
  7457. * @returns the webGL uniform buffer
  7458. */
  7459. createUniformBuffer(elements: FloatArray): DataBuffer;
  7460. /**
  7461. * Create a dynamic uniform buffer
  7462. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7463. * @param elements defines the content of the uniform buffer
  7464. * @returns the webGL uniform buffer
  7465. */
  7466. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7467. /**
  7468. * Update an existing uniform buffer
  7469. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7470. * @param uniformBuffer defines the target uniform buffer
  7471. * @param elements defines the content to update
  7472. * @param offset defines the offset in the uniform buffer where update should start
  7473. * @param count defines the size of the data to update
  7474. */
  7475. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7476. /**
  7477. * Bind an uniform buffer to the current webGL context
  7478. * @param buffer defines the buffer to bind
  7479. */
  7480. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7481. /**
  7482. * Bind a buffer to the current webGL context at a given location
  7483. * @param buffer defines the buffer to bind
  7484. * @param location defines the index where to bind the buffer
  7485. */
  7486. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7487. /**
  7488. * Bind a specific block at a given index in a specific shader program
  7489. * @param pipelineContext defines the pipeline context to use
  7490. * @param blockName defines the block name
  7491. * @param index defines the index where to bind the block
  7492. */
  7493. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7494. }
  7495. }
  7496. }
  7497. declare module "babylonjs/Materials/uniformBuffer" {
  7498. import { Nullable, FloatArray } from "babylonjs/types";
  7499. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7500. import { Engine } from "babylonjs/Engines/engine";
  7501. import { Effect } from "babylonjs/Materials/effect";
  7502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7503. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7504. import { Color3 } from "babylonjs/Maths/math.color";
  7505. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7506. /**
  7507. * Uniform buffer objects.
  7508. *
  7509. * Handles blocks of uniform on the GPU.
  7510. *
  7511. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7512. *
  7513. * For more information, please refer to :
  7514. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7515. */
  7516. export class UniformBuffer {
  7517. private _engine;
  7518. private _buffer;
  7519. private _data;
  7520. private _bufferData;
  7521. private _dynamic?;
  7522. private _uniformLocations;
  7523. private _uniformSizes;
  7524. private _uniformLocationPointer;
  7525. private _needSync;
  7526. private _noUBO;
  7527. private _currentEffect;
  7528. /** @hidden */
  7529. _alreadyBound: boolean;
  7530. private static _MAX_UNIFORM_SIZE;
  7531. private static _tempBuffer;
  7532. /**
  7533. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7534. * This is dynamic to allow compat with webgl 1 and 2.
  7535. * You will need to pass the name of the uniform as well as the value.
  7536. */
  7537. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7538. /**
  7539. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7540. * This is dynamic to allow compat with webgl 1 and 2.
  7541. * You will need to pass the name of the uniform as well as the value.
  7542. */
  7543. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7544. /**
  7545. * Lambda to Update a single float in a uniform buffer.
  7546. * This is dynamic to allow compat with webgl 1 and 2.
  7547. * You will need to pass the name of the uniform as well as the value.
  7548. */
  7549. updateFloat: (name: string, x: number) => void;
  7550. /**
  7551. * Lambda to Update a vec2 of float in a uniform buffer.
  7552. * This is dynamic to allow compat with webgl 1 and 2.
  7553. * You will need to pass the name of the uniform as well as the value.
  7554. */
  7555. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7556. /**
  7557. * Lambda to Update a vec3 of float in a uniform buffer.
  7558. * This is dynamic to allow compat with webgl 1 and 2.
  7559. * You will need to pass the name of the uniform as well as the value.
  7560. */
  7561. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7562. /**
  7563. * Lambda to Update a vec4 of float in a uniform buffer.
  7564. * This is dynamic to allow compat with webgl 1 and 2.
  7565. * You will need to pass the name of the uniform as well as the value.
  7566. */
  7567. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7568. /**
  7569. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7570. * This is dynamic to allow compat with webgl 1 and 2.
  7571. * You will need to pass the name of the uniform as well as the value.
  7572. */
  7573. updateMatrix: (name: string, mat: Matrix) => void;
  7574. /**
  7575. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7576. * This is dynamic to allow compat with webgl 1 and 2.
  7577. * You will need to pass the name of the uniform as well as the value.
  7578. */
  7579. updateVector3: (name: string, vector: Vector3) => void;
  7580. /**
  7581. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7582. * This is dynamic to allow compat with webgl 1 and 2.
  7583. * You will need to pass the name of the uniform as well as the value.
  7584. */
  7585. updateVector4: (name: string, vector: Vector4) => void;
  7586. /**
  7587. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7588. * This is dynamic to allow compat with webgl 1 and 2.
  7589. * You will need to pass the name of the uniform as well as the value.
  7590. */
  7591. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7592. /**
  7593. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7594. * This is dynamic to allow compat with webgl 1 and 2.
  7595. * You will need to pass the name of the uniform as well as the value.
  7596. */
  7597. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7598. /**
  7599. * Instantiates a new Uniform buffer objects.
  7600. *
  7601. * Handles blocks of uniform on the GPU.
  7602. *
  7603. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7604. *
  7605. * For more information, please refer to :
  7606. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7607. * @param engine Define the engine the buffer is associated with
  7608. * @param data Define the data contained in the buffer
  7609. * @param dynamic Define if the buffer is updatable
  7610. */
  7611. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7612. /**
  7613. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7614. * or just falling back on setUniformXXX calls.
  7615. */
  7616. get useUbo(): boolean;
  7617. /**
  7618. * Indicates if the WebGL underlying uniform buffer is in sync
  7619. * with the javascript cache data.
  7620. */
  7621. get isSync(): boolean;
  7622. /**
  7623. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7624. * Also, a dynamic UniformBuffer will disable cache verification and always
  7625. * update the underlying WebGL uniform buffer to the GPU.
  7626. * @returns if Dynamic, otherwise false
  7627. */
  7628. isDynamic(): boolean;
  7629. /**
  7630. * The data cache on JS side.
  7631. * @returns the underlying data as a float array
  7632. */
  7633. getData(): Float32Array;
  7634. /**
  7635. * The underlying WebGL Uniform buffer.
  7636. * @returns the webgl buffer
  7637. */
  7638. getBuffer(): Nullable<DataBuffer>;
  7639. /**
  7640. * std140 layout specifies how to align data within an UBO structure.
  7641. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7642. * for specs.
  7643. */
  7644. private _fillAlignment;
  7645. /**
  7646. * Adds an uniform in the buffer.
  7647. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7648. * for the layout to be correct !
  7649. * @param name Name of the uniform, as used in the uniform block in the shader.
  7650. * @param size Data size, or data directly.
  7651. */
  7652. addUniform(name: string, size: number | number[]): void;
  7653. /**
  7654. * Adds a Matrix 4x4 to the uniform buffer.
  7655. * @param name Name of the uniform, as used in the uniform block in the shader.
  7656. * @param mat A 4x4 matrix.
  7657. */
  7658. addMatrix(name: string, mat: Matrix): void;
  7659. /**
  7660. * Adds a vec2 to the uniform buffer.
  7661. * @param name Name of the uniform, as used in the uniform block in the shader.
  7662. * @param x Define the x component value of the vec2
  7663. * @param y Define the y component value of the vec2
  7664. */
  7665. addFloat2(name: string, x: number, y: number): void;
  7666. /**
  7667. * Adds a vec3 to the uniform buffer.
  7668. * @param name Name of the uniform, as used in the uniform block in the shader.
  7669. * @param x Define the x component value of the vec3
  7670. * @param y Define the y component value of the vec3
  7671. * @param z Define the z component value of the vec3
  7672. */
  7673. addFloat3(name: string, x: number, y: number, z: number): void;
  7674. /**
  7675. * Adds a vec3 to the uniform buffer.
  7676. * @param name Name of the uniform, as used in the uniform block in the shader.
  7677. * @param color Define the vec3 from a Color
  7678. */
  7679. addColor3(name: string, color: Color3): void;
  7680. /**
  7681. * Adds a vec4 to the uniform buffer.
  7682. * @param name Name of the uniform, as used in the uniform block in the shader.
  7683. * @param color Define the rgb components from a Color
  7684. * @param alpha Define the a component of the vec4
  7685. */
  7686. addColor4(name: string, color: Color3, alpha: number): void;
  7687. /**
  7688. * Adds a vec3 to the uniform buffer.
  7689. * @param name Name of the uniform, as used in the uniform block in the shader.
  7690. * @param vector Define the vec3 components from a Vector
  7691. */
  7692. addVector3(name: string, vector: Vector3): void;
  7693. /**
  7694. * Adds a Matrix 3x3 to the uniform buffer.
  7695. * @param name Name of the uniform, as used in the uniform block in the shader.
  7696. */
  7697. addMatrix3x3(name: string): void;
  7698. /**
  7699. * Adds a Matrix 2x2 to the uniform buffer.
  7700. * @param name Name of the uniform, as used in the uniform block in the shader.
  7701. */
  7702. addMatrix2x2(name: string): void;
  7703. /**
  7704. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7705. */
  7706. create(): void;
  7707. /** @hidden */
  7708. _rebuild(): void;
  7709. /**
  7710. * Updates the WebGL Uniform Buffer on the GPU.
  7711. * If the `dynamic` flag is set to true, no cache comparison is done.
  7712. * Otherwise, the buffer will be updated only if the cache differs.
  7713. */
  7714. update(): void;
  7715. /**
  7716. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7717. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7718. * @param data Define the flattened data
  7719. * @param size Define the size of the data.
  7720. */
  7721. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7722. private _valueCache;
  7723. private _cacheMatrix;
  7724. private _updateMatrix3x3ForUniform;
  7725. private _updateMatrix3x3ForEffect;
  7726. private _updateMatrix2x2ForEffect;
  7727. private _updateMatrix2x2ForUniform;
  7728. private _updateFloatForEffect;
  7729. private _updateFloatForUniform;
  7730. private _updateFloat2ForEffect;
  7731. private _updateFloat2ForUniform;
  7732. private _updateFloat3ForEffect;
  7733. private _updateFloat3ForUniform;
  7734. private _updateFloat4ForEffect;
  7735. private _updateFloat4ForUniform;
  7736. private _updateMatrixForEffect;
  7737. private _updateMatrixForUniform;
  7738. private _updateVector3ForEffect;
  7739. private _updateVector3ForUniform;
  7740. private _updateVector4ForEffect;
  7741. private _updateVector4ForUniform;
  7742. private _updateColor3ForEffect;
  7743. private _updateColor3ForUniform;
  7744. private _updateColor4ForEffect;
  7745. private _updateColor4ForUniform;
  7746. /**
  7747. * Sets a sampler uniform on the effect.
  7748. * @param name Define the name of the sampler.
  7749. * @param texture Define the texture to set in the sampler
  7750. */
  7751. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7752. /**
  7753. * Directly updates the value of the uniform in the cache AND on the GPU.
  7754. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7755. * @param data Define the flattened data
  7756. */
  7757. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7758. /**
  7759. * Binds this uniform buffer to an effect.
  7760. * @param effect Define the effect to bind the buffer to
  7761. * @param name Name of the uniform block in the shader.
  7762. */
  7763. bindToEffect(effect: Effect, name: string): void;
  7764. /**
  7765. * Disposes the uniform buffer.
  7766. */
  7767. dispose(): void;
  7768. }
  7769. }
  7770. declare module "babylonjs/Misc/iInspectable" {
  7771. /**
  7772. * Enum that determines the text-wrapping mode to use.
  7773. */
  7774. export enum InspectableType {
  7775. /**
  7776. * Checkbox for booleans
  7777. */
  7778. Checkbox = 0,
  7779. /**
  7780. * Sliders for numbers
  7781. */
  7782. Slider = 1,
  7783. /**
  7784. * Vector3
  7785. */
  7786. Vector3 = 2,
  7787. /**
  7788. * Quaternions
  7789. */
  7790. Quaternion = 3,
  7791. /**
  7792. * Color3
  7793. */
  7794. Color3 = 4,
  7795. /**
  7796. * String
  7797. */
  7798. String = 5
  7799. }
  7800. /**
  7801. * Interface used to define custom inspectable properties.
  7802. * This interface is used by the inspector to display custom property grids
  7803. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7804. */
  7805. export interface IInspectable {
  7806. /**
  7807. * Gets the label to display
  7808. */
  7809. label: string;
  7810. /**
  7811. * Gets the name of the property to edit
  7812. */
  7813. propertyName: string;
  7814. /**
  7815. * Gets the type of the editor to use
  7816. */
  7817. type: InspectableType;
  7818. /**
  7819. * Gets the minimum value of the property when using in "slider" mode
  7820. */
  7821. min?: number;
  7822. /**
  7823. * Gets the maximum value of the property when using in "slider" mode
  7824. */
  7825. max?: number;
  7826. /**
  7827. * Gets the setp to use when using in "slider" mode
  7828. */
  7829. step?: number;
  7830. }
  7831. }
  7832. declare module "babylonjs/Misc/timingTools" {
  7833. /**
  7834. * Class used to provide helper for timing
  7835. */
  7836. export class TimingTools {
  7837. /**
  7838. * Polyfill for setImmediate
  7839. * @param action defines the action to execute after the current execution block
  7840. */
  7841. static SetImmediate(action: () => void): void;
  7842. }
  7843. }
  7844. declare module "babylonjs/Misc/instantiationTools" {
  7845. /**
  7846. * Class used to enable instatition of objects by class name
  7847. */
  7848. export class InstantiationTools {
  7849. /**
  7850. * Use this object to register external classes like custom textures or material
  7851. * to allow the laoders to instantiate them
  7852. */
  7853. static RegisteredExternalClasses: {
  7854. [key: string]: Object;
  7855. };
  7856. /**
  7857. * Tries to instantiate a new object from a given class name
  7858. * @param className defines the class name to instantiate
  7859. * @returns the new object or null if the system was not able to do the instantiation
  7860. */
  7861. static Instantiate(className: string): any;
  7862. }
  7863. }
  7864. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7865. /**
  7866. * Define options used to create a depth texture
  7867. */
  7868. export class DepthTextureCreationOptions {
  7869. /** Specifies whether or not a stencil should be allocated in the texture */
  7870. generateStencil?: boolean;
  7871. /** Specifies whether or not bilinear filtering is enable on the texture */
  7872. bilinearFiltering?: boolean;
  7873. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7874. comparisonFunction?: number;
  7875. /** Specifies if the created texture is a cube texture */
  7876. isCube?: boolean;
  7877. }
  7878. }
  7879. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7881. import { Nullable } from "babylonjs/types";
  7882. import { Scene } from "babylonjs/scene";
  7883. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7884. module "babylonjs/Engines/thinEngine" {
  7885. interface ThinEngine {
  7886. /**
  7887. * Creates a depth stencil cube texture.
  7888. * This is only available in WebGL 2.
  7889. * @param size The size of face edge in the cube texture.
  7890. * @param options The options defining the cube texture.
  7891. * @returns The cube texture
  7892. */
  7893. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7894. /**
  7895. * Creates a cube texture
  7896. * @param rootUrl defines the url where the files to load is located
  7897. * @param scene defines the current scene
  7898. * @param files defines the list of files to load (1 per face)
  7899. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7900. * @param onLoad defines an optional callback raised when the texture is loaded
  7901. * @param onError defines an optional callback raised if there is an issue to load the texture
  7902. * @param format defines the format of the data
  7903. * @param forcedExtension defines the extension to use to pick the right loader
  7904. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7905. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7906. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7907. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7908. * @returns the cube texture as an InternalTexture
  7909. */
  7910. 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;
  7911. /**
  7912. * Creates a cube texture
  7913. * @param rootUrl defines the url where the files to load is located
  7914. * @param scene defines the current scene
  7915. * @param files defines the list of files to load (1 per face)
  7916. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7917. * @param onLoad defines an optional callback raised when the texture is loaded
  7918. * @param onError defines an optional callback raised if there is an issue to load the texture
  7919. * @param format defines the format of the data
  7920. * @param forcedExtension defines the extension to use to pick the right loader
  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): InternalTexture;
  7924. /**
  7925. * Creates a cube texture
  7926. * @param rootUrl defines the url where the files to load is located
  7927. * @param scene defines the current scene
  7928. * @param files defines the list of files to load (1 per face)
  7929. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7930. * @param onLoad defines an optional callback raised when the texture is loaded
  7931. * @param onError defines an optional callback raised if there is an issue to load the texture
  7932. * @param format defines the format of the data
  7933. * @param forcedExtension defines the extension to use to pick the right loader
  7934. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7935. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7936. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7937. * @returns the cube texture as an InternalTexture
  7938. */
  7939. 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;
  7940. /** @hidden */
  7941. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7942. /** @hidden */
  7943. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7944. /** @hidden */
  7945. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7946. /** @hidden */
  7947. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7948. /**
  7949. * @hidden
  7950. */
  7951. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7952. }
  7953. }
  7954. }
  7955. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7956. import { Nullable } from "babylonjs/types";
  7957. import { Scene } from "babylonjs/scene";
  7958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7960. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7961. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7962. import { Observable } from "babylonjs/Misc/observable";
  7963. /**
  7964. * Class for creating a cube texture
  7965. */
  7966. export class CubeTexture extends BaseTexture {
  7967. private _delayedOnLoad;
  7968. /**
  7969. * Observable triggered once the texture has been loaded.
  7970. */
  7971. onLoadObservable: Observable<CubeTexture>;
  7972. /**
  7973. * The url of the texture
  7974. */
  7975. url: string;
  7976. /**
  7977. * Gets or sets the center of the bounding box associated with the cube texture.
  7978. * It must define where the camera used to render the texture was set
  7979. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7980. */
  7981. boundingBoxPosition: Vector3;
  7982. private _boundingBoxSize;
  7983. /**
  7984. * Gets or sets the size of the bounding box associated with the cube texture
  7985. * When defined, the cubemap will switch to local mode
  7986. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7987. * @example https://www.babylonjs-playground.com/#RNASML
  7988. */
  7989. set boundingBoxSize(value: Vector3);
  7990. /**
  7991. * Returns the bounding box size
  7992. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7993. */
  7994. get boundingBoxSize(): Vector3;
  7995. protected _rotationY: number;
  7996. /**
  7997. * Sets texture matrix rotation angle around Y axis in radians.
  7998. */
  7999. set rotationY(value: number);
  8000. /**
  8001. * Gets texture matrix rotation angle around Y axis radians.
  8002. */
  8003. get rotationY(): number;
  8004. /**
  8005. * Are mip maps generated for this texture or not.
  8006. */
  8007. get noMipmap(): boolean;
  8008. private _noMipmap;
  8009. private _files;
  8010. protected _forcedExtension: Nullable<string>;
  8011. private _extensions;
  8012. private _textureMatrix;
  8013. private _format;
  8014. private _createPolynomials;
  8015. /**
  8016. * Creates a cube texture from an array of image urls
  8017. * @param files defines an array of image urls
  8018. * @param scene defines the hosting scene
  8019. * @param noMipmap specifies if mip maps are not used
  8020. * @returns a cube texture
  8021. */
  8022. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8023. /**
  8024. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8025. * @param url defines the url of the prefiltered texture
  8026. * @param scene defines the scene the texture is attached to
  8027. * @param forcedExtension defines the extension of the file if different from the url
  8028. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8029. * @return the prefiltered texture
  8030. */
  8031. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8032. /**
  8033. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8034. * as prefiltered data.
  8035. * @param rootUrl defines the url of the texture or the root name of the six images
  8036. * @param null defines the scene or engine the texture is attached to
  8037. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8038. * @param noMipmap defines if mipmaps should be created or not
  8039. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8040. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8041. * @param onError defines a callback triggered in case of error during load
  8042. * @param format defines the internal format to use for the texture once loaded
  8043. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8044. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8045. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8046. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8047. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8048. * @return the cube texture
  8049. */
  8050. 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);
  8051. /**
  8052. * Get the current class name of the texture useful for serialization or dynamic coding.
  8053. * @returns "CubeTexture"
  8054. */
  8055. getClassName(): string;
  8056. /**
  8057. * Update the url (and optional buffer) of this texture if url was null during construction.
  8058. * @param url the url of the texture
  8059. * @param forcedExtension defines the extension to use
  8060. * @param onLoad callback called when the texture is loaded (defaults to null)
  8061. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8062. */
  8063. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8064. /**
  8065. * Delays loading of the cube texture
  8066. * @param forcedExtension defines the extension to use
  8067. */
  8068. delayLoad(forcedExtension?: string): void;
  8069. /**
  8070. * Returns the reflection texture matrix
  8071. * @returns the reflection texture matrix
  8072. */
  8073. getReflectionTextureMatrix(): Matrix;
  8074. /**
  8075. * Sets the reflection texture matrix
  8076. * @param value Reflection texture matrix
  8077. */
  8078. setReflectionTextureMatrix(value: Matrix): void;
  8079. /**
  8080. * Parses text to create a cube texture
  8081. * @param parsedTexture define the serialized text to read from
  8082. * @param scene defines the hosting scene
  8083. * @param rootUrl defines the root url of the cube texture
  8084. * @returns a cube texture
  8085. */
  8086. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8087. /**
  8088. * Makes a clone, or deep copy, of the cube texture
  8089. * @returns a new cube texture
  8090. */
  8091. clone(): CubeTexture;
  8092. }
  8093. }
  8094. declare module "babylonjs/Materials/materialDefines" {
  8095. /**
  8096. * Manages the defines for the Material
  8097. */
  8098. export class MaterialDefines {
  8099. /** @hidden */
  8100. protected _keys: string[];
  8101. private _isDirty;
  8102. /** @hidden */
  8103. _renderId: number;
  8104. /** @hidden */
  8105. _areLightsDirty: boolean;
  8106. /** @hidden */
  8107. _areLightsDisposed: boolean;
  8108. /** @hidden */
  8109. _areAttributesDirty: boolean;
  8110. /** @hidden */
  8111. _areTexturesDirty: boolean;
  8112. /** @hidden */
  8113. _areFresnelDirty: boolean;
  8114. /** @hidden */
  8115. _areMiscDirty: boolean;
  8116. /** @hidden */
  8117. _arePrePassDirty: boolean;
  8118. /** @hidden */
  8119. _areImageProcessingDirty: boolean;
  8120. /** @hidden */
  8121. _normals: boolean;
  8122. /** @hidden */
  8123. _uvs: boolean;
  8124. /** @hidden */
  8125. _needNormals: boolean;
  8126. /** @hidden */
  8127. _needUVs: boolean;
  8128. [id: string]: any;
  8129. /**
  8130. * Specifies if the material needs to be re-calculated
  8131. */
  8132. get isDirty(): boolean;
  8133. /**
  8134. * Marks the material to indicate that it has been re-calculated
  8135. */
  8136. markAsProcessed(): void;
  8137. /**
  8138. * Marks the material to indicate that it needs to be re-calculated
  8139. */
  8140. markAsUnprocessed(): void;
  8141. /**
  8142. * Marks the material to indicate all of its defines need to be re-calculated
  8143. */
  8144. markAllAsDirty(): void;
  8145. /**
  8146. * Marks the material to indicate that image processing needs to be re-calculated
  8147. */
  8148. markAsImageProcessingDirty(): void;
  8149. /**
  8150. * Marks the material to indicate the lights need to be re-calculated
  8151. * @param disposed Defines whether the light is dirty due to dispose or not
  8152. */
  8153. markAsLightDirty(disposed?: boolean): void;
  8154. /**
  8155. * Marks the attribute state as changed
  8156. */
  8157. markAsAttributesDirty(): void;
  8158. /**
  8159. * Marks the texture state as changed
  8160. */
  8161. markAsTexturesDirty(): void;
  8162. /**
  8163. * Marks the fresnel state as changed
  8164. */
  8165. markAsFresnelDirty(): void;
  8166. /**
  8167. * Marks the misc state as changed
  8168. */
  8169. markAsMiscDirty(): void;
  8170. /**
  8171. * Marks the prepass state as changed
  8172. */
  8173. markAsPrePassDirty(): void;
  8174. /**
  8175. * Rebuilds the material defines
  8176. */
  8177. rebuild(): void;
  8178. /**
  8179. * Specifies if two material defines are equal
  8180. * @param other - A material define instance to compare to
  8181. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8182. */
  8183. isEqual(other: MaterialDefines): boolean;
  8184. /**
  8185. * Clones this instance's defines to another instance
  8186. * @param other - material defines to clone values to
  8187. */
  8188. cloneTo(other: MaterialDefines): void;
  8189. /**
  8190. * Resets the material define values
  8191. */
  8192. reset(): void;
  8193. /**
  8194. * Converts the material define values to a string
  8195. * @returns - String of material define information
  8196. */
  8197. toString(): string;
  8198. }
  8199. }
  8200. declare module "babylonjs/Materials/colorCurves" {
  8201. import { Effect } from "babylonjs/Materials/effect";
  8202. /**
  8203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8205. * 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;
  8206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8207. */
  8208. export class ColorCurves {
  8209. private _dirty;
  8210. private _tempColor;
  8211. private _globalCurve;
  8212. private _highlightsCurve;
  8213. private _midtonesCurve;
  8214. private _shadowsCurve;
  8215. private _positiveCurve;
  8216. private _negativeCurve;
  8217. private _globalHue;
  8218. private _globalDensity;
  8219. private _globalSaturation;
  8220. private _globalExposure;
  8221. /**
  8222. * Gets the global Hue value.
  8223. * 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).
  8224. */
  8225. get globalHue(): number;
  8226. /**
  8227. * Sets the global Hue value.
  8228. * 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).
  8229. */
  8230. set globalHue(value: number);
  8231. /**
  8232. * Gets the global Density value.
  8233. * 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.
  8234. * Values less than zero provide a filter of opposite hue.
  8235. */
  8236. get globalDensity(): number;
  8237. /**
  8238. * Sets the global Density value.
  8239. * 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.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. set globalDensity(value: number);
  8243. /**
  8244. * Gets the global Saturation value.
  8245. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8246. */
  8247. get globalSaturation(): number;
  8248. /**
  8249. * Sets the global Saturation value.
  8250. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8251. */
  8252. set globalSaturation(value: number);
  8253. /**
  8254. * Gets the global Exposure value.
  8255. * 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.
  8256. */
  8257. get globalExposure(): number;
  8258. /**
  8259. * Sets the global Exposure value.
  8260. * 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.
  8261. */
  8262. set globalExposure(value: number);
  8263. private _highlightsHue;
  8264. private _highlightsDensity;
  8265. private _highlightsSaturation;
  8266. private _highlightsExposure;
  8267. /**
  8268. * Gets the highlights Hue value.
  8269. * 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).
  8270. */
  8271. get highlightsHue(): number;
  8272. /**
  8273. * Sets the highlights Hue value.
  8274. * 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).
  8275. */
  8276. set highlightsHue(value: number);
  8277. /**
  8278. * Gets the highlights Density value.
  8279. * 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.
  8280. * Values less than zero provide a filter of opposite hue.
  8281. */
  8282. get highlightsDensity(): number;
  8283. /**
  8284. * Sets the highlights Density value.
  8285. * 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.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. set highlightsDensity(value: number);
  8289. /**
  8290. * Gets the highlights Saturation value.
  8291. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8292. */
  8293. get highlightsSaturation(): number;
  8294. /**
  8295. * Sets the highlights Saturation value.
  8296. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8297. */
  8298. set highlightsSaturation(value: number);
  8299. /**
  8300. * Gets the highlights Exposure value.
  8301. * 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.
  8302. */
  8303. get highlightsExposure(): number;
  8304. /**
  8305. * Sets the highlights Exposure value.
  8306. * 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.
  8307. */
  8308. set highlightsExposure(value: number);
  8309. private _midtonesHue;
  8310. private _midtonesDensity;
  8311. private _midtonesSaturation;
  8312. private _midtonesExposure;
  8313. /**
  8314. * Gets the midtones Hue value.
  8315. * 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).
  8316. */
  8317. get midtonesHue(): number;
  8318. /**
  8319. * Sets the midtones Hue value.
  8320. * 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).
  8321. */
  8322. set midtonesHue(value: number);
  8323. /**
  8324. * Gets the midtones Density value.
  8325. * 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.
  8326. * Values less than zero provide a filter of opposite hue.
  8327. */
  8328. get midtonesDensity(): number;
  8329. /**
  8330. * Sets the midtones Density value.
  8331. * 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.
  8332. * Values less than zero provide a filter of opposite hue.
  8333. */
  8334. set midtonesDensity(value: number);
  8335. /**
  8336. * Gets the midtones Saturation value.
  8337. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8338. */
  8339. get midtonesSaturation(): number;
  8340. /**
  8341. * Sets the midtones Saturation value.
  8342. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8343. */
  8344. set midtonesSaturation(value: number);
  8345. /**
  8346. * Gets the midtones Exposure value.
  8347. * 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.
  8348. */
  8349. get midtonesExposure(): number;
  8350. /**
  8351. * Sets the midtones Exposure value.
  8352. * 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.
  8353. */
  8354. set midtonesExposure(value: number);
  8355. private _shadowsHue;
  8356. private _shadowsDensity;
  8357. private _shadowsSaturation;
  8358. private _shadowsExposure;
  8359. /**
  8360. * Gets the shadows Hue value.
  8361. * 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).
  8362. */
  8363. get shadowsHue(): number;
  8364. /**
  8365. * Sets the shadows Hue value.
  8366. * 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).
  8367. */
  8368. set shadowsHue(value: number);
  8369. /**
  8370. * Gets the shadows Density value.
  8371. * 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.
  8372. * Values less than zero provide a filter of opposite hue.
  8373. */
  8374. get shadowsDensity(): number;
  8375. /**
  8376. * Sets the shadows Density value.
  8377. * 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.
  8378. * Values less than zero provide a filter of opposite hue.
  8379. */
  8380. set shadowsDensity(value: number);
  8381. /**
  8382. * Gets the shadows Saturation value.
  8383. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8384. */
  8385. get shadowsSaturation(): number;
  8386. /**
  8387. * Sets the shadows Saturation value.
  8388. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8389. */
  8390. set shadowsSaturation(value: number);
  8391. /**
  8392. * Gets the shadows Exposure value.
  8393. * 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.
  8394. */
  8395. get shadowsExposure(): number;
  8396. /**
  8397. * Sets the shadows Exposure value.
  8398. * 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.
  8399. */
  8400. set shadowsExposure(value: number);
  8401. /**
  8402. * Returns the class name
  8403. * @returns The class name
  8404. */
  8405. getClassName(): string;
  8406. /**
  8407. * Binds the color curves to the shader.
  8408. * @param colorCurves The color curve to bind
  8409. * @param effect The effect to bind to
  8410. * @param positiveUniform The positive uniform shader parameter
  8411. * @param neutralUniform The neutral uniform shader parameter
  8412. * @param negativeUniform The negative uniform shader parameter
  8413. */
  8414. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8415. /**
  8416. * Prepare the list of uniforms associated with the ColorCurves effects.
  8417. * @param uniformsList The list of uniforms used in the effect
  8418. */
  8419. static PrepareUniforms(uniformsList: string[]): void;
  8420. /**
  8421. * Returns color grading data based on a hue, density, saturation and exposure value.
  8422. * @param filterHue The hue of the color filter.
  8423. * @param filterDensity The density of the color filter.
  8424. * @param saturation The saturation.
  8425. * @param exposure The exposure.
  8426. * @param result The result data container.
  8427. */
  8428. private getColorGradingDataToRef;
  8429. /**
  8430. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8431. * @param value The input slider value in range [-100,100].
  8432. * @returns Adjusted value.
  8433. */
  8434. private static applyColorGradingSliderNonlinear;
  8435. /**
  8436. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8437. * @param hue The hue (H) input.
  8438. * @param saturation The saturation (S) input.
  8439. * @param brightness The brightness (B) input.
  8440. * @result An RGBA color represented as Vector4.
  8441. */
  8442. private static fromHSBToRef;
  8443. /**
  8444. * Returns a value clamped between min and max
  8445. * @param value The value to clamp
  8446. * @param min The minimum of value
  8447. * @param max The maximum of value
  8448. * @returns The clamped value.
  8449. */
  8450. private static clamp;
  8451. /**
  8452. * Clones the current color curve instance.
  8453. * @return The cloned curves
  8454. */
  8455. clone(): ColorCurves;
  8456. /**
  8457. * Serializes the current color curve instance to a json representation.
  8458. * @return a JSON representation
  8459. */
  8460. serialize(): any;
  8461. /**
  8462. * Parses the color curve from a json representation.
  8463. * @param source the JSON source to parse
  8464. * @return The parsed curves
  8465. */
  8466. static Parse(source: any): ColorCurves;
  8467. }
  8468. }
  8469. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8470. import { Observable } from "babylonjs/Misc/observable";
  8471. import { Nullable } from "babylonjs/types";
  8472. import { Color4 } from "babylonjs/Maths/math.color";
  8473. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8474. import { Effect } from "babylonjs/Materials/effect";
  8475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8476. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8477. /**
  8478. * Interface to follow in your material defines to integrate easily the
  8479. * Image proccessing functions.
  8480. * @hidden
  8481. */
  8482. export interface IImageProcessingConfigurationDefines {
  8483. IMAGEPROCESSING: boolean;
  8484. VIGNETTE: boolean;
  8485. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8486. VIGNETTEBLENDMODEOPAQUE: boolean;
  8487. TONEMAPPING: boolean;
  8488. TONEMAPPING_ACES: boolean;
  8489. CONTRAST: boolean;
  8490. EXPOSURE: boolean;
  8491. COLORCURVES: boolean;
  8492. COLORGRADING: boolean;
  8493. COLORGRADING3D: boolean;
  8494. SAMPLER3DGREENDEPTH: boolean;
  8495. SAMPLER3DBGRMAP: boolean;
  8496. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8497. }
  8498. /**
  8499. * @hidden
  8500. */
  8501. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8502. IMAGEPROCESSING: boolean;
  8503. VIGNETTE: boolean;
  8504. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8505. VIGNETTEBLENDMODEOPAQUE: boolean;
  8506. TONEMAPPING: boolean;
  8507. TONEMAPPING_ACES: boolean;
  8508. CONTRAST: boolean;
  8509. COLORCURVES: boolean;
  8510. COLORGRADING: boolean;
  8511. COLORGRADING3D: boolean;
  8512. SAMPLER3DGREENDEPTH: boolean;
  8513. SAMPLER3DBGRMAP: boolean;
  8514. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8515. EXPOSURE: boolean;
  8516. constructor();
  8517. }
  8518. /**
  8519. * This groups together the common properties used for image processing either in direct forward pass
  8520. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8521. * or not.
  8522. */
  8523. export class ImageProcessingConfiguration {
  8524. /**
  8525. * Default tone mapping applied in BabylonJS.
  8526. */
  8527. static readonly TONEMAPPING_STANDARD: number;
  8528. /**
  8529. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8530. * to other engines rendering to increase portability.
  8531. */
  8532. static readonly TONEMAPPING_ACES: number;
  8533. /**
  8534. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8535. */
  8536. colorCurves: Nullable<ColorCurves>;
  8537. private _colorCurvesEnabled;
  8538. /**
  8539. * Gets wether the color curves effect is enabled.
  8540. */
  8541. get colorCurvesEnabled(): boolean;
  8542. /**
  8543. * Sets wether the color curves effect is enabled.
  8544. */
  8545. set colorCurvesEnabled(value: boolean);
  8546. private _colorGradingTexture;
  8547. /**
  8548. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8549. */
  8550. get colorGradingTexture(): Nullable<BaseTexture>;
  8551. /**
  8552. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8553. */
  8554. set colorGradingTexture(value: Nullable<BaseTexture>);
  8555. private _colorGradingEnabled;
  8556. /**
  8557. * Gets wether the color grading effect is enabled.
  8558. */
  8559. get colorGradingEnabled(): boolean;
  8560. /**
  8561. * Sets wether the color grading effect is enabled.
  8562. */
  8563. set colorGradingEnabled(value: boolean);
  8564. private _colorGradingWithGreenDepth;
  8565. /**
  8566. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8567. */
  8568. get colorGradingWithGreenDepth(): boolean;
  8569. /**
  8570. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8571. */
  8572. set colorGradingWithGreenDepth(value: boolean);
  8573. private _colorGradingBGR;
  8574. /**
  8575. * Gets wether the color grading texture contains BGR values.
  8576. */
  8577. get colorGradingBGR(): boolean;
  8578. /**
  8579. * Sets wether the color grading texture contains BGR values.
  8580. */
  8581. set colorGradingBGR(value: boolean);
  8582. /** @hidden */
  8583. _exposure: number;
  8584. /**
  8585. * Gets the Exposure used in the effect.
  8586. */
  8587. get exposure(): number;
  8588. /**
  8589. * Sets the Exposure used in the effect.
  8590. */
  8591. set exposure(value: number);
  8592. private _toneMappingEnabled;
  8593. /**
  8594. * Gets wether the tone mapping effect is enabled.
  8595. */
  8596. get toneMappingEnabled(): boolean;
  8597. /**
  8598. * Sets wether the tone mapping effect is enabled.
  8599. */
  8600. set toneMappingEnabled(value: boolean);
  8601. private _toneMappingType;
  8602. /**
  8603. * Gets the type of tone mapping effect.
  8604. */
  8605. get toneMappingType(): number;
  8606. /**
  8607. * Sets the type of tone mapping effect used in BabylonJS.
  8608. */
  8609. set toneMappingType(value: number);
  8610. protected _contrast: number;
  8611. /**
  8612. * Gets the contrast used in the effect.
  8613. */
  8614. get contrast(): number;
  8615. /**
  8616. * Sets the contrast used in the effect.
  8617. */
  8618. set contrast(value: number);
  8619. /**
  8620. * Vignette stretch size.
  8621. */
  8622. vignetteStretch: number;
  8623. /**
  8624. * Vignette centre X Offset.
  8625. */
  8626. vignetteCentreX: number;
  8627. /**
  8628. * Vignette centre Y Offset.
  8629. */
  8630. vignetteCentreY: number;
  8631. /**
  8632. * Vignette weight or intensity of the vignette effect.
  8633. */
  8634. vignetteWeight: number;
  8635. /**
  8636. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8637. * if vignetteEnabled is set to true.
  8638. */
  8639. vignetteColor: Color4;
  8640. /**
  8641. * Camera field of view used by the Vignette effect.
  8642. */
  8643. vignetteCameraFov: number;
  8644. private _vignetteBlendMode;
  8645. /**
  8646. * Gets the vignette blend mode allowing different kind of effect.
  8647. */
  8648. get vignetteBlendMode(): number;
  8649. /**
  8650. * Sets the vignette blend mode allowing different kind of effect.
  8651. */
  8652. set vignetteBlendMode(value: number);
  8653. private _vignetteEnabled;
  8654. /**
  8655. * Gets wether the vignette effect is enabled.
  8656. */
  8657. get vignetteEnabled(): boolean;
  8658. /**
  8659. * Sets wether the vignette effect is enabled.
  8660. */
  8661. set vignetteEnabled(value: boolean);
  8662. private _applyByPostProcess;
  8663. /**
  8664. * Gets wether the image processing is applied through a post process or not.
  8665. */
  8666. get applyByPostProcess(): boolean;
  8667. /**
  8668. * Sets wether the image processing is applied through a post process or not.
  8669. */
  8670. set applyByPostProcess(value: boolean);
  8671. private _isEnabled;
  8672. /**
  8673. * Gets wether the image processing is enabled or not.
  8674. */
  8675. get isEnabled(): boolean;
  8676. /**
  8677. * Sets wether the image processing is enabled or not.
  8678. */
  8679. set isEnabled(value: boolean);
  8680. /**
  8681. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8682. */
  8683. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8684. /**
  8685. * Method called each time the image processing information changes requires to recompile the effect.
  8686. */
  8687. protected _updateParameters(): void;
  8688. /**
  8689. * Gets the current class name.
  8690. * @return "ImageProcessingConfiguration"
  8691. */
  8692. getClassName(): string;
  8693. /**
  8694. * Prepare the list of uniforms associated with the Image Processing effects.
  8695. * @param uniforms The list of uniforms used in the effect
  8696. * @param defines the list of defines currently in use
  8697. */
  8698. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8699. /**
  8700. * Prepare the list of samplers associated with the Image Processing effects.
  8701. * @param samplersList The list of uniforms used in the effect
  8702. * @param defines the list of defines currently in use
  8703. */
  8704. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8705. /**
  8706. * Prepare the list of defines associated to the shader.
  8707. * @param defines the list of defines to complete
  8708. * @param forPostProcess Define if we are currently in post process mode or not
  8709. */
  8710. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8711. /**
  8712. * Returns true if all the image processing information are ready.
  8713. * @returns True if ready, otherwise, false
  8714. */
  8715. isReady(): boolean;
  8716. /**
  8717. * Binds the image processing to the shader.
  8718. * @param effect The effect to bind to
  8719. * @param overrideAspectRatio Override the aspect ratio of the effect
  8720. */
  8721. bind(effect: Effect, overrideAspectRatio?: number): void;
  8722. /**
  8723. * Clones the current image processing instance.
  8724. * @return The cloned image processing
  8725. */
  8726. clone(): ImageProcessingConfiguration;
  8727. /**
  8728. * Serializes the current image processing instance to a json representation.
  8729. * @return a JSON representation
  8730. */
  8731. serialize(): any;
  8732. /**
  8733. * Parses the image processing from a json representation.
  8734. * @param source the JSON source to parse
  8735. * @return The parsed image processing
  8736. */
  8737. static Parse(source: any): ImageProcessingConfiguration;
  8738. private static _VIGNETTEMODE_MULTIPLY;
  8739. private static _VIGNETTEMODE_OPAQUE;
  8740. /**
  8741. * Used to apply the vignette as a mix with the pixel color.
  8742. */
  8743. static get VIGNETTEMODE_MULTIPLY(): number;
  8744. /**
  8745. * Used to apply the vignette as a replacement of the pixel color.
  8746. */
  8747. static get VIGNETTEMODE_OPAQUE(): number;
  8748. }
  8749. }
  8750. declare module "babylonjs/Shaders/postprocess.vertex" {
  8751. /** @hidden */
  8752. export var postprocessVertexShader: {
  8753. name: string;
  8754. shader: string;
  8755. };
  8756. }
  8757. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8758. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8759. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8760. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8761. /**
  8762. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8763. */
  8764. export type RenderTargetTextureSize = number | {
  8765. width: number;
  8766. height: number;
  8767. layers?: number;
  8768. };
  8769. module "babylonjs/Engines/thinEngine" {
  8770. interface ThinEngine {
  8771. /**
  8772. * Creates a new render target texture
  8773. * @param size defines the size of the texture
  8774. * @param options defines the options used to create the texture
  8775. * @returns a new render target texture stored in an InternalTexture
  8776. */
  8777. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8778. /**
  8779. * Creates a depth stencil texture.
  8780. * This is only available in WebGL 2 or with the depth texture extension available.
  8781. * @param size The size of face edge in the texture.
  8782. * @param options The options defining the texture.
  8783. * @returns The texture
  8784. */
  8785. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8786. /** @hidden */
  8787. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8788. }
  8789. }
  8790. }
  8791. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8792. /**
  8793. * Defines the kind of connection point for node based material
  8794. */
  8795. export enum NodeMaterialBlockConnectionPointTypes {
  8796. /** Float */
  8797. Float = 1,
  8798. /** Int */
  8799. Int = 2,
  8800. /** Vector2 */
  8801. Vector2 = 4,
  8802. /** Vector3 */
  8803. Vector3 = 8,
  8804. /** Vector4 */
  8805. Vector4 = 16,
  8806. /** Color3 */
  8807. Color3 = 32,
  8808. /** Color4 */
  8809. Color4 = 64,
  8810. /** Matrix */
  8811. Matrix = 128,
  8812. /** Custom object */
  8813. Object = 256,
  8814. /** Detect type based on connection */
  8815. AutoDetect = 1024,
  8816. /** Output type that will be defined by input type */
  8817. BasedOnInput = 2048
  8818. }
  8819. }
  8820. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8821. /**
  8822. * Enum used to define the target of a block
  8823. */
  8824. export enum NodeMaterialBlockTargets {
  8825. /** Vertex shader */
  8826. Vertex = 1,
  8827. /** Fragment shader */
  8828. Fragment = 2,
  8829. /** Neutral */
  8830. Neutral = 4,
  8831. /** Vertex and Fragment */
  8832. VertexAndFragment = 3
  8833. }
  8834. }
  8835. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8836. /**
  8837. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8838. */
  8839. export enum NodeMaterialBlockConnectionPointMode {
  8840. /** Value is an uniform */
  8841. Uniform = 0,
  8842. /** Value is a mesh attribute */
  8843. Attribute = 1,
  8844. /** Value is a varying between vertex and fragment shaders */
  8845. Varying = 2,
  8846. /** Mode is undefined */
  8847. Undefined = 3
  8848. }
  8849. }
  8850. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8851. /**
  8852. * Enum used to define system values e.g. values automatically provided by the system
  8853. */
  8854. export enum NodeMaterialSystemValues {
  8855. /** World */
  8856. World = 1,
  8857. /** View */
  8858. View = 2,
  8859. /** Projection */
  8860. Projection = 3,
  8861. /** ViewProjection */
  8862. ViewProjection = 4,
  8863. /** WorldView */
  8864. WorldView = 5,
  8865. /** WorldViewProjection */
  8866. WorldViewProjection = 6,
  8867. /** CameraPosition */
  8868. CameraPosition = 7,
  8869. /** Fog Color */
  8870. FogColor = 8,
  8871. /** Delta time */
  8872. DeltaTime = 9
  8873. }
  8874. }
  8875. declare module "babylonjs/Maths/math.axis" {
  8876. import { Vector3 } from "babylonjs/Maths/math.vector";
  8877. /** Defines supported spaces */
  8878. export enum Space {
  8879. /** Local (object) space */
  8880. LOCAL = 0,
  8881. /** World space */
  8882. WORLD = 1,
  8883. /** Bone space */
  8884. BONE = 2
  8885. }
  8886. /** Defines the 3 main axes */
  8887. export class Axis {
  8888. /** X axis */
  8889. static X: Vector3;
  8890. /** Y axis */
  8891. static Y: Vector3;
  8892. /** Z axis */
  8893. static Z: Vector3;
  8894. }
  8895. }
  8896. declare module "babylonjs/Maths/math.frustum" {
  8897. import { Matrix } from "babylonjs/Maths/math.vector";
  8898. import { DeepImmutable } from "babylonjs/types";
  8899. import { Plane } from "babylonjs/Maths/math.plane";
  8900. /**
  8901. * Represents a camera frustum
  8902. */
  8903. export class Frustum {
  8904. /**
  8905. * Gets the planes representing the frustum
  8906. * @param transform matrix to be applied to the returned planes
  8907. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8908. */
  8909. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8910. /**
  8911. * Gets the near frustum plane transformed by the transform matrix
  8912. * @param transform transformation matrix to be applied to the resulting frustum plane
  8913. * @param frustumPlane the resuling frustum plane
  8914. */
  8915. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8916. /**
  8917. * Gets the far frustum plane transformed by the transform matrix
  8918. * @param transform transformation matrix to be applied to the resulting frustum plane
  8919. * @param frustumPlane the resuling frustum plane
  8920. */
  8921. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8922. /**
  8923. * Gets the left frustum plane transformed by the transform matrix
  8924. * @param transform transformation matrix to be applied to the resulting frustum plane
  8925. * @param frustumPlane the resuling frustum plane
  8926. */
  8927. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8928. /**
  8929. * Gets the right frustum plane transformed by the transform matrix
  8930. * @param transform transformation matrix to be applied to the resulting frustum plane
  8931. * @param frustumPlane the resuling frustum plane
  8932. */
  8933. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8934. /**
  8935. * Gets the top frustum plane transformed by the transform matrix
  8936. * @param transform transformation matrix to be applied to the resulting frustum plane
  8937. * @param frustumPlane the resuling frustum plane
  8938. */
  8939. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8940. /**
  8941. * Gets the bottom frustum plane transformed by the transform matrix
  8942. * @param transform transformation matrix to be applied to the resulting frustum plane
  8943. * @param frustumPlane the resuling frustum plane
  8944. */
  8945. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8946. /**
  8947. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8948. * @param transform transformation matrix to be applied to the resulting frustum planes
  8949. * @param frustumPlanes the resuling frustum planes
  8950. */
  8951. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8952. }
  8953. }
  8954. declare module "babylonjs/Maths/math.size" {
  8955. /**
  8956. * Interface for the size containing width and height
  8957. */
  8958. export interface ISize {
  8959. /**
  8960. * Width
  8961. */
  8962. width: number;
  8963. /**
  8964. * Heighht
  8965. */
  8966. height: number;
  8967. }
  8968. /**
  8969. * Size containing widht and height
  8970. */
  8971. export class Size implements ISize {
  8972. /**
  8973. * Width
  8974. */
  8975. width: number;
  8976. /**
  8977. * Height
  8978. */
  8979. height: number;
  8980. /**
  8981. * Creates a Size object from the given width and height (floats).
  8982. * @param width width of the new size
  8983. * @param height height of the new size
  8984. */
  8985. constructor(width: number, height: number);
  8986. /**
  8987. * Returns a string with the Size width and height
  8988. * @returns a string with the Size width and height
  8989. */
  8990. toString(): string;
  8991. /**
  8992. * "Size"
  8993. * @returns the string "Size"
  8994. */
  8995. getClassName(): string;
  8996. /**
  8997. * Returns the Size hash code.
  8998. * @returns a hash code for a unique width and height
  8999. */
  9000. getHashCode(): number;
  9001. /**
  9002. * Updates the current size from the given one.
  9003. * @param src the given size
  9004. */
  9005. copyFrom(src: Size): void;
  9006. /**
  9007. * Updates in place the current Size from the given floats.
  9008. * @param width width of the new size
  9009. * @param height height of the new size
  9010. * @returns the updated Size.
  9011. */
  9012. copyFromFloats(width: number, height: number): Size;
  9013. /**
  9014. * Updates in place the current Size from the given floats.
  9015. * @param width width to set
  9016. * @param height height to set
  9017. * @returns the updated Size.
  9018. */
  9019. set(width: number, height: number): Size;
  9020. /**
  9021. * Multiplies the width and height by numbers
  9022. * @param w factor to multiple the width by
  9023. * @param h factor to multiple the height by
  9024. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9025. */
  9026. multiplyByFloats(w: number, h: number): Size;
  9027. /**
  9028. * Clones the size
  9029. * @returns a new Size copied from the given one.
  9030. */
  9031. clone(): Size;
  9032. /**
  9033. * True if the current Size and the given one width and height are strictly equal.
  9034. * @param other the other size to compare against
  9035. * @returns True if the current Size and the given one width and height are strictly equal.
  9036. */
  9037. equals(other: Size): boolean;
  9038. /**
  9039. * The surface of the Size : width * height (float).
  9040. */
  9041. get surface(): number;
  9042. /**
  9043. * Create a new size of zero
  9044. * @returns a new Size set to (0.0, 0.0)
  9045. */
  9046. static Zero(): Size;
  9047. /**
  9048. * Sums the width and height of two sizes
  9049. * @param otherSize size to add to this size
  9050. * @returns a new Size set as the addition result of the current Size and the given one.
  9051. */
  9052. add(otherSize: Size): Size;
  9053. /**
  9054. * Subtracts the width and height of two
  9055. * @param otherSize size to subtract to this size
  9056. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9057. */
  9058. subtract(otherSize: Size): Size;
  9059. /**
  9060. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9061. * @param start starting size to lerp between
  9062. * @param end end size to lerp between
  9063. * @param amount amount to lerp between the start and end values
  9064. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9065. */
  9066. static Lerp(start: Size, end: Size, amount: number): Size;
  9067. }
  9068. }
  9069. declare module "babylonjs/Maths/math.vertexFormat" {
  9070. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9071. /**
  9072. * Contains position and normal vectors for a vertex
  9073. */
  9074. export class PositionNormalVertex {
  9075. /** the position of the vertex (defaut: 0,0,0) */
  9076. position: Vector3;
  9077. /** the normal of the vertex (defaut: 0,1,0) */
  9078. normal: Vector3;
  9079. /**
  9080. * Creates a PositionNormalVertex
  9081. * @param position the position of the vertex (defaut: 0,0,0)
  9082. * @param normal the normal of the vertex (defaut: 0,1,0)
  9083. */
  9084. constructor(
  9085. /** the position of the vertex (defaut: 0,0,0) */
  9086. position?: Vector3,
  9087. /** the normal of the vertex (defaut: 0,1,0) */
  9088. normal?: Vector3);
  9089. /**
  9090. * Clones the PositionNormalVertex
  9091. * @returns the cloned PositionNormalVertex
  9092. */
  9093. clone(): PositionNormalVertex;
  9094. }
  9095. /**
  9096. * Contains position, normal and uv vectors for a vertex
  9097. */
  9098. export class PositionNormalTextureVertex {
  9099. /** the position of the vertex (defaut: 0,0,0) */
  9100. position: Vector3;
  9101. /** the normal of the vertex (defaut: 0,1,0) */
  9102. normal: Vector3;
  9103. /** the uv of the vertex (default: 0,0) */
  9104. uv: Vector2;
  9105. /**
  9106. * Creates a PositionNormalTextureVertex
  9107. * @param position the position of the vertex (defaut: 0,0,0)
  9108. * @param normal the normal of the vertex (defaut: 0,1,0)
  9109. * @param uv the uv of the vertex (default: 0,0)
  9110. */
  9111. constructor(
  9112. /** the position of the vertex (defaut: 0,0,0) */
  9113. position?: Vector3,
  9114. /** the normal of the vertex (defaut: 0,1,0) */
  9115. normal?: Vector3,
  9116. /** the uv of the vertex (default: 0,0) */
  9117. uv?: Vector2);
  9118. /**
  9119. * Clones the PositionNormalTextureVertex
  9120. * @returns the cloned PositionNormalTextureVertex
  9121. */
  9122. clone(): PositionNormalTextureVertex;
  9123. }
  9124. }
  9125. declare module "babylonjs/Maths/math" {
  9126. export * from "babylonjs/Maths/math.axis";
  9127. export * from "babylonjs/Maths/math.color";
  9128. export * from "babylonjs/Maths/math.constants";
  9129. export * from "babylonjs/Maths/math.frustum";
  9130. export * from "babylonjs/Maths/math.path";
  9131. export * from "babylonjs/Maths/math.plane";
  9132. export * from "babylonjs/Maths/math.size";
  9133. export * from "babylonjs/Maths/math.vector";
  9134. export * from "babylonjs/Maths/math.vertexFormat";
  9135. export * from "babylonjs/Maths/math.viewport";
  9136. }
  9137. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9138. /**
  9139. * Enum defining the type of animations supported by InputBlock
  9140. */
  9141. export enum AnimatedInputBlockTypes {
  9142. /** No animation */
  9143. None = 0,
  9144. /** Time based animation. Will only work for floats */
  9145. Time = 1
  9146. }
  9147. }
  9148. declare module "babylonjs/Lights/shadowLight" {
  9149. import { Camera } from "babylonjs/Cameras/camera";
  9150. import { Scene } from "babylonjs/scene";
  9151. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9153. import { Light } from "babylonjs/Lights/light";
  9154. /**
  9155. * Interface describing all the common properties and methods a shadow light needs to implement.
  9156. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9157. * as well as binding the different shadow properties to the effects.
  9158. */
  9159. export interface IShadowLight extends Light {
  9160. /**
  9161. * The light id in the scene (used in scene.findLighById for instance)
  9162. */
  9163. id: string;
  9164. /**
  9165. * The position the shdow will be casted from.
  9166. */
  9167. position: Vector3;
  9168. /**
  9169. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9170. */
  9171. direction: Vector3;
  9172. /**
  9173. * The transformed position. Position of the light in world space taking parenting in account.
  9174. */
  9175. transformedPosition: Vector3;
  9176. /**
  9177. * The transformed direction. Direction of the light in world space taking parenting in account.
  9178. */
  9179. transformedDirection: Vector3;
  9180. /**
  9181. * The friendly name of the light in the scene.
  9182. */
  9183. name: string;
  9184. /**
  9185. * Defines the shadow projection clipping minimum z value.
  9186. */
  9187. shadowMinZ: number;
  9188. /**
  9189. * Defines the shadow projection clipping maximum z value.
  9190. */
  9191. shadowMaxZ: number;
  9192. /**
  9193. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9194. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9195. */
  9196. computeTransformedInformation(): boolean;
  9197. /**
  9198. * Gets the scene the light belongs to.
  9199. * @returns The scene
  9200. */
  9201. getScene(): Scene;
  9202. /**
  9203. * Callback defining a custom Projection Matrix Builder.
  9204. * This can be used to override the default projection matrix computation.
  9205. */
  9206. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9207. /**
  9208. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9209. * @param matrix The materix to updated with the projection information
  9210. * @param viewMatrix The transform matrix of the light
  9211. * @param renderList The list of mesh to render in the map
  9212. * @returns The current light
  9213. */
  9214. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9215. /**
  9216. * Gets the current depth scale used in ESM.
  9217. * @returns The scale
  9218. */
  9219. getDepthScale(): number;
  9220. /**
  9221. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9222. * @returns true if a cube texture needs to be use
  9223. */
  9224. needCube(): boolean;
  9225. /**
  9226. * Detects if the projection matrix requires to be recomputed this frame.
  9227. * @returns true if it requires to be recomputed otherwise, false.
  9228. */
  9229. needProjectionMatrixCompute(): boolean;
  9230. /**
  9231. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9232. */
  9233. forceProjectionMatrixCompute(): void;
  9234. /**
  9235. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9236. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9237. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9238. */
  9239. getShadowDirection(faceIndex?: number): Vector3;
  9240. /**
  9241. * Gets the minZ used for shadow according to both the scene and the light.
  9242. * @param activeCamera The camera we are returning the min for
  9243. * @returns the depth min z
  9244. */
  9245. getDepthMinZ(activeCamera: Camera): number;
  9246. /**
  9247. * Gets the maxZ used for shadow according to both the scene and the light.
  9248. * @param activeCamera The camera we are returning the max for
  9249. * @returns the depth max z
  9250. */
  9251. getDepthMaxZ(activeCamera: Camera): number;
  9252. }
  9253. /**
  9254. * Base implementation IShadowLight
  9255. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9256. */
  9257. export abstract class ShadowLight extends Light implements IShadowLight {
  9258. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9259. protected _position: Vector3;
  9260. protected _setPosition(value: Vector3): void;
  9261. /**
  9262. * Sets the position the shadow will be casted from. Also use as the light position for both
  9263. * point and spot lights.
  9264. */
  9265. get position(): Vector3;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. set position(value: Vector3);
  9271. protected _direction: Vector3;
  9272. protected _setDirection(value: Vector3): void;
  9273. /**
  9274. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9275. * Also use as the light direction on spot and directional lights.
  9276. */
  9277. get direction(): Vector3;
  9278. /**
  9279. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9280. * Also use as the light direction on spot and directional lights.
  9281. */
  9282. set direction(value: Vector3);
  9283. protected _shadowMinZ: number;
  9284. /**
  9285. * Gets the shadow projection clipping minimum z value.
  9286. */
  9287. get shadowMinZ(): number;
  9288. /**
  9289. * Sets the shadow projection clipping minimum z value.
  9290. */
  9291. set shadowMinZ(value: number);
  9292. protected _shadowMaxZ: number;
  9293. /**
  9294. * Sets the shadow projection clipping maximum z value.
  9295. */
  9296. get shadowMaxZ(): number;
  9297. /**
  9298. * Gets the shadow projection clipping maximum z value.
  9299. */
  9300. set shadowMaxZ(value: number);
  9301. /**
  9302. * Callback defining a custom Projection Matrix Builder.
  9303. * This can be used to override the default projection matrix computation.
  9304. */
  9305. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9306. /**
  9307. * The transformed position. Position of the light in world space taking parenting in account.
  9308. */
  9309. transformedPosition: Vector3;
  9310. /**
  9311. * The transformed direction. Direction of the light in world space taking parenting in account.
  9312. */
  9313. transformedDirection: Vector3;
  9314. private _needProjectionMatrixCompute;
  9315. /**
  9316. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9317. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9318. */
  9319. computeTransformedInformation(): boolean;
  9320. /**
  9321. * Return the depth scale used for the shadow map.
  9322. * @returns the depth scale.
  9323. */
  9324. getDepthScale(): number;
  9325. /**
  9326. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9327. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9328. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9329. */
  9330. getShadowDirection(faceIndex?: number): Vector3;
  9331. /**
  9332. * Returns the ShadowLight absolute position in the World.
  9333. * @returns the position vector in world space
  9334. */
  9335. getAbsolutePosition(): Vector3;
  9336. /**
  9337. * Sets the ShadowLight direction toward the passed target.
  9338. * @param target The point to target in local space
  9339. * @returns the updated ShadowLight direction
  9340. */
  9341. setDirectionToTarget(target: Vector3): Vector3;
  9342. /**
  9343. * Returns the light rotation in euler definition.
  9344. * @returns the x y z rotation in local space.
  9345. */
  9346. getRotation(): Vector3;
  9347. /**
  9348. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9349. * @returns true if a cube texture needs to be use
  9350. */
  9351. needCube(): boolean;
  9352. /**
  9353. * Detects if the projection matrix requires to be recomputed this frame.
  9354. * @returns true if it requires to be recomputed otherwise, false.
  9355. */
  9356. needProjectionMatrixCompute(): boolean;
  9357. /**
  9358. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9359. */
  9360. forceProjectionMatrixCompute(): void;
  9361. /** @hidden */
  9362. _initCache(): void;
  9363. /** @hidden */
  9364. _isSynchronized(): boolean;
  9365. /**
  9366. * Computes the world matrix of the node
  9367. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9368. * @returns the world matrix
  9369. */
  9370. computeWorldMatrix(force?: boolean): Matrix;
  9371. /**
  9372. * Gets the minZ used for shadow according to both the scene and the light.
  9373. * @param activeCamera The camera we are returning the min for
  9374. * @returns the depth min z
  9375. */
  9376. getDepthMinZ(activeCamera: Camera): number;
  9377. /**
  9378. * Gets the maxZ used for shadow according to both the scene and the light.
  9379. * @param activeCamera The camera we are returning the max for
  9380. * @returns the depth max z
  9381. */
  9382. getDepthMaxZ(activeCamera: Camera): number;
  9383. /**
  9384. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9385. * @param matrix The materix to updated with the projection information
  9386. * @param viewMatrix The transform matrix of the light
  9387. * @param renderList The list of mesh to render in the map
  9388. * @returns The current light
  9389. */
  9390. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9391. }
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9394. /** @hidden */
  9395. export var packingFunctions: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9401. /** @hidden */
  9402. export var bayerDitherFunctions: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9408. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9409. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9410. /** @hidden */
  9411. export var shadowMapFragmentDeclaration: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9417. /** @hidden */
  9418. export var clipPlaneFragmentDeclaration: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9424. /** @hidden */
  9425. export var clipPlaneFragment: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9431. /** @hidden */
  9432. export var shadowMapFragment: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9438. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9439. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9440. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9441. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9442. /** @hidden */
  9443. export var shadowMapPixelShader: {
  9444. name: string;
  9445. shader: string;
  9446. };
  9447. }
  9448. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9449. /** @hidden */
  9450. export var bonesDeclaration: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9456. /** @hidden */
  9457. export var morphTargetsVertexGlobalDeclaration: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9463. /** @hidden */
  9464. export var morphTargetsVertexDeclaration: {
  9465. name: string;
  9466. shader: string;
  9467. };
  9468. }
  9469. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9470. /** @hidden */
  9471. export var instancesDeclaration: {
  9472. name: string;
  9473. shader: string;
  9474. };
  9475. }
  9476. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9477. /** @hidden */
  9478. export var helperFunctions: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9484. /** @hidden */
  9485. export var shadowMapVertexDeclaration: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9491. /** @hidden */
  9492. export var clipPlaneVertexDeclaration: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9498. /** @hidden */
  9499. export var morphTargetsVertex: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9505. /** @hidden */
  9506. export var instancesVertex: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9512. /** @hidden */
  9513. export var bonesVertex: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9519. /** @hidden */
  9520. export var shadowMapVertexNormalBias: {
  9521. name: string;
  9522. shader: string;
  9523. };
  9524. }
  9525. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9526. /** @hidden */
  9527. export var shadowMapVertexMetric: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9533. /** @hidden */
  9534. export var clipPlaneVertex: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9540. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9543. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9544. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9545. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9549. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9550. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9551. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9552. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9553. /** @hidden */
  9554. export var shadowMapVertexShader: {
  9555. name: string;
  9556. shader: string;
  9557. };
  9558. }
  9559. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9560. /** @hidden */
  9561. export var depthBoxBlurPixelShader: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9567. /** @hidden */
  9568. export var shadowMapFragmentSoftTransparentShadow: {
  9569. name: string;
  9570. shader: string;
  9571. };
  9572. }
  9573. declare module "babylonjs/Materials/effectFallbacks" {
  9574. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9575. import { Effect } from "babylonjs/Materials/effect";
  9576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9577. /**
  9578. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9579. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9580. */
  9581. export class EffectFallbacks implements IEffectFallbacks {
  9582. private _defines;
  9583. private _currentRank;
  9584. private _maxRank;
  9585. private _mesh;
  9586. /**
  9587. * Removes the fallback from the bound mesh.
  9588. */
  9589. unBindMesh(): void;
  9590. /**
  9591. * Adds a fallback on the specified property.
  9592. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9593. * @param define The name of the define in the shader
  9594. */
  9595. addFallback(rank: number, define: string): void;
  9596. /**
  9597. * Sets the mesh to use CPU skinning when needing to fallback.
  9598. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9599. * @param mesh The mesh to use the fallbacks.
  9600. */
  9601. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9602. /**
  9603. * Checks to see if more fallbacks are still availible.
  9604. */
  9605. get hasMoreFallbacks(): boolean;
  9606. /**
  9607. * Removes the defines that should be removed when falling back.
  9608. * @param currentDefines defines the current define statements for the shader.
  9609. * @param effect defines the current effect we try to compile
  9610. * @returns The resulting defines with defines of the current rank removed.
  9611. */
  9612. reduce(currentDefines: string, effect: Effect): string;
  9613. }
  9614. }
  9615. declare module "babylonjs/Actions/action" {
  9616. import { Observable } from "babylonjs/Misc/observable";
  9617. import { Condition } from "babylonjs/Actions/condition";
  9618. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9619. import { Nullable } from "babylonjs/types";
  9620. import { Scene } from "babylonjs/scene";
  9621. import { ActionManager } from "babylonjs/Actions/actionManager";
  9622. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9623. import { Node } from "babylonjs/node";
  9624. /**
  9625. * Interface used to define Action
  9626. */
  9627. export interface IAction {
  9628. /**
  9629. * Trigger for the action
  9630. */
  9631. trigger: number;
  9632. /** Options of the trigger */
  9633. triggerOptions: any;
  9634. /**
  9635. * Gets the trigger parameters
  9636. * @returns the trigger parameters
  9637. */
  9638. getTriggerParameter(): any;
  9639. /**
  9640. * Internal only - executes current action event
  9641. * @hidden
  9642. */
  9643. _executeCurrent(evt?: ActionEvent): void;
  9644. /**
  9645. * Serialize placeholder for child classes
  9646. * @param parent of child
  9647. * @returns the serialized object
  9648. */
  9649. serialize(parent: any): any;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _prepare(): void;
  9655. /**
  9656. * Internal only - manager for action
  9657. * @hidden
  9658. */
  9659. _actionManager: Nullable<AbstractActionManager>;
  9660. /**
  9661. * Adds action to chain of actions, may be a DoNothingAction
  9662. * @param action defines the next action to execute
  9663. * @returns The action passed in
  9664. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9665. */
  9666. then(action: IAction): IAction;
  9667. }
  9668. /**
  9669. * The action to be carried out following a trigger
  9670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9671. */
  9672. export class Action implements IAction {
  9673. /** the trigger, with or without parameters, for the action */
  9674. triggerOptions: any;
  9675. /**
  9676. * Trigger for the action
  9677. */
  9678. trigger: number;
  9679. /**
  9680. * Internal only - manager for action
  9681. * @hidden
  9682. */
  9683. _actionManager: ActionManager;
  9684. private _nextActiveAction;
  9685. private _child;
  9686. private _condition?;
  9687. private _triggerParameter;
  9688. /**
  9689. * An event triggered prior to action being executed.
  9690. */
  9691. onBeforeExecuteObservable: Observable<Action>;
  9692. /**
  9693. * Creates a new Action
  9694. * @param triggerOptions the trigger, with or without parameters, for the action
  9695. * @param condition an optional determinant of action
  9696. */
  9697. constructor(
  9698. /** the trigger, with or without parameters, for the action */
  9699. triggerOptions: any, condition?: Condition);
  9700. /**
  9701. * Internal only
  9702. * @hidden
  9703. */
  9704. _prepare(): void;
  9705. /**
  9706. * Gets the trigger parameters
  9707. * @returns the trigger parameters
  9708. */
  9709. getTriggerParameter(): any;
  9710. /**
  9711. * Internal only - executes current action event
  9712. * @hidden
  9713. */
  9714. _executeCurrent(evt?: ActionEvent): void;
  9715. /**
  9716. * Execute placeholder for child classes
  9717. * @param evt optional action event
  9718. */
  9719. execute(evt?: ActionEvent): void;
  9720. /**
  9721. * Skips to next active action
  9722. */
  9723. skipToNextActiveAction(): void;
  9724. /**
  9725. * Adds action to chain of actions, may be a DoNothingAction
  9726. * @param action defines the next action to execute
  9727. * @returns The action passed in
  9728. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9729. */
  9730. then(action: Action): Action;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. _getProperty(propertyPath: string): string;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. _getEffectiveTarget(target: any, propertyPath: string): any;
  9741. /**
  9742. * Serialize placeholder for child classes
  9743. * @param parent of child
  9744. * @returns the serialized object
  9745. */
  9746. serialize(parent: any): any;
  9747. /**
  9748. * Internal only called by serialize
  9749. * @hidden
  9750. */
  9751. protected _serialize(serializedAction: any, parent?: any): any;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. static _SerializeValueAsString: (value: any) => string;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. static _GetTargetProperty: (target: Scene | Node) => {
  9762. name: string;
  9763. targetType: string;
  9764. value: string;
  9765. };
  9766. }
  9767. }
  9768. declare module "babylonjs/Actions/condition" {
  9769. import { ActionManager } from "babylonjs/Actions/actionManager";
  9770. /**
  9771. * A Condition applied to an Action
  9772. */
  9773. export class Condition {
  9774. /**
  9775. * Internal only - manager for action
  9776. * @hidden
  9777. */
  9778. _actionManager: ActionManager;
  9779. /**
  9780. * Internal only
  9781. * @hidden
  9782. */
  9783. _evaluationId: number;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. _currentResult: boolean;
  9789. /**
  9790. * Creates a new Condition
  9791. * @param actionManager the manager of the action the condition is applied to
  9792. */
  9793. constructor(actionManager: ActionManager);
  9794. /**
  9795. * Check if the current condition is valid
  9796. * @returns a boolean
  9797. */
  9798. isValid(): boolean;
  9799. /**
  9800. * Internal only
  9801. * @hidden
  9802. */
  9803. _getProperty(propertyPath: string): string;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. _getEffectiveTarget(target: any, propertyPath: string): any;
  9809. /**
  9810. * Serialize placeholder for child classes
  9811. * @returns the serialized object
  9812. */
  9813. serialize(): any;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. protected _serialize(serializedCondition: any): any;
  9819. }
  9820. /**
  9821. * Defines specific conditional operators as extensions of Condition
  9822. */
  9823. export class ValueCondition extends Condition {
  9824. /** path to specify the property of the target the conditional operator uses */
  9825. propertyPath: string;
  9826. /** the value compared by the conditional operator against the current value of the property */
  9827. value: any;
  9828. /** the conditional operator, default ValueCondition.IsEqual */
  9829. operator: number;
  9830. /**
  9831. * Internal only
  9832. * @hidden
  9833. */
  9834. private static _IsEqual;
  9835. /**
  9836. * Internal only
  9837. * @hidden
  9838. */
  9839. private static _IsDifferent;
  9840. /**
  9841. * Internal only
  9842. * @hidden
  9843. */
  9844. private static _IsGreater;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private static _IsLesser;
  9850. /**
  9851. * returns the number for IsEqual
  9852. */
  9853. static get IsEqual(): number;
  9854. /**
  9855. * Returns the number for IsDifferent
  9856. */
  9857. static get IsDifferent(): number;
  9858. /**
  9859. * Returns the number for IsGreater
  9860. */
  9861. static get IsGreater(): number;
  9862. /**
  9863. * Returns the number for IsLesser
  9864. */
  9865. static get IsLesser(): number;
  9866. /**
  9867. * Internal only The action manager for the condition
  9868. * @hidden
  9869. */
  9870. _actionManager: ActionManager;
  9871. /**
  9872. * Internal only
  9873. * @hidden
  9874. */
  9875. private _target;
  9876. /**
  9877. * Internal only
  9878. * @hidden
  9879. */
  9880. private _effectiveTarget;
  9881. /**
  9882. * Internal only
  9883. * @hidden
  9884. */
  9885. private _property;
  9886. /**
  9887. * Creates a new ValueCondition
  9888. * @param actionManager manager for the action the condition applies to
  9889. * @param target for the action
  9890. * @param propertyPath path to specify the property of the target the conditional operator uses
  9891. * @param value the value compared by the conditional operator against the current value of the property
  9892. * @param operator the conditional operator, default ValueCondition.IsEqual
  9893. */
  9894. constructor(actionManager: ActionManager, target: any,
  9895. /** path to specify the property of the target the conditional operator uses */
  9896. propertyPath: string,
  9897. /** the value compared by the conditional operator against the current value of the property */
  9898. value: any,
  9899. /** the conditional operator, default ValueCondition.IsEqual */
  9900. operator?: number);
  9901. /**
  9902. * Compares the given value with the property value for the specified conditional operator
  9903. * @returns the result of the comparison
  9904. */
  9905. isValid(): boolean;
  9906. /**
  9907. * Serialize the ValueCondition into a JSON compatible object
  9908. * @returns serialization object
  9909. */
  9910. serialize(): any;
  9911. /**
  9912. * Gets the name of the conditional operator for the ValueCondition
  9913. * @param operator the conditional operator
  9914. * @returns the name
  9915. */
  9916. static GetOperatorName(operator: number): string;
  9917. }
  9918. /**
  9919. * Defines a predicate condition as an extension of Condition
  9920. */
  9921. export class PredicateCondition extends Condition {
  9922. /** defines the predicate function used to validate the condition */
  9923. predicate: () => boolean;
  9924. /**
  9925. * Internal only - manager for action
  9926. * @hidden
  9927. */
  9928. _actionManager: ActionManager;
  9929. /**
  9930. * Creates a new PredicateCondition
  9931. * @param actionManager manager for the action the condition applies to
  9932. * @param predicate defines the predicate function used to validate the condition
  9933. */
  9934. constructor(actionManager: ActionManager,
  9935. /** defines the predicate function used to validate the condition */
  9936. predicate: () => boolean);
  9937. /**
  9938. * @returns the validity of the predicate condition
  9939. */
  9940. isValid(): boolean;
  9941. }
  9942. /**
  9943. * Defines a state condition as an extension of Condition
  9944. */
  9945. export class StateCondition extends Condition {
  9946. /** Value to compare with target state */
  9947. value: string;
  9948. /**
  9949. * Internal only - manager for action
  9950. * @hidden
  9951. */
  9952. _actionManager: ActionManager;
  9953. /**
  9954. * Internal only
  9955. * @hidden
  9956. */
  9957. private _target;
  9958. /**
  9959. * Creates a new StateCondition
  9960. * @param actionManager manager for the action the condition applies to
  9961. * @param target of the condition
  9962. * @param value to compare with target state
  9963. */
  9964. constructor(actionManager: ActionManager, target: any,
  9965. /** Value to compare with target state */
  9966. value: string);
  9967. /**
  9968. * Gets a boolean indicating if the current condition is met
  9969. * @returns the validity of the state
  9970. */
  9971. isValid(): boolean;
  9972. /**
  9973. * Serialize the StateCondition into a JSON compatible object
  9974. * @returns serialization object
  9975. */
  9976. serialize(): any;
  9977. }
  9978. }
  9979. declare module "babylonjs/Actions/directActions" {
  9980. import { Action } from "babylonjs/Actions/action";
  9981. import { Condition } from "babylonjs/Actions/condition";
  9982. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9983. /**
  9984. * This defines an action responsible to toggle a boolean once triggered.
  9985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9986. */
  9987. export class SwitchBooleanAction extends Action {
  9988. /**
  9989. * The path to the boolean property in the target object
  9990. */
  9991. propertyPath: string;
  9992. private _target;
  9993. private _effectiveTarget;
  9994. private _property;
  9995. /**
  9996. * Instantiate the action
  9997. * @param triggerOptions defines the trigger options
  9998. * @param target defines the object containing the boolean
  9999. * @param propertyPath defines the path to the boolean property in the target object
  10000. * @param condition defines the trigger related conditions
  10001. */
  10002. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10003. /** @hidden */
  10004. _prepare(): void;
  10005. /**
  10006. * Execute the action toggle the boolean value.
  10007. */
  10008. execute(): void;
  10009. /**
  10010. * Serializes the actions and its related information.
  10011. * @param parent defines the object to serialize in
  10012. * @returns the serialized object
  10013. */
  10014. serialize(parent: any): any;
  10015. }
  10016. /**
  10017. * This defines an action responsible to set a the state field of the target
  10018. * to a desired value once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetStateAction extends Action {
  10022. /**
  10023. * The value to store in the state field.
  10024. */
  10025. value: string;
  10026. private _target;
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param target defines the object containing the state property
  10031. * @param value defines the value to store in the state field
  10032. * @param condition defines the trigger related conditions
  10033. */
  10034. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10035. /**
  10036. * Execute the action and store the value on the target state property.
  10037. */
  10038. execute(): void;
  10039. /**
  10040. * Serializes the actions and its related information.
  10041. * @param parent defines the object to serialize in
  10042. * @returns the serialized object
  10043. */
  10044. serialize(parent: any): any;
  10045. }
  10046. /**
  10047. * This defines an action responsible to set a property of the target
  10048. * to a desired value once triggered.
  10049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10050. */
  10051. export class SetValueAction extends Action {
  10052. /**
  10053. * The path of the property to set in the target.
  10054. */
  10055. propertyPath: string;
  10056. /**
  10057. * The value to set in the property
  10058. */
  10059. value: any;
  10060. private _target;
  10061. private _effectiveTarget;
  10062. private _property;
  10063. /**
  10064. * Instantiate the action
  10065. * @param triggerOptions defines the trigger options
  10066. * @param target defines the object containing the property
  10067. * @param propertyPath defines the path of the property to set in the target
  10068. * @param value defines the value to set in the property
  10069. * @param condition defines the trigger related conditions
  10070. */
  10071. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10072. /** @hidden */
  10073. _prepare(): void;
  10074. /**
  10075. * Execute the action and set the targetted property to the desired value.
  10076. */
  10077. execute(): void;
  10078. /**
  10079. * Serializes the actions and its related information.
  10080. * @param parent defines the object to serialize in
  10081. * @returns the serialized object
  10082. */
  10083. serialize(parent: any): any;
  10084. }
  10085. /**
  10086. * This defines an action responsible to increment the target value
  10087. * to a desired value once triggered.
  10088. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10089. */
  10090. export class IncrementValueAction extends Action {
  10091. /**
  10092. * The path of the property to increment in the target.
  10093. */
  10094. propertyPath: string;
  10095. /**
  10096. * The value we should increment the property by.
  10097. */
  10098. value: any;
  10099. private _target;
  10100. private _effectiveTarget;
  10101. private _property;
  10102. /**
  10103. * Instantiate the action
  10104. * @param triggerOptions defines the trigger options
  10105. * @param target defines the object containing the property
  10106. * @param propertyPath defines the path of the property to increment in the target
  10107. * @param value defines the value value we should increment the property by
  10108. * @param condition defines the trigger related conditions
  10109. */
  10110. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10111. /** @hidden */
  10112. _prepare(): void;
  10113. /**
  10114. * Execute the action and increment the target of the value amount.
  10115. */
  10116. execute(): void;
  10117. /**
  10118. * Serializes the actions and its related information.
  10119. * @param parent defines the object to serialize in
  10120. * @returns the serialized object
  10121. */
  10122. serialize(parent: any): any;
  10123. }
  10124. /**
  10125. * This defines an action responsible to start an animation once triggered.
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10127. */
  10128. export class PlayAnimationAction extends Action {
  10129. /**
  10130. * Where the animation should start (animation frame)
  10131. */
  10132. from: number;
  10133. /**
  10134. * Where the animation should stop (animation frame)
  10135. */
  10136. to: number;
  10137. /**
  10138. * Define if the animation should loop or stop after the first play.
  10139. */
  10140. loop?: boolean;
  10141. private _target;
  10142. /**
  10143. * Instantiate the action
  10144. * @param triggerOptions defines the trigger options
  10145. * @param target defines the target animation or animation name
  10146. * @param from defines from where the animation should start (animation frame)
  10147. * @param end defines where the animation should stop (animation frame)
  10148. * @param loop defines if the animation should loop or stop after the first play
  10149. * @param condition defines the trigger related conditions
  10150. */
  10151. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10152. /** @hidden */
  10153. _prepare(): void;
  10154. /**
  10155. * Execute the action and play the animation.
  10156. */
  10157. execute(): void;
  10158. /**
  10159. * Serializes the actions and its related information.
  10160. * @param parent defines the object to serialize in
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. }
  10165. /**
  10166. * This defines an action responsible to stop an animation once triggered.
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10168. */
  10169. export class StopAnimationAction extends Action {
  10170. private _target;
  10171. /**
  10172. * Instantiate the action
  10173. * @param triggerOptions defines the trigger options
  10174. * @param target defines the target animation or animation name
  10175. * @param condition defines the trigger related conditions
  10176. */
  10177. constructor(triggerOptions: any, target: any, condition?: Condition);
  10178. /** @hidden */
  10179. _prepare(): void;
  10180. /**
  10181. * Execute the action and stop the animation.
  10182. */
  10183. execute(): void;
  10184. /**
  10185. * Serializes the actions and its related information.
  10186. * @param parent defines the object to serialize in
  10187. * @returns the serialized object
  10188. */
  10189. serialize(parent: any): any;
  10190. }
  10191. /**
  10192. * This defines an action responsible that does nothing once triggered.
  10193. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10194. */
  10195. export class DoNothingAction extends Action {
  10196. /**
  10197. * Instantiate the action
  10198. * @param triggerOptions defines the trigger options
  10199. * @param condition defines the trigger related conditions
  10200. */
  10201. constructor(triggerOptions?: any, condition?: Condition);
  10202. /**
  10203. * Execute the action and do nothing.
  10204. */
  10205. execute(): void;
  10206. /**
  10207. * Serializes the actions and its related information.
  10208. * @param parent defines the object to serialize in
  10209. * @returns the serialized object
  10210. */
  10211. serialize(parent: any): any;
  10212. }
  10213. /**
  10214. * This defines an action responsible to trigger several actions once triggered.
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10216. */
  10217. export class CombineAction extends Action {
  10218. /**
  10219. * The list of aggregated animations to run.
  10220. */
  10221. children: Action[];
  10222. /**
  10223. * Instantiate the action
  10224. * @param triggerOptions defines the trigger options
  10225. * @param children defines the list of aggregated animations to run
  10226. * @param condition defines the trigger related conditions
  10227. */
  10228. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10229. /** @hidden */
  10230. _prepare(): void;
  10231. /**
  10232. * Execute the action and executes all the aggregated actions.
  10233. */
  10234. execute(evt: ActionEvent): void;
  10235. /**
  10236. * Serializes the actions and its related information.
  10237. * @param parent defines the object to serialize in
  10238. * @returns the serialized object
  10239. */
  10240. serialize(parent: any): any;
  10241. }
  10242. /**
  10243. * This defines an action responsible to run code (external event) once triggered.
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10245. */
  10246. export class ExecuteCodeAction extends Action {
  10247. /**
  10248. * The callback function to run.
  10249. */
  10250. func: (evt: ActionEvent) => void;
  10251. /**
  10252. * Instantiate the action
  10253. * @param triggerOptions defines the trigger options
  10254. * @param func defines the callback function to run
  10255. * @param condition defines the trigger related conditions
  10256. */
  10257. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10258. /**
  10259. * Execute the action and run the attached code.
  10260. */
  10261. execute(evt: ActionEvent): void;
  10262. }
  10263. /**
  10264. * This defines an action responsible to set the parent property of the target once triggered.
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10266. */
  10267. export class SetParentAction extends Action {
  10268. private _parent;
  10269. private _target;
  10270. /**
  10271. * Instantiate the action
  10272. * @param triggerOptions defines the trigger options
  10273. * @param target defines the target containing the parent property
  10274. * @param parent defines from where the animation should start (animation frame)
  10275. * @param condition defines the trigger related conditions
  10276. */
  10277. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10278. /** @hidden */
  10279. _prepare(): void;
  10280. /**
  10281. * Execute the action and set the parent property.
  10282. */
  10283. execute(): void;
  10284. /**
  10285. * Serializes the actions and its related information.
  10286. * @param parent defines the object to serialize in
  10287. * @returns the serialized object
  10288. */
  10289. serialize(parent: any): any;
  10290. }
  10291. }
  10292. declare module "babylonjs/Actions/actionManager" {
  10293. import { Nullable } from "babylonjs/types";
  10294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10295. import { Scene } from "babylonjs/scene";
  10296. import { IAction } from "babylonjs/Actions/action";
  10297. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10298. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10299. /**
  10300. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10301. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10303. */
  10304. export class ActionManager extends AbstractActionManager {
  10305. /**
  10306. * Nothing
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10308. */
  10309. static readonly NothingTrigger: number;
  10310. /**
  10311. * On pick
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly OnPickTrigger: number;
  10315. /**
  10316. * On left pick
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnLeftPickTrigger: number;
  10320. /**
  10321. * On right pick
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnRightPickTrigger: number;
  10325. /**
  10326. * On center pick
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnCenterPickTrigger: number;
  10330. /**
  10331. * On pick down
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickDownTrigger: number;
  10335. /**
  10336. * On double pick
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnDoublePickTrigger: number;
  10340. /**
  10341. * On pick up
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnPickUpTrigger: number;
  10345. /**
  10346. * On pick out.
  10347. * This trigger will only be raised if you also declared a OnPickDown
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnPickOutTrigger: number;
  10351. /**
  10352. * On long press
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnLongPressTrigger: number;
  10356. /**
  10357. * On pointer over
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnPointerOverTrigger: number;
  10361. /**
  10362. * On pointer out
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnPointerOutTrigger: number;
  10366. /**
  10367. * On every frame
  10368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10369. */
  10370. static readonly OnEveryFrameTrigger: number;
  10371. /**
  10372. * On intersection enter
  10373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10374. */
  10375. static readonly OnIntersectionEnterTrigger: number;
  10376. /**
  10377. * On intersection exit
  10378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10379. */
  10380. static readonly OnIntersectionExitTrigger: number;
  10381. /**
  10382. * On key down
  10383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10384. */
  10385. static readonly OnKeyDownTrigger: number;
  10386. /**
  10387. * On key up
  10388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10389. */
  10390. static readonly OnKeyUpTrigger: number;
  10391. private _scene;
  10392. /**
  10393. * Creates a new action manager
  10394. * @param scene defines the hosting scene
  10395. */
  10396. constructor(scene: Scene);
  10397. /**
  10398. * Releases all associated resources
  10399. */
  10400. dispose(): void;
  10401. /**
  10402. * Gets hosting scene
  10403. * @returns the hosting scene
  10404. */
  10405. getScene(): Scene;
  10406. /**
  10407. * Does this action manager handles actions of any of the given triggers
  10408. * @param triggers defines the triggers to be tested
  10409. * @return a boolean indicating whether one (or more) of the triggers is handled
  10410. */
  10411. hasSpecificTriggers(triggers: number[]): boolean;
  10412. /**
  10413. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10414. * speed.
  10415. * @param triggerA defines the trigger to be tested
  10416. * @param triggerB defines the trigger to be tested
  10417. * @return a boolean indicating whether one (or more) of the triggers is handled
  10418. */
  10419. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10420. /**
  10421. * Does this action manager handles actions of a given trigger
  10422. * @param trigger defines the trigger to be tested
  10423. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10424. * @return whether the trigger is handled
  10425. */
  10426. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10427. /**
  10428. * Does this action manager has pointer triggers
  10429. */
  10430. get hasPointerTriggers(): boolean;
  10431. /**
  10432. * Does this action manager has pick triggers
  10433. */
  10434. get hasPickTriggers(): boolean;
  10435. /**
  10436. * Registers an action to this action manager
  10437. * @param action defines the action to be registered
  10438. * @return the action amended (prepared) after registration
  10439. */
  10440. registerAction(action: IAction): Nullable<IAction>;
  10441. /**
  10442. * Unregisters an action to this action manager
  10443. * @param action defines the action to be unregistered
  10444. * @return a boolean indicating whether the action has been unregistered
  10445. */
  10446. unregisterAction(action: IAction): Boolean;
  10447. /**
  10448. * Process a specific trigger
  10449. * @param trigger defines the trigger to process
  10450. * @param evt defines the event details to be processed
  10451. */
  10452. processTrigger(trigger: number, evt?: IActionEvent): void;
  10453. /** @hidden */
  10454. _getEffectiveTarget(target: any, propertyPath: string): any;
  10455. /** @hidden */
  10456. _getProperty(propertyPath: string): string;
  10457. /**
  10458. * Serialize this manager to a JSON object
  10459. * @param name defines the property name to store this manager
  10460. * @returns a JSON representation of this manager
  10461. */
  10462. serialize(name: string): any;
  10463. /**
  10464. * Creates a new ActionManager from a JSON data
  10465. * @param parsedActions defines the JSON data to read from
  10466. * @param object defines the hosting mesh
  10467. * @param scene defines the hosting scene
  10468. */
  10469. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10470. /**
  10471. * Get a trigger name by index
  10472. * @param trigger defines the trigger index
  10473. * @returns a trigger name
  10474. */
  10475. static GetTriggerName(trigger: number): string;
  10476. }
  10477. }
  10478. declare module "babylonjs/Sprites/sprite" {
  10479. import { Vector3 } from "babylonjs/Maths/math.vector";
  10480. import { Nullable } from "babylonjs/types";
  10481. import { ActionManager } from "babylonjs/Actions/actionManager";
  10482. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10483. import { Color4 } from "babylonjs/Maths/math.color";
  10484. import { Observable } from "babylonjs/Misc/observable";
  10485. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10486. import { Animation } from "babylonjs/Animations/animation";
  10487. /**
  10488. * Class used to represent a sprite
  10489. * @see https://doc.babylonjs.com/babylon101/sprites
  10490. */
  10491. export class Sprite implements IAnimatable {
  10492. /** defines the name */
  10493. name: string;
  10494. /** Gets or sets the current world position */
  10495. position: Vector3;
  10496. /** Gets or sets the main color */
  10497. color: Color4;
  10498. /** Gets or sets the width */
  10499. width: number;
  10500. /** Gets or sets the height */
  10501. height: number;
  10502. /** Gets or sets rotation angle */
  10503. angle: number;
  10504. /** Gets or sets the cell index in the sprite sheet */
  10505. cellIndex: number;
  10506. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10507. cellRef: string;
  10508. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10509. invertU: boolean;
  10510. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10511. invertV: boolean;
  10512. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10513. disposeWhenFinishedAnimating: boolean;
  10514. /** Gets the list of attached animations */
  10515. animations: Nullable<Array<Animation>>;
  10516. /** Gets or sets a boolean indicating if the sprite can be picked */
  10517. isPickable: boolean;
  10518. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10519. useAlphaForPicking: boolean;
  10520. /** @hidden */
  10521. _xOffset: number;
  10522. /** @hidden */
  10523. _yOffset: number;
  10524. /** @hidden */
  10525. _xSize: number;
  10526. /** @hidden */
  10527. _ySize: number;
  10528. /**
  10529. * Gets or sets the associated action manager
  10530. */
  10531. actionManager: Nullable<ActionManager>;
  10532. /**
  10533. * An event triggered when the control has been disposed
  10534. */
  10535. onDisposeObservable: Observable<Sprite>;
  10536. private _animationStarted;
  10537. private _loopAnimation;
  10538. private _fromIndex;
  10539. private _toIndex;
  10540. private _delay;
  10541. private _direction;
  10542. private _manager;
  10543. private _time;
  10544. private _onAnimationEnd;
  10545. /**
  10546. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10547. */
  10548. isVisible: boolean;
  10549. /**
  10550. * Gets or sets the sprite size
  10551. */
  10552. get size(): number;
  10553. set size(value: number);
  10554. /**
  10555. * Returns a boolean indicating if the animation is started
  10556. */
  10557. get animationStarted(): boolean;
  10558. /**
  10559. * Gets or sets the unique id of the sprite
  10560. */
  10561. uniqueId: number;
  10562. /**
  10563. * Gets the manager of this sprite
  10564. */
  10565. get manager(): ISpriteManager;
  10566. /**
  10567. * Creates a new Sprite
  10568. * @param name defines the name
  10569. * @param manager defines the manager
  10570. */
  10571. constructor(
  10572. /** defines the name */
  10573. name: string, manager: ISpriteManager);
  10574. /**
  10575. * Returns the string "Sprite"
  10576. * @returns "Sprite"
  10577. */
  10578. getClassName(): string;
  10579. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10580. get fromIndex(): number;
  10581. set fromIndex(value: number);
  10582. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10583. get toIndex(): number;
  10584. set toIndex(value: number);
  10585. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10586. get loopAnimation(): boolean;
  10587. set loopAnimation(value: boolean);
  10588. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10589. get delay(): number;
  10590. set delay(value: number);
  10591. /**
  10592. * Starts an animation
  10593. * @param from defines the initial key
  10594. * @param to defines the end key
  10595. * @param loop defines if the animation must loop
  10596. * @param delay defines the start delay (in ms)
  10597. * @param onAnimationEnd defines a callback to call when animation ends
  10598. */
  10599. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10600. /** Stops current animation (if any) */
  10601. stopAnimation(): void;
  10602. /** @hidden */
  10603. _animate(deltaTime: number): void;
  10604. /** Release associated resources */
  10605. dispose(): void;
  10606. /**
  10607. * Serializes the sprite to a JSON object
  10608. * @returns the JSON object
  10609. */
  10610. serialize(): any;
  10611. /**
  10612. * Parses a JSON object to create a new sprite
  10613. * @param parsedSprite The JSON object to parse
  10614. * @param manager defines the hosting manager
  10615. * @returns the new sprite
  10616. */
  10617. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10618. }
  10619. }
  10620. declare module "babylonjs/Collisions/pickingInfo" {
  10621. import { Nullable } from "babylonjs/types";
  10622. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10624. import { Sprite } from "babylonjs/Sprites/sprite";
  10625. import { Ray } from "babylonjs/Culling/ray";
  10626. /**
  10627. * Information about the result of picking within a scene
  10628. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10629. */
  10630. export class PickingInfo {
  10631. /** @hidden */
  10632. _pickingUnavailable: boolean;
  10633. /**
  10634. * If the pick collided with an object
  10635. */
  10636. hit: boolean;
  10637. /**
  10638. * Distance away where the pick collided
  10639. */
  10640. distance: number;
  10641. /**
  10642. * The location of pick collision
  10643. */
  10644. pickedPoint: Nullable<Vector3>;
  10645. /**
  10646. * The mesh corresponding the the pick collision
  10647. */
  10648. pickedMesh: Nullable<AbstractMesh>;
  10649. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10650. bu: number;
  10651. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10652. bv: number;
  10653. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10654. faceId: number;
  10655. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10656. subMeshFaceId: number;
  10657. /** Id of the the submesh that was picked */
  10658. subMeshId: number;
  10659. /** If a sprite was picked, this will be the sprite the pick collided with */
  10660. pickedSprite: Nullable<Sprite>;
  10661. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10662. thinInstanceIndex: number;
  10663. /**
  10664. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10665. */
  10666. originMesh: Nullable<AbstractMesh>;
  10667. /**
  10668. * The ray that was used to perform the picking.
  10669. */
  10670. ray: Nullable<Ray>;
  10671. /**
  10672. * Gets the normal correspodning to the face the pick collided with
  10673. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10674. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10675. * @returns The normal correspodning to the face the pick collided with
  10676. */
  10677. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10678. /**
  10679. * Gets the texture coordinates of where the pick occured
  10680. * @returns the vector containing the coordnates of the texture
  10681. */
  10682. getTextureCoordinates(): Nullable<Vector2>;
  10683. }
  10684. }
  10685. declare module "babylonjs/Culling/ray" {
  10686. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10687. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10689. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10690. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10691. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10692. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10693. import { Plane } from "babylonjs/Maths/math.plane";
  10694. /**
  10695. * Class representing a ray with position and direction
  10696. */
  10697. export class Ray {
  10698. /** origin point */
  10699. origin: Vector3;
  10700. /** direction */
  10701. direction: Vector3;
  10702. /** length of the ray */
  10703. length: number;
  10704. private static readonly _TmpVector3;
  10705. private _tmpRay;
  10706. /**
  10707. * Creates a new ray
  10708. * @param origin origin point
  10709. * @param direction direction
  10710. * @param length length of the ray
  10711. */
  10712. constructor(
  10713. /** origin point */
  10714. origin: Vector3,
  10715. /** direction */
  10716. direction: Vector3,
  10717. /** length of the ray */
  10718. length?: number);
  10719. /**
  10720. * Checks if the ray intersects a box
  10721. * This does not account for the ray lenght by design to improve perfs.
  10722. * @param minimum bound of the box
  10723. * @param maximum bound of the box
  10724. * @param intersectionTreshold extra extend to be added to the box in all direction
  10725. * @returns if the box was hit
  10726. */
  10727. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10728. /**
  10729. * Checks if the ray intersects a box
  10730. * This does not account for the ray lenght by design to improve perfs.
  10731. * @param box the bounding box to check
  10732. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10733. * @returns if the box was hit
  10734. */
  10735. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10736. /**
  10737. * If the ray hits a sphere
  10738. * @param sphere the bounding sphere to check
  10739. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10740. * @returns true if it hits the sphere
  10741. */
  10742. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10743. /**
  10744. * If the ray hits a triange
  10745. * @param vertex0 triangle vertex
  10746. * @param vertex1 triangle vertex
  10747. * @param vertex2 triangle vertex
  10748. * @returns intersection information if hit
  10749. */
  10750. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10751. /**
  10752. * Checks if ray intersects a plane
  10753. * @param plane the plane to check
  10754. * @returns the distance away it was hit
  10755. */
  10756. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10757. /**
  10758. * Calculate the intercept of a ray on a given axis
  10759. * @param axis to check 'x' | 'y' | 'z'
  10760. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10761. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10762. */
  10763. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10764. /**
  10765. * Checks if ray intersects a mesh
  10766. * @param mesh the mesh to check
  10767. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10768. * @returns picking info of the intersecton
  10769. */
  10770. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10771. /**
  10772. * Checks if ray intersects a mesh
  10773. * @param meshes the meshes to check
  10774. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10775. * @param results array to store result in
  10776. * @returns Array of picking infos
  10777. */
  10778. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10779. private _comparePickingInfo;
  10780. private static smallnum;
  10781. private static rayl;
  10782. /**
  10783. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10784. * @param sega the first point of the segment to test the intersection against
  10785. * @param segb the second point of the segment to test the intersection against
  10786. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10787. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10788. */
  10789. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10790. /**
  10791. * Update the ray from viewport position
  10792. * @param x position
  10793. * @param y y position
  10794. * @param viewportWidth viewport width
  10795. * @param viewportHeight viewport height
  10796. * @param world world matrix
  10797. * @param view view matrix
  10798. * @param projection projection matrix
  10799. * @returns this ray updated
  10800. */
  10801. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10802. /**
  10803. * Creates a ray with origin and direction of 0,0,0
  10804. * @returns the new ray
  10805. */
  10806. static Zero(): Ray;
  10807. /**
  10808. * Creates a new ray from screen space and viewport
  10809. * @param x position
  10810. * @param y y position
  10811. * @param viewportWidth viewport width
  10812. * @param viewportHeight viewport height
  10813. * @param world world matrix
  10814. * @param view view matrix
  10815. * @param projection projection matrix
  10816. * @returns new ray
  10817. */
  10818. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10819. /**
  10820. * 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
  10821. * transformed to the given world matrix.
  10822. * @param origin The origin point
  10823. * @param end The end point
  10824. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10825. * @returns the new ray
  10826. */
  10827. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10828. /**
  10829. * Transforms a ray by a matrix
  10830. * @param ray ray to transform
  10831. * @param matrix matrix to apply
  10832. * @returns the resulting new ray
  10833. */
  10834. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10835. /**
  10836. * Transforms a ray by a matrix
  10837. * @param ray ray to transform
  10838. * @param matrix matrix to apply
  10839. * @param result ray to store result in
  10840. */
  10841. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10842. /**
  10843. * Unproject a ray from screen space to object space
  10844. * @param sourceX defines the screen space x coordinate to use
  10845. * @param sourceY defines the screen space y coordinate to use
  10846. * @param viewportWidth defines the current width of the viewport
  10847. * @param viewportHeight defines the current height of the viewport
  10848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10849. * @param view defines the view matrix to use
  10850. * @param projection defines the projection matrix to use
  10851. */
  10852. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10853. }
  10854. /**
  10855. * Type used to define predicate used to select faces when a mesh intersection is detected
  10856. */
  10857. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10858. module "babylonjs/scene" {
  10859. interface Scene {
  10860. /** @hidden */
  10861. _tempPickingRay: Nullable<Ray>;
  10862. /** @hidden */
  10863. _cachedRayForTransform: Ray;
  10864. /** @hidden */
  10865. _pickWithRayInverseMatrix: Matrix;
  10866. /** @hidden */
  10867. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10868. /** @hidden */
  10869. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10870. /** @hidden */
  10871. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10872. }
  10873. }
  10874. }
  10875. declare module "babylonjs/sceneComponent" {
  10876. import { Scene } from "babylonjs/scene";
  10877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10879. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10880. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10881. import { Nullable } from "babylonjs/types";
  10882. import { Camera } from "babylonjs/Cameras/camera";
  10883. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10884. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10885. import { AbstractScene } from "babylonjs/abstractScene";
  10886. import { Mesh } from "babylonjs/Meshes/mesh";
  10887. /**
  10888. * Groups all the scene component constants in one place to ease maintenance.
  10889. * @hidden
  10890. */
  10891. export class SceneComponentConstants {
  10892. static readonly NAME_EFFECTLAYER: string;
  10893. static readonly NAME_LAYER: string;
  10894. static readonly NAME_LENSFLARESYSTEM: string;
  10895. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10896. static readonly NAME_PARTICLESYSTEM: string;
  10897. static readonly NAME_GAMEPAD: string;
  10898. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10899. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10900. static readonly NAME_PREPASSRENDERER: string;
  10901. static readonly NAME_DEPTHRENDERER: string;
  10902. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10903. static readonly NAME_SPRITE: string;
  10904. static readonly NAME_SUBSURFACE: string;
  10905. static readonly NAME_OUTLINERENDERER: string;
  10906. static readonly NAME_PROCEDURALTEXTURE: string;
  10907. static readonly NAME_SHADOWGENERATOR: string;
  10908. static readonly NAME_OCTREE: string;
  10909. static readonly NAME_PHYSICSENGINE: string;
  10910. static readonly NAME_AUDIO: string;
  10911. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10912. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10913. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10914. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10915. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10916. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10917. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10918. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10919. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10920. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10921. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10922. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10923. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10924. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10925. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10926. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10927. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10928. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10929. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10930. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10931. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10932. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10933. static readonly STEP_AFTERRENDER_AUDIO: number;
  10934. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10935. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10936. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10937. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10938. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10939. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10940. static readonly STEP_POINTERMOVE_SPRITE: number;
  10941. static readonly STEP_POINTERDOWN_SPRITE: number;
  10942. static readonly STEP_POINTERUP_SPRITE: number;
  10943. }
  10944. /**
  10945. * This represents a scene component.
  10946. *
  10947. * This is used to decouple the dependency the scene is having on the different workloads like
  10948. * layers, post processes...
  10949. */
  10950. export interface ISceneComponent {
  10951. /**
  10952. * The name of the component. Each component must have a unique name.
  10953. */
  10954. name: string;
  10955. /**
  10956. * The scene the component belongs to.
  10957. */
  10958. scene: Scene;
  10959. /**
  10960. * Register the component to one instance of a scene.
  10961. */
  10962. register(): void;
  10963. /**
  10964. * Rebuilds the elements related to this component in case of
  10965. * context lost for instance.
  10966. */
  10967. rebuild(): void;
  10968. /**
  10969. * Disposes the component and the associated ressources.
  10970. */
  10971. dispose(): void;
  10972. }
  10973. /**
  10974. * This represents a SERIALIZABLE scene component.
  10975. *
  10976. * This extends Scene Component to add Serialization methods on top.
  10977. */
  10978. export interface ISceneSerializableComponent extends ISceneComponent {
  10979. /**
  10980. * Adds all the elements from the container to the scene
  10981. * @param container the container holding the elements
  10982. */
  10983. addFromContainer(container: AbstractScene): void;
  10984. /**
  10985. * Removes all the elements in the container from the scene
  10986. * @param container contains the elements to remove
  10987. * @param dispose if the removed element should be disposed (default: false)
  10988. */
  10989. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10990. /**
  10991. * Serializes the component data to the specified json object
  10992. * @param serializationObject The object to serialize to
  10993. */
  10994. serialize(serializationObject: any): void;
  10995. }
  10996. /**
  10997. * Strong typing of a Mesh related stage step action
  10998. */
  10999. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11000. /**
  11001. * Strong typing of a Evaluate Sub Mesh related stage step action
  11002. */
  11003. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11004. /**
  11005. * Strong typing of a Active Mesh related stage step action
  11006. */
  11007. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11008. /**
  11009. * Strong typing of a Camera related stage step action
  11010. */
  11011. export type CameraStageAction = (camera: Camera) => void;
  11012. /**
  11013. * Strong typing of a Camera Frame buffer related stage step action
  11014. */
  11015. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11016. /**
  11017. * Strong typing of a Render Target related stage step action
  11018. */
  11019. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11020. /**
  11021. * Strong typing of a RenderingGroup related stage step action
  11022. */
  11023. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11024. /**
  11025. * Strong typing of a Mesh Render related stage step action
  11026. */
  11027. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11028. /**
  11029. * Strong typing of a simple stage step action
  11030. */
  11031. export type SimpleStageAction = () => void;
  11032. /**
  11033. * Strong typing of a render target action.
  11034. */
  11035. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11036. /**
  11037. * Strong typing of a pointer move action.
  11038. */
  11039. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11040. /**
  11041. * Strong typing of a pointer up/down action.
  11042. */
  11043. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11044. /**
  11045. * Representation of a stage in the scene (Basically a list of ordered steps)
  11046. * @hidden
  11047. */
  11048. export class Stage<T extends Function> extends Array<{
  11049. index: number;
  11050. component: ISceneComponent;
  11051. action: T;
  11052. }> {
  11053. /**
  11054. * Hide ctor from the rest of the world.
  11055. * @param items The items to add.
  11056. */
  11057. private constructor();
  11058. /**
  11059. * Creates a new Stage.
  11060. * @returns A new instance of a Stage
  11061. */
  11062. static Create<T extends Function>(): Stage<T>;
  11063. /**
  11064. * Registers a step in an ordered way in the targeted stage.
  11065. * @param index Defines the position to register the step in
  11066. * @param component Defines the component attached to the step
  11067. * @param action Defines the action to launch during the step
  11068. */
  11069. registerStep(index: number, component: ISceneComponent, action: T): void;
  11070. /**
  11071. * Clears all the steps from the stage.
  11072. */
  11073. clear(): void;
  11074. }
  11075. }
  11076. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11077. import { Nullable } from "babylonjs/types";
  11078. import { Observable } from "babylonjs/Misc/observable";
  11079. import { Scene } from "babylonjs/scene";
  11080. import { Sprite } from "babylonjs/Sprites/sprite";
  11081. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11082. import { Ray } from "babylonjs/Culling/ray";
  11083. import { Camera } from "babylonjs/Cameras/camera";
  11084. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11085. import { ISceneComponent } from "babylonjs/sceneComponent";
  11086. module "babylonjs/scene" {
  11087. interface Scene {
  11088. /** @hidden */
  11089. _pointerOverSprite: Nullable<Sprite>;
  11090. /** @hidden */
  11091. _pickedDownSprite: Nullable<Sprite>;
  11092. /** @hidden */
  11093. _tempSpritePickingRay: Nullable<Ray>;
  11094. /**
  11095. * All of the sprite managers added to this scene
  11096. * @see https://doc.babylonjs.com/babylon101/sprites
  11097. */
  11098. spriteManagers: Array<ISpriteManager>;
  11099. /**
  11100. * An event triggered when sprites rendering is about to start
  11101. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11102. */
  11103. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11104. /**
  11105. * An event triggered when sprites rendering is done
  11106. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11107. */
  11108. onAfterSpritesRenderingObservable: Observable<Scene>;
  11109. /** @hidden */
  11110. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11111. /** Launch a ray to try to pick a sprite in the scene
  11112. * @param x position on screen
  11113. * @param y position on screen
  11114. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11115. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11116. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11117. * @returns a PickingInfo
  11118. */
  11119. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11120. /** Use the given ray to pick a sprite in the scene
  11121. * @param ray The ray (in world space) to use to pick meshes
  11122. * @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
  11123. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11124. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11125. * @returns a PickingInfo
  11126. */
  11127. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11128. /** @hidden */
  11129. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11130. /** Launch a ray to try to pick sprites in the scene
  11131. * @param x position on screen
  11132. * @param y position on screen
  11133. * @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
  11134. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11135. * @returns a PickingInfo array
  11136. */
  11137. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11138. /** Use the given ray to pick sprites in the scene
  11139. * @param ray The ray (in world space) to use to pick meshes
  11140. * @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
  11141. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11142. * @returns a PickingInfo array
  11143. */
  11144. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11145. /**
  11146. * Force the sprite under the pointer
  11147. * @param sprite defines the sprite to use
  11148. */
  11149. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11150. /**
  11151. * Gets the sprite under the pointer
  11152. * @returns a Sprite or null if no sprite is under the pointer
  11153. */
  11154. getPointerOverSprite(): Nullable<Sprite>;
  11155. }
  11156. }
  11157. /**
  11158. * Defines the sprite scene component responsible to manage sprites
  11159. * in a given scene.
  11160. */
  11161. export class SpriteSceneComponent implements ISceneComponent {
  11162. /**
  11163. * The component name helpfull to identify the component in the list of scene components.
  11164. */
  11165. readonly name: string;
  11166. /**
  11167. * The scene the component belongs to.
  11168. */
  11169. scene: Scene;
  11170. /** @hidden */
  11171. private _spritePredicate;
  11172. /**
  11173. * Creates a new instance of the component for the given scene
  11174. * @param scene Defines the scene to register the component in
  11175. */
  11176. constructor(scene: Scene);
  11177. /**
  11178. * Registers the component in a given scene
  11179. */
  11180. register(): void;
  11181. /**
  11182. * Rebuilds the elements related to this component in case of
  11183. * context lost for instance.
  11184. */
  11185. rebuild(): void;
  11186. /**
  11187. * Disposes the component and the associated ressources.
  11188. */
  11189. dispose(): void;
  11190. private _pickSpriteButKeepRay;
  11191. private _pointerMove;
  11192. private _pointerDown;
  11193. private _pointerUp;
  11194. }
  11195. }
  11196. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11197. /** @hidden */
  11198. export var fogFragmentDeclaration: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11204. /** @hidden */
  11205. export var fogFragment: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11211. /** @hidden */
  11212. export var imageProcessingCompatibility: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module "babylonjs/Shaders/sprites.fragment" {
  11218. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11219. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11220. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11221. /** @hidden */
  11222. export var spritesPixelShader: {
  11223. name: string;
  11224. shader: string;
  11225. };
  11226. }
  11227. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11228. /** @hidden */
  11229. export var fogVertexDeclaration: {
  11230. name: string;
  11231. shader: string;
  11232. };
  11233. }
  11234. declare module "babylonjs/Shaders/sprites.vertex" {
  11235. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11236. /** @hidden */
  11237. export var spritesVertexShader: {
  11238. name: string;
  11239. shader: string;
  11240. };
  11241. }
  11242. declare module "babylonjs/Sprites/spriteManager" {
  11243. import { IDisposable, Scene } from "babylonjs/scene";
  11244. import { Nullable } from "babylonjs/types";
  11245. import { Observable } from "babylonjs/Misc/observable";
  11246. import { Sprite } from "babylonjs/Sprites/sprite";
  11247. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11248. import { Camera } from "babylonjs/Cameras/camera";
  11249. import { Texture } from "babylonjs/Materials/Textures/texture";
  11250. import "babylonjs/Shaders/sprites.fragment";
  11251. import "babylonjs/Shaders/sprites.vertex";
  11252. import { Ray } from "babylonjs/Culling/ray";
  11253. /**
  11254. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11255. */
  11256. export interface ISpriteManager extends IDisposable {
  11257. /**
  11258. * Gets manager's name
  11259. */
  11260. name: string;
  11261. /**
  11262. * Restricts the camera to viewing objects with the same layerMask.
  11263. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11264. */
  11265. layerMask: number;
  11266. /**
  11267. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11268. */
  11269. isPickable: boolean;
  11270. /**
  11271. * Gets the hosting scene
  11272. */
  11273. scene: Scene;
  11274. /**
  11275. * Specifies the rendering group id for this mesh (0 by default)
  11276. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11277. */
  11278. renderingGroupId: number;
  11279. /**
  11280. * Defines the list of sprites managed by the manager.
  11281. */
  11282. sprites: Array<Sprite>;
  11283. /**
  11284. * Gets or sets the spritesheet texture
  11285. */
  11286. texture: Texture;
  11287. /** Defines the default width of a cell in the spritesheet */
  11288. cellWidth: number;
  11289. /** Defines the default height of a cell in the spritesheet */
  11290. cellHeight: number;
  11291. /**
  11292. * Tests the intersection of a sprite with a specific ray.
  11293. * @param ray The ray we are sending to test the collision
  11294. * @param camera The camera space we are sending rays in
  11295. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11296. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11297. * @returns picking info or null.
  11298. */
  11299. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11300. /**
  11301. * Intersects the sprites with a ray
  11302. * @param ray defines the ray to intersect with
  11303. * @param camera defines the current active camera
  11304. * @param predicate defines a predicate used to select candidate sprites
  11305. * @returns null if no hit or a PickingInfo array
  11306. */
  11307. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11308. /**
  11309. * Renders the list of sprites on screen.
  11310. */
  11311. render(): void;
  11312. }
  11313. /**
  11314. * Class used to manage multiple sprites on the same spritesheet
  11315. * @see https://doc.babylonjs.com/babylon101/sprites
  11316. */
  11317. export class SpriteManager implements ISpriteManager {
  11318. /** defines the manager's name */
  11319. name: string;
  11320. /** Define the Url to load snippets */
  11321. static SnippetUrl: string;
  11322. /** Snippet ID if the manager was created from the snippet server */
  11323. snippetId: string;
  11324. /** Gets the list of sprites */
  11325. sprites: Sprite[];
  11326. /** Gets or sets the rendering group id (0 by default) */
  11327. renderingGroupId: number;
  11328. /** Gets or sets camera layer mask */
  11329. layerMask: number;
  11330. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11331. fogEnabled: boolean;
  11332. /** Gets or sets a boolean indicating if the sprites are pickable */
  11333. isPickable: boolean;
  11334. /** Defines the default width of a cell in the spritesheet */
  11335. cellWidth: number;
  11336. /** Defines the default height of a cell in the spritesheet */
  11337. cellHeight: number;
  11338. /** Associative array from JSON sprite data file */
  11339. private _cellData;
  11340. /** Array of sprite names from JSON sprite data file */
  11341. private _spriteMap;
  11342. /** True when packed cell data from JSON file is ready*/
  11343. private _packedAndReady;
  11344. private _textureContent;
  11345. private _useInstancing;
  11346. /**
  11347. * An event triggered when the manager is disposed.
  11348. */
  11349. onDisposeObservable: Observable<SpriteManager>;
  11350. private _onDisposeObserver;
  11351. /**
  11352. * Callback called when the manager is disposed
  11353. */
  11354. set onDispose(callback: () => void);
  11355. private _capacity;
  11356. private _fromPacked;
  11357. private _spriteTexture;
  11358. private _epsilon;
  11359. private _scene;
  11360. private _vertexData;
  11361. private _buffer;
  11362. private _vertexBuffers;
  11363. private _spriteBuffer;
  11364. private _indexBuffer;
  11365. private _effectBase;
  11366. private _effectFog;
  11367. private _vertexBufferSize;
  11368. /**
  11369. * Gets or sets the unique id of the sprite
  11370. */
  11371. uniqueId: number;
  11372. /**
  11373. * Gets the array of sprites
  11374. */
  11375. get children(): Sprite[];
  11376. /**
  11377. * Gets the hosting scene
  11378. */
  11379. get scene(): Scene;
  11380. /**
  11381. * Gets the capacity of the manager
  11382. */
  11383. get capacity(): number;
  11384. /**
  11385. * Gets or sets the spritesheet texture
  11386. */
  11387. get texture(): Texture;
  11388. set texture(value: Texture);
  11389. private _blendMode;
  11390. /**
  11391. * Blend mode use to render the particle, it can be any of
  11392. * the static Constants.ALPHA_x properties provided in this class.
  11393. * Default value is Constants.ALPHA_COMBINE
  11394. */
  11395. get blendMode(): number;
  11396. set blendMode(blendMode: number);
  11397. /** Disables writing to the depth buffer when rendering the sprites.
  11398. * It can be handy to disable depth writing when using textures without alpha channel
  11399. * and setting some specific blend modes.
  11400. */
  11401. disableDepthWrite: boolean;
  11402. /**
  11403. * Creates a new sprite manager
  11404. * @param name defines the manager's name
  11405. * @param imgUrl defines the sprite sheet url
  11406. * @param capacity defines the maximum allowed number of sprites
  11407. * @param cellSize defines the size of a sprite cell
  11408. * @param scene defines the hosting scene
  11409. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11410. * @param samplingMode defines the smapling mode to use with spritesheet
  11411. * @param fromPacked set to false; do not alter
  11412. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11413. */
  11414. constructor(
  11415. /** defines the manager's name */
  11416. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11417. /**
  11418. * Returns the string "SpriteManager"
  11419. * @returns "SpriteManager"
  11420. */
  11421. getClassName(): string;
  11422. private _makePacked;
  11423. private _appendSpriteVertex;
  11424. private _checkTextureAlpha;
  11425. /**
  11426. * Intersects the sprites with a ray
  11427. * @param ray defines the ray to intersect with
  11428. * @param camera defines the current active camera
  11429. * @param predicate defines a predicate used to select candidate sprites
  11430. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11431. * @returns null if no hit or a PickingInfo
  11432. */
  11433. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11434. /**
  11435. * Intersects the sprites with a ray
  11436. * @param ray defines the ray to intersect with
  11437. * @param camera defines the current active camera
  11438. * @param predicate defines a predicate used to select candidate sprites
  11439. * @returns null if no hit or a PickingInfo array
  11440. */
  11441. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Render all child sprites
  11444. */
  11445. render(): void;
  11446. /**
  11447. * Release associated resources
  11448. */
  11449. dispose(): void;
  11450. /**
  11451. * Serializes the sprite manager to a JSON object
  11452. * @param serializeTexture defines if the texture must be serialized as well
  11453. * @returns the JSON object
  11454. */
  11455. serialize(serializeTexture?: boolean): any;
  11456. /**
  11457. * Parses a JSON object to create a new sprite manager.
  11458. * @param parsedManager The JSON object to parse
  11459. * @param scene The scene to create the sprite managerin
  11460. * @param rootUrl The root url to use to load external dependencies like texture
  11461. * @returns the new sprite manager
  11462. */
  11463. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11464. /**
  11465. * Creates a sprite manager from a snippet saved in a remote file
  11466. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11467. * @param url defines the url to load from
  11468. * @param scene defines the hosting scene
  11469. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11470. * @returns a promise that will resolve to the new sprite manager
  11471. */
  11472. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11473. /**
  11474. * Creates a sprite manager from a snippet saved by the sprite editor
  11475. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11476. * @param scene defines the hosting scene
  11477. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11478. * @returns a promise that will resolve to the new sprite manager
  11479. */
  11480. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11481. }
  11482. }
  11483. declare module "babylonjs/Misc/gradients" {
  11484. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11485. /** Interface used by value gradients (color, factor, ...) */
  11486. export interface IValueGradient {
  11487. /**
  11488. * Gets or sets the gradient value (between 0 and 1)
  11489. */
  11490. gradient: number;
  11491. }
  11492. /** Class used to store color4 gradient */
  11493. export class ColorGradient implements IValueGradient {
  11494. /**
  11495. * Gets or sets the gradient value (between 0 and 1)
  11496. */
  11497. gradient: number;
  11498. /**
  11499. * Gets or sets first associated color
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Gets or sets second associated color
  11504. */
  11505. color2?: Color4 | undefined;
  11506. /**
  11507. * Creates a new color4 gradient
  11508. * @param gradient gets or sets the gradient value (between 0 and 1)
  11509. * @param color1 gets or sets first associated color
  11510. * @param color2 gets or sets first second color
  11511. */
  11512. constructor(
  11513. /**
  11514. * Gets or sets the gradient value (between 0 and 1)
  11515. */
  11516. gradient: number,
  11517. /**
  11518. * Gets or sets first associated color
  11519. */
  11520. color1: Color4,
  11521. /**
  11522. * Gets or sets second associated color
  11523. */
  11524. color2?: Color4 | undefined);
  11525. /**
  11526. * Will get a color picked randomly between color1 and color2.
  11527. * If color2 is undefined then color1 will be used
  11528. * @param result defines the target Color4 to store the result in
  11529. */
  11530. getColorToRef(result: Color4): void;
  11531. }
  11532. /** Class used to store color 3 gradient */
  11533. export class Color3Gradient implements IValueGradient {
  11534. /**
  11535. * Gets or sets the gradient value (between 0 and 1)
  11536. */
  11537. gradient: number;
  11538. /**
  11539. * Gets or sets the associated color
  11540. */
  11541. color: Color3;
  11542. /**
  11543. * Creates a new color3 gradient
  11544. * @param gradient gets or sets the gradient value (between 0 and 1)
  11545. * @param color gets or sets associated color
  11546. */
  11547. constructor(
  11548. /**
  11549. * Gets or sets the gradient value (between 0 and 1)
  11550. */
  11551. gradient: number,
  11552. /**
  11553. * Gets or sets the associated color
  11554. */
  11555. color: Color3);
  11556. }
  11557. /** Class used to store factor gradient */
  11558. export class FactorGradient implements IValueGradient {
  11559. /**
  11560. * Gets or sets the gradient value (between 0 and 1)
  11561. */
  11562. gradient: number;
  11563. /**
  11564. * Gets or sets first associated factor
  11565. */
  11566. factor1: number;
  11567. /**
  11568. * Gets or sets second associated factor
  11569. */
  11570. factor2?: number | undefined;
  11571. /**
  11572. * Creates a new factor gradient
  11573. * @param gradient gets or sets the gradient value (between 0 and 1)
  11574. * @param factor1 gets or sets first associated factor
  11575. * @param factor2 gets or sets second associated factor
  11576. */
  11577. constructor(
  11578. /**
  11579. * Gets or sets the gradient value (between 0 and 1)
  11580. */
  11581. gradient: number,
  11582. /**
  11583. * Gets or sets first associated factor
  11584. */
  11585. factor1: number,
  11586. /**
  11587. * Gets or sets second associated factor
  11588. */
  11589. factor2?: number | undefined);
  11590. /**
  11591. * Will get a number picked randomly between factor1 and factor2.
  11592. * If factor2 is undefined then factor1 will be used
  11593. * @returns the picked number
  11594. */
  11595. getFactor(): number;
  11596. }
  11597. /**
  11598. * Helper used to simplify some generic gradient tasks
  11599. */
  11600. export class GradientHelper {
  11601. /**
  11602. * Gets the current gradient from an array of IValueGradient
  11603. * @param ratio defines the current ratio to get
  11604. * @param gradients defines the array of IValueGradient
  11605. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11606. */
  11607. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11608. }
  11609. }
  11610. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11611. import { Nullable } from "babylonjs/types";
  11612. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11613. import { Scene } from "babylonjs/scene";
  11614. module "babylonjs/Engines/thinEngine" {
  11615. interface ThinEngine {
  11616. /**
  11617. * Creates a raw texture
  11618. * @param data defines the data to store in the texture
  11619. * @param width defines the width of the texture
  11620. * @param height defines the height of the texture
  11621. * @param format defines the format of the data
  11622. * @param generateMipMaps defines if the engine should generate the mip levels
  11623. * @param invertY defines if data must be stored with Y axis inverted
  11624. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11625. * @param compression defines the compression used (null by default)
  11626. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11627. * @returns the raw texture inside an InternalTexture
  11628. */
  11629. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11630. /**
  11631. * Update a raw texture
  11632. * @param texture defines the texture to update
  11633. * @param data defines the data to store in the texture
  11634. * @param format defines the format of the data
  11635. * @param invertY defines if data must be stored with Y axis inverted
  11636. */
  11637. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11638. /**
  11639. * Update a raw texture
  11640. * @param texture defines the texture to update
  11641. * @param data defines the data to store in the texture
  11642. * @param format defines the format of the data
  11643. * @param invertY defines if data must be stored with Y axis inverted
  11644. * @param compression defines the compression used (null by default)
  11645. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11646. */
  11647. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11648. /**
  11649. * Creates a new raw cube texture
  11650. * @param data defines the array of data to use to create each face
  11651. * @param size defines the size of the textures
  11652. * @param format defines the format of the data
  11653. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11654. * @param generateMipMaps defines if the engine should generate the mip levels
  11655. * @param invertY defines if data must be stored with Y axis inverted
  11656. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11657. * @param compression defines the compression used (null by default)
  11658. * @returns the cube texture as an InternalTexture
  11659. */
  11660. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11661. /**
  11662. * Update a raw cube texture
  11663. * @param texture defines the texture to udpdate
  11664. * @param data defines the data to store
  11665. * @param format defines the data format
  11666. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11667. * @param invertY defines if data must be stored with Y axis inverted
  11668. */
  11669. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11670. /**
  11671. * Update a raw cube texture
  11672. * @param texture defines the texture to udpdate
  11673. * @param data defines the data to store
  11674. * @param format defines the data format
  11675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the compression used (null by default)
  11678. */
  11679. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11680. /**
  11681. * Update a raw cube texture
  11682. * @param texture defines the texture to udpdate
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11686. * @param invertY defines if data must be stored with Y axis inverted
  11687. * @param compression defines the compression used (null by default)
  11688. * @param level defines which level of the texture to update
  11689. */
  11690. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11691. /**
  11692. * Creates a new raw cube texture from a specified url
  11693. * @param url defines the url where the data is located
  11694. * @param scene defines the current scene
  11695. * @param size defines the size of the textures
  11696. * @param format defines the format of the data
  11697. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11698. * @param noMipmap defines if the engine should avoid generating the mip levels
  11699. * @param callback defines a callback used to extract texture data from loaded data
  11700. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11701. * @param onLoad defines a callback called when texture is loaded
  11702. * @param onError defines a callback called if there is an error
  11703. * @returns the cube texture as an InternalTexture
  11704. */
  11705. 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;
  11706. /**
  11707. * Creates a new raw cube texture from a specified url
  11708. * @param url defines the url where the data is located
  11709. * @param scene defines the current scene
  11710. * @param size defines the size of the textures
  11711. * @param format defines the format of the data
  11712. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11713. * @param noMipmap defines if the engine should avoid generating the mip levels
  11714. * @param callback defines a callback used to extract texture data from loaded data
  11715. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11716. * @param onLoad defines a callback called when texture is loaded
  11717. * @param onError defines a callback called if there is an error
  11718. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. * @returns the cube texture as an InternalTexture
  11721. */
  11722. 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;
  11723. /**
  11724. * Creates a new raw 3D texture
  11725. * @param data defines the data used to create the texture
  11726. * @param width defines the width of the texture
  11727. * @param height defines the height of the texture
  11728. * @param depth defines the depth of the texture
  11729. * @param format defines the format of the texture
  11730. * @param generateMipMaps defines if the engine must generate mip levels
  11731. * @param invertY defines if data must be stored with Y axis inverted
  11732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11733. * @param compression defines the compressed used (can be null)
  11734. * @param textureType defines the compressed used (can be null)
  11735. * @returns a new raw 3D texture (stored in an InternalTexture)
  11736. */
  11737. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11738. /**
  11739. * Update a raw 3D texture
  11740. * @param texture defines the texture to update
  11741. * @param data defines the data to store
  11742. * @param format defines the data format
  11743. * @param invertY defines if data must be stored with Y axis inverted
  11744. */
  11745. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11746. /**
  11747. * Update a raw 3D texture
  11748. * @param texture defines the texture to update
  11749. * @param data defines the data to store
  11750. * @param format defines the data format
  11751. * @param invertY defines if data must be stored with Y axis inverted
  11752. * @param compression defines the used compression (can be null)
  11753. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11754. */
  11755. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11756. /**
  11757. * Creates a new raw 2D array texture
  11758. * @param data defines the data used to create the texture
  11759. * @param width defines the width of the texture
  11760. * @param height defines the height of the texture
  11761. * @param depth defines the number of layers of the texture
  11762. * @param format defines the format of the texture
  11763. * @param generateMipMaps defines if the engine must generate mip levels
  11764. * @param invertY defines if data must be stored with Y axis inverted
  11765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11766. * @param compression defines the compressed used (can be null)
  11767. * @param textureType defines the compressed used (can be null)
  11768. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11769. */
  11770. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11771. /**
  11772. * Update a raw 2D array texture
  11773. * @param texture defines the texture to update
  11774. * @param data defines the data to store
  11775. * @param format defines the data format
  11776. * @param invertY defines if data must be stored with Y axis inverted
  11777. */
  11778. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11779. /**
  11780. * Update a raw 2D array texture
  11781. * @param texture defines the texture to update
  11782. * @param data defines the data to store
  11783. * @param format defines the data format
  11784. * @param invertY defines if data must be stored with Y axis inverted
  11785. * @param compression defines the used compression (can be null)
  11786. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11787. */
  11788. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11789. }
  11790. }
  11791. }
  11792. declare module "babylonjs/Materials/Textures/rawTexture" {
  11793. import { Texture } from "babylonjs/Materials/Textures/texture";
  11794. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11795. import { Nullable } from "babylonjs/types";
  11796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11797. import { Scene } from "babylonjs/scene";
  11798. /**
  11799. * Raw texture can help creating a texture directly from an array of data.
  11800. * This can be super useful if you either get the data from an uncompressed source or
  11801. * if you wish to create your texture pixel by pixel.
  11802. */
  11803. export class RawTexture extends Texture {
  11804. /**
  11805. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11806. */
  11807. format: number;
  11808. /**
  11809. * Instantiates a new RawTexture.
  11810. * Raw texture can help creating a texture directly from an array of data.
  11811. * This can be super useful if you either get the data from an uncompressed source or
  11812. * if you wish to create your texture pixel by pixel.
  11813. * @param data define the array of data to use to create the texture
  11814. * @param width define the width of the texture
  11815. * @param height define the height of the texture
  11816. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11817. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11818. * @param generateMipMaps define whether mip maps should be generated or not
  11819. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11820. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11821. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11822. */
  11823. constructor(data: ArrayBufferView, width: number, height: number,
  11824. /**
  11825. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11826. */
  11827. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11828. /**
  11829. * Updates the texture underlying data.
  11830. * @param data Define the new data of the texture
  11831. */
  11832. update(data: ArrayBufferView): void;
  11833. /**
  11834. * Creates a luminance 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 luminance texture
  11843. */
  11844. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11845. /**
  11846. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  11855. */
  11856. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11857. /**
  11858. * Creates an alpha texture from some data.
  11859. * @param data Define the texture data
  11860. * @param width Define the width of the texture
  11861. * @param height Define the height of the texture
  11862. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11863. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11864. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11865. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11866. * @returns the alpha texture
  11867. */
  11868. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11869. /**
  11870. * Creates a RGB texture from some data.
  11871. * @param data Define the texture data
  11872. * @param width Define the width of the texture
  11873. * @param height Define the height of the texture
  11874. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11879. * @returns the RGB alpha texture
  11880. */
  11881. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11882. /**
  11883. * Creates a RGBA texture from some data.
  11884. * @param data Define the texture data
  11885. * @param width Define the width of the texture
  11886. * @param height Define the height of the texture
  11887. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11892. * @returns the RGBA texture
  11893. */
  11894. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11895. /**
  11896. * Creates a R texture from some data.
  11897. * @param data Define the texture data
  11898. * @param width Define the width of the texture
  11899. * @param height Define the height of the texture
  11900. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11905. * @returns the R texture
  11906. */
  11907. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11908. }
  11909. }
  11910. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11911. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11912. import { IndicesArray, DataArray } from "babylonjs/types";
  11913. module "babylonjs/Engines/thinEngine" {
  11914. interface ThinEngine {
  11915. /**
  11916. * Update a dynamic index buffer
  11917. * @param indexBuffer defines the target index buffer
  11918. * @param indices defines the data to update
  11919. * @param offset defines the offset in the target index buffer where update should start
  11920. */
  11921. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11922. /**
  11923. * Updates a dynamic vertex buffer.
  11924. * @param vertexBuffer the vertex buffer to update
  11925. * @param data the data used to update the vertex buffer
  11926. * @param byteOffset the byte offset of the data
  11927. * @param byteLength the byte length of the data
  11928. */
  11929. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11930. }
  11931. }
  11932. }
  11933. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11934. import { Scene } from "babylonjs/scene";
  11935. import { ISceneComponent } from "babylonjs/sceneComponent";
  11936. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11937. module "babylonjs/abstractScene" {
  11938. interface AbstractScene {
  11939. /**
  11940. * The list of procedural textures added to the scene
  11941. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11942. */
  11943. proceduralTextures: Array<ProceduralTexture>;
  11944. }
  11945. }
  11946. /**
  11947. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11948. * in a given scene.
  11949. */
  11950. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11951. /**
  11952. * The component name helpfull to identify the component in the list of scene components.
  11953. */
  11954. readonly name: string;
  11955. /**
  11956. * The scene the component belongs to.
  11957. */
  11958. scene: Scene;
  11959. /**
  11960. * Creates a new instance of the component for the given scene
  11961. * @param scene Defines the scene to register the component in
  11962. */
  11963. constructor(scene: Scene);
  11964. /**
  11965. * Registers the component in a given scene
  11966. */
  11967. register(): void;
  11968. /**
  11969. * Rebuilds the elements related to this component in case of
  11970. * context lost for instance.
  11971. */
  11972. rebuild(): void;
  11973. /**
  11974. * Disposes the component and the associated ressources.
  11975. */
  11976. dispose(): void;
  11977. private _beforeClear;
  11978. }
  11979. }
  11980. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11981. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11982. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11983. module "babylonjs/Engines/thinEngine" {
  11984. interface ThinEngine {
  11985. /**
  11986. * Creates a new render target cube texture
  11987. * @param size defines the size of the texture
  11988. * @param options defines the options used to create the texture
  11989. * @returns a new render target cube texture stored in an InternalTexture
  11990. */
  11991. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11992. }
  11993. }
  11994. }
  11995. declare module "babylonjs/Shaders/procedural.vertex" {
  11996. /** @hidden */
  11997. export var proceduralVertexShader: {
  11998. name: string;
  11999. shader: string;
  12000. };
  12001. }
  12002. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12003. import { Observable } from "babylonjs/Misc/observable";
  12004. import { Nullable } from "babylonjs/types";
  12005. import { Scene } from "babylonjs/scene";
  12006. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12007. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12008. import { Effect } from "babylonjs/Materials/effect";
  12009. import { Texture } from "babylonjs/Materials/Textures/texture";
  12010. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12011. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12012. import "babylonjs/Shaders/procedural.vertex";
  12013. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12014. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12015. /**
  12016. * 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.
  12017. * This is the base class of any Procedural texture and contains most of the shareable code.
  12018. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12019. */
  12020. export class ProceduralTexture extends Texture {
  12021. /**
  12022. * Define if the texture is enabled or not (disabled texture will not render)
  12023. */
  12024. isEnabled: boolean;
  12025. /**
  12026. * Define if the texture must be cleared before rendering (default is true)
  12027. */
  12028. autoClear: boolean;
  12029. /**
  12030. * Callback called when the texture is generated
  12031. */
  12032. onGenerated: () => void;
  12033. /**
  12034. * Event raised when the texture is generated
  12035. */
  12036. onGeneratedObservable: Observable<ProceduralTexture>;
  12037. /**
  12038. * Event raised before the texture is generated
  12039. */
  12040. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12041. /**
  12042. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12043. */
  12044. nodeMaterialSource: Nullable<NodeMaterial>;
  12045. /** @hidden */
  12046. _generateMipMaps: boolean;
  12047. /** @hidden **/
  12048. _effect: Effect;
  12049. /** @hidden */
  12050. _textures: {
  12051. [key: string]: Texture;
  12052. };
  12053. /** @hidden */
  12054. protected _fallbackTexture: Nullable<Texture>;
  12055. private _size;
  12056. private _currentRefreshId;
  12057. private _frameId;
  12058. private _refreshRate;
  12059. private _vertexBuffers;
  12060. private _indexBuffer;
  12061. private _uniforms;
  12062. private _samplers;
  12063. private _fragment;
  12064. private _floats;
  12065. private _ints;
  12066. private _floatsArrays;
  12067. private _colors3;
  12068. private _colors4;
  12069. private _vectors2;
  12070. private _vectors3;
  12071. private _matrices;
  12072. private _fallbackTextureUsed;
  12073. private _fullEngine;
  12074. private _cachedDefines;
  12075. private _contentUpdateId;
  12076. private _contentData;
  12077. /**
  12078. * Instantiates a new procedural texture.
  12079. * 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.
  12080. * This is the base class of any Procedural texture and contains most of the shareable code.
  12081. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12082. * @param name Define the name of the texture
  12083. * @param size Define the size of the texture to create
  12084. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12085. * @param scene Define the scene the texture belongs to
  12086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12087. * @param generateMipMaps Define if the texture should creates mip maps or not
  12088. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12089. * @param textureType The FBO internal texture type
  12090. */
  12091. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12092. /**
  12093. * The effect that is created when initializing the post process.
  12094. * @returns The created effect corresponding the the postprocess.
  12095. */
  12096. getEffect(): Effect;
  12097. /**
  12098. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12099. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12100. */
  12101. getContent(): Nullable<ArrayBufferView>;
  12102. private _createIndexBuffer;
  12103. /** @hidden */
  12104. _rebuild(): void;
  12105. /**
  12106. * Resets the texture in order to recreate its associated resources.
  12107. * This can be called in case of context loss
  12108. */
  12109. reset(): void;
  12110. protected _getDefines(): string;
  12111. /**
  12112. * Is the texture ready to be used ? (rendered at least once)
  12113. * @returns true if ready, otherwise, false.
  12114. */
  12115. isReady(): boolean;
  12116. /**
  12117. * Resets the refresh counter of the texture and start bak from scratch.
  12118. * Could be useful to regenerate the texture if it is setup to render only once.
  12119. */
  12120. resetRefreshCounter(): void;
  12121. /**
  12122. * Set the fragment shader to use in order to render the texture.
  12123. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12124. */
  12125. setFragment(fragment: any): void;
  12126. /**
  12127. * Define the refresh rate of the texture or the rendering frequency.
  12128. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12129. */
  12130. get refreshRate(): number;
  12131. set refreshRate(value: number);
  12132. /** @hidden */
  12133. _shouldRender(): boolean;
  12134. /**
  12135. * Get the size the texture is rendering at.
  12136. * @returns the size (on cube texture it is always squared)
  12137. */
  12138. getRenderSize(): RenderTargetTextureSize;
  12139. /**
  12140. * Resize the texture to new value.
  12141. * @param size Define the new size the texture should have
  12142. * @param generateMipMaps Define whether the new texture should create mip maps
  12143. */
  12144. resize(size: number, generateMipMaps: boolean): void;
  12145. private _checkUniform;
  12146. /**
  12147. * Set a texture in the shader program used to render.
  12148. * @param name Define the name of the uniform samplers as defined in the shader
  12149. * @param texture Define the texture to bind to this sampler
  12150. * @return the texture itself allowing "fluent" like uniform updates
  12151. */
  12152. setTexture(name: string, texture: Texture): ProceduralTexture;
  12153. /**
  12154. * Set a float in the shader.
  12155. * @param name Define the name of the uniform as defined in the shader
  12156. * @param value Define the value to give to the uniform
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setFloat(name: string, value: number): ProceduralTexture;
  12160. /**
  12161. * Set a int in the shader.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setInt(name: string, value: number): ProceduralTexture;
  12167. /**
  12168. * Set an array of floats in the shader.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setFloats(name: string, value: number[]): ProceduralTexture;
  12174. /**
  12175. * Set a vec3 in the shader from a Color3.
  12176. * @param name Define the name of the uniform as defined in the shader
  12177. * @param value Define the value to give to the uniform
  12178. * @return the texture itself allowing "fluent" like uniform updates
  12179. */
  12180. setColor3(name: string, value: Color3): ProceduralTexture;
  12181. /**
  12182. * Set a vec4 in the shader from a Color4.
  12183. * @param name Define the name of the uniform as defined in the shader
  12184. * @param value Define the value to give to the uniform
  12185. * @return the texture itself allowing "fluent" like uniform updates
  12186. */
  12187. setColor4(name: string, value: Color4): ProceduralTexture;
  12188. /**
  12189. * Set a vec2 in the shader from a Vector2.
  12190. * @param name Define the name of the uniform as defined in the shader
  12191. * @param value Define the value to give to the uniform
  12192. * @return the texture itself allowing "fluent" like uniform updates
  12193. */
  12194. setVector2(name: string, value: Vector2): ProceduralTexture;
  12195. /**
  12196. * Set a vec3 in the shader from a Vector3.
  12197. * @param name Define the name of the uniform as defined in the shader
  12198. * @param value Define the value to give to the uniform
  12199. * @return the texture itself allowing "fluent" like uniform updates
  12200. */
  12201. setVector3(name: string, value: Vector3): ProceduralTexture;
  12202. /**
  12203. * Set a mat4 in the shader from a MAtrix.
  12204. * @param name Define the name of the uniform as defined in the shader
  12205. * @param value Define the value to give to the uniform
  12206. * @return the texture itself allowing "fluent" like uniform updates
  12207. */
  12208. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12209. /**
  12210. * Render the texture to its associated render target.
  12211. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12212. */
  12213. render(useCameraPostProcess?: boolean): void;
  12214. /**
  12215. * Clone the texture.
  12216. * @returns the cloned texture
  12217. */
  12218. clone(): ProceduralTexture;
  12219. /**
  12220. * Dispose the texture and release its asoociated resources.
  12221. */
  12222. dispose(): void;
  12223. }
  12224. }
  12225. declare module "babylonjs/Particles/baseParticleSystem" {
  12226. import { Nullable } from "babylonjs/types";
  12227. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12229. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12230. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12231. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12233. import { Color4 } from "babylonjs/Maths/math.color";
  12234. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12235. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12236. import { Animation } from "babylonjs/Animations/animation";
  12237. import { Scene } from "babylonjs/scene";
  12238. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12239. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12240. /**
  12241. * This represents the base class for particle system in Babylon.
  12242. * 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.
  12243. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12244. * @example https://doc.babylonjs.com/babylon101/particles
  12245. */
  12246. export class BaseParticleSystem {
  12247. /**
  12248. * Source color is added to the destination color without alpha affecting the result
  12249. */
  12250. static BLENDMODE_ONEONE: number;
  12251. /**
  12252. * Blend current color and particle color using particle’s alpha
  12253. */
  12254. static BLENDMODE_STANDARD: number;
  12255. /**
  12256. * Add current color and particle color multiplied by particle’s alpha
  12257. */
  12258. static BLENDMODE_ADD: number;
  12259. /**
  12260. * Multiply current color with particle color
  12261. */
  12262. static BLENDMODE_MULTIPLY: number;
  12263. /**
  12264. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12265. */
  12266. static BLENDMODE_MULTIPLYADD: number;
  12267. /**
  12268. * List of animations used by the particle system.
  12269. */
  12270. animations: Animation[];
  12271. /**
  12272. * Gets or sets the unique id of the particle system
  12273. */
  12274. uniqueId: number;
  12275. /**
  12276. * The id of the Particle system.
  12277. */
  12278. id: string;
  12279. /**
  12280. * The friendly name of the Particle system.
  12281. */
  12282. name: string;
  12283. /**
  12284. * Snippet ID if the particle system was created from the snippet server
  12285. */
  12286. snippetId: string;
  12287. /**
  12288. * The rendering group used by the Particle system to chose when to render.
  12289. */
  12290. renderingGroupId: number;
  12291. /**
  12292. * The emitter represents the Mesh or position we are attaching the particle system to.
  12293. */
  12294. emitter: Nullable<AbstractMesh | Vector3>;
  12295. /**
  12296. * The maximum number of particles to emit per frame
  12297. */
  12298. emitRate: number;
  12299. /**
  12300. * If you want to launch only a few particles at once, that can be done, as well.
  12301. */
  12302. manualEmitCount: number;
  12303. /**
  12304. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12305. */
  12306. updateSpeed: number;
  12307. /**
  12308. * The amount of time the particle system is running (depends of the overall update speed).
  12309. */
  12310. targetStopDuration: number;
  12311. /**
  12312. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12313. */
  12314. disposeOnStop: boolean;
  12315. /**
  12316. * Minimum power of emitting particles.
  12317. */
  12318. minEmitPower: number;
  12319. /**
  12320. * Maximum power of emitting particles.
  12321. */
  12322. maxEmitPower: number;
  12323. /**
  12324. * Minimum life time of emitting particles.
  12325. */
  12326. minLifeTime: number;
  12327. /**
  12328. * Maximum life time of emitting particles.
  12329. */
  12330. maxLifeTime: number;
  12331. /**
  12332. * Minimum Size of emitting particles.
  12333. */
  12334. minSize: number;
  12335. /**
  12336. * Maximum Size of emitting particles.
  12337. */
  12338. maxSize: number;
  12339. /**
  12340. * Minimum scale of emitting particles on X axis.
  12341. */
  12342. minScaleX: number;
  12343. /**
  12344. * Maximum scale of emitting particles on X axis.
  12345. */
  12346. maxScaleX: number;
  12347. /**
  12348. * Minimum scale of emitting particles on Y axis.
  12349. */
  12350. minScaleY: number;
  12351. /**
  12352. * Maximum scale of emitting particles on Y axis.
  12353. */
  12354. maxScaleY: number;
  12355. /**
  12356. * Gets or sets the minimal initial rotation in radians.
  12357. */
  12358. minInitialRotation: number;
  12359. /**
  12360. * Gets or sets the maximal initial rotation in radians.
  12361. */
  12362. maxInitialRotation: number;
  12363. /**
  12364. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12365. */
  12366. minAngularSpeed: number;
  12367. /**
  12368. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12369. */
  12370. maxAngularSpeed: number;
  12371. /**
  12372. * The texture used to render each particle. (this can be a spritesheet)
  12373. */
  12374. particleTexture: Nullable<BaseTexture>;
  12375. /**
  12376. * The layer mask we are rendering the particles through.
  12377. */
  12378. layerMask: number;
  12379. /**
  12380. * This can help using your own shader to render the particle system.
  12381. * The according effect will be created
  12382. */
  12383. customShader: any;
  12384. /**
  12385. * By default particle system starts as soon as they are created. This prevents the
  12386. * automatic start to happen and let you decide when to start emitting particles.
  12387. */
  12388. preventAutoStart: boolean;
  12389. private _noiseTexture;
  12390. /**
  12391. * Gets or sets a texture used to add random noise to particle positions
  12392. */
  12393. get noiseTexture(): Nullable<ProceduralTexture>;
  12394. set noiseTexture(value: Nullable<ProceduralTexture>);
  12395. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12396. noiseStrength: Vector3;
  12397. /**
  12398. * Callback triggered when the particle animation is ending.
  12399. */
  12400. onAnimationEnd: Nullable<() => void>;
  12401. /**
  12402. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12403. */
  12404. blendMode: number;
  12405. /**
  12406. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12407. * to override the particles.
  12408. */
  12409. forceDepthWrite: boolean;
  12410. /** 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 */
  12411. preWarmCycles: number;
  12412. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12413. preWarmStepOffset: number;
  12414. /**
  12415. * 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)
  12416. */
  12417. spriteCellChangeSpeed: number;
  12418. /**
  12419. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12420. */
  12421. startSpriteCellID: number;
  12422. /**
  12423. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12424. */
  12425. endSpriteCellID: number;
  12426. /**
  12427. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12428. */
  12429. spriteCellWidth: number;
  12430. /**
  12431. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12432. */
  12433. spriteCellHeight: number;
  12434. /**
  12435. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12436. */
  12437. spriteRandomStartCell: boolean;
  12438. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12439. translationPivot: Vector2;
  12440. /** @hidden */
  12441. protected _isAnimationSheetEnabled: boolean;
  12442. /**
  12443. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12444. */
  12445. beginAnimationOnStart: boolean;
  12446. /**
  12447. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12448. */
  12449. beginAnimationFrom: number;
  12450. /**
  12451. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12452. */
  12453. beginAnimationTo: number;
  12454. /**
  12455. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12456. */
  12457. beginAnimationLoop: boolean;
  12458. /**
  12459. * Gets or sets a world offset applied to all particles
  12460. */
  12461. worldOffset: Vector3;
  12462. /**
  12463. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12464. */
  12465. get isAnimationSheetEnabled(): boolean;
  12466. set isAnimationSheetEnabled(value: boolean);
  12467. /**
  12468. * Get hosting scene
  12469. * @returns the scene
  12470. */
  12471. getScene(): Nullable<Scene>;
  12472. /**
  12473. * You can use gravity if you want to give an orientation to your particles.
  12474. */
  12475. gravity: Vector3;
  12476. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12477. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12478. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12479. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12480. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12481. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12482. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12483. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12484. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12485. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12486. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12487. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12488. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12489. /**
  12490. * Defines the delay in milliseconds before starting the system (0 by default)
  12491. */
  12492. startDelay: number;
  12493. /**
  12494. * Gets the current list of drag gradients.
  12495. * You must use addDragGradient and removeDragGradient to udpate this list
  12496. * @returns the list of drag gradients
  12497. */
  12498. getDragGradients(): Nullable<Array<FactorGradient>>;
  12499. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12500. limitVelocityDamping: number;
  12501. /**
  12502. * Gets the current list of limit velocity gradients.
  12503. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12504. * @returns the list of limit velocity gradients
  12505. */
  12506. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12507. /**
  12508. * Gets the current list of color gradients.
  12509. * You must use addColorGradient and removeColorGradient to udpate this list
  12510. * @returns the list of color gradients
  12511. */
  12512. getColorGradients(): Nullable<Array<ColorGradient>>;
  12513. /**
  12514. * Gets the current list of size gradients.
  12515. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12516. * @returns the list of size gradients
  12517. */
  12518. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12519. /**
  12520. * Gets the current list of color remap gradients.
  12521. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12522. * @returns the list of color remap gradients
  12523. */
  12524. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12525. /**
  12526. * Gets the current list of alpha remap gradients.
  12527. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12528. * @returns the list of alpha remap gradients
  12529. */
  12530. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12531. /**
  12532. * Gets the current list of life time gradients.
  12533. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12534. * @returns the list of life time gradients
  12535. */
  12536. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12537. /**
  12538. * Gets the current list of angular speed gradients.
  12539. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12540. * @returns the list of angular speed gradients
  12541. */
  12542. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12543. /**
  12544. * Gets the current list of velocity gradients.
  12545. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12546. * @returns the list of velocity gradients
  12547. */
  12548. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12549. /**
  12550. * Gets the current list of start size gradients.
  12551. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12552. * @returns the list of start size gradients
  12553. */
  12554. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12555. /**
  12556. * Gets the current list of emit rate gradients.
  12557. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12558. * @returns the list of emit rate gradients
  12559. */
  12560. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12561. /**
  12562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12563. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12564. */
  12565. get direction1(): Vector3;
  12566. set direction1(value: Vector3);
  12567. /**
  12568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12569. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12570. */
  12571. get direction2(): Vector3;
  12572. set direction2(value: Vector3);
  12573. /**
  12574. * 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.
  12575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12576. */
  12577. get minEmitBox(): Vector3;
  12578. set minEmitBox(value: Vector3);
  12579. /**
  12580. * 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.
  12581. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12582. */
  12583. get maxEmitBox(): Vector3;
  12584. set maxEmitBox(value: Vector3);
  12585. /**
  12586. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12587. */
  12588. color1: Color4;
  12589. /**
  12590. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12591. */
  12592. color2: Color4;
  12593. /**
  12594. * Color the particle will have at the end of its lifetime
  12595. */
  12596. colorDead: Color4;
  12597. /**
  12598. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12599. */
  12600. textureMask: Color4;
  12601. /**
  12602. * The particle emitter type defines the emitter used by the particle system.
  12603. * It can be for example box, sphere, or cone...
  12604. */
  12605. particleEmitterType: IParticleEmitterType;
  12606. /** @hidden */
  12607. _isSubEmitter: boolean;
  12608. /**
  12609. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12610. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12611. */
  12612. billboardMode: number;
  12613. protected _isBillboardBased: boolean;
  12614. /**
  12615. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12616. */
  12617. get isBillboardBased(): boolean;
  12618. set isBillboardBased(value: boolean);
  12619. /**
  12620. * The scene the particle system belongs to.
  12621. */
  12622. protected _scene: Nullable<Scene>;
  12623. /**
  12624. * The engine the particle system belongs to.
  12625. */
  12626. protected _engine: ThinEngine;
  12627. /**
  12628. * Local cache of defines for image processing.
  12629. */
  12630. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12631. /**
  12632. * Default configuration related to image processing available in the standard Material.
  12633. */
  12634. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12635. /**
  12636. * Gets the image processing configuration used either in this material.
  12637. */
  12638. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12639. /**
  12640. * Sets the Default image processing configuration used either in the this material.
  12641. *
  12642. * If sets to null, the scene one is in use.
  12643. */
  12644. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12645. /**
  12646. * Attaches a new image processing configuration to the Standard Material.
  12647. * @param configuration
  12648. */
  12649. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12650. /** @hidden */
  12651. protected _reset(): void;
  12652. /** @hidden */
  12653. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12654. /**
  12655. * Instantiates a particle system.
  12656. * 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.
  12657. * @param name The name of the particle system
  12658. */
  12659. constructor(name: string);
  12660. /**
  12661. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12662. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12663. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12664. * @returns the emitter
  12665. */
  12666. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12667. /**
  12668. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12669. * @param radius The radius of the hemisphere to emit from
  12670. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12671. * @returns the emitter
  12672. */
  12673. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12674. /**
  12675. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12676. * @param radius The radius of the sphere to emit from
  12677. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12678. * @returns the emitter
  12679. */
  12680. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12681. /**
  12682. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12683. * @param radius The radius of the sphere to emit from
  12684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12686. * @returns the emitter
  12687. */
  12688. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12689. /**
  12690. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12691. * @param radius The radius of the emission cylinder
  12692. * @param height The height of the emission cylinder
  12693. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12694. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12695. * @returns the emitter
  12696. */
  12697. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12698. /**
  12699. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12700. * @param radius The radius of the cylinder to emit from
  12701. * @param height The height of the emission cylinder
  12702. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12703. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12704. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12705. * @returns the emitter
  12706. */
  12707. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12708. /**
  12709. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12710. * @param radius The radius of the cone to emit from
  12711. * @param angle The base angle of the cone
  12712. * @returns the emitter
  12713. */
  12714. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12715. /**
  12716. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12719. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12720. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12721. * @returns the emitter
  12722. */
  12723. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12724. }
  12725. }
  12726. declare module "babylonjs/Particles/subEmitter" {
  12727. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12728. import { Scene } from "babylonjs/scene";
  12729. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12730. /**
  12731. * Type of sub emitter
  12732. */
  12733. export enum SubEmitterType {
  12734. /**
  12735. * Attached to the particle over it's lifetime
  12736. */
  12737. ATTACHED = 0,
  12738. /**
  12739. * Created when the particle dies
  12740. */
  12741. END = 1
  12742. }
  12743. /**
  12744. * Sub emitter class used to emit particles from an existing particle
  12745. */
  12746. export class SubEmitter {
  12747. /**
  12748. * the particle system to be used by the sub emitter
  12749. */
  12750. particleSystem: ParticleSystem;
  12751. /**
  12752. * Type of the submitter (Default: END)
  12753. */
  12754. type: SubEmitterType;
  12755. /**
  12756. * 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)
  12757. * Note: This only is supported when using an emitter of type Mesh
  12758. */
  12759. inheritDirection: boolean;
  12760. /**
  12761. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12762. */
  12763. inheritedVelocityAmount: number;
  12764. /**
  12765. * Creates a sub emitter
  12766. * @param particleSystem the particle system to be used by the sub emitter
  12767. */
  12768. constructor(
  12769. /**
  12770. * the particle system to be used by the sub emitter
  12771. */
  12772. particleSystem: ParticleSystem);
  12773. /**
  12774. * Clones the sub emitter
  12775. * @returns the cloned sub emitter
  12776. */
  12777. clone(): SubEmitter;
  12778. /**
  12779. * Serialize current object to a JSON object
  12780. * @returns the serialized object
  12781. */
  12782. serialize(): any;
  12783. /** @hidden */
  12784. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12785. /**
  12786. * Creates a new SubEmitter from a serialized JSON version
  12787. * @param serializationObject defines the JSON object to read from
  12788. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12789. * @param rootUrl defines the rootUrl for data loading
  12790. * @returns a new SubEmitter
  12791. */
  12792. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12793. /** Release associated resources */
  12794. dispose(): void;
  12795. }
  12796. }
  12797. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12798. /** @hidden */
  12799. export var imageProcessingDeclaration: {
  12800. name: string;
  12801. shader: string;
  12802. };
  12803. }
  12804. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12805. /** @hidden */
  12806. export var imageProcessingFunctions: {
  12807. name: string;
  12808. shader: string;
  12809. };
  12810. }
  12811. declare module "babylonjs/Shaders/particles.fragment" {
  12812. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12813. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12814. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12815. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12816. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12817. /** @hidden */
  12818. export var particlesPixelShader: {
  12819. name: string;
  12820. shader: string;
  12821. };
  12822. }
  12823. declare module "babylonjs/Shaders/particles.vertex" {
  12824. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12825. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12826. /** @hidden */
  12827. export var particlesVertexShader: {
  12828. name: string;
  12829. shader: string;
  12830. };
  12831. }
  12832. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12833. import { Nullable } from "babylonjs/types";
  12834. import { Plane } from "babylonjs/Maths/math";
  12835. /**
  12836. * Interface used to define entities containing multiple clip planes
  12837. */
  12838. export interface IClipPlanesHolder {
  12839. /**
  12840. * Gets or sets the active clipplane 1
  12841. */
  12842. clipPlane: Nullable<Plane>;
  12843. /**
  12844. * Gets or sets the active clipplane 2
  12845. */
  12846. clipPlane2: Nullable<Plane>;
  12847. /**
  12848. * Gets or sets the active clipplane 3
  12849. */
  12850. clipPlane3: Nullable<Plane>;
  12851. /**
  12852. * Gets or sets the active clipplane 4
  12853. */
  12854. clipPlane4: Nullable<Plane>;
  12855. /**
  12856. * Gets or sets the active clipplane 5
  12857. */
  12858. clipPlane5: Nullable<Plane>;
  12859. /**
  12860. * Gets or sets the active clipplane 6
  12861. */
  12862. clipPlane6: Nullable<Plane>;
  12863. }
  12864. }
  12865. declare module "babylonjs/Materials/thinMaterialHelper" {
  12866. import { Effect } from "babylonjs/Materials/effect";
  12867. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12868. /**
  12869. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12870. *
  12871. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12872. *
  12873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12874. */
  12875. export class ThinMaterialHelper {
  12876. /**
  12877. * Binds the clip plane information from the holder to the effect.
  12878. * @param effect The effect we are binding the data to
  12879. * @param holder The entity containing the clip plane information
  12880. */
  12881. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12882. }
  12883. }
  12884. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12885. module "babylonjs/Engines/thinEngine" {
  12886. interface ThinEngine {
  12887. /**
  12888. * Sets alpha constants used by some alpha blending modes
  12889. * @param r defines the red component
  12890. * @param g defines the green component
  12891. * @param b defines the blue component
  12892. * @param a defines the alpha component
  12893. */
  12894. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12895. /**
  12896. * Sets the current alpha mode
  12897. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12898. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12899. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12900. */
  12901. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12902. /**
  12903. * Gets the current alpha mode
  12904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12905. * @returns the current alpha mode
  12906. */
  12907. getAlphaMode(): number;
  12908. /**
  12909. * Sets the current alpha equation
  12910. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12911. */
  12912. setAlphaEquation(equation: number): void;
  12913. /**
  12914. * Gets the current alpha equation.
  12915. * @returns the current alpha equation
  12916. */
  12917. getAlphaEquation(): number;
  12918. }
  12919. }
  12920. }
  12921. declare module "babylonjs/Particles/particleSystem" {
  12922. import { Nullable } from "babylonjs/types";
  12923. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12924. import { Observable } from "babylonjs/Misc/observable";
  12925. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12926. import { Effect } from "babylonjs/Materials/effect";
  12927. import { IDisposable } from "babylonjs/scene";
  12928. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12929. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12930. import { Particle } from "babylonjs/Particles/particle";
  12931. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12932. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12933. import "babylonjs/Shaders/particles.fragment";
  12934. import "babylonjs/Shaders/particles.vertex";
  12935. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12936. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12937. import "babylonjs/Engines/Extensions/engine.alpha";
  12938. import { Scene } from "babylonjs/scene";
  12939. /**
  12940. * This represents a particle system in Babylon.
  12941. * 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.
  12942. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12943. * @example https://doc.babylonjs.com/babylon101/particles
  12944. */
  12945. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12946. /**
  12947. * Billboard mode will only apply to Y axis
  12948. */
  12949. static readonly BILLBOARDMODE_Y: number;
  12950. /**
  12951. * Billboard mode will apply to all axes
  12952. */
  12953. static readonly BILLBOARDMODE_ALL: number;
  12954. /**
  12955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12956. */
  12957. static readonly BILLBOARDMODE_STRETCHED: number;
  12958. /**
  12959. * This function can be defined to provide custom update for active particles.
  12960. * This function will be called instead of regular update (age, position, color, etc.).
  12961. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12962. */
  12963. updateFunction: (particles: Particle[]) => void;
  12964. private _emitterWorldMatrix;
  12965. /**
  12966. * This function can be defined to specify initial direction for every new particle.
  12967. * It by default use the emitterType defined function
  12968. */
  12969. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12970. /**
  12971. * This function can be defined to specify initial position for every new particle.
  12972. * It by default use the emitterType defined function
  12973. */
  12974. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12975. /**
  12976. * @hidden
  12977. */
  12978. _inheritedVelocityOffset: Vector3;
  12979. /**
  12980. * An event triggered when the system is disposed
  12981. */
  12982. onDisposeObservable: Observable<IParticleSystem>;
  12983. /**
  12984. * An event triggered when the system is stopped
  12985. */
  12986. onStoppedObservable: Observable<IParticleSystem>;
  12987. private _onDisposeObserver;
  12988. /**
  12989. * Sets a callback that will be triggered when the system is disposed
  12990. */
  12991. set onDispose(callback: () => void);
  12992. private _particles;
  12993. private _epsilon;
  12994. private _capacity;
  12995. private _stockParticles;
  12996. private _newPartsExcess;
  12997. private _vertexData;
  12998. private _vertexBuffer;
  12999. private _vertexBuffers;
  13000. private _spriteBuffer;
  13001. private _indexBuffer;
  13002. private _effect;
  13003. private _customEffect;
  13004. private _cachedDefines;
  13005. private _scaledColorStep;
  13006. private _colorDiff;
  13007. private _scaledDirection;
  13008. private _scaledGravity;
  13009. private _currentRenderId;
  13010. private _alive;
  13011. private _useInstancing;
  13012. private _vertexArrayObject;
  13013. private _started;
  13014. private _stopped;
  13015. private _actualFrame;
  13016. private _scaledUpdateSpeed;
  13017. private _vertexBufferSize;
  13018. /** @hidden */
  13019. _currentEmitRateGradient: Nullable<FactorGradient>;
  13020. /** @hidden */
  13021. _currentEmitRate1: number;
  13022. /** @hidden */
  13023. _currentEmitRate2: number;
  13024. /** @hidden */
  13025. _currentStartSizeGradient: Nullable<FactorGradient>;
  13026. /** @hidden */
  13027. _currentStartSize1: number;
  13028. /** @hidden */
  13029. _currentStartSize2: number;
  13030. private readonly _rawTextureWidth;
  13031. private _rampGradientsTexture;
  13032. private _useRampGradients;
  13033. /** Gets or sets a matrix to use to compute projection */
  13034. defaultProjectionMatrix: Matrix;
  13035. /** Gets or sets a matrix to use to compute view */
  13036. defaultViewMatrix: Matrix;
  13037. /** Gets or sets a boolean indicating that ramp gradients must be used
  13038. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13039. */
  13040. get useRampGradients(): boolean;
  13041. set useRampGradients(value: boolean);
  13042. /**
  13043. * 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.
  13044. * 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: [])
  13045. */
  13046. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13047. private _subEmitters;
  13048. /**
  13049. * @hidden
  13050. * If the particle systems emitter should be disposed when the particle system is disposed
  13051. */
  13052. _disposeEmitterOnDispose: boolean;
  13053. /**
  13054. * The current active Sub-systems, this property is used by the root particle system only.
  13055. */
  13056. activeSubSystems: Array<ParticleSystem>;
  13057. /**
  13058. * Specifies if the particles are updated in emitter local space or world space
  13059. */
  13060. isLocal: boolean;
  13061. private _rootParticleSystem;
  13062. /**
  13063. * Gets the current list of active particles
  13064. */
  13065. get particles(): Particle[];
  13066. /**
  13067. * Gets the number of particles active at the same time.
  13068. * @returns The number of active particles.
  13069. */
  13070. getActiveCount(): number;
  13071. /**
  13072. * Returns the string "ParticleSystem"
  13073. * @returns a string containing the class name
  13074. */
  13075. getClassName(): string;
  13076. /**
  13077. * Gets a boolean indicating that the system is stopping
  13078. * @returns true if the system is currently stopping
  13079. */
  13080. isStopping(): boolean;
  13081. /**
  13082. * Gets the custom effect used to render the particles
  13083. * @param blendMode Blend mode for which the effect should be retrieved
  13084. * @returns The effect
  13085. */
  13086. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13087. /**
  13088. * Sets the custom effect used to render the particles
  13089. * @param effect The effect to set
  13090. * @param blendMode Blend mode for which the effect should be set
  13091. */
  13092. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13093. /** @hidden */
  13094. private _onBeforeDrawParticlesObservable;
  13095. /**
  13096. * Observable that will be called just before the particles are drawn
  13097. */
  13098. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13099. /**
  13100. * Gets the name of the particle vertex shader
  13101. */
  13102. get vertexShaderName(): string;
  13103. /**
  13104. * Instantiates a particle system.
  13105. * 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.
  13106. * @param name The name of the particle system
  13107. * @param capacity The max number of particles alive at the same time
  13108. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13109. * @param customEffect a custom effect used to change the way particles are rendered by default
  13110. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13111. * @param epsilon Offset used to render the particles
  13112. */
  13113. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13114. private _addFactorGradient;
  13115. private _removeFactorGradient;
  13116. /**
  13117. * Adds a new life time gradient
  13118. * @param gradient defines the gradient to use (between 0 and 1)
  13119. * @param factor defines the life time factor to affect to the specified gradient
  13120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13121. * @returns the current particle system
  13122. */
  13123. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13124. /**
  13125. * Remove a specific life time gradient
  13126. * @param gradient defines the gradient to remove
  13127. * @returns the current particle system
  13128. */
  13129. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13130. /**
  13131. * Adds a new size gradient
  13132. * @param gradient defines the gradient to use (between 0 and 1)
  13133. * @param factor defines the size factor to affect to the specified gradient
  13134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13135. * @returns the current particle system
  13136. */
  13137. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13138. /**
  13139. * Remove a specific size gradient
  13140. * @param gradient defines the gradient to remove
  13141. * @returns the current particle system
  13142. */
  13143. removeSizeGradient(gradient: number): IParticleSystem;
  13144. /**
  13145. * Adds a new color remap gradient
  13146. * @param gradient defines the gradient to use (between 0 and 1)
  13147. * @param min defines the color remap minimal range
  13148. * @param max defines the color remap maximal range
  13149. * @returns the current particle system
  13150. */
  13151. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13152. /**
  13153. * Remove a specific color remap gradient
  13154. * @param gradient defines the gradient to remove
  13155. * @returns the current particle system
  13156. */
  13157. removeColorRemapGradient(gradient: number): IParticleSystem;
  13158. /**
  13159. * Adds a new alpha remap gradient
  13160. * @param gradient defines the gradient to use (between 0 and 1)
  13161. * @param min defines the alpha remap minimal range
  13162. * @param max defines the alpha remap maximal range
  13163. * @returns the current particle system
  13164. */
  13165. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13166. /**
  13167. * Remove a specific alpha remap gradient
  13168. * @param gradient defines the gradient to remove
  13169. * @returns the current particle system
  13170. */
  13171. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13172. /**
  13173. * Adds a new angular speed gradient
  13174. * @param gradient defines the gradient to use (between 0 and 1)
  13175. * @param factor defines the angular speed to affect to the specified gradient
  13176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13177. * @returns the current particle system
  13178. */
  13179. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13180. /**
  13181. * Remove a specific angular speed gradient
  13182. * @param gradient defines the gradient to remove
  13183. * @returns the current particle system
  13184. */
  13185. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13186. /**
  13187. * Adds a new velocity gradient
  13188. * @param gradient defines the gradient to use (between 0 and 1)
  13189. * @param factor defines the velocity to affect to the specified gradient
  13190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13191. * @returns the current particle system
  13192. */
  13193. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13194. /**
  13195. * Remove a specific velocity gradient
  13196. * @param gradient defines the gradient to remove
  13197. * @returns the current particle system
  13198. */
  13199. removeVelocityGradient(gradient: number): IParticleSystem;
  13200. /**
  13201. * Adds a new limit velocity gradient
  13202. * @param gradient defines the gradient to use (between 0 and 1)
  13203. * @param factor defines the limit velocity value to affect to the specified gradient
  13204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13205. * @returns the current particle system
  13206. */
  13207. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13208. /**
  13209. * Remove a specific limit velocity gradient
  13210. * @param gradient defines the gradient to remove
  13211. * @returns the current particle system
  13212. */
  13213. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13214. /**
  13215. * Adds a new drag gradient
  13216. * @param gradient defines the gradient to use (between 0 and 1)
  13217. * @param factor defines the drag value to affect to the specified gradient
  13218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13219. * @returns the current particle system
  13220. */
  13221. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13222. /**
  13223. * Remove a specific drag gradient
  13224. * @param gradient defines the gradient to remove
  13225. * @returns the current particle system
  13226. */
  13227. removeDragGradient(gradient: number): IParticleSystem;
  13228. /**
  13229. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13230. * @param gradient defines the gradient to use (between 0 and 1)
  13231. * @param factor defines the emit rate value to affect to the specified gradient
  13232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13233. * @returns the current particle system
  13234. */
  13235. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13236. /**
  13237. * Remove a specific emit rate gradient
  13238. * @param gradient defines the gradient to remove
  13239. * @returns the current particle system
  13240. */
  13241. removeEmitRateGradient(gradient: number): IParticleSystem;
  13242. /**
  13243. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13244. * @param gradient defines the gradient to use (between 0 and 1)
  13245. * @param factor defines the start size value to affect to the specified gradient
  13246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13247. * @returns the current particle system
  13248. */
  13249. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13250. /**
  13251. * Remove a specific start size gradient
  13252. * @param gradient defines the gradient to remove
  13253. * @returns the current particle system
  13254. */
  13255. removeStartSizeGradient(gradient: number): IParticleSystem;
  13256. private _createRampGradientTexture;
  13257. /**
  13258. * Gets the current list of ramp gradients.
  13259. * You must use addRampGradient and removeRampGradient to udpate this list
  13260. * @returns the list of ramp gradients
  13261. */
  13262. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13263. /** Force the system to rebuild all gradients that need to be resync */
  13264. forceRefreshGradients(): void;
  13265. private _syncRampGradientTexture;
  13266. /**
  13267. * Adds a new ramp gradient used to remap particle colors
  13268. * @param gradient defines the gradient to use (between 0 and 1)
  13269. * @param color defines the color to affect to the specified gradient
  13270. * @returns the current particle system
  13271. */
  13272. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13273. /**
  13274. * Remove a specific ramp gradient
  13275. * @param gradient defines the gradient to remove
  13276. * @returns the current particle system
  13277. */
  13278. removeRampGradient(gradient: number): ParticleSystem;
  13279. /**
  13280. * Adds a new color gradient
  13281. * @param gradient defines the gradient to use (between 0 and 1)
  13282. * @param color1 defines the color to affect to the specified gradient
  13283. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13284. * @returns this particle system
  13285. */
  13286. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13287. /**
  13288. * Remove a specific color gradient
  13289. * @param gradient defines the gradient to remove
  13290. * @returns this particle system
  13291. */
  13292. removeColorGradient(gradient: number): IParticleSystem;
  13293. private _fetchR;
  13294. protected _reset(): void;
  13295. private _resetEffect;
  13296. private _createVertexBuffers;
  13297. private _createIndexBuffer;
  13298. /**
  13299. * Gets the maximum number of particles active at the same time.
  13300. * @returns The max number of active particles.
  13301. */
  13302. getCapacity(): number;
  13303. /**
  13304. * Gets whether there are still active particles in the system.
  13305. * @returns True if it is alive, otherwise false.
  13306. */
  13307. isAlive(): boolean;
  13308. /**
  13309. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13310. * @returns True if it has been started, otherwise false.
  13311. */
  13312. isStarted(): boolean;
  13313. private _prepareSubEmitterInternalArray;
  13314. /**
  13315. * Starts the particle system and begins to emit
  13316. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13317. */
  13318. start(delay?: number): void;
  13319. /**
  13320. * Stops the particle system.
  13321. * @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.
  13322. */
  13323. stop(stopSubEmitters?: boolean): void;
  13324. /**
  13325. * Remove all active particles
  13326. */
  13327. reset(): void;
  13328. /**
  13329. * @hidden (for internal use only)
  13330. */
  13331. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13332. /**
  13333. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13334. * Its lifetime will start back at 0.
  13335. */
  13336. recycleParticle: (particle: Particle) => void;
  13337. private _stopSubEmitters;
  13338. private _createParticle;
  13339. private _removeFromRoot;
  13340. private _emitFromParticle;
  13341. private _update;
  13342. /** @hidden */
  13343. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13344. /** @hidden */
  13345. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13346. /**
  13347. * Fill the defines array according to the current settings of the particle system
  13348. * @param defines Array to be updated
  13349. * @param blendMode blend mode to take into account when updating the array
  13350. */
  13351. fillDefines(defines: Array<string>, blendMode: number): void;
  13352. /**
  13353. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13354. * @param uniforms Uniforms array to fill
  13355. * @param attributes Attributes array to fill
  13356. * @param samplers Samplers array to fill
  13357. */
  13358. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13359. /** @hidden */
  13360. private _getEffect;
  13361. /**
  13362. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13363. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13364. */
  13365. animate(preWarmOnly?: boolean): void;
  13366. private _appendParticleVertices;
  13367. /**
  13368. * Rebuilds the particle system.
  13369. */
  13370. rebuild(): void;
  13371. /**
  13372. * Is this system ready to be used/rendered
  13373. * @return true if the system is ready
  13374. */
  13375. isReady(): boolean;
  13376. private _render;
  13377. /**
  13378. * Renders the particle system in its current state.
  13379. * @returns the current number of particles
  13380. */
  13381. render(): number;
  13382. /**
  13383. * Disposes the particle system and free the associated resources
  13384. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13385. */
  13386. dispose(disposeTexture?: boolean): void;
  13387. /**
  13388. * Clones the particle system.
  13389. * @param name The name of the cloned object
  13390. * @param newEmitter The new emitter to use
  13391. * @returns the cloned particle system
  13392. */
  13393. clone(name: string, newEmitter: any): ParticleSystem;
  13394. /**
  13395. * Serializes the particle system to a JSON object
  13396. * @param serializeTexture defines if the texture must be serialized as well
  13397. * @returns the JSON object
  13398. */
  13399. serialize(serializeTexture?: boolean): any;
  13400. /** @hidden */
  13401. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13402. /** @hidden */
  13403. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13404. /**
  13405. * Parses a JSON object to create a particle system.
  13406. * @param parsedParticleSystem The JSON object to parse
  13407. * @param sceneOrEngine The scene or the engine to create the particle system in
  13408. * @param rootUrl The root url to use to load external dependencies like texture
  13409. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13410. * @returns the Parsed particle system
  13411. */
  13412. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13413. }
  13414. }
  13415. declare module "babylonjs/Particles/particle" {
  13416. import { Nullable } from "babylonjs/types";
  13417. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13418. import { Color4 } from "babylonjs/Maths/math.color";
  13419. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13420. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13421. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13422. /**
  13423. * A particle represents one of the element emitted by a particle system.
  13424. * This is mainly define by its coordinates, direction, velocity and age.
  13425. */
  13426. export class Particle {
  13427. /**
  13428. * The particle system the particle belongs to.
  13429. */
  13430. particleSystem: ParticleSystem;
  13431. private static _Count;
  13432. /**
  13433. * Unique ID of the particle
  13434. */
  13435. id: number;
  13436. /**
  13437. * The world position of the particle in the scene.
  13438. */
  13439. position: Vector3;
  13440. /**
  13441. * The world direction of the particle in the scene.
  13442. */
  13443. direction: Vector3;
  13444. /**
  13445. * The color of the particle.
  13446. */
  13447. color: Color4;
  13448. /**
  13449. * The color change of the particle per step.
  13450. */
  13451. colorStep: Color4;
  13452. /**
  13453. * Defines how long will the life of the particle be.
  13454. */
  13455. lifeTime: number;
  13456. /**
  13457. * The current age of the particle.
  13458. */
  13459. age: number;
  13460. /**
  13461. * The current size of the particle.
  13462. */
  13463. size: number;
  13464. /**
  13465. * The current scale of the particle.
  13466. */
  13467. scale: Vector2;
  13468. /**
  13469. * The current angle of the particle.
  13470. */
  13471. angle: number;
  13472. /**
  13473. * Defines how fast is the angle changing.
  13474. */
  13475. angularSpeed: number;
  13476. /**
  13477. * Defines the cell index used by the particle to be rendered from a sprite.
  13478. */
  13479. cellIndex: number;
  13480. /**
  13481. * The information required to support color remapping
  13482. */
  13483. remapData: Vector4;
  13484. /** @hidden */
  13485. _randomCellOffset?: number;
  13486. /** @hidden */
  13487. _initialDirection: Nullable<Vector3>;
  13488. /** @hidden */
  13489. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13490. /** @hidden */
  13491. _initialStartSpriteCellID: number;
  13492. /** @hidden */
  13493. _initialEndSpriteCellID: number;
  13494. /** @hidden */
  13495. _currentColorGradient: Nullable<ColorGradient>;
  13496. /** @hidden */
  13497. _currentColor1: Color4;
  13498. /** @hidden */
  13499. _currentColor2: Color4;
  13500. /** @hidden */
  13501. _currentSizeGradient: Nullable<FactorGradient>;
  13502. /** @hidden */
  13503. _currentSize1: number;
  13504. /** @hidden */
  13505. _currentSize2: number;
  13506. /** @hidden */
  13507. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13508. /** @hidden */
  13509. _currentAngularSpeed1: number;
  13510. /** @hidden */
  13511. _currentAngularSpeed2: number;
  13512. /** @hidden */
  13513. _currentVelocityGradient: Nullable<FactorGradient>;
  13514. /** @hidden */
  13515. _currentVelocity1: number;
  13516. /** @hidden */
  13517. _currentVelocity2: number;
  13518. /** @hidden */
  13519. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13520. /** @hidden */
  13521. _currentLimitVelocity1: number;
  13522. /** @hidden */
  13523. _currentLimitVelocity2: number;
  13524. /** @hidden */
  13525. _currentDragGradient: Nullable<FactorGradient>;
  13526. /** @hidden */
  13527. _currentDrag1: number;
  13528. /** @hidden */
  13529. _currentDrag2: number;
  13530. /** @hidden */
  13531. _randomNoiseCoordinates1: Vector3;
  13532. /** @hidden */
  13533. _randomNoiseCoordinates2: Vector3;
  13534. /** @hidden */
  13535. _localPosition?: Vector3;
  13536. /**
  13537. * Creates a new instance Particle
  13538. * @param particleSystem the particle system the particle belongs to
  13539. */
  13540. constructor(
  13541. /**
  13542. * The particle system the particle belongs to.
  13543. */
  13544. particleSystem: ParticleSystem);
  13545. private updateCellInfoFromSystem;
  13546. /**
  13547. * Defines how the sprite cell index is updated for the particle
  13548. */
  13549. updateCellIndex(): void;
  13550. /** @hidden */
  13551. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13552. /** @hidden */
  13553. _inheritParticleInfoToSubEmitters(): void;
  13554. /** @hidden */
  13555. _reset(): void;
  13556. /**
  13557. * Copy the properties of particle to another one.
  13558. * @param other the particle to copy the information to.
  13559. */
  13560. copyTo(other: Particle): void;
  13561. }
  13562. }
  13563. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13564. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13565. import { Effect } from "babylonjs/Materials/effect";
  13566. import { Particle } from "babylonjs/Particles/particle";
  13567. import { Nullable } from "babylonjs/types";
  13568. import { Scene } from "babylonjs/scene";
  13569. /**
  13570. * Particle emitter represents a volume emitting particles.
  13571. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13572. */
  13573. export interface IParticleEmitterType {
  13574. /**
  13575. * Called by the particle System when the direction is computed for the created particle.
  13576. * @param worldMatrix is the world matrix of the particle system
  13577. * @param directionToUpdate is the direction vector to update with the result
  13578. * @param particle is the particle we are computed the direction for
  13579. * @param isLocal defines if the direction should be set in local space
  13580. */
  13581. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13582. /**
  13583. * Called by the particle System when the position is computed for the created particle.
  13584. * @param worldMatrix is the world matrix of the particle system
  13585. * @param positionToUpdate is the position vector to update with the result
  13586. * @param particle is the particle we are computed the position for
  13587. * @param isLocal defines if the position should be set in local space
  13588. */
  13589. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13590. /**
  13591. * Clones the current emitter and returns a copy of it
  13592. * @returns the new emitter
  13593. */
  13594. clone(): IParticleEmitterType;
  13595. /**
  13596. * Called by the GPUParticleSystem to setup the update shader
  13597. * @param effect defines the update shader
  13598. */
  13599. applyToShader(effect: Effect): void;
  13600. /**
  13601. * Returns a string to use to update the GPU particles update shader
  13602. * @returns the effect defines string
  13603. */
  13604. getEffectDefines(): string;
  13605. /**
  13606. * Returns a string representing the class name
  13607. * @returns a string containing the class name
  13608. */
  13609. getClassName(): string;
  13610. /**
  13611. * Serializes the particle system to a JSON object.
  13612. * @returns the JSON object
  13613. */
  13614. serialize(): any;
  13615. /**
  13616. * Parse properties from a JSON object
  13617. * @param serializationObject defines the JSON object
  13618. * @param scene defines the hosting scene
  13619. */
  13620. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13621. }
  13622. }
  13623. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13624. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13625. import { Effect } from "babylonjs/Materials/effect";
  13626. import { Particle } from "babylonjs/Particles/particle";
  13627. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13628. /**
  13629. * Particle emitter emitting particles from the inside of a box.
  13630. * It emits the particles randomly between 2 given directions.
  13631. */
  13632. export class BoxParticleEmitter implements IParticleEmitterType {
  13633. /**
  13634. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13635. */
  13636. direction1: Vector3;
  13637. /**
  13638. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13639. */
  13640. direction2: Vector3;
  13641. /**
  13642. * 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.
  13643. */
  13644. minEmitBox: Vector3;
  13645. /**
  13646. * 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.
  13647. */
  13648. maxEmitBox: Vector3;
  13649. /**
  13650. * Creates a new instance BoxParticleEmitter
  13651. */
  13652. constructor();
  13653. /**
  13654. * Called by the particle System when the direction is computed for the created particle.
  13655. * @param worldMatrix is the world matrix of the particle system
  13656. * @param directionToUpdate is the direction vector to update with the result
  13657. * @param particle is the particle we are computed the direction for
  13658. * @param isLocal defines if the direction should be set in local space
  13659. */
  13660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13661. /**
  13662. * Called by the particle System when the position is computed for the created particle.
  13663. * @param worldMatrix is the world matrix of the particle system
  13664. * @param positionToUpdate is the position vector to update with the result
  13665. * @param particle is the particle we are computed the position for
  13666. * @param isLocal defines if the position should be set in local space
  13667. */
  13668. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13669. /**
  13670. * Clones the current emitter and returns a copy of it
  13671. * @returns the new emitter
  13672. */
  13673. clone(): BoxParticleEmitter;
  13674. /**
  13675. * Called by the GPUParticleSystem to setup the update shader
  13676. * @param effect defines the update shader
  13677. */
  13678. applyToShader(effect: Effect): void;
  13679. /**
  13680. * Returns a string to use to update the GPU particles update shader
  13681. * @returns a string containng the defines string
  13682. */
  13683. getEffectDefines(): string;
  13684. /**
  13685. * Returns the string "BoxParticleEmitter"
  13686. * @returns a string containing the class name
  13687. */
  13688. getClassName(): string;
  13689. /**
  13690. * Serializes the particle system to a JSON object.
  13691. * @returns the JSON object
  13692. */
  13693. serialize(): any;
  13694. /**
  13695. * Parse properties from a JSON object
  13696. * @param serializationObject defines the JSON object
  13697. */
  13698. parse(serializationObject: any): void;
  13699. }
  13700. }
  13701. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13702. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13703. import { Effect } from "babylonjs/Materials/effect";
  13704. import { Particle } from "babylonjs/Particles/particle";
  13705. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13706. /**
  13707. * Particle emitter emitting particles from the inside of a cone.
  13708. * It emits the particles alongside the cone volume from the base to the particle.
  13709. * The emission direction might be randomized.
  13710. */
  13711. export class ConeParticleEmitter implements IParticleEmitterType {
  13712. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13713. directionRandomizer: number;
  13714. private _radius;
  13715. private _angle;
  13716. private _height;
  13717. /**
  13718. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13719. */
  13720. radiusRange: number;
  13721. /**
  13722. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13723. */
  13724. heightRange: number;
  13725. /**
  13726. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13727. */
  13728. emitFromSpawnPointOnly: boolean;
  13729. /**
  13730. * Gets or sets the radius of the emission cone
  13731. */
  13732. get radius(): number;
  13733. set radius(value: number);
  13734. /**
  13735. * Gets or sets the angle of the emission cone
  13736. */
  13737. get angle(): number;
  13738. set angle(value: number);
  13739. private _buildHeight;
  13740. /**
  13741. * Creates a new instance ConeParticleEmitter
  13742. * @param radius the radius of the emission cone (1 by default)
  13743. * @param angle the cone base angle (PI by default)
  13744. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13745. */
  13746. constructor(radius?: number, angle?: number,
  13747. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13748. directionRandomizer?: number);
  13749. /**
  13750. * Called by the particle System when the direction is computed for the created particle.
  13751. * @param worldMatrix is the world matrix of the particle system
  13752. * @param directionToUpdate is the direction vector to update with the result
  13753. * @param particle is the particle we are computed the direction for
  13754. * @param isLocal defines if the direction should be set in local space
  13755. */
  13756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13757. /**
  13758. * Called by the particle System when the position is computed for the created particle.
  13759. * @param worldMatrix is the world matrix of the particle system
  13760. * @param positionToUpdate is the position vector to update with the result
  13761. * @param particle is the particle we are computed the position for
  13762. * @param isLocal defines if the position should be set in local space
  13763. */
  13764. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13765. /**
  13766. * Clones the current emitter and returns a copy of it
  13767. * @returns the new emitter
  13768. */
  13769. clone(): ConeParticleEmitter;
  13770. /**
  13771. * Called by the GPUParticleSystem to setup the update shader
  13772. * @param effect defines the update shader
  13773. */
  13774. applyToShader(effect: Effect): void;
  13775. /**
  13776. * Returns a string to use to update the GPU particles update shader
  13777. * @returns a string containng the defines string
  13778. */
  13779. getEffectDefines(): string;
  13780. /**
  13781. * Returns the string "ConeParticleEmitter"
  13782. * @returns a string containing the class name
  13783. */
  13784. getClassName(): string;
  13785. /**
  13786. * Serializes the particle system to a JSON object.
  13787. * @returns the JSON object
  13788. */
  13789. serialize(): any;
  13790. /**
  13791. * Parse properties from a JSON object
  13792. * @param serializationObject defines the JSON object
  13793. */
  13794. parse(serializationObject: any): void;
  13795. }
  13796. }
  13797. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13798. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13799. import { Effect } from "babylonjs/Materials/effect";
  13800. import { Particle } from "babylonjs/Particles/particle";
  13801. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13802. /**
  13803. * Particle emitter emitting particles from the inside of a cylinder.
  13804. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13805. */
  13806. export class CylinderParticleEmitter implements IParticleEmitterType {
  13807. /**
  13808. * The radius of the emission cylinder.
  13809. */
  13810. radius: number;
  13811. /**
  13812. * The height of the emission cylinder.
  13813. */
  13814. height: number;
  13815. /**
  13816. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13817. */
  13818. radiusRange: number;
  13819. /**
  13820. * How much to randomize the particle direction [0-1].
  13821. */
  13822. directionRandomizer: number;
  13823. /**
  13824. * Creates a new instance CylinderParticleEmitter
  13825. * @param radius the radius of the emission cylinder (1 by default)
  13826. * @param height the height of the emission cylinder (1 by default)
  13827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13828. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13829. */
  13830. constructor(
  13831. /**
  13832. * The radius of the emission cylinder.
  13833. */
  13834. radius?: number,
  13835. /**
  13836. * The height of the emission cylinder.
  13837. */
  13838. height?: number,
  13839. /**
  13840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13841. */
  13842. radiusRange?: number,
  13843. /**
  13844. * How much to randomize the particle direction [0-1].
  13845. */
  13846. directionRandomizer?: number);
  13847. /**
  13848. * Called by the particle System when the direction is computed for the created particle.
  13849. * @param worldMatrix is the world matrix of the particle system
  13850. * @param directionToUpdate is the direction vector to update with the result
  13851. * @param particle is the particle we are computed the direction for
  13852. * @param isLocal defines if the direction should be set in local space
  13853. */
  13854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13855. /**
  13856. * Called by the particle System when the position is computed for the created particle.
  13857. * @param worldMatrix is the world matrix of the particle system
  13858. * @param positionToUpdate is the position vector to update with the result
  13859. * @param particle is the particle we are computed the position for
  13860. * @param isLocal defines if the position should be set in local space
  13861. */
  13862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13863. /**
  13864. * Clones the current emitter and returns a copy of it
  13865. * @returns the new emitter
  13866. */
  13867. clone(): CylinderParticleEmitter;
  13868. /**
  13869. * Called by the GPUParticleSystem to setup the update shader
  13870. * @param effect defines the update shader
  13871. */
  13872. applyToShader(effect: Effect): void;
  13873. /**
  13874. * Returns a string to use to update the GPU particles update shader
  13875. * @returns a string containng the defines string
  13876. */
  13877. getEffectDefines(): string;
  13878. /**
  13879. * Returns the string "CylinderParticleEmitter"
  13880. * @returns a string containing the class name
  13881. */
  13882. getClassName(): string;
  13883. /**
  13884. * Serializes the particle system to a JSON object.
  13885. * @returns the JSON object
  13886. */
  13887. serialize(): any;
  13888. /**
  13889. * Parse properties from a JSON object
  13890. * @param serializationObject defines the JSON object
  13891. */
  13892. parse(serializationObject: any): void;
  13893. }
  13894. /**
  13895. * Particle emitter emitting particles from the inside of a cylinder.
  13896. * It emits the particles randomly between two vectors.
  13897. */
  13898. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13899. /**
  13900. * The min limit of the emission direction.
  13901. */
  13902. direction1: Vector3;
  13903. /**
  13904. * The max limit of the emission direction.
  13905. */
  13906. direction2: Vector3;
  13907. /**
  13908. * Creates a new instance CylinderDirectedParticleEmitter
  13909. * @param radius the radius of the emission cylinder (1 by default)
  13910. * @param height the height of the emission cylinder (1 by default)
  13911. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13912. * @param direction1 the min limit of the emission direction (up vector by default)
  13913. * @param direction2 the max limit of the emission direction (up vector by default)
  13914. */
  13915. constructor(radius?: number, height?: number, radiusRange?: number,
  13916. /**
  13917. * The min limit of the emission direction.
  13918. */
  13919. direction1?: Vector3,
  13920. /**
  13921. * The max limit of the emission direction.
  13922. */
  13923. direction2?: Vector3);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. */
  13930. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13931. /**
  13932. * Clones the current emitter and returns a copy of it
  13933. * @returns the new emitter
  13934. */
  13935. clone(): CylinderDirectedParticleEmitter;
  13936. /**
  13937. * Called by the GPUParticleSystem to setup the update shader
  13938. * @param effect defines the update shader
  13939. */
  13940. applyToShader(effect: Effect): void;
  13941. /**
  13942. * Returns a string to use to update the GPU particles update shader
  13943. * @returns a string containng the defines string
  13944. */
  13945. getEffectDefines(): string;
  13946. /**
  13947. * Returns the string "CylinderDirectedParticleEmitter"
  13948. * @returns a string containing the class name
  13949. */
  13950. getClassName(): string;
  13951. /**
  13952. * Serializes the particle system to a JSON object.
  13953. * @returns the JSON object
  13954. */
  13955. serialize(): any;
  13956. /**
  13957. * Parse properties from a JSON object
  13958. * @param serializationObject defines the JSON object
  13959. */
  13960. parse(serializationObject: any): void;
  13961. }
  13962. }
  13963. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13964. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13965. import { Effect } from "babylonjs/Materials/effect";
  13966. import { Particle } from "babylonjs/Particles/particle";
  13967. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13968. /**
  13969. * Particle emitter emitting particles from the inside of a hemisphere.
  13970. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13971. */
  13972. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13973. /**
  13974. * The radius of the emission hemisphere.
  13975. */
  13976. radius: number;
  13977. /**
  13978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13979. */
  13980. radiusRange: number;
  13981. /**
  13982. * How much to randomize the particle direction [0-1].
  13983. */
  13984. directionRandomizer: number;
  13985. /**
  13986. * Creates a new instance HemisphericParticleEmitter
  13987. * @param radius the radius of the emission hemisphere (1 by default)
  13988. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13989. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13990. */
  13991. constructor(
  13992. /**
  13993. * The radius of the emission hemisphere.
  13994. */
  13995. radius?: number,
  13996. /**
  13997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13998. */
  13999. radiusRange?: number,
  14000. /**
  14001. * How much to randomize the particle direction [0-1].
  14002. */
  14003. directionRandomizer?: number);
  14004. /**
  14005. * Called by the particle System when the direction is computed for the created particle.
  14006. * @param worldMatrix is the world matrix of the particle system
  14007. * @param directionToUpdate is the direction vector to update with the result
  14008. * @param particle is the particle we are computed the direction for
  14009. * @param isLocal defines if the direction should be set in local space
  14010. */
  14011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14012. /**
  14013. * Called by the particle System when the position is computed for the created particle.
  14014. * @param worldMatrix is the world matrix of the particle system
  14015. * @param positionToUpdate is the position vector to update with the result
  14016. * @param particle is the particle we are computed the position for
  14017. * @param isLocal defines if the position should be set in local space
  14018. */
  14019. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14020. /**
  14021. * Clones the current emitter and returns a copy of it
  14022. * @returns the new emitter
  14023. */
  14024. clone(): HemisphericParticleEmitter;
  14025. /**
  14026. * Called by the GPUParticleSystem to setup the update shader
  14027. * @param effect defines the update shader
  14028. */
  14029. applyToShader(effect: Effect): void;
  14030. /**
  14031. * Returns a string to use to update the GPU particles update shader
  14032. * @returns a string containng the defines string
  14033. */
  14034. getEffectDefines(): string;
  14035. /**
  14036. * Returns the string "HemisphericParticleEmitter"
  14037. * @returns a string containing the class name
  14038. */
  14039. getClassName(): string;
  14040. /**
  14041. * Serializes the particle system to a JSON object.
  14042. * @returns the JSON object
  14043. */
  14044. serialize(): any;
  14045. /**
  14046. * Parse properties from a JSON object
  14047. * @param serializationObject defines the JSON object
  14048. */
  14049. parse(serializationObject: any): void;
  14050. }
  14051. }
  14052. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14053. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14054. import { Effect } from "babylonjs/Materials/effect";
  14055. import { Particle } from "babylonjs/Particles/particle";
  14056. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14057. /**
  14058. * Particle emitter emitting particles from a point.
  14059. * It emits the particles randomly between 2 given directions.
  14060. */
  14061. export class PointParticleEmitter implements IParticleEmitterType {
  14062. /**
  14063. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14064. */
  14065. direction1: Vector3;
  14066. /**
  14067. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14068. */
  14069. direction2: Vector3;
  14070. /**
  14071. * Creates a new instance PointParticleEmitter
  14072. */
  14073. constructor();
  14074. /**
  14075. * Called by the particle System when the direction is computed for the created particle.
  14076. * @param worldMatrix is the world matrix of the particle system
  14077. * @param directionToUpdate is the direction vector to update with the result
  14078. * @param particle is the particle we are computed the direction for
  14079. * @param isLocal defines if the direction should be set in local space
  14080. */
  14081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14082. /**
  14083. * Called by the particle System when the position is computed for the created particle.
  14084. * @param worldMatrix is the world matrix of the particle system
  14085. * @param positionToUpdate is the position vector to update with the result
  14086. * @param particle is the particle we are computed the position for
  14087. * @param isLocal defines if the position should be set in local space
  14088. */
  14089. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14090. /**
  14091. * Clones the current emitter and returns a copy of it
  14092. * @returns the new emitter
  14093. */
  14094. clone(): PointParticleEmitter;
  14095. /**
  14096. * Called by the GPUParticleSystem to setup the update shader
  14097. * @param effect defines the update shader
  14098. */
  14099. applyToShader(effect: Effect): void;
  14100. /**
  14101. * Returns a string to use to update the GPU particles update shader
  14102. * @returns a string containng the defines string
  14103. */
  14104. getEffectDefines(): string;
  14105. /**
  14106. * Returns the string "PointParticleEmitter"
  14107. * @returns a string containing the class name
  14108. */
  14109. getClassName(): string;
  14110. /**
  14111. * Serializes the particle system to a JSON object.
  14112. * @returns the JSON object
  14113. */
  14114. serialize(): any;
  14115. /**
  14116. * Parse properties from a JSON object
  14117. * @param serializationObject defines the JSON object
  14118. */
  14119. parse(serializationObject: any): void;
  14120. }
  14121. }
  14122. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14123. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14124. import { Effect } from "babylonjs/Materials/effect";
  14125. import { Particle } from "babylonjs/Particles/particle";
  14126. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14127. /**
  14128. * Particle emitter emitting particles from the inside of a sphere.
  14129. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14130. */
  14131. export class SphereParticleEmitter implements IParticleEmitterType {
  14132. /**
  14133. * The radius of the emission sphere.
  14134. */
  14135. radius: number;
  14136. /**
  14137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14138. */
  14139. radiusRange: number;
  14140. /**
  14141. * How much to randomize the particle direction [0-1].
  14142. */
  14143. directionRandomizer: number;
  14144. /**
  14145. * Creates a new instance SphereParticleEmitter
  14146. * @param radius the radius of the emission sphere (1 by default)
  14147. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14148. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14149. */
  14150. constructor(
  14151. /**
  14152. * The radius of the emission sphere.
  14153. */
  14154. radius?: number,
  14155. /**
  14156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14157. */
  14158. radiusRange?: number,
  14159. /**
  14160. * How much to randomize the particle direction [0-1].
  14161. */
  14162. directionRandomizer?: number);
  14163. /**
  14164. * Called by the particle System when the direction is computed for the created particle.
  14165. * @param worldMatrix is the world matrix of the particle system
  14166. * @param directionToUpdate is the direction vector to update with the result
  14167. * @param particle is the particle we are computed the direction for
  14168. * @param isLocal defines if the direction should be set in local space
  14169. */
  14170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14171. /**
  14172. * Called by the particle System when the position is computed for the created particle.
  14173. * @param worldMatrix is the world matrix of the particle system
  14174. * @param positionToUpdate is the position vector to update with the result
  14175. * @param particle is the particle we are computed the position for
  14176. * @param isLocal defines if the position should be set in local space
  14177. */
  14178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14179. /**
  14180. * Clones the current emitter and returns a copy of it
  14181. * @returns the new emitter
  14182. */
  14183. clone(): SphereParticleEmitter;
  14184. /**
  14185. * Called by the GPUParticleSystem to setup the update shader
  14186. * @param effect defines the update shader
  14187. */
  14188. applyToShader(effect: Effect): void;
  14189. /**
  14190. * Returns a string to use to update the GPU particles update shader
  14191. * @returns a string containng the defines string
  14192. */
  14193. getEffectDefines(): string;
  14194. /**
  14195. * Returns the string "SphereParticleEmitter"
  14196. * @returns a string containing the class name
  14197. */
  14198. getClassName(): string;
  14199. /**
  14200. * Serializes the particle system to a JSON object.
  14201. * @returns the JSON object
  14202. */
  14203. serialize(): any;
  14204. /**
  14205. * Parse properties from a JSON object
  14206. * @param serializationObject defines the JSON object
  14207. */
  14208. parse(serializationObject: any): void;
  14209. }
  14210. /**
  14211. * Particle emitter emitting particles from the inside of a sphere.
  14212. * It emits the particles randomly between two vectors.
  14213. */
  14214. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14215. /**
  14216. * The min limit of the emission direction.
  14217. */
  14218. direction1: Vector3;
  14219. /**
  14220. * The max limit of the emission direction.
  14221. */
  14222. direction2: Vector3;
  14223. /**
  14224. * Creates a new instance SphereDirectedParticleEmitter
  14225. * @param radius the radius of the emission sphere (1 by default)
  14226. * @param direction1 the min limit of the emission direction (up vector by default)
  14227. * @param direction2 the max limit of the emission direction (up vector by default)
  14228. */
  14229. constructor(radius?: number,
  14230. /**
  14231. * The min limit of the emission direction.
  14232. */
  14233. direction1?: Vector3,
  14234. /**
  14235. * The max limit of the emission direction.
  14236. */
  14237. direction2?: Vector3);
  14238. /**
  14239. * Called by the particle System when the direction is computed for the created particle.
  14240. * @param worldMatrix is the world matrix of the particle system
  14241. * @param directionToUpdate is the direction vector to update with the result
  14242. * @param particle is the particle we are computed the direction for
  14243. */
  14244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14245. /**
  14246. * Clones the current emitter and returns a copy of it
  14247. * @returns the new emitter
  14248. */
  14249. clone(): SphereDirectedParticleEmitter;
  14250. /**
  14251. * Called by the GPUParticleSystem to setup the update shader
  14252. * @param effect defines the update shader
  14253. */
  14254. applyToShader(effect: Effect): void;
  14255. /**
  14256. * Returns a string to use to update the GPU particles update shader
  14257. * @returns a string containng the defines string
  14258. */
  14259. getEffectDefines(): string;
  14260. /**
  14261. * Returns the string "SphereDirectedParticleEmitter"
  14262. * @returns a string containing the class name
  14263. */
  14264. getClassName(): string;
  14265. /**
  14266. * Serializes the particle system to a JSON object.
  14267. * @returns the JSON object
  14268. */
  14269. serialize(): any;
  14270. /**
  14271. * Parse properties from a JSON object
  14272. * @param serializationObject defines the JSON object
  14273. */
  14274. parse(serializationObject: any): void;
  14275. }
  14276. }
  14277. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14279. import { Effect } from "babylonjs/Materials/effect";
  14280. import { Particle } from "babylonjs/Particles/particle";
  14281. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14282. import { Nullable } from "babylonjs/types";
  14283. /**
  14284. * Particle emitter emitting particles from a custom list of positions.
  14285. */
  14286. export class CustomParticleEmitter implements IParticleEmitterType {
  14287. /**
  14288. * Gets or sets the position generator that will create the inital position of each particle.
  14289. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14290. */
  14291. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14292. /**
  14293. * Gets or sets the destination generator that will create the final destination of each particle.
  14294. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14295. */
  14296. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14297. /**
  14298. * Creates a new instance CustomParticleEmitter
  14299. */
  14300. constructor();
  14301. /**
  14302. * Called by the particle System when the direction is computed for the created particle.
  14303. * @param worldMatrix is the world matrix of the particle system
  14304. * @param directionToUpdate is the direction vector to update with the result
  14305. * @param particle is the particle we are computed the direction for
  14306. * @param isLocal defines if the direction should be set in local space
  14307. */
  14308. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14309. /**
  14310. * Called by the particle System when the position is computed for the created particle.
  14311. * @param worldMatrix is the world matrix of the particle system
  14312. * @param positionToUpdate is the position vector to update with the result
  14313. * @param particle is the particle we are computed the position for
  14314. * @param isLocal defines if the position should be set in local space
  14315. */
  14316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14317. /**
  14318. * Clones the current emitter and returns a copy of it
  14319. * @returns the new emitter
  14320. */
  14321. clone(): CustomParticleEmitter;
  14322. /**
  14323. * Called by the GPUParticleSystem to setup the update shader
  14324. * @param effect defines the update shader
  14325. */
  14326. applyToShader(effect: Effect): void;
  14327. /**
  14328. * Returns a string to use to update the GPU particles update shader
  14329. * @returns a string containng the defines string
  14330. */
  14331. getEffectDefines(): string;
  14332. /**
  14333. * Returns the string "PointParticleEmitter"
  14334. * @returns a string containing the class name
  14335. */
  14336. getClassName(): string;
  14337. /**
  14338. * Serializes the particle system to a JSON object.
  14339. * @returns the JSON object
  14340. */
  14341. serialize(): any;
  14342. /**
  14343. * Parse properties from a JSON object
  14344. * @param serializationObject defines the JSON object
  14345. */
  14346. parse(serializationObject: any): void;
  14347. }
  14348. }
  14349. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14350. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14351. import { Effect } from "babylonjs/Materials/effect";
  14352. import { Particle } from "babylonjs/Particles/particle";
  14353. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14354. import { Nullable } from "babylonjs/types";
  14355. import { Scene } from "babylonjs/scene";
  14356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14357. /**
  14358. * Particle emitter emitting particles from the inside of a box.
  14359. * It emits the particles randomly between 2 given directions.
  14360. */
  14361. export class MeshParticleEmitter implements IParticleEmitterType {
  14362. private _indices;
  14363. private _positions;
  14364. private _normals;
  14365. private _storedNormal;
  14366. private _mesh;
  14367. /**
  14368. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14369. */
  14370. direction1: Vector3;
  14371. /**
  14372. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14373. */
  14374. direction2: Vector3;
  14375. /**
  14376. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14377. */
  14378. useMeshNormalsForDirection: boolean;
  14379. /** Defines the mesh to use as source */
  14380. get mesh(): Nullable<AbstractMesh>;
  14381. set mesh(value: Nullable<AbstractMesh>);
  14382. /**
  14383. * Creates a new instance MeshParticleEmitter
  14384. * @param mesh defines the mesh to use as source
  14385. */
  14386. constructor(mesh?: Nullable<AbstractMesh>);
  14387. /**
  14388. * Called by the particle System when the direction is computed for the created particle.
  14389. * @param worldMatrix is the world matrix of the particle system
  14390. * @param directionToUpdate is the direction vector to update with the result
  14391. * @param particle is the particle we are computed the direction for
  14392. * @param isLocal defines if the direction should be set in local space
  14393. */
  14394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14395. /**
  14396. * Called by the particle System when the position is computed for the created particle.
  14397. * @param worldMatrix is the world matrix of the particle system
  14398. * @param positionToUpdate is the position vector to update with the result
  14399. * @param particle is the particle we are computed the position for
  14400. * @param isLocal defines if the position should be set in local space
  14401. */
  14402. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14403. /**
  14404. * Clones the current emitter and returns a copy of it
  14405. * @returns the new emitter
  14406. */
  14407. clone(): MeshParticleEmitter;
  14408. /**
  14409. * Called by the GPUParticleSystem to setup the update shader
  14410. * @param effect defines the update shader
  14411. */
  14412. applyToShader(effect: Effect): void;
  14413. /**
  14414. * Returns a string to use to update the GPU particles update shader
  14415. * @returns a string containng the defines string
  14416. */
  14417. getEffectDefines(): string;
  14418. /**
  14419. * Returns the string "BoxParticleEmitter"
  14420. * @returns a string containing the class name
  14421. */
  14422. getClassName(): string;
  14423. /**
  14424. * Serializes the particle system to a JSON object.
  14425. * @returns the JSON object
  14426. */
  14427. serialize(): any;
  14428. /**
  14429. * Parse properties from a JSON object
  14430. * @param serializationObject defines the JSON object
  14431. * @param scene defines the hosting scene
  14432. */
  14433. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14434. }
  14435. }
  14436. declare module "babylonjs/Particles/EmitterTypes/index" {
  14437. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14438. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14439. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14440. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14441. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14442. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14443. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14444. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14445. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14446. }
  14447. declare module "babylonjs/Particles/IParticleSystem" {
  14448. import { Nullable } from "babylonjs/types";
  14449. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14451. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14452. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14453. import { Scene } from "babylonjs/scene";
  14454. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14455. import { Effect } from "babylonjs/Materials/effect";
  14456. import { Observable } from "babylonjs/Misc/observable";
  14457. import { Animation } from "babylonjs/Animations/animation";
  14458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14459. /**
  14460. * Interface representing a particle system in Babylon.js.
  14461. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14462. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14463. */
  14464. export interface IParticleSystem {
  14465. /**
  14466. * List of animations used by the particle system.
  14467. */
  14468. animations: Animation[];
  14469. /**
  14470. * The id of the Particle system.
  14471. */
  14472. id: string;
  14473. /**
  14474. * The name of the Particle system.
  14475. */
  14476. name: string;
  14477. /**
  14478. * The emitter represents the Mesh or position we are attaching the particle system to.
  14479. */
  14480. emitter: Nullable<AbstractMesh | Vector3>;
  14481. /**
  14482. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14483. */
  14484. isBillboardBased: boolean;
  14485. /**
  14486. * The rendering group used by the Particle system to chose when to render.
  14487. */
  14488. renderingGroupId: number;
  14489. /**
  14490. * The layer mask we are rendering the particles through.
  14491. */
  14492. layerMask: number;
  14493. /**
  14494. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14495. */
  14496. updateSpeed: number;
  14497. /**
  14498. * The amount of time the particle system is running (depends of the overall update speed).
  14499. */
  14500. targetStopDuration: number;
  14501. /**
  14502. * The texture used to render each particle. (this can be a spritesheet)
  14503. */
  14504. particleTexture: Nullable<BaseTexture>;
  14505. /**
  14506. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14507. */
  14508. blendMode: number;
  14509. /**
  14510. * Minimum life time of emitting particles.
  14511. */
  14512. minLifeTime: number;
  14513. /**
  14514. * Maximum life time of emitting particles.
  14515. */
  14516. maxLifeTime: number;
  14517. /**
  14518. * Minimum Size of emitting particles.
  14519. */
  14520. minSize: number;
  14521. /**
  14522. * Maximum Size of emitting particles.
  14523. */
  14524. maxSize: number;
  14525. /**
  14526. * Minimum scale of emitting particles on X axis.
  14527. */
  14528. minScaleX: number;
  14529. /**
  14530. * Maximum scale of emitting particles on X axis.
  14531. */
  14532. maxScaleX: number;
  14533. /**
  14534. * Minimum scale of emitting particles on Y axis.
  14535. */
  14536. minScaleY: number;
  14537. /**
  14538. * Maximum scale of emitting particles on Y axis.
  14539. */
  14540. maxScaleY: number;
  14541. /**
  14542. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14543. */
  14544. color1: Color4;
  14545. /**
  14546. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14547. */
  14548. color2: Color4;
  14549. /**
  14550. * Color the particle will have at the end of its lifetime.
  14551. */
  14552. colorDead: Color4;
  14553. /**
  14554. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14555. */
  14556. emitRate: number;
  14557. /**
  14558. * You can use gravity if you want to give an orientation to your particles.
  14559. */
  14560. gravity: Vector3;
  14561. /**
  14562. * Minimum power of emitting particles.
  14563. */
  14564. minEmitPower: number;
  14565. /**
  14566. * Maximum power of emitting particles.
  14567. */
  14568. maxEmitPower: number;
  14569. /**
  14570. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14571. */
  14572. minAngularSpeed: number;
  14573. /**
  14574. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14575. */
  14576. maxAngularSpeed: number;
  14577. /**
  14578. * Gets or sets the minimal initial rotation in radians.
  14579. */
  14580. minInitialRotation: number;
  14581. /**
  14582. * Gets or sets the maximal initial rotation in radians.
  14583. */
  14584. maxInitialRotation: number;
  14585. /**
  14586. * The particle emitter type defines the emitter used by the particle system.
  14587. * It can be for example box, sphere, or cone...
  14588. */
  14589. particleEmitterType: Nullable<IParticleEmitterType>;
  14590. /**
  14591. * Defines the delay in milliseconds before starting the system (0 by default)
  14592. */
  14593. startDelay: number;
  14594. /**
  14595. * 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
  14596. */
  14597. preWarmCycles: number;
  14598. /**
  14599. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14600. */
  14601. preWarmStepOffset: number;
  14602. /**
  14603. * 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)
  14604. */
  14605. spriteCellChangeSpeed: number;
  14606. /**
  14607. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14608. */
  14609. startSpriteCellID: number;
  14610. /**
  14611. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14612. */
  14613. endSpriteCellID: number;
  14614. /**
  14615. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14616. */
  14617. spriteCellWidth: number;
  14618. /**
  14619. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14620. */
  14621. spriteCellHeight: number;
  14622. /**
  14623. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14624. */
  14625. spriteRandomStartCell: boolean;
  14626. /**
  14627. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14628. */
  14629. isAnimationSheetEnabled: boolean;
  14630. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14631. translationPivot: Vector2;
  14632. /**
  14633. * Gets or sets a texture used to add random noise to particle positions
  14634. */
  14635. noiseTexture: Nullable<BaseTexture>;
  14636. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14637. noiseStrength: Vector3;
  14638. /**
  14639. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14640. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14641. */
  14642. billboardMode: number;
  14643. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14644. limitVelocityDamping: number;
  14645. /**
  14646. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14647. */
  14648. beginAnimationOnStart: boolean;
  14649. /**
  14650. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14651. */
  14652. beginAnimationFrom: number;
  14653. /**
  14654. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14655. */
  14656. beginAnimationTo: number;
  14657. /**
  14658. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14659. */
  14660. beginAnimationLoop: boolean;
  14661. /**
  14662. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14663. */
  14664. disposeOnStop: boolean;
  14665. /**
  14666. * Specifies if the particles are updated in emitter local space or world space
  14667. */
  14668. isLocal: boolean;
  14669. /** Snippet ID if the particle system was created from the snippet server */
  14670. snippetId: string;
  14671. /** Gets or sets a matrix to use to compute projection */
  14672. defaultProjectionMatrix: Matrix;
  14673. /**
  14674. * Gets the maximum number of particles active at the same time.
  14675. * @returns The max number of active particles.
  14676. */
  14677. getCapacity(): number;
  14678. /**
  14679. * Gets the number of particles active at the same time.
  14680. * @returns The number of active particles.
  14681. */
  14682. getActiveCount(): number;
  14683. /**
  14684. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14685. * @returns True if it has been started, otherwise false.
  14686. */
  14687. isStarted(): boolean;
  14688. /**
  14689. * Animates the particle system for this frame.
  14690. */
  14691. animate(): void;
  14692. /**
  14693. * Renders the particle system in its current state.
  14694. * @returns the current number of particles
  14695. */
  14696. render(): number;
  14697. /**
  14698. * Dispose the particle system and frees its associated resources.
  14699. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14700. */
  14701. dispose(disposeTexture?: boolean): void;
  14702. /**
  14703. * An event triggered when the system is disposed
  14704. */
  14705. onDisposeObservable: Observable<IParticleSystem>;
  14706. /**
  14707. * An event triggered when the system is stopped
  14708. */
  14709. onStoppedObservable: Observable<IParticleSystem>;
  14710. /**
  14711. * Clones the particle system.
  14712. * @param name The name of the cloned object
  14713. * @param newEmitter The new emitter to use
  14714. * @returns the cloned particle system
  14715. */
  14716. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14717. /**
  14718. * Serializes the particle system to a JSON object
  14719. * @param serializeTexture defines if the texture must be serialized as well
  14720. * @returns the JSON object
  14721. */
  14722. serialize(serializeTexture: boolean): any;
  14723. /**
  14724. * Rebuild the particle system
  14725. */
  14726. rebuild(): void;
  14727. /** Force the system to rebuild all gradients that need to be resync */
  14728. forceRefreshGradients(): void;
  14729. /**
  14730. * Starts the particle system and begins to emit
  14731. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14732. */
  14733. start(delay?: number): void;
  14734. /**
  14735. * Stops the particle system.
  14736. */
  14737. stop(): void;
  14738. /**
  14739. * Remove all active particles
  14740. */
  14741. reset(): void;
  14742. /**
  14743. * Gets a boolean indicating that the system is stopping
  14744. * @returns true if the system is currently stopping
  14745. */
  14746. isStopping(): boolean;
  14747. /**
  14748. * Is this system ready to be used/rendered
  14749. * @return true if the system is ready
  14750. */
  14751. isReady(): boolean;
  14752. /**
  14753. * Returns the string "ParticleSystem"
  14754. * @returns a string containing the class name
  14755. */
  14756. getClassName(): string;
  14757. /**
  14758. * Gets the custom effect used to render the particles
  14759. * @param blendMode Blend mode for which the effect should be retrieved
  14760. * @returns The effect
  14761. */
  14762. getCustomEffect(blendMode: number): Nullable<Effect>;
  14763. /**
  14764. * Sets the custom effect used to render the particles
  14765. * @param effect The effect to set
  14766. * @param blendMode Blend mode for which the effect should be set
  14767. */
  14768. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14769. /**
  14770. * Fill the defines array according to the current settings of the particle system
  14771. * @param defines Array to be updated
  14772. * @param blendMode blend mode to take into account when updating the array
  14773. */
  14774. fillDefines(defines: Array<string>, blendMode: number): void;
  14775. /**
  14776. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14777. * @param uniforms Uniforms array to fill
  14778. * @param attributes Attributes array to fill
  14779. * @param samplers Samplers array to fill
  14780. */
  14781. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14782. /**
  14783. * Observable that will be called just before the particles are drawn
  14784. */
  14785. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14786. /**
  14787. * Gets the name of the particle vertex shader
  14788. */
  14789. vertexShaderName: string;
  14790. /**
  14791. * Adds a new color gradient
  14792. * @param gradient defines the gradient to use (between 0 and 1)
  14793. * @param color1 defines the color to affect to the specified gradient
  14794. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14795. * @returns the current particle system
  14796. */
  14797. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14798. /**
  14799. * Remove a specific color gradient
  14800. * @param gradient defines the gradient to remove
  14801. * @returns the current particle system
  14802. */
  14803. removeColorGradient(gradient: number): IParticleSystem;
  14804. /**
  14805. * Adds a new size gradient
  14806. * @param gradient defines the gradient to use (between 0 and 1)
  14807. * @param factor defines the size factor to affect to the specified gradient
  14808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14809. * @returns the current particle system
  14810. */
  14811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14812. /**
  14813. * Remove a specific size gradient
  14814. * @param gradient defines the gradient to remove
  14815. * @returns the current particle system
  14816. */
  14817. removeSizeGradient(gradient: number): IParticleSystem;
  14818. /**
  14819. * Gets the current list of color gradients.
  14820. * You must use addColorGradient and removeColorGradient to udpate this list
  14821. * @returns the list of color gradients
  14822. */
  14823. getColorGradients(): Nullable<Array<ColorGradient>>;
  14824. /**
  14825. * Gets the current list of size gradients.
  14826. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14827. * @returns the list of size gradients
  14828. */
  14829. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14830. /**
  14831. * Gets the current list of angular speed gradients.
  14832. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14833. * @returns the list of angular speed gradients
  14834. */
  14835. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14836. /**
  14837. * Adds a new angular speed gradient
  14838. * @param gradient defines the gradient to use (between 0 and 1)
  14839. * @param factor defines the angular speed to affect to the specified gradient
  14840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14841. * @returns the current particle system
  14842. */
  14843. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14844. /**
  14845. * Remove a specific angular speed gradient
  14846. * @param gradient defines the gradient to remove
  14847. * @returns the current particle system
  14848. */
  14849. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14850. /**
  14851. * Gets the current list of velocity gradients.
  14852. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14853. * @returns the list of velocity gradients
  14854. */
  14855. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14856. /**
  14857. * Adds a new velocity gradient
  14858. * @param gradient defines the gradient to use (between 0 and 1)
  14859. * @param factor defines the velocity to affect to the specified gradient
  14860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14861. * @returns the current particle system
  14862. */
  14863. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14864. /**
  14865. * Remove a specific velocity gradient
  14866. * @param gradient defines the gradient to remove
  14867. * @returns the current particle system
  14868. */
  14869. removeVelocityGradient(gradient: number): IParticleSystem;
  14870. /**
  14871. * Gets the current list of limit velocity gradients.
  14872. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14873. * @returns the list of limit velocity gradients
  14874. */
  14875. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14876. /**
  14877. * Adds a new limit velocity gradient
  14878. * @param gradient defines the gradient to use (between 0 and 1)
  14879. * @param factor defines the limit velocity to affect to the specified gradient
  14880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14881. * @returns the current particle system
  14882. */
  14883. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14884. /**
  14885. * Remove a specific limit velocity gradient
  14886. * @param gradient defines the gradient to remove
  14887. * @returns the current particle system
  14888. */
  14889. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14890. /**
  14891. * Adds a new drag gradient
  14892. * @param gradient defines the gradient to use (between 0 and 1)
  14893. * @param factor defines the drag to affect to the specified gradient
  14894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14895. * @returns the current particle system
  14896. */
  14897. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14898. /**
  14899. * Remove a specific drag gradient
  14900. * @param gradient defines the gradient to remove
  14901. * @returns the current particle system
  14902. */
  14903. removeDragGradient(gradient: number): IParticleSystem;
  14904. /**
  14905. * Gets the current list of drag gradients.
  14906. * You must use addDragGradient and removeDragGradient to udpate this list
  14907. * @returns the list of drag gradients
  14908. */
  14909. getDragGradients(): Nullable<Array<FactorGradient>>;
  14910. /**
  14911. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14912. * @param gradient defines the gradient to use (between 0 and 1)
  14913. * @param factor defines the emit rate to affect to the specified gradient
  14914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14915. * @returns the current particle system
  14916. */
  14917. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14918. /**
  14919. * Remove a specific emit rate gradient
  14920. * @param gradient defines the gradient to remove
  14921. * @returns the current particle system
  14922. */
  14923. removeEmitRateGradient(gradient: number): IParticleSystem;
  14924. /**
  14925. * Gets the current list of emit rate gradients.
  14926. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14927. * @returns the list of emit rate gradients
  14928. */
  14929. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14930. /**
  14931. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14932. * @param gradient defines the gradient to use (between 0 and 1)
  14933. * @param factor defines the start size to affect to the specified gradient
  14934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14935. * @returns the current particle system
  14936. */
  14937. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14938. /**
  14939. * Remove a specific start size gradient
  14940. * @param gradient defines the gradient to remove
  14941. * @returns the current particle system
  14942. */
  14943. removeStartSizeGradient(gradient: number): IParticleSystem;
  14944. /**
  14945. * Gets the current list of start size gradients.
  14946. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14947. * @returns the list of start size gradients
  14948. */
  14949. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14950. /**
  14951. * Adds a new life time gradient
  14952. * @param gradient defines the gradient to use (between 0 and 1)
  14953. * @param factor defines the life time factor to affect to the specified gradient
  14954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14955. * @returns the current particle system
  14956. */
  14957. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14958. /**
  14959. * Remove a specific life time gradient
  14960. * @param gradient defines the gradient to remove
  14961. * @returns the current particle system
  14962. */
  14963. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14964. /**
  14965. * Gets the current list of life time gradients.
  14966. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14967. * @returns the list of life time gradients
  14968. */
  14969. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14970. /**
  14971. * Gets the current list of color gradients.
  14972. * You must use addColorGradient and removeColorGradient to udpate this list
  14973. * @returns the list of color gradients
  14974. */
  14975. getColorGradients(): Nullable<Array<ColorGradient>>;
  14976. /**
  14977. * Adds a new ramp gradient used to remap particle colors
  14978. * @param gradient defines the gradient to use (between 0 and 1)
  14979. * @param color defines the color to affect to the specified gradient
  14980. * @returns the current particle system
  14981. */
  14982. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14983. /**
  14984. * Gets the current list of ramp gradients.
  14985. * You must use addRampGradient and removeRampGradient to udpate this list
  14986. * @returns the list of ramp gradients
  14987. */
  14988. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14989. /** Gets or sets a boolean indicating that ramp gradients must be used
  14990. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14991. */
  14992. useRampGradients: boolean;
  14993. /**
  14994. * Adds a new color remap gradient
  14995. * @param gradient defines the gradient to use (between 0 and 1)
  14996. * @param min defines the color remap minimal range
  14997. * @param max defines the color remap maximal range
  14998. * @returns the current particle system
  14999. */
  15000. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15001. /**
  15002. * Gets the current list of color remap gradients.
  15003. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15004. * @returns the list of color remap gradients
  15005. */
  15006. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15007. /**
  15008. * Adds a new alpha remap gradient
  15009. * @param gradient defines the gradient to use (between 0 and 1)
  15010. * @param min defines the alpha remap minimal range
  15011. * @param max defines the alpha remap maximal range
  15012. * @returns the current particle system
  15013. */
  15014. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15015. /**
  15016. * Gets the current list of alpha remap gradients.
  15017. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15018. * @returns the list of alpha remap gradients
  15019. */
  15020. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15021. /**
  15022. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15023. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15024. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15025. * @returns the emitter
  15026. */
  15027. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15028. /**
  15029. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15030. * @param radius The radius of the hemisphere to emit from
  15031. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15032. * @returns the emitter
  15033. */
  15034. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15035. /**
  15036. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15037. * @param radius The radius of the sphere to emit from
  15038. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15039. * @returns the emitter
  15040. */
  15041. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15042. /**
  15043. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15044. * @param radius The radius of the sphere to emit from
  15045. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15046. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15047. * @returns the emitter
  15048. */
  15049. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15050. /**
  15051. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15052. * @param radius The radius of the emission cylinder
  15053. * @param height The height of the emission cylinder
  15054. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15055. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15056. * @returns the emitter
  15057. */
  15058. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15059. /**
  15060. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15061. * @param radius The radius of the cylinder to emit from
  15062. * @param height The height of the emission cylinder
  15063. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15064. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15065. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15066. * @returns the emitter
  15067. */
  15068. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15069. /**
  15070. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15071. * @param radius The radius of the cone to emit from
  15072. * @param angle The base angle of the cone
  15073. * @returns the emitter
  15074. */
  15075. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15076. /**
  15077. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15078. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15079. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15080. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15081. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15082. * @returns the emitter
  15083. */
  15084. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15085. /**
  15086. * Get hosting scene
  15087. * @returns the scene
  15088. */
  15089. getScene(): Nullable<Scene>;
  15090. }
  15091. }
  15092. declare module "babylonjs/Meshes/transformNode" {
  15093. import { DeepImmutable } from "babylonjs/types";
  15094. import { Observable } from "babylonjs/Misc/observable";
  15095. import { Nullable } from "babylonjs/types";
  15096. import { Camera } from "babylonjs/Cameras/camera";
  15097. import { Scene } from "babylonjs/scene";
  15098. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15099. import { Node } from "babylonjs/node";
  15100. import { Bone } from "babylonjs/Bones/bone";
  15101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15102. import { Space } from "babylonjs/Maths/math.axis";
  15103. /**
  15104. * 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.
  15105. * @see https://doc.babylonjs.com/how_to/transformnode
  15106. */
  15107. export class TransformNode extends Node {
  15108. /**
  15109. * Object will not rotate to face the camera
  15110. */
  15111. static BILLBOARDMODE_NONE: number;
  15112. /**
  15113. * Object will rotate to face the camera but only on the x axis
  15114. */
  15115. static BILLBOARDMODE_X: number;
  15116. /**
  15117. * Object will rotate to face the camera but only on the y axis
  15118. */
  15119. static BILLBOARDMODE_Y: number;
  15120. /**
  15121. * Object will rotate to face the camera but only on the z axis
  15122. */
  15123. static BILLBOARDMODE_Z: number;
  15124. /**
  15125. * Object will rotate to face the camera
  15126. */
  15127. static BILLBOARDMODE_ALL: number;
  15128. /**
  15129. * Object will rotate to face the camera's position instead of orientation
  15130. */
  15131. static BILLBOARDMODE_USE_POSITION: number;
  15132. private static _TmpRotation;
  15133. private static _TmpScaling;
  15134. private static _TmpTranslation;
  15135. private _forward;
  15136. private _forwardInverted;
  15137. private _up;
  15138. private _right;
  15139. private _rightInverted;
  15140. private _position;
  15141. private _rotation;
  15142. private _rotationQuaternion;
  15143. protected _scaling: Vector3;
  15144. protected _isDirty: boolean;
  15145. private _transformToBoneReferal;
  15146. private _isAbsoluteSynced;
  15147. private _billboardMode;
  15148. /**
  15149. * Gets or sets the billboard mode. Default is 0.
  15150. *
  15151. * | Value | Type | Description |
  15152. * | --- | --- | --- |
  15153. * | 0 | BILLBOARDMODE_NONE | |
  15154. * | 1 | BILLBOARDMODE_X | |
  15155. * | 2 | BILLBOARDMODE_Y | |
  15156. * | 4 | BILLBOARDMODE_Z | |
  15157. * | 7 | BILLBOARDMODE_ALL | |
  15158. *
  15159. */
  15160. get billboardMode(): number;
  15161. set billboardMode(value: number);
  15162. private _preserveParentRotationForBillboard;
  15163. /**
  15164. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15165. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15166. */
  15167. get preserveParentRotationForBillboard(): boolean;
  15168. set preserveParentRotationForBillboard(value: boolean);
  15169. /**
  15170. * 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
  15171. */
  15172. scalingDeterminant: number;
  15173. private _infiniteDistance;
  15174. /**
  15175. * Gets or sets the distance of the object to max, often used by skybox
  15176. */
  15177. get infiniteDistance(): boolean;
  15178. set infiniteDistance(value: boolean);
  15179. /**
  15180. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15181. * By default the system will update normals to compensate
  15182. */
  15183. ignoreNonUniformScaling: boolean;
  15184. /**
  15185. * 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
  15186. */
  15187. reIntegrateRotationIntoRotationQuaternion: boolean;
  15188. /** @hidden */
  15189. _poseMatrix: Nullable<Matrix>;
  15190. /** @hidden */
  15191. _localMatrix: Matrix;
  15192. private _usePivotMatrix;
  15193. private _absolutePosition;
  15194. private _absoluteScaling;
  15195. private _absoluteRotationQuaternion;
  15196. private _pivotMatrix;
  15197. private _pivotMatrixInverse;
  15198. /** @hidden */
  15199. _postMultiplyPivotMatrix: boolean;
  15200. protected _isWorldMatrixFrozen: boolean;
  15201. /** @hidden */
  15202. _indexInSceneTransformNodesArray: number;
  15203. /**
  15204. * An event triggered after the world matrix is updated
  15205. */
  15206. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15207. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15208. /**
  15209. * Gets a string identifying the name of the class
  15210. * @returns "TransformNode" string
  15211. */
  15212. getClassName(): string;
  15213. /**
  15214. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15215. */
  15216. get position(): Vector3;
  15217. set position(newPosition: Vector3);
  15218. /**
  15219. * 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)).
  15220. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15221. */
  15222. get rotation(): Vector3;
  15223. set rotation(newRotation: Vector3);
  15224. /**
  15225. * 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)).
  15226. */
  15227. get scaling(): Vector3;
  15228. set scaling(newScaling: Vector3);
  15229. /**
  15230. * 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).
  15231. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15232. */
  15233. get rotationQuaternion(): Nullable<Quaternion>;
  15234. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15235. /**
  15236. * The forward direction of that transform in world space.
  15237. */
  15238. get forward(): Vector3;
  15239. /**
  15240. * The up direction of that transform in world space.
  15241. */
  15242. get up(): Vector3;
  15243. /**
  15244. * The right direction of that transform in world space.
  15245. */
  15246. get right(): Vector3;
  15247. /**
  15248. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15249. * @param matrix the matrix to copy the pose from
  15250. * @returns this TransformNode.
  15251. */
  15252. updatePoseMatrix(matrix: Matrix): TransformNode;
  15253. /**
  15254. * Returns the mesh Pose matrix.
  15255. * @returns the pose matrix
  15256. */
  15257. getPoseMatrix(): Matrix;
  15258. /** @hidden */
  15259. _isSynchronized(): boolean;
  15260. /** @hidden */
  15261. _initCache(): void;
  15262. /**
  15263. * Flag the transform node as dirty (Forcing it to update everything)
  15264. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15265. * @returns this transform node
  15266. */
  15267. markAsDirty(property: string): TransformNode;
  15268. /**
  15269. * Returns the current mesh absolute position.
  15270. * Returns a Vector3.
  15271. */
  15272. get absolutePosition(): Vector3;
  15273. /**
  15274. * Returns the current mesh absolute scaling.
  15275. * Returns a Vector3.
  15276. */
  15277. get absoluteScaling(): Vector3;
  15278. /**
  15279. * Returns the current mesh absolute rotation.
  15280. * Returns a Quaternion.
  15281. */
  15282. get absoluteRotationQuaternion(): Quaternion;
  15283. /**
  15284. * Sets a new matrix to apply before all other transformation
  15285. * @param matrix defines the transform matrix
  15286. * @returns the current TransformNode
  15287. */
  15288. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15289. /**
  15290. * Sets a new pivot matrix to the current node
  15291. * @param matrix defines the new pivot matrix to use
  15292. * @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
  15293. * @returns the current TransformNode
  15294. */
  15295. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15296. /**
  15297. * Returns the mesh pivot matrix.
  15298. * Default : Identity.
  15299. * @returns the matrix
  15300. */
  15301. getPivotMatrix(): Matrix;
  15302. /**
  15303. * Instantiate (when possible) or clone that node with its hierarchy
  15304. * @param newParent defines the new parent to use for the instance (or clone)
  15305. * @param options defines options to configure how copy is done
  15306. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15307. * @returns an instance (or a clone) of the current node with its hiearchy
  15308. */
  15309. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15310. doNotInstantiate: boolean;
  15311. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15312. /**
  15313. * Prevents the World matrix to be computed any longer
  15314. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15315. * @returns the TransformNode.
  15316. */
  15317. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15318. /**
  15319. * Allows back the World matrix computation.
  15320. * @returns the TransformNode.
  15321. */
  15322. unfreezeWorldMatrix(): this;
  15323. /**
  15324. * True if the World matrix has been frozen.
  15325. */
  15326. get isWorldMatrixFrozen(): boolean;
  15327. /**
  15328. * Retuns the mesh absolute position in the World.
  15329. * @returns a Vector3.
  15330. */
  15331. getAbsolutePosition(): Vector3;
  15332. /**
  15333. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15334. * @param absolutePosition the absolute position to set
  15335. * @returns the TransformNode.
  15336. */
  15337. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15338. /**
  15339. * Sets the mesh position in its local space.
  15340. * @param vector3 the position to set in localspace
  15341. * @returns the TransformNode.
  15342. */
  15343. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15344. /**
  15345. * Returns the mesh position in the local space from the current World matrix values.
  15346. * @returns a new Vector3.
  15347. */
  15348. getPositionExpressedInLocalSpace(): Vector3;
  15349. /**
  15350. * Translates the mesh along the passed Vector3 in its local space.
  15351. * @param vector3 the distance to translate in localspace
  15352. * @returns the TransformNode.
  15353. */
  15354. locallyTranslate(vector3: Vector3): TransformNode;
  15355. private static _lookAtVectorCache;
  15356. /**
  15357. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15358. * @param targetPoint the position (must be in same space as current mesh) to look at
  15359. * @param yawCor optional yaw (y-axis) correction in radians
  15360. * @param pitchCor optional pitch (x-axis) correction in radians
  15361. * @param rollCor optional roll (z-axis) correction in radians
  15362. * @param space the choosen space of the target
  15363. * @returns the TransformNode.
  15364. */
  15365. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15366. /**
  15367. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15368. * This Vector3 is expressed in the World space.
  15369. * @param localAxis axis to rotate
  15370. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15371. */
  15372. getDirection(localAxis: Vector3): Vector3;
  15373. /**
  15374. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15375. * localAxis is expressed in the mesh local space.
  15376. * result is computed in the Wordl space from the mesh World matrix.
  15377. * @param localAxis axis to rotate
  15378. * @param result the resulting transformnode
  15379. * @returns this TransformNode.
  15380. */
  15381. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15382. /**
  15383. * Sets this transform node rotation to the given local axis.
  15384. * @param localAxis the axis in local space
  15385. * @param yawCor optional yaw (y-axis) correction in radians
  15386. * @param pitchCor optional pitch (x-axis) correction in radians
  15387. * @param rollCor optional roll (z-axis) correction in radians
  15388. * @returns this TransformNode
  15389. */
  15390. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15391. /**
  15392. * Sets a new pivot point to the current node
  15393. * @param point defines the new pivot point to use
  15394. * @param space defines if the point is in world or local space (local by default)
  15395. * @returns the current TransformNode
  15396. */
  15397. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15398. /**
  15399. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15400. * @returns the pivot point
  15401. */
  15402. getPivotPoint(): Vector3;
  15403. /**
  15404. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15405. * @param result the vector3 to store the result
  15406. * @returns this TransformNode.
  15407. */
  15408. getPivotPointToRef(result: Vector3): TransformNode;
  15409. /**
  15410. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15411. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15412. */
  15413. getAbsolutePivotPoint(): Vector3;
  15414. /**
  15415. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15416. * @param result vector3 to store the result
  15417. * @returns this TransformNode.
  15418. */
  15419. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15420. /**
  15421. * Defines the passed node as the parent of the current node.
  15422. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15423. * @see https://doc.babylonjs.com/how_to/parenting
  15424. * @param node the node ot set as the parent
  15425. * @returns this TransformNode.
  15426. */
  15427. setParent(node: Nullable<Node>): TransformNode;
  15428. private _nonUniformScaling;
  15429. /**
  15430. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15431. */
  15432. get nonUniformScaling(): boolean;
  15433. /** @hidden */
  15434. _updateNonUniformScalingState(value: boolean): boolean;
  15435. /**
  15436. * Attach the current TransformNode to another TransformNode associated with a bone
  15437. * @param bone Bone affecting the TransformNode
  15438. * @param affectedTransformNode TransformNode associated with the bone
  15439. * @returns this object
  15440. */
  15441. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15442. /**
  15443. * Detach the transform node if its associated with a bone
  15444. * @returns this object
  15445. */
  15446. detachFromBone(): TransformNode;
  15447. private static _rotationAxisCache;
  15448. /**
  15449. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15450. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15451. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15452. * The passed axis is also normalized.
  15453. * @param axis the axis to rotate around
  15454. * @param amount the amount to rotate in radians
  15455. * @param space Space to rotate in (Default: local)
  15456. * @returns the TransformNode.
  15457. */
  15458. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15459. /**
  15460. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15461. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15462. * The passed axis is also normalized. .
  15463. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15464. * @param point the point to rotate around
  15465. * @param axis the axis to rotate around
  15466. * @param amount the amount to rotate in radians
  15467. * @returns the TransformNode
  15468. */
  15469. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15470. /**
  15471. * Translates the mesh along the axis vector for the passed distance in the given space.
  15472. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15473. * @param axis the axis to translate in
  15474. * @param distance the distance to translate
  15475. * @param space Space to rotate in (Default: local)
  15476. * @returns the TransformNode.
  15477. */
  15478. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15479. /**
  15480. * Adds a rotation step to the mesh current rotation.
  15481. * x, y, z are Euler angles expressed in radians.
  15482. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15483. * This means this rotation is made in the mesh local space only.
  15484. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15485. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15486. * ```javascript
  15487. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15488. * ```
  15489. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15490. * 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.
  15491. * @param x Rotation to add
  15492. * @param y Rotation to add
  15493. * @param z Rotation to add
  15494. * @returns the TransformNode.
  15495. */
  15496. addRotation(x: number, y: number, z: number): TransformNode;
  15497. /**
  15498. * @hidden
  15499. */
  15500. protected _getEffectiveParent(): Nullable<Node>;
  15501. /**
  15502. * Computes the world matrix of the node
  15503. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15504. * @returns the world matrix
  15505. */
  15506. computeWorldMatrix(force?: boolean): Matrix;
  15507. /**
  15508. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15509. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15510. */
  15511. resetLocalMatrix(independentOfChildren?: boolean): void;
  15512. protected _afterComputeWorldMatrix(): void;
  15513. /**
  15514. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15515. * @param func callback function to add
  15516. *
  15517. * @returns the TransformNode.
  15518. */
  15519. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15520. /**
  15521. * Removes a registered callback function.
  15522. * @param func callback function to remove
  15523. * @returns the TransformNode.
  15524. */
  15525. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15526. /**
  15527. * Gets the position of the current mesh in camera space
  15528. * @param camera defines the camera to use
  15529. * @returns a position
  15530. */
  15531. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15532. /**
  15533. * Returns the distance from the mesh to the active camera
  15534. * @param camera defines the camera to use
  15535. * @returns the distance
  15536. */
  15537. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15538. /**
  15539. * Clone the current transform node
  15540. * @param name Name of the new clone
  15541. * @param newParent New parent for the clone
  15542. * @param doNotCloneChildren Do not clone children hierarchy
  15543. * @returns the new transform node
  15544. */
  15545. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15546. /**
  15547. * Serializes the objects information.
  15548. * @param currentSerializationObject defines the object to serialize in
  15549. * @returns the serialized object
  15550. */
  15551. serialize(currentSerializationObject?: any): any;
  15552. /**
  15553. * Returns a new TransformNode object parsed from the source provided.
  15554. * @param parsedTransformNode is the source.
  15555. * @param scene the scne the object belongs to
  15556. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15557. * @returns a new TransformNode object parsed from the source provided.
  15558. */
  15559. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15560. /**
  15561. * Get all child-transformNodes of this node
  15562. * @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
  15563. * @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
  15564. * @returns an array of TransformNode
  15565. */
  15566. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15567. /**
  15568. * Releases resources associated with this transform node.
  15569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15571. */
  15572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15573. /**
  15574. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15575. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15576. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15577. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15578. * @returns the current mesh
  15579. */
  15580. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15581. private _syncAbsoluteScalingAndRotation;
  15582. }
  15583. }
  15584. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15585. /**
  15586. * Class used to override all child animations of a given target
  15587. */
  15588. export class AnimationPropertiesOverride {
  15589. /**
  15590. * Gets or sets a value indicating if animation blending must be used
  15591. */
  15592. enableBlending: boolean;
  15593. /**
  15594. * Gets or sets the blending speed to use when enableBlending is true
  15595. */
  15596. blendingSpeed: number;
  15597. /**
  15598. * Gets or sets the default loop mode to use
  15599. */
  15600. loopMode: number;
  15601. }
  15602. }
  15603. declare module "babylonjs/Bones/bone" {
  15604. import { Skeleton } from "babylonjs/Bones/skeleton";
  15605. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15606. import { Nullable } from "babylonjs/types";
  15607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15608. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15609. import { Node } from "babylonjs/node";
  15610. import { Space } from "babylonjs/Maths/math.axis";
  15611. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15612. /**
  15613. * Class used to store bone information
  15614. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15615. */
  15616. export class Bone extends Node {
  15617. /**
  15618. * defines the bone name
  15619. */
  15620. name: string;
  15621. private static _tmpVecs;
  15622. private static _tmpQuat;
  15623. private static _tmpMats;
  15624. /**
  15625. * Gets the list of child bones
  15626. */
  15627. children: Bone[];
  15628. /** Gets the animations associated with this bone */
  15629. animations: import("babylonjs/Animations/animation").Animation[];
  15630. /**
  15631. * Gets or sets bone length
  15632. */
  15633. length: number;
  15634. /**
  15635. * @hidden Internal only
  15636. * Set this value to map this bone to a different index in the transform matrices
  15637. * Set this value to -1 to exclude the bone from the transform matrices
  15638. */
  15639. _index: Nullable<number>;
  15640. private _skeleton;
  15641. private _localMatrix;
  15642. private _restPose;
  15643. private _bindPose;
  15644. private _baseMatrix;
  15645. private _absoluteTransform;
  15646. private _invertedAbsoluteTransform;
  15647. private _parent;
  15648. private _scalingDeterminant;
  15649. private _worldTransform;
  15650. private _localScaling;
  15651. private _localRotation;
  15652. private _localPosition;
  15653. private _needToDecompose;
  15654. private _needToCompose;
  15655. /** @hidden */
  15656. _linkedTransformNode: Nullable<TransformNode>;
  15657. /** @hidden */
  15658. _waitingTransformNodeId: Nullable<string>;
  15659. /** @hidden */
  15660. get _matrix(): Matrix;
  15661. /** @hidden */
  15662. set _matrix(value: Matrix);
  15663. /**
  15664. * Create a new bone
  15665. * @param name defines the bone name
  15666. * @param skeleton defines the parent skeleton
  15667. * @param parentBone defines the parent (can be null if the bone is the root)
  15668. * @param localMatrix defines the local matrix
  15669. * @param restPose defines the rest pose matrix
  15670. * @param baseMatrix defines the base matrix
  15671. * @param index defines index of the bone in the hiearchy
  15672. */
  15673. constructor(
  15674. /**
  15675. * defines the bone name
  15676. */
  15677. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15678. /**
  15679. * Gets the current object class name.
  15680. * @return the class name
  15681. */
  15682. getClassName(): string;
  15683. /**
  15684. * Gets the parent skeleton
  15685. * @returns a skeleton
  15686. */
  15687. getSkeleton(): Skeleton;
  15688. /**
  15689. * Gets parent bone
  15690. * @returns a bone or null if the bone is the root of the bone hierarchy
  15691. */
  15692. getParent(): Nullable<Bone>;
  15693. /**
  15694. * Returns an array containing the root bones
  15695. * @returns an array containing the root bones
  15696. */
  15697. getChildren(): Array<Bone>;
  15698. /**
  15699. * Gets the node index in matrix array generated for rendering
  15700. * @returns the node index
  15701. */
  15702. getIndex(): number;
  15703. /**
  15704. * Sets the parent bone
  15705. * @param parent defines the parent (can be null if the bone is the root)
  15706. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15707. */
  15708. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15709. /**
  15710. * Gets the local matrix
  15711. * @returns a matrix
  15712. */
  15713. getLocalMatrix(): Matrix;
  15714. /**
  15715. * Gets the base matrix (initial matrix which remains unchanged)
  15716. * @returns a matrix
  15717. */
  15718. getBaseMatrix(): Matrix;
  15719. /**
  15720. * Gets the rest pose matrix
  15721. * @returns a matrix
  15722. */
  15723. getRestPose(): Matrix;
  15724. /**
  15725. * Sets the rest pose matrix
  15726. * @param matrix the local-space rest pose to set for this bone
  15727. */
  15728. setRestPose(matrix: Matrix): void;
  15729. /**
  15730. * Gets the bind pose matrix
  15731. * @returns the bind pose matrix
  15732. */
  15733. getBindPose(): Matrix;
  15734. /**
  15735. * Sets the bind pose matrix
  15736. * @param matrix the local-space bind pose to set for this bone
  15737. */
  15738. setBindPose(matrix: Matrix): void;
  15739. /**
  15740. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15741. */
  15742. getWorldMatrix(): Matrix;
  15743. /**
  15744. * Sets the local matrix to rest pose matrix
  15745. */
  15746. returnToRest(): void;
  15747. /**
  15748. * Gets the inverse of the absolute transform matrix.
  15749. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15750. * @returns a matrix
  15751. */
  15752. getInvertedAbsoluteTransform(): Matrix;
  15753. /**
  15754. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15755. * @returns a matrix
  15756. */
  15757. getAbsoluteTransform(): Matrix;
  15758. /**
  15759. * Links with the given transform node.
  15760. * The local matrix of this bone is copied from the transform node every frame.
  15761. * @param transformNode defines the transform node to link to
  15762. */
  15763. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15764. /**
  15765. * Gets the node used to drive the bone's transformation
  15766. * @returns a transform node or null
  15767. */
  15768. getTransformNode(): Nullable<TransformNode>;
  15769. /** Gets or sets current position (in local space) */
  15770. get position(): Vector3;
  15771. set position(newPosition: Vector3);
  15772. /** Gets or sets current rotation (in local space) */
  15773. get rotation(): Vector3;
  15774. set rotation(newRotation: Vector3);
  15775. /** Gets or sets current rotation quaternion (in local space) */
  15776. get rotationQuaternion(): Quaternion;
  15777. set rotationQuaternion(newRotation: Quaternion);
  15778. /** Gets or sets current scaling (in local space) */
  15779. get scaling(): Vector3;
  15780. set scaling(newScaling: Vector3);
  15781. /**
  15782. * Gets the animation properties override
  15783. */
  15784. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15785. private _decompose;
  15786. private _compose;
  15787. /**
  15788. * Update the base and local matrices
  15789. * @param matrix defines the new base or local matrix
  15790. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15791. * @param updateLocalMatrix defines if the local matrix should be updated
  15792. */
  15793. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15794. /** @hidden */
  15795. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15796. /**
  15797. * Flag the bone as dirty (Forcing it to update everything)
  15798. */
  15799. markAsDirty(): void;
  15800. /** @hidden */
  15801. _markAsDirtyAndCompose(): void;
  15802. private _markAsDirtyAndDecompose;
  15803. /**
  15804. * Translate the bone in local or world space
  15805. * @param vec The amount to translate the bone
  15806. * @param space The space that the translation is in
  15807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15808. */
  15809. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15810. /**
  15811. * Set the postion of the bone in local or world space
  15812. * @param position The position to set the bone
  15813. * @param space The space that the position is in
  15814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15815. */
  15816. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15817. /**
  15818. * Set the absolute position of the bone (world space)
  15819. * @param position The position to set the bone
  15820. * @param mesh The mesh that this bone is attached to
  15821. */
  15822. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15823. /**
  15824. * Scale the bone on the x, y and z axes (in local space)
  15825. * @param x The amount to scale the bone on the x axis
  15826. * @param y The amount to scale the bone on the y axis
  15827. * @param z The amount to scale the bone on the z axis
  15828. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15829. */
  15830. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15831. /**
  15832. * Set the bone scaling in local space
  15833. * @param scale defines the scaling vector
  15834. */
  15835. setScale(scale: Vector3): void;
  15836. /**
  15837. * Gets the current scaling in local space
  15838. * @returns the current scaling vector
  15839. */
  15840. getScale(): Vector3;
  15841. /**
  15842. * Gets the current scaling in local space and stores it in a target vector
  15843. * @param result defines the target vector
  15844. */
  15845. getScaleToRef(result: Vector3): void;
  15846. /**
  15847. * Set the yaw, pitch, and roll of the bone in local or world space
  15848. * @param yaw The rotation of the bone on the y axis
  15849. * @param pitch The rotation of the bone on the x axis
  15850. * @param roll The rotation of the bone on the z axis
  15851. * @param space The space that the axes of rotation are in
  15852. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15853. */
  15854. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15855. /**
  15856. * Add a rotation to the bone on an axis in local or world space
  15857. * @param axis The axis to rotate the bone on
  15858. * @param amount The amount to rotate the bone
  15859. * @param space The space that the axis is in
  15860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15861. */
  15862. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15863. /**
  15864. * Set the rotation of the bone to a particular axis angle in local or world space
  15865. * @param axis The axis to rotate the bone on
  15866. * @param angle The angle that the bone should be rotated to
  15867. * @param space The space that the axis is in
  15868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15869. */
  15870. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15871. /**
  15872. * Set the euler rotation of the bone in local or world space
  15873. * @param rotation The euler rotation that the bone should be set to
  15874. * @param space The space that the rotation is in
  15875. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15876. */
  15877. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15878. /**
  15879. * Set the quaternion rotation of the bone in local or world space
  15880. * @param quat The quaternion rotation that the bone should be set to
  15881. * @param space The space that the rotation is in
  15882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15883. */
  15884. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15885. /**
  15886. * Set the rotation matrix of the bone in local or world space
  15887. * @param rotMat The rotation matrix that the bone should be set to
  15888. * @param space The space that the rotation is in
  15889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15890. */
  15891. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15892. private _rotateWithMatrix;
  15893. private _getNegativeRotationToRef;
  15894. /**
  15895. * Get the position of the bone in local or world space
  15896. * @param space The space that the returned position is in
  15897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15898. * @returns The position of the bone
  15899. */
  15900. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15901. /**
  15902. * Copy the position of the bone to a vector3 in local or world space
  15903. * @param space The space that the returned position is in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @param result The vector3 to copy the position to
  15906. */
  15907. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15908. /**
  15909. * Get the absolute position of the bone (world space)
  15910. * @param mesh The mesh that this bone is attached to
  15911. * @returns The absolute position of the bone
  15912. */
  15913. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15914. /**
  15915. * Copy the absolute position of the bone (world space) to the result param
  15916. * @param mesh The mesh that this bone is attached to
  15917. * @param result The vector3 to copy the absolute position to
  15918. */
  15919. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15920. /**
  15921. * Compute the absolute transforms of this bone and its children
  15922. */
  15923. computeAbsoluteTransforms(): void;
  15924. /**
  15925. * Get the world direction from an axis that is in the local space of the bone
  15926. * @param localAxis The local direction that is used to compute the world direction
  15927. * @param mesh The mesh that this bone is attached to
  15928. * @returns The world direction
  15929. */
  15930. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15931. /**
  15932. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15933. * @param localAxis The local direction that is used to compute the world direction
  15934. * @param mesh The mesh that this bone is attached to
  15935. * @param result The vector3 that the world direction will be copied to
  15936. */
  15937. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15938. /**
  15939. * Get the euler rotation of the bone in local or world space
  15940. * @param space The space that the rotation should be in
  15941. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15942. * @returns The euler rotation
  15943. */
  15944. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15945. /**
  15946. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15947. * @param space The space that the rotation should be in
  15948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15949. * @param result The vector3 that the rotation should be copied to
  15950. */
  15951. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15952. /**
  15953. * Get the quaternion rotation of the bone in either local or world space
  15954. * @param space The space that the rotation should be in
  15955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15956. * @returns The quaternion rotation
  15957. */
  15958. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15959. /**
  15960. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15961. * @param space The space that the rotation should be in
  15962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15963. * @param result The quaternion that the rotation should be copied to
  15964. */
  15965. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15966. /**
  15967. * Get the rotation matrix of the bone in local or world space
  15968. * @param space The space that the rotation should be in
  15969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15970. * @returns The rotation matrix
  15971. */
  15972. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15973. /**
  15974. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15975. * @param space The space that the rotation should be in
  15976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15977. * @param result The quaternion that the rotation should be copied to
  15978. */
  15979. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15980. /**
  15981. * Get the world position of a point that is in the local space of the bone
  15982. * @param position The local position
  15983. * @param mesh The mesh that this bone is attached to
  15984. * @returns The world position
  15985. */
  15986. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15987. /**
  15988. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15989. * @param position The local position
  15990. * @param mesh The mesh that this bone is attached to
  15991. * @param result The vector3 that the world position should be copied to
  15992. */
  15993. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15994. /**
  15995. * Get the local position of a point that is in world space
  15996. * @param position The world position
  15997. * @param mesh The mesh that this bone is attached to
  15998. * @returns The local position
  15999. */
  16000. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16001. /**
  16002. * Get the local position of a point that is in world space and copy it to the result param
  16003. * @param position The world position
  16004. * @param mesh The mesh that this bone is attached to
  16005. * @param result The vector3 that the local position should be copied to
  16006. */
  16007. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16008. /**
  16009. * Set the current local matrix as the restPose for this bone.
  16010. */
  16011. setCurrentPoseAsRest(): void;
  16012. }
  16013. }
  16014. declare module "babylonjs/Animations/runtimeAnimation" {
  16015. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16016. import { Animatable } from "babylonjs/Animations/animatable";
  16017. import { Scene } from "babylonjs/scene";
  16018. /**
  16019. * Defines a runtime animation
  16020. */
  16021. export class RuntimeAnimation {
  16022. private _events;
  16023. /**
  16024. * The current frame of the runtime animation
  16025. */
  16026. private _currentFrame;
  16027. /**
  16028. * The animation used by the runtime animation
  16029. */
  16030. private _animation;
  16031. /**
  16032. * The target of the runtime animation
  16033. */
  16034. private _target;
  16035. /**
  16036. * The initiating animatable
  16037. */
  16038. private _host;
  16039. /**
  16040. * The original value of the runtime animation
  16041. */
  16042. private _originalValue;
  16043. /**
  16044. * The original blend value of the runtime animation
  16045. */
  16046. private _originalBlendValue;
  16047. /**
  16048. * The offsets cache of the runtime animation
  16049. */
  16050. private _offsetsCache;
  16051. /**
  16052. * The high limits cache of the runtime animation
  16053. */
  16054. private _highLimitsCache;
  16055. /**
  16056. * Specifies if the runtime animation has been stopped
  16057. */
  16058. private _stopped;
  16059. /**
  16060. * The blending factor of the runtime animation
  16061. */
  16062. private _blendingFactor;
  16063. /**
  16064. * The BabylonJS scene
  16065. */
  16066. private _scene;
  16067. /**
  16068. * The current value of the runtime animation
  16069. */
  16070. private _currentValue;
  16071. /** @hidden */
  16072. _animationState: _IAnimationState;
  16073. /**
  16074. * The active target of the runtime animation
  16075. */
  16076. private _activeTargets;
  16077. private _currentActiveTarget;
  16078. private _directTarget;
  16079. /**
  16080. * The target path of the runtime animation
  16081. */
  16082. private _targetPath;
  16083. /**
  16084. * The weight of the runtime animation
  16085. */
  16086. private _weight;
  16087. /**
  16088. * The ratio offset of the runtime animation
  16089. */
  16090. private _ratioOffset;
  16091. /**
  16092. * The previous delay of the runtime animation
  16093. */
  16094. private _previousDelay;
  16095. /**
  16096. * The previous ratio of the runtime animation
  16097. */
  16098. private _previousRatio;
  16099. private _enableBlending;
  16100. private _keys;
  16101. private _minFrame;
  16102. private _maxFrame;
  16103. private _minValue;
  16104. private _maxValue;
  16105. private _targetIsArray;
  16106. /**
  16107. * Gets the current frame of the runtime animation
  16108. */
  16109. get currentFrame(): number;
  16110. /**
  16111. * Gets the weight of the runtime animation
  16112. */
  16113. get weight(): number;
  16114. /**
  16115. * Gets the current value of the runtime animation
  16116. */
  16117. get currentValue(): any;
  16118. /**
  16119. * Gets the target path of the runtime animation
  16120. */
  16121. get targetPath(): string;
  16122. /**
  16123. * Gets the actual target of the runtime animation
  16124. */
  16125. get target(): any;
  16126. /**
  16127. * Gets the additive state of the runtime animation
  16128. */
  16129. get isAdditive(): boolean;
  16130. /** @hidden */
  16131. _onLoop: () => void;
  16132. /**
  16133. * Create a new RuntimeAnimation object
  16134. * @param target defines the target of the animation
  16135. * @param animation defines the source animation object
  16136. * @param scene defines the hosting scene
  16137. * @param host defines the initiating Animatable
  16138. */
  16139. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16140. private _preparePath;
  16141. /**
  16142. * Gets the animation from the runtime animation
  16143. */
  16144. get animation(): Animation;
  16145. /**
  16146. * Resets the runtime animation to the beginning
  16147. * @param restoreOriginal defines whether to restore the target property to the original value
  16148. */
  16149. reset(restoreOriginal?: boolean): void;
  16150. /**
  16151. * Specifies if the runtime animation is stopped
  16152. * @returns Boolean specifying if the runtime animation is stopped
  16153. */
  16154. isStopped(): boolean;
  16155. /**
  16156. * Disposes of the runtime animation
  16157. */
  16158. dispose(): void;
  16159. /**
  16160. * Apply the interpolated value to the target
  16161. * @param currentValue defines the value computed by the animation
  16162. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16163. */
  16164. setValue(currentValue: any, weight: number): void;
  16165. private _getOriginalValues;
  16166. private _setValue;
  16167. /**
  16168. * Gets the loop pmode of the runtime animation
  16169. * @returns Loop Mode
  16170. */
  16171. private _getCorrectLoopMode;
  16172. /**
  16173. * Move the current animation to a given frame
  16174. * @param frame defines the frame to move to
  16175. */
  16176. goToFrame(frame: number): void;
  16177. /**
  16178. * @hidden Internal use only
  16179. */
  16180. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16181. /**
  16182. * Execute the current animation
  16183. * @param delay defines the delay to add to the current frame
  16184. * @param from defines the lower bound of the animation range
  16185. * @param to defines the upper bound of the animation range
  16186. * @param loop defines if the current animation must loop
  16187. * @param speedRatio defines the current speed ratio
  16188. * @param weight defines the weight of the animation (default is -1 so no weight)
  16189. * @param onLoop optional callback called when animation loops
  16190. * @returns a boolean indicating if the animation is running
  16191. */
  16192. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16193. }
  16194. }
  16195. declare module "babylonjs/Animations/animatable" {
  16196. import { Animation } from "babylonjs/Animations/animation";
  16197. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16198. import { Nullable } from "babylonjs/types";
  16199. import { Observable } from "babylonjs/Misc/observable";
  16200. import { Scene } from "babylonjs/scene";
  16201. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16202. import { Node } from "babylonjs/node";
  16203. /**
  16204. * Class used to store an actual running animation
  16205. */
  16206. export class Animatable {
  16207. /** defines the target object */
  16208. target: any;
  16209. /** defines the starting frame number (default is 0) */
  16210. fromFrame: number;
  16211. /** defines the ending frame number (default is 100) */
  16212. toFrame: number;
  16213. /** defines if the animation must loop (default is false) */
  16214. loopAnimation: boolean;
  16215. /** defines a callback to call when animation ends if it is not looping */
  16216. onAnimationEnd?: (() => void) | null | undefined;
  16217. /** defines a callback to call when animation loops */
  16218. onAnimationLoop?: (() => void) | null | undefined;
  16219. /** defines whether the animation should be evaluated additively */
  16220. isAdditive: boolean;
  16221. private _localDelayOffset;
  16222. private _pausedDelay;
  16223. private _runtimeAnimations;
  16224. private _paused;
  16225. private _scene;
  16226. private _speedRatio;
  16227. private _weight;
  16228. private _syncRoot;
  16229. /**
  16230. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16231. * This will only apply for non looping animation (default is true)
  16232. */
  16233. disposeOnEnd: boolean;
  16234. /**
  16235. * Gets a boolean indicating if the animation has started
  16236. */
  16237. animationStarted: boolean;
  16238. /**
  16239. * Observer raised when the animation ends
  16240. */
  16241. onAnimationEndObservable: Observable<Animatable>;
  16242. /**
  16243. * Observer raised when the animation loops
  16244. */
  16245. onAnimationLoopObservable: Observable<Animatable>;
  16246. /**
  16247. * Gets the root Animatable used to synchronize and normalize animations
  16248. */
  16249. get syncRoot(): Nullable<Animatable>;
  16250. /**
  16251. * Gets the current frame of the first RuntimeAnimation
  16252. * Used to synchronize Animatables
  16253. */
  16254. get masterFrame(): number;
  16255. /**
  16256. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16257. */
  16258. get weight(): number;
  16259. set weight(value: number);
  16260. /**
  16261. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16262. */
  16263. get speedRatio(): number;
  16264. set speedRatio(value: number);
  16265. /**
  16266. * Creates a new Animatable
  16267. * @param scene defines the hosting scene
  16268. * @param target defines the target object
  16269. * @param fromFrame defines the starting frame number (default is 0)
  16270. * @param toFrame defines the ending frame number (default is 100)
  16271. * @param loopAnimation defines if the animation must loop (default is false)
  16272. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16273. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16274. * @param animations defines a group of animation to add to the new Animatable
  16275. * @param onAnimationLoop defines a callback to call when animation loops
  16276. * @param isAdditive defines whether the animation should be evaluated additively
  16277. */
  16278. constructor(scene: Scene,
  16279. /** defines the target object */
  16280. target: any,
  16281. /** defines the starting frame number (default is 0) */
  16282. fromFrame?: number,
  16283. /** defines the ending frame number (default is 100) */
  16284. toFrame?: number,
  16285. /** defines if the animation must loop (default is false) */
  16286. loopAnimation?: boolean, speedRatio?: number,
  16287. /** defines a callback to call when animation ends if it is not looping */
  16288. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16289. /** defines a callback to call when animation loops */
  16290. onAnimationLoop?: (() => void) | null | undefined,
  16291. /** defines whether the animation should be evaluated additively */
  16292. isAdditive?: boolean);
  16293. /**
  16294. * Synchronize and normalize current Animatable with a source Animatable
  16295. * This is useful when using animation weights and when animations are not of the same length
  16296. * @param root defines the root Animatable to synchronize with
  16297. * @returns the current Animatable
  16298. */
  16299. syncWith(root: Animatable): Animatable;
  16300. /**
  16301. * Gets the list of runtime animations
  16302. * @returns an array of RuntimeAnimation
  16303. */
  16304. getAnimations(): RuntimeAnimation[];
  16305. /**
  16306. * Adds more animations to the current animatable
  16307. * @param target defines the target of the animations
  16308. * @param animations defines the new animations to add
  16309. */
  16310. appendAnimations(target: any, animations: Animation[]): void;
  16311. /**
  16312. * Gets the source animation for a specific property
  16313. * @param property defines the propertyu to look for
  16314. * @returns null or the source animation for the given property
  16315. */
  16316. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16317. /**
  16318. * Gets the runtime animation for a specific property
  16319. * @param property defines the propertyu to look for
  16320. * @returns null or the runtime animation for the given property
  16321. */
  16322. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16323. /**
  16324. * Resets the animatable to its original state
  16325. */
  16326. reset(): void;
  16327. /**
  16328. * Allows the animatable to blend with current running animations
  16329. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16330. * @param blendingSpeed defines the blending speed to use
  16331. */
  16332. enableBlending(blendingSpeed: number): void;
  16333. /**
  16334. * Disable animation blending
  16335. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16336. */
  16337. disableBlending(): void;
  16338. /**
  16339. * Jump directly to a given frame
  16340. * @param frame defines the frame to jump to
  16341. */
  16342. goToFrame(frame: number): void;
  16343. /**
  16344. * Pause the animation
  16345. */
  16346. pause(): void;
  16347. /**
  16348. * Restart the animation
  16349. */
  16350. restart(): void;
  16351. private _raiseOnAnimationEnd;
  16352. /**
  16353. * Stop and delete the current animation
  16354. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16355. * @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)
  16356. */
  16357. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16358. /**
  16359. * Wait asynchronously for the animation to end
  16360. * @returns a promise which will be fullfilled when the animation ends
  16361. */
  16362. waitAsync(): Promise<Animatable>;
  16363. /** @hidden */
  16364. _animate(delay: number): boolean;
  16365. }
  16366. module "babylonjs/scene" {
  16367. interface Scene {
  16368. /** @hidden */
  16369. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16370. /** @hidden */
  16371. _processLateAnimationBindingsForMatrices(holder: {
  16372. totalWeight: number;
  16373. totalAdditiveWeight: number;
  16374. animations: RuntimeAnimation[];
  16375. additiveAnimations: RuntimeAnimation[];
  16376. originalValue: Matrix;
  16377. }): any;
  16378. /** @hidden */
  16379. _processLateAnimationBindingsForQuaternions(holder: {
  16380. totalWeight: number;
  16381. totalAdditiveWeight: number;
  16382. animations: RuntimeAnimation[];
  16383. additiveAnimations: RuntimeAnimation[];
  16384. originalValue: Quaternion;
  16385. }, refQuaternion: Quaternion): Quaternion;
  16386. /** @hidden */
  16387. _processLateAnimationBindings(): void;
  16388. /**
  16389. * Will start the animation sequence of a given target
  16390. * @param target defines the target
  16391. * @param from defines from which frame should animation start
  16392. * @param to defines until which frame should animation run.
  16393. * @param weight defines the weight to apply to the animation (1.0 by default)
  16394. * @param loop defines if the animation loops
  16395. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16396. * @param onAnimationEnd defines the function to be executed when the animation ends
  16397. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  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 animatable object created for this animation
  16402. */
  16403. 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;
  16404. /**
  16405. * Will start the animation sequence of a given target
  16406. * @param target defines the target
  16407. * @param from defines from which frame should animation start
  16408. * @param to defines until which frame should animation run.
  16409. * @param loop defines if the animation loops
  16410. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16411. * @param onAnimationEnd defines the function to be executed when the animation ends
  16412. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16413. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16414. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16415. * @param onAnimationLoop defines the callback to call when an animation loops
  16416. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16417. * @returns the animatable object created for this animation
  16418. */
  16419. 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;
  16420. /**
  16421. * Will start the animation sequence of a given target and its hierarchy
  16422. * @param target defines the target
  16423. * @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.
  16424. * @param from defines from which frame should animation start
  16425. * @param to defines until which frame should animation run.
  16426. * @param loop defines if the animation loops
  16427. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16428. * @param onAnimationEnd defines the function to be executed when the animation ends
  16429. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16430. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16431. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16432. * @param onAnimationLoop defines the callback to call when an animation loops
  16433. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16434. * @returns the list of created animatables
  16435. */
  16436. 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[];
  16437. /**
  16438. * Begin a new animation on a given node
  16439. * @param target defines the target where the animation will take place
  16440. * @param animations defines the list of animations to start
  16441. * @param from defines the initial value
  16442. * @param to defines the final value
  16443. * @param loop defines if you want animation to loop (off by default)
  16444. * @param speedRatio defines the speed ratio to apply to all animations
  16445. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16446. * @param onAnimationLoop defines the callback to call when an animation loops
  16447. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16448. * @returns the list of created animatables
  16449. */
  16450. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16451. /**
  16452. * Begin a new animation on a given node and its hierarchy
  16453. * @param target defines the root node where the animation will take place
  16454. * @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.
  16455. * @param animations defines the list of animations to start
  16456. * @param from defines the initial value
  16457. * @param to defines the final value
  16458. * @param loop defines if you want animation to loop (off by default)
  16459. * @param speedRatio defines the speed ratio to apply to all animations
  16460. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16461. * @param onAnimationLoop defines the callback to call when an animation loops
  16462. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16463. * @returns the list of animatables created for all nodes
  16464. */
  16465. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16466. /**
  16467. * Gets the animatable associated with a specific target
  16468. * @param target defines the target of the animatable
  16469. * @returns the required animatable if found
  16470. */
  16471. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16472. /**
  16473. * Gets all animatables associated with a given target
  16474. * @param target defines the target to look animatables for
  16475. * @returns an array of Animatables
  16476. */
  16477. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16478. /**
  16479. * Stops and removes all animations that have been applied to the scene
  16480. */
  16481. stopAllAnimations(): void;
  16482. /**
  16483. * Gets the current delta time used by animation engine
  16484. */
  16485. deltaTime: number;
  16486. }
  16487. }
  16488. module "babylonjs/Bones/bone" {
  16489. interface Bone {
  16490. /**
  16491. * Copy an animation range from another bone
  16492. * @param source defines the source bone
  16493. * @param rangeName defines the range name to copy
  16494. * @param frameOffset defines the frame offset
  16495. * @param rescaleAsRequired defines if rescaling must be applied if required
  16496. * @param skelDimensionsRatio defines the scaling ratio
  16497. * @returns true if operation was successful
  16498. */
  16499. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16500. }
  16501. }
  16502. }
  16503. declare module "babylonjs/Bones/skeleton" {
  16504. import { Bone } from "babylonjs/Bones/bone";
  16505. import { Observable } from "babylonjs/Misc/observable";
  16506. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16507. import { Scene } from "babylonjs/scene";
  16508. import { Nullable } from "babylonjs/types";
  16509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16510. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16511. import { Animatable } from "babylonjs/Animations/animatable";
  16512. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16513. import { Animation } from "babylonjs/Animations/animation";
  16514. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16515. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16516. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16517. /**
  16518. * Class used to handle skinning animations
  16519. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16520. */
  16521. export class Skeleton implements IAnimatable {
  16522. /** defines the skeleton name */
  16523. name: string;
  16524. /** defines the skeleton Id */
  16525. id: string;
  16526. /**
  16527. * Defines the list of child bones
  16528. */
  16529. bones: Bone[];
  16530. /**
  16531. * Defines an estimate of the dimension of the skeleton at rest
  16532. */
  16533. dimensionsAtRest: Vector3;
  16534. /**
  16535. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16536. */
  16537. needInitialSkinMatrix: boolean;
  16538. /**
  16539. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16540. */
  16541. overrideMesh: Nullable<AbstractMesh>;
  16542. /**
  16543. * Gets the list of animations attached to this skeleton
  16544. */
  16545. animations: Array<Animation>;
  16546. private _scene;
  16547. private _isDirty;
  16548. private _transformMatrices;
  16549. private _transformMatrixTexture;
  16550. private _meshesWithPoseMatrix;
  16551. private _animatables;
  16552. private _identity;
  16553. private _synchronizedWithMesh;
  16554. private _ranges;
  16555. private _lastAbsoluteTransformsUpdateId;
  16556. private _canUseTextureForBones;
  16557. private _uniqueId;
  16558. /** @hidden */
  16559. _numBonesWithLinkedTransformNode: number;
  16560. /** @hidden */
  16561. _hasWaitingData: Nullable<boolean>;
  16562. /** @hidden */
  16563. _waitingOverrideMeshId: Nullable<string>;
  16564. /**
  16565. * Specifies if the skeleton should be serialized
  16566. */
  16567. doNotSerialize: boolean;
  16568. private _useTextureToStoreBoneMatrices;
  16569. /**
  16570. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16571. * Please note that this option is not available if the hardware does not support it
  16572. */
  16573. get useTextureToStoreBoneMatrices(): boolean;
  16574. set useTextureToStoreBoneMatrices(value: boolean);
  16575. private _animationPropertiesOverride;
  16576. /**
  16577. * Gets or sets the animation properties override
  16578. */
  16579. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16580. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16581. /**
  16582. * List of inspectable custom properties (used by the Inspector)
  16583. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16584. */
  16585. inspectableCustomProperties: IInspectable[];
  16586. /**
  16587. * An observable triggered before computing the skeleton's matrices
  16588. */
  16589. onBeforeComputeObservable: Observable<Skeleton>;
  16590. /**
  16591. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16592. */
  16593. get isUsingTextureForMatrices(): boolean;
  16594. /**
  16595. * Gets the unique ID of this skeleton
  16596. */
  16597. get uniqueId(): number;
  16598. /**
  16599. * Creates a new skeleton
  16600. * @param name defines the skeleton name
  16601. * @param id defines the skeleton Id
  16602. * @param scene defines the hosting scene
  16603. */
  16604. constructor(
  16605. /** defines the skeleton name */
  16606. name: string,
  16607. /** defines the skeleton Id */
  16608. id: string, scene: Scene);
  16609. /**
  16610. * Gets the current object class name.
  16611. * @return the class name
  16612. */
  16613. getClassName(): string;
  16614. /**
  16615. * Returns an array containing the root bones
  16616. * @returns an array containing the root bones
  16617. */
  16618. getChildren(): Array<Bone>;
  16619. /**
  16620. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16621. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16622. * @returns a Float32Array containing matrices data
  16623. */
  16624. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16625. /**
  16626. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16627. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16628. * @returns a raw texture containing the data
  16629. */
  16630. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16631. /**
  16632. * Gets the current hosting scene
  16633. * @returns a scene object
  16634. */
  16635. getScene(): Scene;
  16636. /**
  16637. * Gets a string representing the current skeleton data
  16638. * @param fullDetails defines a boolean indicating if we want a verbose version
  16639. * @returns a string representing the current skeleton data
  16640. */
  16641. toString(fullDetails?: boolean): string;
  16642. /**
  16643. * Get bone's index searching by name
  16644. * @param name defines bone's name to search for
  16645. * @return the indice of the bone. Returns -1 if not found
  16646. */
  16647. getBoneIndexByName(name: string): number;
  16648. /**
  16649. * Creater a new animation range
  16650. * @param name defines the name of the range
  16651. * @param from defines the start key
  16652. * @param to defines the end key
  16653. */
  16654. createAnimationRange(name: string, from: number, to: number): void;
  16655. /**
  16656. * Delete a specific animation range
  16657. * @param name defines the name of the range
  16658. * @param deleteFrames defines if frames must be removed as well
  16659. */
  16660. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16661. /**
  16662. * Gets a specific animation range
  16663. * @param name defines the name of the range to look for
  16664. * @returns the requested animation range or null if not found
  16665. */
  16666. getAnimationRange(name: string): Nullable<AnimationRange>;
  16667. /**
  16668. * Gets the list of all animation ranges defined on this skeleton
  16669. * @returns an array
  16670. */
  16671. getAnimationRanges(): Nullable<AnimationRange>[];
  16672. /**
  16673. * Copy animation range from a source skeleton.
  16674. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16675. * @param source defines the source skeleton
  16676. * @param name defines the name of the range to copy
  16677. * @param rescaleAsRequired defines if rescaling must be applied if required
  16678. * @returns true if operation was successful
  16679. */
  16680. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16681. /**
  16682. * Forces the skeleton to go to rest pose
  16683. */
  16684. returnToRest(): void;
  16685. private _getHighestAnimationFrame;
  16686. /**
  16687. * Begin a specific animation range
  16688. * @param name defines the name of the range to start
  16689. * @param loop defines if looping must be turned on (false by default)
  16690. * @param speedRatio defines the speed ratio to apply (1 by default)
  16691. * @param onAnimationEnd defines a callback which will be called when animation will end
  16692. * @returns a new animatable
  16693. */
  16694. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16695. /**
  16696. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16697. * @param skeleton defines the Skeleton containing the animation range to convert
  16698. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16699. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16700. * @returns the original skeleton
  16701. */
  16702. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16703. /** @hidden */
  16704. _markAsDirty(): void;
  16705. /** @hidden */
  16706. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16707. /** @hidden */
  16708. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16709. private _computeTransformMatrices;
  16710. /**
  16711. * Build all resources required to render a skeleton
  16712. */
  16713. prepare(): void;
  16714. /**
  16715. * Gets the list of animatables currently running for this skeleton
  16716. * @returns an array of animatables
  16717. */
  16718. getAnimatables(): IAnimatable[];
  16719. /**
  16720. * Clone the current skeleton
  16721. * @param name defines the name of the new skeleton
  16722. * @param id defines the id of the new skeleton
  16723. * @returns the new skeleton
  16724. */
  16725. clone(name: string, id?: string): Skeleton;
  16726. /**
  16727. * Enable animation blending for this skeleton
  16728. * @param blendingSpeed defines the blending speed to apply
  16729. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16730. */
  16731. enableBlending(blendingSpeed?: number): void;
  16732. /**
  16733. * Releases all resources associated with the current skeleton
  16734. */
  16735. dispose(): void;
  16736. /**
  16737. * Serialize the skeleton in a JSON object
  16738. * @returns a JSON object
  16739. */
  16740. serialize(): any;
  16741. /**
  16742. * Creates a new skeleton from serialized data
  16743. * @param parsedSkeleton defines the serialized data
  16744. * @param scene defines the hosting scene
  16745. * @returns a new skeleton
  16746. */
  16747. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16748. /**
  16749. * Compute all node absolute transforms
  16750. * @param forceUpdate defines if computation must be done even if cache is up to date
  16751. */
  16752. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16753. /**
  16754. * Gets the root pose matrix
  16755. * @returns a matrix
  16756. */
  16757. getPoseMatrix(): Nullable<Matrix>;
  16758. /**
  16759. * Sorts bones per internal index
  16760. */
  16761. sortBones(): void;
  16762. private _sortBones;
  16763. /**
  16764. * Set the current local matrix as the restPose for all bones in the skeleton.
  16765. */
  16766. setCurrentPoseAsRest(): void;
  16767. }
  16768. }
  16769. declare module "babylonjs/Meshes/instancedMesh" {
  16770. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16771. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16772. import { Camera } from "babylonjs/Cameras/camera";
  16773. import { Node } from "babylonjs/node";
  16774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16775. import { Mesh } from "babylonjs/Meshes/mesh";
  16776. import { Material } from "babylonjs/Materials/material";
  16777. import { Skeleton } from "babylonjs/Bones/skeleton";
  16778. import { Light } from "babylonjs/Lights/light";
  16779. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16780. /**
  16781. * Creates an instance based on a source mesh.
  16782. */
  16783. export class InstancedMesh extends AbstractMesh {
  16784. private _sourceMesh;
  16785. private _currentLOD;
  16786. /** @hidden */
  16787. _indexInSourceMeshInstanceArray: number;
  16788. constructor(name: string, source: Mesh);
  16789. /**
  16790. * Returns the string "InstancedMesh".
  16791. */
  16792. getClassName(): string;
  16793. /** Gets the list of lights affecting that mesh */
  16794. get lightSources(): Light[];
  16795. _resyncLightSources(): void;
  16796. _resyncLightSource(light: Light): void;
  16797. _removeLightSource(light: Light, dispose: boolean): void;
  16798. /**
  16799. * If the source mesh receives shadows
  16800. */
  16801. get receiveShadows(): boolean;
  16802. /**
  16803. * The material of the source mesh
  16804. */
  16805. get material(): Nullable<Material>;
  16806. /**
  16807. * Visibility of the source mesh
  16808. */
  16809. get visibility(): number;
  16810. /**
  16811. * Skeleton of the source mesh
  16812. */
  16813. get skeleton(): Nullable<Skeleton>;
  16814. /**
  16815. * Rendering ground id of the source mesh
  16816. */
  16817. get renderingGroupId(): number;
  16818. set renderingGroupId(value: number);
  16819. /**
  16820. * Returns the total number of vertices (integer).
  16821. */
  16822. getTotalVertices(): number;
  16823. /**
  16824. * Returns a positive integer : the total number of indices in this mesh geometry.
  16825. * @returns the numner of indices or zero if the mesh has no geometry.
  16826. */
  16827. getTotalIndices(): number;
  16828. /**
  16829. * The source mesh of the instance
  16830. */
  16831. get sourceMesh(): Mesh;
  16832. /**
  16833. * Creates a new InstancedMesh object from the mesh model.
  16834. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16835. * @param name defines the name of the new instance
  16836. * @returns a new InstancedMesh
  16837. */
  16838. createInstance(name: string): InstancedMesh;
  16839. /**
  16840. * Is this node ready to be used/rendered
  16841. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16842. * @return {boolean} is it ready
  16843. */
  16844. isReady(completeCheck?: boolean): boolean;
  16845. /**
  16846. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16847. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16848. * @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.
  16849. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16850. */
  16851. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16852. /**
  16853. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16854. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16855. * The `data` are either a numeric array either a Float32Array.
  16856. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16857. * 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).
  16858. * Note that a new underlying VertexBuffer object is created each call.
  16859. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16860. *
  16861. * Possible `kind` values :
  16862. * - VertexBuffer.PositionKind
  16863. * - VertexBuffer.UVKind
  16864. * - VertexBuffer.UV2Kind
  16865. * - VertexBuffer.UV3Kind
  16866. * - VertexBuffer.UV4Kind
  16867. * - VertexBuffer.UV5Kind
  16868. * - VertexBuffer.UV6Kind
  16869. * - VertexBuffer.ColorKind
  16870. * - VertexBuffer.MatricesIndicesKind
  16871. * - VertexBuffer.MatricesIndicesExtraKind
  16872. * - VertexBuffer.MatricesWeightsKind
  16873. * - VertexBuffer.MatricesWeightsExtraKind
  16874. *
  16875. * Returns the Mesh.
  16876. */
  16877. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16878. /**
  16879. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16880. * If the mesh has no geometry, it is simply returned as it is.
  16881. * The `data` are either a numeric array either a Float32Array.
  16882. * No new underlying VertexBuffer object is created.
  16883. * 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.
  16884. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16885. *
  16886. * Possible `kind` values :
  16887. * - VertexBuffer.PositionKind
  16888. * - VertexBuffer.UVKind
  16889. * - VertexBuffer.UV2Kind
  16890. * - VertexBuffer.UV3Kind
  16891. * - VertexBuffer.UV4Kind
  16892. * - VertexBuffer.UV5Kind
  16893. * - VertexBuffer.UV6Kind
  16894. * - VertexBuffer.ColorKind
  16895. * - VertexBuffer.MatricesIndicesKind
  16896. * - VertexBuffer.MatricesIndicesExtraKind
  16897. * - VertexBuffer.MatricesWeightsKind
  16898. * - VertexBuffer.MatricesWeightsExtraKind
  16899. *
  16900. * Returns the Mesh.
  16901. */
  16902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16903. /**
  16904. * Sets the mesh indices.
  16905. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16906. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16907. * This method creates a new index buffer each call.
  16908. * Returns the Mesh.
  16909. */
  16910. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16911. /**
  16912. * Boolean : True if the mesh owns the requested kind of data.
  16913. */
  16914. isVerticesDataPresent(kind: string): boolean;
  16915. /**
  16916. * Returns an array of indices (IndicesArray).
  16917. */
  16918. getIndices(): Nullable<IndicesArray>;
  16919. get _positions(): Nullable<Vector3[]>;
  16920. /**
  16921. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16922. * This means the mesh underlying bounding box and sphere are recomputed.
  16923. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16924. * @returns the current mesh
  16925. */
  16926. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16927. /** @hidden */
  16928. _preActivate(): InstancedMesh;
  16929. /** @hidden */
  16930. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16931. /** @hidden */
  16932. _postActivate(): void;
  16933. getWorldMatrix(): Matrix;
  16934. get isAnInstance(): boolean;
  16935. /**
  16936. * Returns the current associated LOD AbstractMesh.
  16937. */
  16938. getLOD(camera: Camera): AbstractMesh;
  16939. /** @hidden */
  16940. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16941. /** @hidden */
  16942. _syncSubMeshes(): InstancedMesh;
  16943. /** @hidden */
  16944. _generatePointsArray(): boolean;
  16945. /** @hidden */
  16946. _updateBoundingInfo(): AbstractMesh;
  16947. /**
  16948. * Creates a new InstancedMesh from the current mesh.
  16949. * - name (string) : the cloned mesh name
  16950. * - newParent (optional Node) : the optional Node to parent the clone to.
  16951. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16952. *
  16953. * Returns the clone.
  16954. */
  16955. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16956. /**
  16957. * Disposes the InstancedMesh.
  16958. * Returns nothing.
  16959. */
  16960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16961. }
  16962. module "babylonjs/Meshes/mesh" {
  16963. interface Mesh {
  16964. /**
  16965. * Register a custom buffer that will be instanced
  16966. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16967. * @param kind defines the buffer kind
  16968. * @param stride defines the stride in floats
  16969. */
  16970. registerInstancedBuffer(kind: string, stride: number): void;
  16971. /**
  16972. * true to use the edge renderer for all instances of this mesh
  16973. */
  16974. edgesShareWithInstances: boolean;
  16975. /** @hidden */
  16976. _userInstancedBuffersStorage: {
  16977. data: {
  16978. [key: string]: Float32Array;
  16979. };
  16980. sizes: {
  16981. [key: string]: number;
  16982. };
  16983. vertexBuffers: {
  16984. [key: string]: Nullable<VertexBuffer>;
  16985. };
  16986. strides: {
  16987. [key: string]: number;
  16988. };
  16989. };
  16990. }
  16991. }
  16992. module "babylonjs/Meshes/abstractMesh" {
  16993. interface AbstractMesh {
  16994. /**
  16995. * Object used to store instanced buffers defined by user
  16996. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16997. */
  16998. instancedBuffers: {
  16999. [key: string]: any;
  17000. };
  17001. }
  17002. }
  17003. }
  17004. declare module "babylonjs/Materials/shaderMaterial" {
  17005. import { Nullable } from "babylonjs/types";
  17006. import { Scene } from "babylonjs/scene";
  17007. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17009. import { Mesh } from "babylonjs/Meshes/mesh";
  17010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17012. import { Effect } from "babylonjs/Materials/effect";
  17013. import { Material } from "babylonjs/Materials/material";
  17014. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17015. /**
  17016. * Defines the options associated with the creation of a shader material.
  17017. */
  17018. export interface IShaderMaterialOptions {
  17019. /**
  17020. * Does the material work in alpha blend mode
  17021. */
  17022. needAlphaBlending: boolean;
  17023. /**
  17024. * Does the material work in alpha test mode
  17025. */
  17026. needAlphaTesting: boolean;
  17027. /**
  17028. * The list of attribute names used in the shader
  17029. */
  17030. attributes: string[];
  17031. /**
  17032. * The list of unifrom names used in the shader
  17033. */
  17034. uniforms: string[];
  17035. /**
  17036. * The list of UBO names used in the shader
  17037. */
  17038. uniformBuffers: string[];
  17039. /**
  17040. * The list of sampler names used in the shader
  17041. */
  17042. samplers: string[];
  17043. /**
  17044. * The list of defines used in the shader
  17045. */
  17046. defines: string[];
  17047. }
  17048. /**
  17049. * 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.
  17050. *
  17051. * This returned material effects how the mesh will look based on the code in the shaders.
  17052. *
  17053. * @see https://doc.babylonjs.com/how_to/shader_material
  17054. */
  17055. export class ShaderMaterial extends Material {
  17056. private _shaderPath;
  17057. private _options;
  17058. private _textures;
  17059. private _textureArrays;
  17060. private _floats;
  17061. private _ints;
  17062. private _floatsArrays;
  17063. private _colors3;
  17064. private _colors3Arrays;
  17065. private _colors4;
  17066. private _colors4Arrays;
  17067. private _vectors2;
  17068. private _vectors3;
  17069. private _vectors4;
  17070. private _matrices;
  17071. private _matrixArrays;
  17072. private _matrices3x3;
  17073. private _matrices2x2;
  17074. private _vectors2Arrays;
  17075. private _vectors3Arrays;
  17076. private _vectors4Arrays;
  17077. private _cachedWorldViewMatrix;
  17078. private _cachedWorldViewProjectionMatrix;
  17079. private _renderId;
  17080. private _multiview;
  17081. private _cachedDefines;
  17082. /** Define the Url to load snippets */
  17083. static SnippetUrl: string;
  17084. /** Snippet ID if the material was created from the snippet server */
  17085. snippetId: string;
  17086. /**
  17087. * Instantiate a new shader material.
  17088. * 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.
  17089. * This returned material effects how the mesh will look based on the code in the shaders.
  17090. * @see https://doc.babylonjs.com/how_to/shader_material
  17091. * @param name Define the name of the material in the scene
  17092. * @param scene Define the scene the material belongs to
  17093. * @param shaderPath Defines the route to the shader code in one of three ways:
  17094. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17095. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17096. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17097. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17098. * @param options Define the options used to create the shader
  17099. */
  17100. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17101. /**
  17102. * Gets the shader path used to define the shader code
  17103. * It can be modified to trigger a new compilation
  17104. */
  17105. get shaderPath(): any;
  17106. /**
  17107. * Sets the shader path used to define the shader code
  17108. * It can be modified to trigger a new compilation
  17109. */
  17110. set shaderPath(shaderPath: any);
  17111. /**
  17112. * Gets the options used to compile the shader.
  17113. * They can be modified to trigger a new compilation
  17114. */
  17115. get options(): IShaderMaterialOptions;
  17116. /**
  17117. * Gets the current class name of the material e.g. "ShaderMaterial"
  17118. * Mainly use in serialization.
  17119. * @returns the class name
  17120. */
  17121. getClassName(): string;
  17122. /**
  17123. * Specifies if the material will require alpha blending
  17124. * @returns a boolean specifying if alpha blending is needed
  17125. */
  17126. needAlphaBlending(): boolean;
  17127. /**
  17128. * Specifies if this material should be rendered in alpha test mode
  17129. * @returns a boolean specifying if an alpha test is needed.
  17130. */
  17131. needAlphaTesting(): boolean;
  17132. private _checkUniform;
  17133. /**
  17134. * Set a texture in the shader.
  17135. * @param name Define the name of the uniform samplers as defined in the shader
  17136. * @param texture Define the texture to bind to this sampler
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17140. /**
  17141. * Set a texture array in the shader.
  17142. * @param name Define the name of the uniform sampler array as defined in the shader
  17143. * @param textures Define the list of textures to bind to this sampler
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17147. /**
  17148. * Set a float in the shader.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setFloat(name: string, value: number): ShaderMaterial;
  17154. /**
  17155. * Set a int in the shader.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setInt(name: string, value: number): ShaderMaterial;
  17161. /**
  17162. * Set an array of floats in the shader.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setFloats(name: string, value: number[]): ShaderMaterial;
  17168. /**
  17169. * Set a vec3 in the shader from a Color3.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setColor3(name: string, value: Color3): ShaderMaterial;
  17175. /**
  17176. * Set a vec3 array in the shader from a Color3 array.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17182. /**
  17183. * Set a vec4 in the shader from a Color4.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setColor4(name: string, value: Color4): ShaderMaterial;
  17189. /**
  17190. * Set a vec4 array in the shader from a Color4 array.
  17191. * @param name Define the name of the uniform as defined in the shader
  17192. * @param value Define the value to give to the uniform
  17193. * @return the material itself allowing "fluent" like uniform updates
  17194. */
  17195. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17196. /**
  17197. * Set a vec2 in the shader from a Vector2.
  17198. * @param name Define the name of the uniform as defined in the shader
  17199. * @param value Define the value to give to the uniform
  17200. * @return the material itself allowing "fluent" like uniform updates
  17201. */
  17202. setVector2(name: string, value: Vector2): ShaderMaterial;
  17203. /**
  17204. * Set a vec3 in the shader from a Vector3.
  17205. * @param name Define the name of the uniform as defined in the shader
  17206. * @param value Define the value to give to the uniform
  17207. * @return the material itself allowing "fluent" like uniform updates
  17208. */
  17209. setVector3(name: string, value: Vector3): ShaderMaterial;
  17210. /**
  17211. * Set a vec4 in the shader from a Vector4.
  17212. * @param name Define the name of the uniform as defined in the shader
  17213. * @param value Define the value to give to the uniform
  17214. * @return the material itself allowing "fluent" like uniform updates
  17215. */
  17216. setVector4(name: string, value: Vector4): ShaderMaterial;
  17217. /**
  17218. * Set a mat4 in the shader from a Matrix.
  17219. * @param name Define the name of the uniform as defined in the shader
  17220. * @param value Define the value to give to the uniform
  17221. * @return the material itself allowing "fluent" like uniform updates
  17222. */
  17223. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17224. /**
  17225. * Set a float32Array in the shader from a matrix array.
  17226. * @param name Define the name of the uniform as defined in the shader
  17227. * @param value Define the value to give to the uniform
  17228. * @return the material itself allowing "fluent" like uniform updates
  17229. */
  17230. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17231. /**
  17232. * Set a mat3 in the shader from a Float32Array.
  17233. * @param name Define the name of the uniform as defined in the shader
  17234. * @param value Define the value to give to the uniform
  17235. * @return the material itself allowing "fluent" like uniform updates
  17236. */
  17237. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17238. /**
  17239. * Set a mat2 in the shader from a Float32Array.
  17240. * @param name Define the name of the uniform as defined in the shader
  17241. * @param value Define the value to give to the uniform
  17242. * @return the material itself allowing "fluent" like uniform updates
  17243. */
  17244. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17245. /**
  17246. * Set a vec2 array in the shader from a number array.
  17247. * @param name Define the name of the uniform as defined in the shader
  17248. * @param value Define the value to give to the uniform
  17249. * @return the material itself allowing "fluent" like uniform updates
  17250. */
  17251. setArray2(name: string, value: number[]): ShaderMaterial;
  17252. /**
  17253. * Set a vec3 array in the shader from a number array.
  17254. * @param name Define the name of the uniform as defined in the shader
  17255. * @param value Define the value to give to the uniform
  17256. * @return the material itself allowing "fluent" like uniform updates
  17257. */
  17258. setArray3(name: string, value: number[]): ShaderMaterial;
  17259. /**
  17260. * Set a vec4 array in the shader from a number array.
  17261. * @param name Define the name of the uniform as defined in the shader
  17262. * @param value Define the value to give to the uniform
  17263. * @return the material itself allowing "fluent" like uniform updates
  17264. */
  17265. setArray4(name: string, value: number[]): ShaderMaterial;
  17266. private _checkCache;
  17267. /**
  17268. * Specifies that the submesh is ready to be used
  17269. * @param mesh defines the mesh to check
  17270. * @param subMesh defines which submesh to check
  17271. * @param useInstances specifies that instances should be used
  17272. * @returns a boolean indicating that the submesh is ready or not
  17273. */
  17274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17275. /**
  17276. * Checks if the material is ready to render the requested mesh
  17277. * @param mesh Define the mesh to render
  17278. * @param useInstances Define whether or not the material is used with instances
  17279. * @returns true if ready, otherwise false
  17280. */
  17281. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17282. /**
  17283. * Binds the world matrix to the material
  17284. * @param world defines the world transformation matrix
  17285. * @param effectOverride - If provided, use this effect instead of internal effect
  17286. */
  17287. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17288. /**
  17289. * Binds the submesh to this material by preparing the effect and shader to draw
  17290. * @param world defines the world transformation matrix
  17291. * @param mesh defines the mesh containing the submesh
  17292. * @param subMesh defines the submesh to bind the material to
  17293. */
  17294. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17295. /**
  17296. * Binds the material to the mesh
  17297. * @param world defines the world transformation matrix
  17298. * @param mesh defines the mesh to bind the material to
  17299. * @param effectOverride - If provided, use this effect instead of internal effect
  17300. */
  17301. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17302. protected _afterBind(mesh?: Mesh): void;
  17303. /**
  17304. * Gets the active textures from the material
  17305. * @returns an array of textures
  17306. */
  17307. getActiveTextures(): BaseTexture[];
  17308. /**
  17309. * Specifies if the material uses a texture
  17310. * @param texture defines the texture to check against the material
  17311. * @returns a boolean specifying if the material uses the texture
  17312. */
  17313. hasTexture(texture: BaseTexture): boolean;
  17314. /**
  17315. * Makes a duplicate of the material, and gives it a new name
  17316. * @param name defines the new name for the duplicated material
  17317. * @returns the cloned material
  17318. */
  17319. clone(name: string): ShaderMaterial;
  17320. /**
  17321. * Disposes the material
  17322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17324. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17325. */
  17326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17327. /**
  17328. * Serializes this material in a JSON representation
  17329. * @returns the serialized material object
  17330. */
  17331. serialize(): any;
  17332. /**
  17333. * Creates a shader material from parsed shader material data
  17334. * @param source defines the JSON represnetation of the material
  17335. * @param scene defines the hosting scene
  17336. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17337. * @returns a new material
  17338. */
  17339. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17340. /**
  17341. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17342. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17343. * @param url defines the url to load from
  17344. * @param scene defines the hosting scene
  17345. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17346. * @returns a promise that will resolve to the new ShaderMaterial
  17347. */
  17348. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17349. /**
  17350. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17351. * @param snippetId defines the snippet to load
  17352. * @param scene defines the hosting scene
  17353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17354. * @returns a promise that will resolve to the new ShaderMaterial
  17355. */
  17356. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17357. }
  17358. }
  17359. declare module "babylonjs/Shaders/color.fragment" {
  17360. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17361. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17362. /** @hidden */
  17363. export var colorPixelShader: {
  17364. name: string;
  17365. shader: string;
  17366. };
  17367. }
  17368. declare module "babylonjs/Shaders/color.vertex" {
  17369. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17371. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17372. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17375. /** @hidden */
  17376. export var colorVertexShader: {
  17377. name: string;
  17378. shader: string;
  17379. };
  17380. }
  17381. declare module "babylonjs/Meshes/linesMesh" {
  17382. import { Nullable } from "babylonjs/types";
  17383. import { Scene } from "babylonjs/scene";
  17384. import { Color3 } from "babylonjs/Maths/math.color";
  17385. import { Node } from "babylonjs/node";
  17386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17387. import { Mesh } from "babylonjs/Meshes/mesh";
  17388. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17389. import { Effect } from "babylonjs/Materials/effect";
  17390. import { Material } from "babylonjs/Materials/material";
  17391. import "babylonjs/Shaders/color.fragment";
  17392. import "babylonjs/Shaders/color.vertex";
  17393. /**
  17394. * Line mesh
  17395. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17396. */
  17397. export class LinesMesh extends Mesh {
  17398. /**
  17399. * If vertex color should be applied to the mesh
  17400. */
  17401. readonly useVertexColor?: boolean | undefined;
  17402. /**
  17403. * If vertex alpha should be applied to the mesh
  17404. */
  17405. readonly useVertexAlpha?: boolean | undefined;
  17406. /**
  17407. * Color of the line (Default: White)
  17408. */
  17409. color: Color3;
  17410. /**
  17411. * Alpha of the line (Default: 1)
  17412. */
  17413. alpha: number;
  17414. /**
  17415. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17416. * This margin is expressed in world space coordinates, so its value may vary.
  17417. * Default value is 0.1
  17418. */
  17419. intersectionThreshold: number;
  17420. private _colorShader;
  17421. private color4;
  17422. /**
  17423. * Creates a new LinesMesh
  17424. * @param name defines the name
  17425. * @param scene defines the hosting scene
  17426. * @param parent defines the parent mesh if any
  17427. * @param source defines the optional source LinesMesh used to clone data from
  17428. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17429. * When false, achieved by calling a clone(), also passing False.
  17430. * This will make creation of children, recursive.
  17431. * @param useVertexColor defines if this LinesMesh supports vertex color
  17432. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17433. */
  17434. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17435. /**
  17436. * If vertex color should be applied to the mesh
  17437. */
  17438. useVertexColor?: boolean | undefined,
  17439. /**
  17440. * If vertex alpha should be applied to the mesh
  17441. */
  17442. useVertexAlpha?: boolean | undefined);
  17443. private _addClipPlaneDefine;
  17444. private _removeClipPlaneDefine;
  17445. isReady(): boolean;
  17446. /**
  17447. * Returns the string "LineMesh"
  17448. */
  17449. getClassName(): string;
  17450. /**
  17451. * @hidden
  17452. */
  17453. get material(): Material;
  17454. /**
  17455. * @hidden
  17456. */
  17457. set material(value: Material);
  17458. /**
  17459. * @hidden
  17460. */
  17461. get checkCollisions(): boolean;
  17462. /** @hidden */
  17463. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17464. /** @hidden */
  17465. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17466. /**
  17467. * Disposes of the line mesh
  17468. * @param doNotRecurse If children should be disposed
  17469. */
  17470. dispose(doNotRecurse?: boolean): void;
  17471. /**
  17472. * Returns a new LineMesh object cloned from the current one.
  17473. */
  17474. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17475. /**
  17476. * Creates a new InstancedLinesMesh object from the mesh model.
  17477. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17478. * @param name defines the name of the new instance
  17479. * @returns a new InstancedLinesMesh
  17480. */
  17481. createInstance(name: string): InstancedLinesMesh;
  17482. }
  17483. /**
  17484. * Creates an instance based on a source LinesMesh
  17485. */
  17486. export class InstancedLinesMesh extends InstancedMesh {
  17487. /**
  17488. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17489. * This margin is expressed in world space coordinates, so its value may vary.
  17490. * Initilized with the intersectionThreshold value of the source LinesMesh
  17491. */
  17492. intersectionThreshold: number;
  17493. constructor(name: string, source: LinesMesh);
  17494. /**
  17495. * Returns the string "InstancedLinesMesh".
  17496. */
  17497. getClassName(): string;
  17498. }
  17499. }
  17500. declare module "babylonjs/Shaders/line.fragment" {
  17501. /** @hidden */
  17502. export var linePixelShader: {
  17503. name: string;
  17504. shader: string;
  17505. };
  17506. }
  17507. declare module "babylonjs/Shaders/line.vertex" {
  17508. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17509. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17510. /** @hidden */
  17511. export var lineVertexShader: {
  17512. name: string;
  17513. shader: string;
  17514. };
  17515. }
  17516. declare module "babylonjs/Rendering/edgesRenderer" {
  17517. import { Nullable } from "babylonjs/types";
  17518. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17520. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17521. import { IDisposable } from "babylonjs/scene";
  17522. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17523. import "babylonjs/Shaders/line.fragment";
  17524. import "babylonjs/Shaders/line.vertex";
  17525. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17526. import { SmartArray } from "babylonjs/Misc/smartArray";
  17527. module "babylonjs/scene" {
  17528. interface Scene {
  17529. /** @hidden */
  17530. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17531. }
  17532. }
  17533. module "babylonjs/Meshes/abstractMesh" {
  17534. interface AbstractMesh {
  17535. /**
  17536. * Gets the edgesRenderer associated with the mesh
  17537. */
  17538. edgesRenderer: Nullable<EdgesRenderer>;
  17539. }
  17540. }
  17541. module "babylonjs/Meshes/linesMesh" {
  17542. interface LinesMesh {
  17543. /**
  17544. * Enables the edge rendering mode on the mesh.
  17545. * This mode makes the mesh edges visible
  17546. * @param epsilon defines the maximal distance between two angles to detect a face
  17547. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17548. * @returns the currentAbstractMesh
  17549. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17550. */
  17551. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17552. }
  17553. }
  17554. module "babylonjs/Meshes/linesMesh" {
  17555. interface InstancedLinesMesh {
  17556. /**
  17557. * Enables the edge rendering mode on the mesh.
  17558. * This mode makes the mesh edges visible
  17559. * @param epsilon defines the maximal distance between two angles to detect a face
  17560. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17561. * @returns the current InstancedLinesMesh
  17562. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17563. */
  17564. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17565. }
  17566. }
  17567. /**
  17568. * Defines the minimum contract an Edges renderer should follow.
  17569. */
  17570. export interface IEdgesRenderer extends IDisposable {
  17571. /**
  17572. * Gets or sets a boolean indicating if the edgesRenderer is active
  17573. */
  17574. isEnabled: boolean;
  17575. /**
  17576. * Renders the edges of the attached mesh,
  17577. */
  17578. render(): void;
  17579. /**
  17580. * Checks wether or not the edges renderer is ready to render.
  17581. * @return true if ready, otherwise false.
  17582. */
  17583. isReady(): boolean;
  17584. /**
  17585. * List of instances to render in case the source mesh has instances
  17586. */
  17587. customInstances: SmartArray<Matrix>;
  17588. }
  17589. /**
  17590. * Defines the additional options of the edges renderer
  17591. */
  17592. export interface IEdgesRendererOptions {
  17593. /**
  17594. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17595. * If not defined, the default value is true
  17596. */
  17597. useAlternateEdgeFinder?: boolean;
  17598. /**
  17599. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17600. * If not defined, the default value is true.
  17601. * 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)
  17602. * This option is used only if useAlternateEdgeFinder = true
  17603. */
  17604. useFastVertexMerger?: boolean;
  17605. /**
  17606. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17607. * The default value is 1e-6
  17608. * This option is used only if useAlternateEdgeFinder = true
  17609. */
  17610. epsilonVertexMerge?: number;
  17611. /**
  17612. * 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
  17613. * 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.
  17614. * This option is used only if useAlternateEdgeFinder = true
  17615. */
  17616. applyTessellation?: boolean;
  17617. /**
  17618. * 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
  17619. * The default value is 1e-6
  17620. * This option is used only if useAlternateEdgeFinder = true
  17621. */
  17622. epsilonVertexAligned?: number;
  17623. }
  17624. /**
  17625. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17626. */
  17627. export class EdgesRenderer implements IEdgesRenderer {
  17628. /**
  17629. * Define the size of the edges with an orthographic camera
  17630. */
  17631. edgesWidthScalerForOrthographic: number;
  17632. /**
  17633. * Define the size of the edges with a perspective camera
  17634. */
  17635. edgesWidthScalerForPerspective: number;
  17636. protected _source: AbstractMesh;
  17637. protected _linesPositions: number[];
  17638. protected _linesNormals: number[];
  17639. protected _linesIndices: number[];
  17640. protected _epsilon: number;
  17641. protected _indicesCount: number;
  17642. protected _lineShader: ShaderMaterial;
  17643. protected _ib: DataBuffer;
  17644. protected _buffers: {
  17645. [key: string]: Nullable<VertexBuffer>;
  17646. };
  17647. protected _buffersForInstances: {
  17648. [key: string]: Nullable<VertexBuffer>;
  17649. };
  17650. protected _checkVerticesInsteadOfIndices: boolean;
  17651. protected _options: Nullable<IEdgesRendererOptions>;
  17652. private _meshRebuildObserver;
  17653. private _meshDisposeObserver;
  17654. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17655. isEnabled: boolean;
  17656. /**
  17657. * List of instances to render in case the source mesh has instances
  17658. */
  17659. customInstances: SmartArray<Matrix>;
  17660. private static GetShader;
  17661. /**
  17662. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17663. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17664. * @param source Mesh used to create edges
  17665. * @param epsilon sum of angles in adjacency to check for edge
  17666. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17667. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17668. * @param options The options to apply when generating the edges
  17669. */
  17670. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17671. protected _prepareRessources(): void;
  17672. /** @hidden */
  17673. _rebuild(): void;
  17674. /**
  17675. * Releases the required resources for the edges renderer
  17676. */
  17677. dispose(): void;
  17678. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17679. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17680. /**
  17681. * Checks if the pair of p0 and p1 is en edge
  17682. * @param faceIndex
  17683. * @param edge
  17684. * @param faceNormals
  17685. * @param p0
  17686. * @param p1
  17687. * @private
  17688. */
  17689. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17690. /**
  17691. * push line into the position, normal and index buffer
  17692. * @protected
  17693. */
  17694. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17695. /**
  17696. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17697. */
  17698. private _tessellateTriangle;
  17699. private _generateEdgesLinesAlternate;
  17700. /**
  17701. * Generates lines edges from adjacencjes
  17702. * @private
  17703. */
  17704. _generateEdgesLines(): void;
  17705. /**
  17706. * Checks wether or not the edges renderer is ready to render.
  17707. * @return true if ready, otherwise false.
  17708. */
  17709. isReady(): boolean;
  17710. /**
  17711. * Renders the edges of the attached mesh,
  17712. */
  17713. render(): void;
  17714. }
  17715. /**
  17716. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17717. */
  17718. export class LineEdgesRenderer extends EdgesRenderer {
  17719. /**
  17720. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17721. * @param source LineMesh used to generate edges
  17722. * @param epsilon not important (specified angle for edge detection)
  17723. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17724. */
  17725. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17726. /**
  17727. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17728. */
  17729. _generateEdgesLines(): void;
  17730. }
  17731. }
  17732. declare module "babylonjs/Rendering/renderingGroup" {
  17733. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17734. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17736. import { Nullable } from "babylonjs/types";
  17737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17738. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17739. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17740. import { Material } from "babylonjs/Materials/material";
  17741. import { Scene } from "babylonjs/scene";
  17742. /**
  17743. * This represents the object necessary to create a rendering group.
  17744. * This is exclusively used and created by the rendering manager.
  17745. * To modify the behavior, you use the available helpers in your scene or meshes.
  17746. * @hidden
  17747. */
  17748. export class RenderingGroup {
  17749. index: number;
  17750. private static _zeroVector;
  17751. private _scene;
  17752. private _opaqueSubMeshes;
  17753. private _transparentSubMeshes;
  17754. private _alphaTestSubMeshes;
  17755. private _depthOnlySubMeshes;
  17756. private _particleSystems;
  17757. private _spriteManagers;
  17758. private _opaqueSortCompareFn;
  17759. private _alphaTestSortCompareFn;
  17760. private _transparentSortCompareFn;
  17761. private _renderOpaque;
  17762. private _renderAlphaTest;
  17763. private _renderTransparent;
  17764. /** @hidden */
  17765. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17766. onBeforeTransparentRendering: () => void;
  17767. /**
  17768. * Set the opaque sort comparison function.
  17769. * If null the sub meshes will be render in the order they were created
  17770. */
  17771. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17772. /**
  17773. * Set the alpha test sort comparison function.
  17774. * If null the sub meshes will be render in the order they were created
  17775. */
  17776. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17777. /**
  17778. * Set the transparent sort comparison function.
  17779. * If null the sub meshes will be render in the order they were created
  17780. */
  17781. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17782. /**
  17783. * Creates a new rendering group.
  17784. * @param index The rendering group index
  17785. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17786. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17787. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17788. */
  17789. 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>);
  17790. /**
  17791. * Render all the sub meshes contained in the group.
  17792. * @param customRenderFunction Used to override the default render behaviour of the group.
  17793. * @returns true if rendered some submeshes.
  17794. */
  17795. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17796. /**
  17797. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17798. * @param subMeshes The submeshes to render
  17799. */
  17800. private renderOpaqueSorted;
  17801. /**
  17802. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17803. * @param subMeshes The submeshes to render
  17804. */
  17805. private renderAlphaTestSorted;
  17806. /**
  17807. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17808. * @param subMeshes The submeshes to render
  17809. */
  17810. private renderTransparentSorted;
  17811. /**
  17812. * Renders the submeshes in a specified order.
  17813. * @param subMeshes The submeshes to sort before render
  17814. * @param sortCompareFn The comparison function use to sort
  17815. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17816. * @param transparent Specifies to activate blending if true
  17817. */
  17818. private static renderSorted;
  17819. /**
  17820. * Renders the submeshes in the order they were dispatched (no sort applied).
  17821. * @param subMeshes The submeshes to render
  17822. */
  17823. private static renderUnsorted;
  17824. /**
  17825. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17826. * are rendered back to front if in the same alpha index.
  17827. *
  17828. * @param a The first submesh
  17829. * @param b The second submesh
  17830. * @returns The result of the comparison
  17831. */
  17832. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17833. /**
  17834. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17835. * are rendered back to front.
  17836. *
  17837. * @param a The first submesh
  17838. * @param b The second submesh
  17839. * @returns The result of the comparison
  17840. */
  17841. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17842. /**
  17843. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17844. * are rendered front to back (prevent overdraw).
  17845. *
  17846. * @param a The first submesh
  17847. * @param b The second submesh
  17848. * @returns The result of the comparison
  17849. */
  17850. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17851. /**
  17852. * Resets the different lists of submeshes to prepare a new frame.
  17853. */
  17854. prepare(): void;
  17855. dispose(): void;
  17856. /**
  17857. * Inserts the submesh in its correct queue depending on its material.
  17858. * @param subMesh The submesh to dispatch
  17859. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17860. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17861. */
  17862. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17863. dispatchSprites(spriteManager: ISpriteManager): void;
  17864. dispatchParticles(particleSystem: IParticleSystem): void;
  17865. private _renderParticles;
  17866. private _renderSprites;
  17867. }
  17868. }
  17869. declare module "babylonjs/Rendering/renderingManager" {
  17870. import { Nullable } from "babylonjs/types";
  17871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17872. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17873. import { SmartArray } from "babylonjs/Misc/smartArray";
  17874. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17876. import { Material } from "babylonjs/Materials/material";
  17877. import { Scene } from "babylonjs/scene";
  17878. import { Camera } from "babylonjs/Cameras/camera";
  17879. /**
  17880. * Interface describing the different options available in the rendering manager
  17881. * regarding Auto Clear between groups.
  17882. */
  17883. export interface IRenderingManagerAutoClearSetup {
  17884. /**
  17885. * Defines whether or not autoclear is enable.
  17886. */
  17887. autoClear: boolean;
  17888. /**
  17889. * Defines whether or not to autoclear the depth buffer.
  17890. */
  17891. depth: boolean;
  17892. /**
  17893. * Defines whether or not to autoclear the stencil buffer.
  17894. */
  17895. stencil: boolean;
  17896. }
  17897. /**
  17898. * This class is used by the onRenderingGroupObservable
  17899. */
  17900. export class RenderingGroupInfo {
  17901. /**
  17902. * The Scene that being rendered
  17903. */
  17904. scene: Scene;
  17905. /**
  17906. * The camera currently used for the rendering pass
  17907. */
  17908. camera: Nullable<Camera>;
  17909. /**
  17910. * The ID of the renderingGroup being processed
  17911. */
  17912. renderingGroupId: number;
  17913. }
  17914. /**
  17915. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17916. * It is enable to manage the different groups as well as the different necessary sort functions.
  17917. * This should not be used directly aside of the few static configurations
  17918. */
  17919. export class RenderingManager {
  17920. /**
  17921. * The max id used for rendering groups (not included)
  17922. */
  17923. static MAX_RENDERINGGROUPS: number;
  17924. /**
  17925. * The min id used for rendering groups (included)
  17926. */
  17927. static MIN_RENDERINGGROUPS: number;
  17928. /**
  17929. * Used to globally prevent autoclearing scenes.
  17930. */
  17931. static AUTOCLEAR: boolean;
  17932. /**
  17933. * @hidden
  17934. */
  17935. _useSceneAutoClearSetup: boolean;
  17936. private _scene;
  17937. private _renderingGroups;
  17938. private _depthStencilBufferAlreadyCleaned;
  17939. private _autoClearDepthStencil;
  17940. private _customOpaqueSortCompareFn;
  17941. private _customAlphaTestSortCompareFn;
  17942. private _customTransparentSortCompareFn;
  17943. private _renderingGroupInfo;
  17944. /**
  17945. * Instantiates a new rendering group for a particular scene
  17946. * @param scene Defines the scene the groups belongs to
  17947. */
  17948. constructor(scene: Scene);
  17949. private _clearDepthStencilBuffer;
  17950. /**
  17951. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17952. * @hidden
  17953. */
  17954. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17955. /**
  17956. * Resets the different information of the group to prepare a new frame
  17957. * @hidden
  17958. */
  17959. reset(): void;
  17960. /**
  17961. * Dispose and release the group and its associated resources.
  17962. * @hidden
  17963. */
  17964. dispose(): void;
  17965. /**
  17966. * Clear the info related to rendering groups preventing retention points during dispose.
  17967. */
  17968. freeRenderingGroups(): void;
  17969. private _prepareRenderingGroup;
  17970. /**
  17971. * Add a sprite manager to the rendering manager in order to render it this frame.
  17972. * @param spriteManager Define the sprite manager to render
  17973. */
  17974. dispatchSprites(spriteManager: ISpriteManager): void;
  17975. /**
  17976. * Add a particle system to the rendering manager in order to render it this frame.
  17977. * @param particleSystem Define the particle system to render
  17978. */
  17979. dispatchParticles(particleSystem: IParticleSystem): void;
  17980. /**
  17981. * Add a submesh to the manager in order to render it this frame
  17982. * @param subMesh The submesh to dispatch
  17983. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17984. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17985. */
  17986. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17987. /**
  17988. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17989. * This allowed control for front to back rendering or reversly depending of the special needs.
  17990. *
  17991. * @param renderingGroupId The rendering group id corresponding to its index
  17992. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17993. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17994. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17995. */
  17996. 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;
  17997. /**
  17998. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17999. *
  18000. * @param renderingGroupId The rendering group id corresponding to its index
  18001. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18002. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18003. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18004. */
  18005. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18006. /**
  18007. * Gets the current auto clear configuration for one rendering group of the rendering
  18008. * manager.
  18009. * @param index the rendering group index to get the information for
  18010. * @returns The auto clear setup for the requested rendering group
  18011. */
  18012. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18013. }
  18014. }
  18015. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18016. import { SmartArray } from "babylonjs/Misc/smartArray";
  18017. import { Nullable } from "babylonjs/types";
  18018. import { Scene } from "babylonjs/scene";
  18019. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18022. import { Mesh } from "babylonjs/Meshes/mesh";
  18023. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18024. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18025. import { Effect } from "babylonjs/Materials/effect";
  18026. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18028. import "babylonjs/Shaders/shadowMap.fragment";
  18029. import "babylonjs/Shaders/shadowMap.vertex";
  18030. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18031. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18032. import { Observable } from "babylonjs/Misc/observable";
  18033. /**
  18034. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18035. */
  18036. export interface ICustomShaderOptions {
  18037. /**
  18038. * Gets or sets the custom shader name to use
  18039. */
  18040. shaderName: string;
  18041. /**
  18042. * The list of attribute names used in the shader
  18043. */
  18044. attributes?: string[];
  18045. /**
  18046. * The list of unifrom names used in the shader
  18047. */
  18048. uniforms?: string[];
  18049. /**
  18050. * The list of sampler names used in the shader
  18051. */
  18052. samplers?: string[];
  18053. /**
  18054. * The list of defines used in the shader
  18055. */
  18056. defines?: string[];
  18057. }
  18058. /**
  18059. * Interface to implement to create a shadow generator compatible with BJS.
  18060. */
  18061. export interface IShadowGenerator {
  18062. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18063. id: string;
  18064. /**
  18065. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18066. * @returns The render target texture if present otherwise, null
  18067. */
  18068. getShadowMap(): Nullable<RenderTargetTexture>;
  18069. /**
  18070. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18071. * @param subMesh The submesh we want to render in the shadow map
  18072. * @param useInstances Defines wether will draw in the map using instances
  18073. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18074. * @returns true if ready otherwise, false
  18075. */
  18076. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18077. /**
  18078. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18079. * @param defines Defines of the material we want to update
  18080. * @param lightIndex Index of the light in the enabled light list of the material
  18081. */
  18082. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18083. /**
  18084. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18085. * defined in the generator but impacting the effect).
  18086. * It implies the unifroms available on the materials are the standard BJS ones.
  18087. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18088. * @param effect The effect we are binfing the information for
  18089. */
  18090. bindShadowLight(lightIndex: string, effect: Effect): void;
  18091. /**
  18092. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18093. * (eq to shadow prjection matrix * light transform matrix)
  18094. * @returns The transform matrix used to create the shadow map
  18095. */
  18096. getTransformMatrix(): Matrix;
  18097. /**
  18098. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18099. * Cube and 2D textures for instance.
  18100. */
  18101. recreateShadowMap(): void;
  18102. /**
  18103. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18104. * @param onCompiled Callback triggered at the and of the effects compilation
  18105. * @param options Sets of optional options forcing the compilation with different modes
  18106. */
  18107. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18108. useInstances: boolean;
  18109. }>): void;
  18110. /**
  18111. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18112. * @param options Sets of optional options forcing the compilation with different modes
  18113. * @returns A promise that resolves when the compilation completes
  18114. */
  18115. forceCompilationAsync(options?: Partial<{
  18116. useInstances: boolean;
  18117. }>): Promise<void>;
  18118. /**
  18119. * Serializes the shadow generator setup to a json object.
  18120. * @returns The serialized JSON object
  18121. */
  18122. serialize(): any;
  18123. /**
  18124. * Disposes the Shadow map and related Textures and effects.
  18125. */
  18126. dispose(): void;
  18127. }
  18128. /**
  18129. * Default implementation IShadowGenerator.
  18130. * This is the main object responsible of generating shadows in the framework.
  18131. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18132. */
  18133. export class ShadowGenerator implements IShadowGenerator {
  18134. /**
  18135. * Name of the shadow generator class
  18136. */
  18137. static CLASSNAME: string;
  18138. /**
  18139. * Shadow generator mode None: no filtering applied.
  18140. */
  18141. static readonly FILTER_NONE: number;
  18142. /**
  18143. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18145. */
  18146. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18147. /**
  18148. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18149. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18150. */
  18151. static readonly FILTER_POISSONSAMPLING: number;
  18152. /**
  18153. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18154. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18155. */
  18156. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18157. /**
  18158. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18159. * edge artifacts on steep falloff.
  18160. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18161. */
  18162. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18163. /**
  18164. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18165. * edge artifacts on steep falloff.
  18166. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18167. */
  18168. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18169. /**
  18170. * Shadow generator mode PCF: Percentage Closer Filtering
  18171. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18172. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18173. */
  18174. static readonly FILTER_PCF: number;
  18175. /**
  18176. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18177. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18178. * Contact Hardening
  18179. */
  18180. static readonly FILTER_PCSS: number;
  18181. /**
  18182. * Reserved for PCF and PCSS
  18183. * Highest Quality.
  18184. *
  18185. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18186. *
  18187. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18188. */
  18189. static readonly QUALITY_HIGH: number;
  18190. /**
  18191. * Reserved for PCF and PCSS
  18192. * Good tradeoff for quality/perf cross devices
  18193. *
  18194. * Execute PCF on a 3*3 kernel.
  18195. *
  18196. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18197. */
  18198. static readonly QUALITY_MEDIUM: number;
  18199. /**
  18200. * Reserved for PCF and PCSS
  18201. * The lowest quality but the fastest.
  18202. *
  18203. * Execute PCF on a 1*1 kernel.
  18204. *
  18205. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18206. */
  18207. static readonly QUALITY_LOW: number;
  18208. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18209. id: string;
  18210. /** Gets or sets the custom shader name to use */
  18211. customShaderOptions: ICustomShaderOptions;
  18212. /**
  18213. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18214. */
  18215. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18216. /**
  18217. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18218. */
  18219. onAfterShadowMapRenderObservable: Observable<Effect>;
  18220. /**
  18221. * Observable triggered before a mesh is rendered in the shadow map.
  18222. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18223. */
  18224. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18225. /**
  18226. * Observable triggered after a mesh is rendered in the shadow map.
  18227. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18228. */
  18229. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18230. protected _bias: number;
  18231. /**
  18232. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18233. */
  18234. get bias(): number;
  18235. /**
  18236. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18237. */
  18238. set bias(bias: number);
  18239. protected _normalBias: number;
  18240. /**
  18241. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18242. */
  18243. get normalBias(): number;
  18244. /**
  18245. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18246. */
  18247. set normalBias(normalBias: number);
  18248. protected _blurBoxOffset: number;
  18249. /**
  18250. * Gets the blur box offset: offset applied during the blur pass.
  18251. * Only useful if useKernelBlur = false
  18252. */
  18253. get blurBoxOffset(): number;
  18254. /**
  18255. * Sets the blur box offset: offset applied during the blur pass.
  18256. * Only useful if useKernelBlur = false
  18257. */
  18258. set blurBoxOffset(value: number);
  18259. protected _blurScale: number;
  18260. /**
  18261. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18262. * 2 means half of the size.
  18263. */
  18264. get blurScale(): number;
  18265. /**
  18266. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18267. * 2 means half of the size.
  18268. */
  18269. set blurScale(value: number);
  18270. protected _blurKernel: number;
  18271. /**
  18272. * Gets the blur kernel: kernel size of the blur pass.
  18273. * Only useful if useKernelBlur = true
  18274. */
  18275. get blurKernel(): number;
  18276. /**
  18277. * Sets the blur kernel: kernel size of the blur pass.
  18278. * Only useful if useKernelBlur = true
  18279. */
  18280. set blurKernel(value: number);
  18281. protected _useKernelBlur: boolean;
  18282. /**
  18283. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18284. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18285. */
  18286. get useKernelBlur(): boolean;
  18287. /**
  18288. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18289. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18290. */
  18291. set useKernelBlur(value: boolean);
  18292. protected _depthScale: number;
  18293. /**
  18294. * Gets the depth scale used in ESM mode.
  18295. */
  18296. get depthScale(): number;
  18297. /**
  18298. * Sets the depth scale used in ESM mode.
  18299. * This can override the scale stored on the light.
  18300. */
  18301. set depthScale(value: number);
  18302. protected _validateFilter(filter: number): number;
  18303. protected _filter: number;
  18304. /**
  18305. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18306. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18307. */
  18308. get filter(): number;
  18309. /**
  18310. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18311. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18312. */
  18313. set filter(value: number);
  18314. /**
  18315. * Gets if the current filter is set to Poisson Sampling.
  18316. */
  18317. get usePoissonSampling(): boolean;
  18318. /**
  18319. * Sets the current filter to Poisson Sampling.
  18320. */
  18321. set usePoissonSampling(value: boolean);
  18322. /**
  18323. * Gets if the current filter is set to ESM.
  18324. */
  18325. get useExponentialShadowMap(): boolean;
  18326. /**
  18327. * Sets the current filter is to ESM.
  18328. */
  18329. set useExponentialShadowMap(value: boolean);
  18330. /**
  18331. * Gets if the current filter is set to filtered ESM.
  18332. */
  18333. get useBlurExponentialShadowMap(): boolean;
  18334. /**
  18335. * Gets if the current filter is set to filtered ESM.
  18336. */
  18337. set useBlurExponentialShadowMap(value: boolean);
  18338. /**
  18339. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18340. * exponential to prevent steep falloff artifacts).
  18341. */
  18342. get useCloseExponentialShadowMap(): boolean;
  18343. /**
  18344. * Sets the current filter to "close ESM" (using the inverse of the
  18345. * exponential to prevent steep falloff artifacts).
  18346. */
  18347. set useCloseExponentialShadowMap(value: boolean);
  18348. /**
  18349. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18350. * exponential to prevent steep falloff artifacts).
  18351. */
  18352. get useBlurCloseExponentialShadowMap(): boolean;
  18353. /**
  18354. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18355. * exponential to prevent steep falloff artifacts).
  18356. */
  18357. set useBlurCloseExponentialShadowMap(value: boolean);
  18358. /**
  18359. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18360. */
  18361. get usePercentageCloserFiltering(): boolean;
  18362. /**
  18363. * Sets the current filter to "PCF" (percentage closer filtering).
  18364. */
  18365. set usePercentageCloserFiltering(value: boolean);
  18366. protected _filteringQuality: number;
  18367. /**
  18368. * Gets the PCF or PCSS Quality.
  18369. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18370. */
  18371. get filteringQuality(): number;
  18372. /**
  18373. * Sets the PCF or PCSS Quality.
  18374. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18375. */
  18376. set filteringQuality(filteringQuality: number);
  18377. /**
  18378. * Gets if the current filter is set to "PCSS" (contact hardening).
  18379. */
  18380. get useContactHardeningShadow(): boolean;
  18381. /**
  18382. * Sets the current filter to "PCSS" (contact hardening).
  18383. */
  18384. set useContactHardeningShadow(value: boolean);
  18385. protected _contactHardeningLightSizeUVRatio: number;
  18386. /**
  18387. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18388. * Using a ratio helps keeping shape stability independently of the map size.
  18389. *
  18390. * It does not account for the light projection as it was having too much
  18391. * instability during the light setup or during light position changes.
  18392. *
  18393. * Only valid if useContactHardeningShadow is true.
  18394. */
  18395. get contactHardeningLightSizeUVRatio(): number;
  18396. /**
  18397. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18398. * Using a ratio helps keeping shape stability independently of the map size.
  18399. *
  18400. * It does not account for the light projection as it was having too much
  18401. * instability during the light setup or during light position changes.
  18402. *
  18403. * Only valid if useContactHardeningShadow is true.
  18404. */
  18405. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18406. protected _darkness: number;
  18407. /** Gets or sets the actual darkness of a shadow */
  18408. get darkness(): number;
  18409. set darkness(value: number);
  18410. /**
  18411. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18412. * 0 means strongest and 1 would means no shadow.
  18413. * @returns the darkness.
  18414. */
  18415. getDarkness(): number;
  18416. /**
  18417. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18418. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18419. * @returns the shadow generator allowing fluent coding.
  18420. */
  18421. setDarkness(darkness: number): ShadowGenerator;
  18422. protected _transparencyShadow: boolean;
  18423. /** Gets or sets the ability to have transparent shadow */
  18424. get transparencyShadow(): boolean;
  18425. set transparencyShadow(value: boolean);
  18426. /**
  18427. * Sets the ability to have transparent shadow (boolean).
  18428. * @param transparent True if transparent else False
  18429. * @returns the shadow generator allowing fluent coding
  18430. */
  18431. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18432. /**
  18433. * Enables or disables shadows with varying strength based on the transparency
  18434. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18435. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18436. * mesh.visibility * alphaTexture.a
  18437. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18438. */
  18439. enableSoftTransparentShadow: boolean;
  18440. protected _shadowMap: Nullable<RenderTargetTexture>;
  18441. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18442. /**
  18443. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18444. * @returns The render target texture if present otherwise, null
  18445. */
  18446. getShadowMap(): Nullable<RenderTargetTexture>;
  18447. /**
  18448. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18449. * @returns The render target texture if the shadow map is present otherwise, null
  18450. */
  18451. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18452. /**
  18453. * Gets the class name of that object
  18454. * @returns "ShadowGenerator"
  18455. */
  18456. getClassName(): string;
  18457. /**
  18458. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18459. * @param mesh Mesh to add
  18460. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18461. * @returns the Shadow Generator itself
  18462. */
  18463. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18464. /**
  18465. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18466. * @param mesh Mesh to remove
  18467. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18468. * @returns the Shadow Generator itself
  18469. */
  18470. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18471. /**
  18472. * Controls the extent to which the shadows fade out at the edge of the frustum
  18473. */
  18474. frustumEdgeFalloff: number;
  18475. protected _light: IShadowLight;
  18476. /**
  18477. * Returns the associated light object.
  18478. * @returns the light generating the shadow
  18479. */
  18480. getLight(): IShadowLight;
  18481. /**
  18482. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18483. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18484. * It might on the other hand introduce peter panning.
  18485. */
  18486. forceBackFacesOnly: boolean;
  18487. protected _scene: Scene;
  18488. protected _lightDirection: Vector3;
  18489. protected _effect: Effect;
  18490. protected _viewMatrix: Matrix;
  18491. protected _projectionMatrix: Matrix;
  18492. protected _transformMatrix: Matrix;
  18493. protected _cachedPosition: Vector3;
  18494. protected _cachedDirection: Vector3;
  18495. protected _cachedDefines: string;
  18496. protected _currentRenderID: number;
  18497. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18498. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18499. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18500. protected _blurPostProcesses: PostProcess[];
  18501. protected _mapSize: number;
  18502. protected _currentFaceIndex: number;
  18503. protected _currentFaceIndexCache: number;
  18504. protected _textureType: number;
  18505. protected _defaultTextureMatrix: Matrix;
  18506. protected _storedUniqueId: Nullable<number>;
  18507. /** @hidden */
  18508. static _SceneComponentInitialization: (scene: Scene) => void;
  18509. /**
  18510. * Gets or sets the size of the texture what stores the shadows
  18511. */
  18512. get mapSize(): number;
  18513. set mapSize(size: number);
  18514. /**
  18515. * Creates a ShadowGenerator object.
  18516. * A ShadowGenerator is the required tool to use the shadows.
  18517. * Each light casting shadows needs to use its own ShadowGenerator.
  18518. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18519. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18520. * @param light The light object generating the shadows.
  18521. * @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.
  18522. */
  18523. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18524. protected _initializeGenerator(): void;
  18525. protected _createTargetRenderTexture(): void;
  18526. protected _initializeShadowMap(): void;
  18527. protected _initializeBlurRTTAndPostProcesses(): void;
  18528. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18529. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18530. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18531. protected _applyFilterValues(): void;
  18532. /**
  18533. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18534. * @param onCompiled Callback triggered at the and of the effects compilation
  18535. * @param options Sets of optional options forcing the compilation with different modes
  18536. */
  18537. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18538. useInstances: boolean;
  18539. }>): void;
  18540. /**
  18541. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18542. * @param options Sets of optional options forcing the compilation with different modes
  18543. * @returns A promise that resolves when the compilation completes
  18544. */
  18545. forceCompilationAsync(options?: Partial<{
  18546. useInstances: boolean;
  18547. }>): Promise<void>;
  18548. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18549. private _prepareShadowDefines;
  18550. /**
  18551. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18552. * @param subMesh The submesh we want to render in the shadow map
  18553. * @param useInstances Defines wether will draw in the map using instances
  18554. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18555. * @returns true if ready otherwise, false
  18556. */
  18557. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18558. /**
  18559. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18560. * @param defines Defines of the material we want to update
  18561. * @param lightIndex Index of the light in the enabled light list of the material
  18562. */
  18563. prepareDefines(defines: any, lightIndex: number): void;
  18564. /**
  18565. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18566. * defined in the generator but impacting the effect).
  18567. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18568. * @param effect The effect we are binfing the information for
  18569. */
  18570. bindShadowLight(lightIndex: string, effect: Effect): void;
  18571. /**
  18572. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18573. * (eq to shadow prjection matrix * light transform matrix)
  18574. * @returns The transform matrix used to create the shadow map
  18575. */
  18576. getTransformMatrix(): Matrix;
  18577. /**
  18578. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18579. * Cube and 2D textures for instance.
  18580. */
  18581. recreateShadowMap(): void;
  18582. protected _disposeBlurPostProcesses(): void;
  18583. protected _disposeRTTandPostProcesses(): void;
  18584. /**
  18585. * Disposes the ShadowGenerator.
  18586. * Returns nothing.
  18587. */
  18588. dispose(): void;
  18589. /**
  18590. * Serializes the shadow generator setup to a json object.
  18591. * @returns The serialized JSON object
  18592. */
  18593. serialize(): any;
  18594. /**
  18595. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18596. * @param parsedShadowGenerator The JSON object to parse
  18597. * @param scene The scene to create the shadow map for
  18598. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18599. * @returns The parsed shadow generator
  18600. */
  18601. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18602. }
  18603. }
  18604. declare module "babylonjs/Lights/light" {
  18605. import { Nullable } from "babylonjs/types";
  18606. import { Scene } from "babylonjs/scene";
  18607. import { Vector3 } from "babylonjs/Maths/math.vector";
  18608. import { Color3 } from "babylonjs/Maths/math.color";
  18609. import { Node } from "babylonjs/node";
  18610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18611. import { Effect } from "babylonjs/Materials/effect";
  18612. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18613. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18614. /**
  18615. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18616. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18617. * 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.
  18618. */
  18619. export abstract class Light extends Node {
  18620. /**
  18621. * Falloff Default: light is falling off following the material specification:
  18622. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18623. */
  18624. static readonly FALLOFF_DEFAULT: number;
  18625. /**
  18626. * Falloff Physical: light is falling off following the inverse squared distance law.
  18627. */
  18628. static readonly FALLOFF_PHYSICAL: number;
  18629. /**
  18630. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18631. * to enhance interoperability with other engines.
  18632. */
  18633. static readonly FALLOFF_GLTF: number;
  18634. /**
  18635. * Falloff Standard: light is falling off like in the standard material
  18636. * to enhance interoperability with other materials.
  18637. */
  18638. static readonly FALLOFF_STANDARD: number;
  18639. /**
  18640. * If every light affecting the material is in this lightmapMode,
  18641. * material.lightmapTexture adds or multiplies
  18642. * (depends on material.useLightmapAsShadowmap)
  18643. * after every other light calculations.
  18644. */
  18645. static readonly LIGHTMAP_DEFAULT: number;
  18646. /**
  18647. * material.lightmapTexture as only diffuse lighting from this light
  18648. * adds only specular lighting from this light
  18649. * adds dynamic shadows
  18650. */
  18651. static readonly LIGHTMAP_SPECULAR: number;
  18652. /**
  18653. * material.lightmapTexture as only lighting
  18654. * no light calculation from this light
  18655. * only adds dynamic shadows from this light
  18656. */
  18657. static readonly LIGHTMAP_SHADOWSONLY: number;
  18658. /**
  18659. * Each light type uses the default quantity according to its type:
  18660. * point/spot lights use luminous intensity
  18661. * directional lights use illuminance
  18662. */
  18663. static readonly INTENSITYMODE_AUTOMATIC: number;
  18664. /**
  18665. * lumen (lm)
  18666. */
  18667. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18668. /**
  18669. * candela (lm/sr)
  18670. */
  18671. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18672. /**
  18673. * lux (lm/m^2)
  18674. */
  18675. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18676. /**
  18677. * nit (cd/m^2)
  18678. */
  18679. static readonly INTENSITYMODE_LUMINANCE: number;
  18680. /**
  18681. * Light type const id of the point light.
  18682. */
  18683. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18684. /**
  18685. * Light type const id of the directional light.
  18686. */
  18687. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18688. /**
  18689. * Light type const id of the spot light.
  18690. */
  18691. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18692. /**
  18693. * Light type const id of the hemispheric light.
  18694. */
  18695. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18696. /**
  18697. * Diffuse gives the basic color to an object.
  18698. */
  18699. diffuse: Color3;
  18700. /**
  18701. * Specular produces a highlight color on an object.
  18702. * Note: This is note affecting PBR materials.
  18703. */
  18704. specular: Color3;
  18705. /**
  18706. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18707. * falling off base on range or angle.
  18708. * This can be set to any values in Light.FALLOFF_x.
  18709. *
  18710. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18711. * other types of materials.
  18712. */
  18713. falloffType: number;
  18714. /**
  18715. * Strength of the light.
  18716. * Note: By default it is define in the framework own unit.
  18717. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18718. */
  18719. intensity: number;
  18720. private _range;
  18721. protected _inverseSquaredRange: number;
  18722. /**
  18723. * Defines how far from the source the light is impacting in scene units.
  18724. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18725. */
  18726. get range(): number;
  18727. /**
  18728. * Defines how far from the source the light is impacting in scene units.
  18729. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18730. */
  18731. set range(value: number);
  18732. /**
  18733. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18734. * of light.
  18735. */
  18736. private _photometricScale;
  18737. private _intensityMode;
  18738. /**
  18739. * Gets the photometric scale used to interpret the intensity.
  18740. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18741. */
  18742. get intensityMode(): number;
  18743. /**
  18744. * Sets the photometric scale used to interpret the intensity.
  18745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18746. */
  18747. set intensityMode(value: number);
  18748. private _radius;
  18749. /**
  18750. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18751. */
  18752. get radius(): number;
  18753. /**
  18754. * sets the light radius used by PBR Materials to simulate soft area lights.
  18755. */
  18756. set radius(value: number);
  18757. private _renderPriority;
  18758. /**
  18759. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18760. * exceeding the number allowed of the materials.
  18761. */
  18762. renderPriority: number;
  18763. private _shadowEnabled;
  18764. /**
  18765. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18766. * the current shadow generator.
  18767. */
  18768. get shadowEnabled(): boolean;
  18769. /**
  18770. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18771. * the current shadow generator.
  18772. */
  18773. set shadowEnabled(value: boolean);
  18774. private _includedOnlyMeshes;
  18775. /**
  18776. * Gets the only meshes impacted by this light.
  18777. */
  18778. get includedOnlyMeshes(): AbstractMesh[];
  18779. /**
  18780. * Sets the only meshes impacted by this light.
  18781. */
  18782. set includedOnlyMeshes(value: AbstractMesh[]);
  18783. private _excludedMeshes;
  18784. /**
  18785. * Gets the meshes not impacted by this light.
  18786. */
  18787. get excludedMeshes(): AbstractMesh[];
  18788. /**
  18789. * Sets the meshes not impacted by this light.
  18790. */
  18791. set excludedMeshes(value: AbstractMesh[]);
  18792. private _excludeWithLayerMask;
  18793. /**
  18794. * Gets the layer id use to find what meshes are not impacted by the light.
  18795. * Inactive if 0
  18796. */
  18797. get excludeWithLayerMask(): number;
  18798. /**
  18799. * Sets the layer id use to find what meshes are not impacted by the light.
  18800. * Inactive if 0
  18801. */
  18802. set excludeWithLayerMask(value: number);
  18803. private _includeOnlyWithLayerMask;
  18804. /**
  18805. * Gets the layer id use to find what meshes are impacted by the light.
  18806. * Inactive if 0
  18807. */
  18808. get includeOnlyWithLayerMask(): number;
  18809. /**
  18810. * Sets the layer id use to find what meshes are impacted by the light.
  18811. * Inactive if 0
  18812. */
  18813. set includeOnlyWithLayerMask(value: number);
  18814. private _lightmapMode;
  18815. /**
  18816. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18817. */
  18818. get lightmapMode(): number;
  18819. /**
  18820. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18821. */
  18822. set lightmapMode(value: number);
  18823. /**
  18824. * Shadow generator associted to the light.
  18825. * @hidden Internal use only.
  18826. */
  18827. _shadowGenerator: Nullable<IShadowGenerator>;
  18828. /**
  18829. * @hidden Internal use only.
  18830. */
  18831. _excludedMeshesIds: string[];
  18832. /**
  18833. * @hidden Internal use only.
  18834. */
  18835. _includedOnlyMeshesIds: string[];
  18836. /**
  18837. * The current light unifom buffer.
  18838. * @hidden Internal use only.
  18839. */
  18840. _uniformBuffer: UniformBuffer;
  18841. /** @hidden */
  18842. _renderId: number;
  18843. /**
  18844. * Creates a Light object in the scene.
  18845. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18846. * @param name The firendly name of the light
  18847. * @param scene The scene the light belongs too
  18848. */
  18849. constructor(name: string, scene: Scene);
  18850. protected abstract _buildUniformLayout(): void;
  18851. /**
  18852. * Sets the passed Effect "effect" with the Light information.
  18853. * @param effect The effect to update
  18854. * @param lightIndex The index of the light in the effect to update
  18855. * @returns The light
  18856. */
  18857. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18858. /**
  18859. * Sets the passed Effect "effect" with the Light textures.
  18860. * @param effect The effect to update
  18861. * @param lightIndex The index of the light in the effect to update
  18862. * @returns The light
  18863. */
  18864. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18865. /**
  18866. * Binds the lights information from the scene to the effect for the given mesh.
  18867. * @param lightIndex Light index
  18868. * @param scene The scene where the light belongs to
  18869. * @param effect The effect we are binding the data to
  18870. * @param useSpecular Defines if specular is supported
  18871. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18872. */
  18873. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18874. /**
  18875. * Sets the passed Effect "effect" with the Light information.
  18876. * @param effect The effect to update
  18877. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18878. * @returns The light
  18879. */
  18880. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18881. /**
  18882. * Returns the string "Light".
  18883. * @returns the class name
  18884. */
  18885. getClassName(): string;
  18886. /** @hidden */
  18887. readonly _isLight: boolean;
  18888. /**
  18889. * Converts the light information to a readable string for debug purpose.
  18890. * @param fullDetails Supports for multiple levels of logging within scene loading
  18891. * @returns the human readable light info
  18892. */
  18893. toString(fullDetails?: boolean): string;
  18894. /** @hidden */
  18895. protected _syncParentEnabledState(): void;
  18896. /**
  18897. * Set the enabled state of this node.
  18898. * @param value - the new enabled state
  18899. */
  18900. setEnabled(value: boolean): void;
  18901. /**
  18902. * Returns the Light associated shadow generator if any.
  18903. * @return the associated shadow generator.
  18904. */
  18905. getShadowGenerator(): Nullable<IShadowGenerator>;
  18906. /**
  18907. * Returns a Vector3, the absolute light position in the World.
  18908. * @returns the world space position of the light
  18909. */
  18910. getAbsolutePosition(): Vector3;
  18911. /**
  18912. * Specifies if the light will affect the passed mesh.
  18913. * @param mesh The mesh to test against the light
  18914. * @return true the mesh is affected otherwise, false.
  18915. */
  18916. canAffectMesh(mesh: AbstractMesh): boolean;
  18917. /**
  18918. * Sort function to order lights for rendering.
  18919. * @param a First Light object to compare to second.
  18920. * @param b Second Light object to compare first.
  18921. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18922. */
  18923. static CompareLightsPriority(a: Light, b: Light): number;
  18924. /**
  18925. * Releases resources associated with this node.
  18926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18928. */
  18929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18930. /**
  18931. * Returns the light type ID (integer).
  18932. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18933. */
  18934. getTypeID(): number;
  18935. /**
  18936. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18937. * @returns the scaled intensity in intensity mode unit
  18938. */
  18939. getScaledIntensity(): number;
  18940. /**
  18941. * Returns a new Light object, named "name", from the current one.
  18942. * @param name The name of the cloned light
  18943. * @param newParent The parent of this light, if it has one
  18944. * @returns the new created light
  18945. */
  18946. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18947. /**
  18948. * Serializes the current light into a Serialization object.
  18949. * @returns the serialized object.
  18950. */
  18951. serialize(): any;
  18952. /**
  18953. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18954. * This new light is named "name" and added to the passed scene.
  18955. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18956. * @param name The friendly name of the light
  18957. * @param scene The scene the new light will belong to
  18958. * @returns the constructor function
  18959. */
  18960. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18961. /**
  18962. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18963. * @param parsedLight The JSON representation of the light
  18964. * @param scene The scene to create the parsed light in
  18965. * @returns the created light after parsing
  18966. */
  18967. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18968. private _hookArrayForExcluded;
  18969. private _hookArrayForIncludedOnly;
  18970. private _resyncMeshes;
  18971. /**
  18972. * Forces the meshes to update their light related information in their rendering used effects
  18973. * @hidden Internal Use Only
  18974. */
  18975. _markMeshesAsLightDirty(): void;
  18976. /**
  18977. * Recomputes the cached photometric scale if needed.
  18978. */
  18979. private _computePhotometricScale;
  18980. /**
  18981. * Returns the Photometric Scale according to the light type and intensity mode.
  18982. */
  18983. private _getPhotometricScale;
  18984. /**
  18985. * Reorder the light in the scene according to their defined priority.
  18986. * @hidden Internal Use Only
  18987. */
  18988. _reorderLightsInScene(): void;
  18989. /**
  18990. * Prepares the list of defines specific to the light type.
  18991. * @param defines the list of defines
  18992. * @param lightIndex defines the index of the light for the effect
  18993. */
  18994. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18995. }
  18996. }
  18997. declare module "babylonjs/Materials/prePassConfiguration" {
  18998. import { Matrix } from "babylonjs/Maths/math.vector";
  18999. import { Mesh } from "babylonjs/Meshes/mesh";
  19000. import { Scene } from "babylonjs/scene";
  19001. import { Effect } from "babylonjs/Materials/effect";
  19002. /**
  19003. * Configuration needed for prepass-capable materials
  19004. */
  19005. export class PrePassConfiguration {
  19006. /**
  19007. * Previous world matrices of meshes carrying this material
  19008. * Used for computing velocity
  19009. */
  19010. previousWorldMatrices: {
  19011. [index: number]: Matrix;
  19012. };
  19013. /**
  19014. * Previous view project matrix
  19015. * Used for computing velocity
  19016. */
  19017. previousViewProjection: Matrix;
  19018. /**
  19019. * Previous bones of meshes carrying this material
  19020. * Used for computing velocity
  19021. */
  19022. previousBones: {
  19023. [index: number]: Float32Array;
  19024. };
  19025. /**
  19026. * Add the required uniforms to the current list.
  19027. * @param uniforms defines the current uniform list.
  19028. */
  19029. static AddUniforms(uniforms: string[]): void;
  19030. /**
  19031. * Add the required samplers to the current list.
  19032. * @param samplers defines the current sampler list.
  19033. */
  19034. static AddSamplers(samplers: string[]): void;
  19035. /**
  19036. * Binds the material data.
  19037. * @param effect defines the effect to update
  19038. * @param scene defines the scene the material belongs to.
  19039. * @param mesh The mesh
  19040. * @param world World matrix of this mesh
  19041. * @param isFrozen Is the material frozen
  19042. */
  19043. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19044. }
  19045. }
  19046. declare module "babylonjs/Cameras/targetCamera" {
  19047. import { Nullable } from "babylonjs/types";
  19048. import { Camera } from "babylonjs/Cameras/camera";
  19049. import { Scene } from "babylonjs/scene";
  19050. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19051. /**
  19052. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19053. * This is the base of the follow, arc rotate cameras and Free camera
  19054. * @see https://doc.babylonjs.com/features/cameras
  19055. */
  19056. export class TargetCamera extends Camera {
  19057. private static _RigCamTransformMatrix;
  19058. private static _TargetTransformMatrix;
  19059. private static _TargetFocalPoint;
  19060. private _tmpUpVector;
  19061. private _tmpTargetVector;
  19062. /**
  19063. * Define the current direction the camera is moving to
  19064. */
  19065. cameraDirection: Vector3;
  19066. /**
  19067. * Define the current rotation the camera is rotating to
  19068. */
  19069. cameraRotation: Vector2;
  19070. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19071. ignoreParentScaling: boolean;
  19072. /**
  19073. * When set, the up vector of the camera will be updated by the rotation of the camera
  19074. */
  19075. updateUpVectorFromRotation: boolean;
  19076. private _tmpQuaternion;
  19077. /**
  19078. * Define the current rotation of the camera
  19079. */
  19080. rotation: Vector3;
  19081. /**
  19082. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19083. */
  19084. rotationQuaternion: Quaternion;
  19085. /**
  19086. * Define the current speed of the camera
  19087. */
  19088. speed: number;
  19089. /**
  19090. * Add constraint to the camera to prevent it to move freely in all directions and
  19091. * around all axis.
  19092. */
  19093. noRotationConstraint: boolean;
  19094. /**
  19095. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19096. * panning
  19097. */
  19098. invertRotation: boolean;
  19099. /**
  19100. * Speed multiplier for inverse camera panning
  19101. */
  19102. inverseRotationSpeed: number;
  19103. /**
  19104. * Define the current target of the camera as an object or a position.
  19105. */
  19106. lockedTarget: any;
  19107. /** @hidden */
  19108. _currentTarget: Vector3;
  19109. /** @hidden */
  19110. _initialFocalDistance: number;
  19111. /** @hidden */
  19112. _viewMatrix: Matrix;
  19113. /** @hidden */
  19114. _camMatrix: Matrix;
  19115. /** @hidden */
  19116. _cameraTransformMatrix: Matrix;
  19117. /** @hidden */
  19118. _cameraRotationMatrix: Matrix;
  19119. /** @hidden */
  19120. _referencePoint: Vector3;
  19121. /** @hidden */
  19122. _transformedReferencePoint: Vector3;
  19123. /** @hidden */
  19124. _reset: () => void;
  19125. private _defaultUp;
  19126. /**
  19127. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19128. * This is the base of the follow, arc rotate cameras and Free camera
  19129. * @see https://doc.babylonjs.com/features/cameras
  19130. * @param name Defines the name of the camera in the scene
  19131. * @param position Defines the start position of the camera in the scene
  19132. * @param scene Defines the scene the camera belongs to
  19133. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19134. */
  19135. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19136. /**
  19137. * Gets the position in front of the camera at a given distance.
  19138. * @param distance The distance from the camera we want the position to be
  19139. * @returns the position
  19140. */
  19141. getFrontPosition(distance: number): Vector3;
  19142. /** @hidden */
  19143. _getLockedTargetPosition(): Nullable<Vector3>;
  19144. private _storedPosition;
  19145. private _storedRotation;
  19146. private _storedRotationQuaternion;
  19147. /**
  19148. * Store current camera state of the camera (fov, position, rotation, etc..)
  19149. * @returns the camera
  19150. */
  19151. storeState(): Camera;
  19152. /**
  19153. * Restored camera state. You must call storeState() first
  19154. * @returns whether it was successful or not
  19155. * @hidden
  19156. */
  19157. _restoreStateValues(): boolean;
  19158. /** @hidden */
  19159. _initCache(): void;
  19160. /** @hidden */
  19161. _updateCache(ignoreParentClass?: boolean): void;
  19162. /** @hidden */
  19163. _isSynchronizedViewMatrix(): boolean;
  19164. /** @hidden */
  19165. _computeLocalCameraSpeed(): number;
  19166. /**
  19167. * Defines the target the camera should look at.
  19168. * @param target Defines the new target as a Vector or a mesh
  19169. */
  19170. setTarget(target: Vector3): void;
  19171. /**
  19172. * Defines the target point of the camera.
  19173. * The camera looks towards it form the radius distance.
  19174. */
  19175. get target(): Vector3;
  19176. set target(value: Vector3);
  19177. /**
  19178. * Return the current target position of the camera. This value is expressed in local space.
  19179. * @returns the target position
  19180. */
  19181. getTarget(): Vector3;
  19182. /** @hidden */
  19183. _decideIfNeedsToMove(): boolean;
  19184. /** @hidden */
  19185. _updatePosition(): void;
  19186. /** @hidden */
  19187. _checkInputs(): void;
  19188. protected _updateCameraRotationMatrix(): void;
  19189. /**
  19190. * 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)
  19191. * @returns the current camera
  19192. */
  19193. private _rotateUpVectorWithCameraRotationMatrix;
  19194. private _cachedRotationZ;
  19195. private _cachedQuaternionRotationZ;
  19196. /** @hidden */
  19197. _getViewMatrix(): Matrix;
  19198. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19199. /**
  19200. * @hidden
  19201. */
  19202. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19203. /**
  19204. * @hidden
  19205. */
  19206. _updateRigCameras(): void;
  19207. private _getRigCamPositionAndTarget;
  19208. /**
  19209. * Gets the current object class name.
  19210. * @return the class name
  19211. */
  19212. getClassName(): string;
  19213. }
  19214. }
  19215. declare module "babylonjs/Events/keyboardEvents" {
  19216. /**
  19217. * Gather the list of keyboard event types as constants.
  19218. */
  19219. export class KeyboardEventTypes {
  19220. /**
  19221. * The keydown event is fired when a key becomes active (pressed).
  19222. */
  19223. static readonly KEYDOWN: number;
  19224. /**
  19225. * The keyup event is fired when a key has been released.
  19226. */
  19227. static readonly KEYUP: number;
  19228. }
  19229. /**
  19230. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19231. */
  19232. export class KeyboardInfo {
  19233. /**
  19234. * Defines the type of event (KeyboardEventTypes)
  19235. */
  19236. type: number;
  19237. /**
  19238. * Defines the related dom event
  19239. */
  19240. event: KeyboardEvent;
  19241. /**
  19242. * Instantiates a new keyboard info.
  19243. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19244. * @param type Defines the type of event (KeyboardEventTypes)
  19245. * @param event Defines the related dom event
  19246. */
  19247. constructor(
  19248. /**
  19249. * Defines the type of event (KeyboardEventTypes)
  19250. */
  19251. type: number,
  19252. /**
  19253. * Defines the related dom event
  19254. */
  19255. event: KeyboardEvent);
  19256. }
  19257. /**
  19258. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19259. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19260. */
  19261. export class KeyboardInfoPre extends KeyboardInfo {
  19262. /**
  19263. * Defines the type of event (KeyboardEventTypes)
  19264. */
  19265. type: number;
  19266. /**
  19267. * Defines the related dom event
  19268. */
  19269. event: KeyboardEvent;
  19270. /**
  19271. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19272. */
  19273. skipOnPointerObservable: boolean;
  19274. /**
  19275. * Instantiates a new keyboard pre info.
  19276. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19277. * @param type Defines the type of event (KeyboardEventTypes)
  19278. * @param event Defines the related dom event
  19279. */
  19280. constructor(
  19281. /**
  19282. * Defines the type of event (KeyboardEventTypes)
  19283. */
  19284. type: number,
  19285. /**
  19286. * Defines the related dom event
  19287. */
  19288. event: KeyboardEvent);
  19289. }
  19290. }
  19291. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19292. import { Nullable } from "babylonjs/types";
  19293. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19295. /**
  19296. * Manage the keyboard inputs to control the movement of a free camera.
  19297. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19298. */
  19299. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19300. /**
  19301. * Defines the camera the input is attached to.
  19302. */
  19303. camera: FreeCamera;
  19304. /**
  19305. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19306. */
  19307. keysUp: number[];
  19308. /**
  19309. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19310. */
  19311. keysUpward: number[];
  19312. /**
  19313. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19314. */
  19315. keysDown: number[];
  19316. /**
  19317. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19318. */
  19319. keysDownward: number[];
  19320. /**
  19321. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19322. */
  19323. keysLeft: number[];
  19324. /**
  19325. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19326. */
  19327. keysRight: number[];
  19328. private _keys;
  19329. private _onCanvasBlurObserver;
  19330. private _onKeyboardObserver;
  19331. private _engine;
  19332. private _scene;
  19333. /**
  19334. * Attach the input controls to a specific dom element to get the input from.
  19335. * @param element Defines the element the controls should be listened from
  19336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19337. */
  19338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19339. /**
  19340. * Detach the current controls from the specified dom element.
  19341. * @param element Defines the element to stop listening the inputs from
  19342. */
  19343. detachControl(element: Nullable<HTMLElement>): void;
  19344. /**
  19345. * Update the current camera state depending on the inputs that have been used this frame.
  19346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19347. */
  19348. checkInputs(): void;
  19349. /**
  19350. * Gets the class name of the current intput.
  19351. * @returns the class name
  19352. */
  19353. getClassName(): string;
  19354. /** @hidden */
  19355. _onLostFocus(): void;
  19356. /**
  19357. * Get the friendly name associated with the input class.
  19358. * @returns the input friendly name
  19359. */
  19360. getSimpleName(): string;
  19361. }
  19362. }
  19363. declare module "babylonjs/Events/pointerEvents" {
  19364. import { Nullable } from "babylonjs/types";
  19365. import { Vector2 } from "babylonjs/Maths/math.vector";
  19366. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19367. import { Ray } from "babylonjs/Culling/ray";
  19368. /**
  19369. * Gather the list of pointer event types as constants.
  19370. */
  19371. export class PointerEventTypes {
  19372. /**
  19373. * 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.
  19374. */
  19375. static readonly POINTERDOWN: number;
  19376. /**
  19377. * The pointerup event is fired when a pointer is no longer active.
  19378. */
  19379. static readonly POINTERUP: number;
  19380. /**
  19381. * The pointermove event is fired when a pointer changes coordinates.
  19382. */
  19383. static readonly POINTERMOVE: number;
  19384. /**
  19385. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19386. */
  19387. static readonly POINTERWHEEL: number;
  19388. /**
  19389. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19390. */
  19391. static readonly POINTERPICK: number;
  19392. /**
  19393. * The pointertap event is fired when a the object has been touched and released without drag.
  19394. */
  19395. static readonly POINTERTAP: number;
  19396. /**
  19397. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19398. */
  19399. static readonly POINTERDOUBLETAP: number;
  19400. }
  19401. /**
  19402. * Base class of pointer info types.
  19403. */
  19404. export class PointerInfoBase {
  19405. /**
  19406. * Defines the type of event (PointerEventTypes)
  19407. */
  19408. type: number;
  19409. /**
  19410. * Defines the related dom event
  19411. */
  19412. event: PointerEvent | MouseWheelEvent;
  19413. /**
  19414. * Instantiates the base class of pointers info.
  19415. * @param type Defines the type of event (PointerEventTypes)
  19416. * @param event Defines the related dom event
  19417. */
  19418. constructor(
  19419. /**
  19420. * Defines the type of event (PointerEventTypes)
  19421. */
  19422. type: number,
  19423. /**
  19424. * Defines the related dom event
  19425. */
  19426. event: PointerEvent | MouseWheelEvent);
  19427. }
  19428. /**
  19429. * This class is used to store pointer related info for the onPrePointerObservable event.
  19430. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19431. */
  19432. export class PointerInfoPre extends PointerInfoBase {
  19433. /**
  19434. * Ray from a pointer if availible (eg. 6dof controller)
  19435. */
  19436. ray: Nullable<Ray>;
  19437. /**
  19438. * Defines the local position of the pointer on the canvas.
  19439. */
  19440. localPosition: Vector2;
  19441. /**
  19442. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19443. */
  19444. skipOnPointerObservable: boolean;
  19445. /**
  19446. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19447. * @param type Defines the type of event (PointerEventTypes)
  19448. * @param event Defines the related dom event
  19449. * @param localX Defines the local x coordinates of the pointer when the event occured
  19450. * @param localY Defines the local y coordinates of the pointer when the event occured
  19451. */
  19452. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19453. }
  19454. /**
  19455. * This type contains all the data related to a pointer event in Babylon.js.
  19456. * 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.
  19457. */
  19458. export class PointerInfo extends PointerInfoBase {
  19459. /**
  19460. * Defines the picking info associated to the info (if any)\
  19461. */
  19462. pickInfo: Nullable<PickingInfo>;
  19463. /**
  19464. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19465. * @param type Defines the type of event (PointerEventTypes)
  19466. * @param event Defines the related dom event
  19467. * @param pickInfo Defines the picking info associated to the info (if any)\
  19468. */
  19469. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19470. /**
  19471. * Defines the picking info associated to the info (if any)\
  19472. */
  19473. pickInfo: Nullable<PickingInfo>);
  19474. }
  19475. /**
  19476. * Data relating to a touch event on the screen.
  19477. */
  19478. export interface PointerTouch {
  19479. /**
  19480. * X coordinate of touch.
  19481. */
  19482. x: number;
  19483. /**
  19484. * Y coordinate of touch.
  19485. */
  19486. y: number;
  19487. /**
  19488. * Id of touch. Unique for each finger.
  19489. */
  19490. pointerId: number;
  19491. /**
  19492. * Event type passed from DOM.
  19493. */
  19494. type: any;
  19495. }
  19496. }
  19497. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19498. import { Observable } from "babylonjs/Misc/observable";
  19499. import { Nullable } from "babylonjs/types";
  19500. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19501. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19502. /**
  19503. * Manage the mouse inputs to control the movement of a free camera.
  19504. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19505. */
  19506. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19507. /**
  19508. * Define if touch is enabled in the mouse input
  19509. */
  19510. touchEnabled: boolean;
  19511. /**
  19512. * Defines the camera the input is attached to.
  19513. */
  19514. camera: FreeCamera;
  19515. /**
  19516. * Defines the buttons associated with the input to handle camera move.
  19517. */
  19518. buttons: number[];
  19519. /**
  19520. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19521. */
  19522. angularSensibility: number;
  19523. private _pointerInput;
  19524. private _onMouseMove;
  19525. private _observer;
  19526. private previousPosition;
  19527. /**
  19528. * Observable for when a pointer move event occurs containing the move offset
  19529. */
  19530. onPointerMovedObservable: Observable<{
  19531. offsetX: number;
  19532. offsetY: number;
  19533. }>;
  19534. /**
  19535. * @hidden
  19536. * If the camera should be rotated automatically based on pointer movement
  19537. */
  19538. _allowCameraRotation: boolean;
  19539. /**
  19540. * Manage the mouse inputs to control the movement of a free camera.
  19541. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19542. * @param touchEnabled Defines if touch is enabled or not
  19543. */
  19544. constructor(
  19545. /**
  19546. * Define if touch is enabled in the mouse input
  19547. */
  19548. touchEnabled?: boolean);
  19549. /**
  19550. * Attach the input controls to a specific dom element to get the input from.
  19551. * @param element Defines the element the controls should be listened from
  19552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19553. */
  19554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19555. /**
  19556. * Called on JS contextmenu event.
  19557. * Override this method to provide functionality.
  19558. */
  19559. protected onContextMenu(evt: PointerEvent): void;
  19560. /**
  19561. * Detach the current controls from the specified dom element.
  19562. * @param element Defines the element to stop listening the inputs from
  19563. */
  19564. detachControl(element: Nullable<HTMLElement>): void;
  19565. /**
  19566. * Gets the class name of the current intput.
  19567. * @returns the class name
  19568. */
  19569. getClassName(): string;
  19570. /**
  19571. * Get the friendly name associated with the input class.
  19572. * @returns the input friendly name
  19573. */
  19574. getSimpleName(): string;
  19575. }
  19576. }
  19577. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19578. import { Nullable } from "babylonjs/types";
  19579. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19580. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19581. /**
  19582. * Manage the touch inputs to control the movement of a free camera.
  19583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19584. */
  19585. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19586. /**
  19587. * Define if mouse events can be treated as touch events
  19588. */
  19589. allowMouse: boolean;
  19590. /**
  19591. * Defines the camera the input is attached to.
  19592. */
  19593. camera: FreeCamera;
  19594. /**
  19595. * Defines the touch sensibility for rotation.
  19596. * The higher the faster.
  19597. */
  19598. touchAngularSensibility: number;
  19599. /**
  19600. * Defines the touch sensibility for move.
  19601. * The higher the faster.
  19602. */
  19603. touchMoveSensibility: number;
  19604. private _offsetX;
  19605. private _offsetY;
  19606. private _pointerPressed;
  19607. private _pointerInput;
  19608. private _observer;
  19609. private _onLostFocus;
  19610. /**
  19611. * Manage the touch inputs to control the movement of a free camera.
  19612. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19613. * @param allowMouse Defines if mouse events can be treated as touch events
  19614. */
  19615. constructor(
  19616. /**
  19617. * Define if mouse events can be treated as touch events
  19618. */
  19619. allowMouse?: boolean);
  19620. /**
  19621. * Attach the input controls to a specific dom element to get the input from.
  19622. * @param element Defines the element the controls should be listened from
  19623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19624. */
  19625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19626. /**
  19627. * Detach the current controls from the specified dom element.
  19628. * @param element Defines the element to stop listening the inputs from
  19629. */
  19630. detachControl(element: Nullable<HTMLElement>): void;
  19631. /**
  19632. * Update the current camera state depending on the inputs that have been used this frame.
  19633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19634. */
  19635. checkInputs(): void;
  19636. /**
  19637. * Gets the class name of the current intput.
  19638. * @returns the class name
  19639. */
  19640. getClassName(): string;
  19641. /**
  19642. * Get the friendly name associated with the input class.
  19643. * @returns the input friendly name
  19644. */
  19645. getSimpleName(): string;
  19646. }
  19647. }
  19648. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19649. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19650. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19651. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19652. import { Nullable } from "babylonjs/types";
  19653. /**
  19654. * Default Inputs manager for the FreeCamera.
  19655. * It groups all the default supported inputs for ease of use.
  19656. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19657. */
  19658. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19659. /**
  19660. * @hidden
  19661. */
  19662. _mouseInput: Nullable<FreeCameraMouseInput>;
  19663. /**
  19664. * Instantiates a new FreeCameraInputsManager.
  19665. * @param camera Defines the camera the inputs belong to
  19666. */
  19667. constructor(camera: FreeCamera);
  19668. /**
  19669. * Add keyboard input support to the input manager.
  19670. * @returns the current input manager
  19671. */
  19672. addKeyboard(): FreeCameraInputsManager;
  19673. /**
  19674. * Add mouse input support to the input manager.
  19675. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19676. * @returns the current input manager
  19677. */
  19678. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19679. /**
  19680. * Removes the mouse input support from the manager
  19681. * @returns the current input manager
  19682. */
  19683. removeMouse(): FreeCameraInputsManager;
  19684. /**
  19685. * Add touch input support to the input manager.
  19686. * @returns the current input manager
  19687. */
  19688. addTouch(): FreeCameraInputsManager;
  19689. /**
  19690. * Remove all attached input methods from a camera
  19691. */
  19692. clear(): void;
  19693. }
  19694. }
  19695. declare module "babylonjs/Cameras/freeCamera" {
  19696. import { Vector3 } from "babylonjs/Maths/math.vector";
  19697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19698. import { Scene } from "babylonjs/scene";
  19699. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19700. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19701. /**
  19702. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19703. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19704. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19705. */
  19706. export class FreeCamera extends TargetCamera {
  19707. /**
  19708. * Define the collision ellipsoid of the camera.
  19709. * This is helpful to simulate a camera body like the player body around the camera
  19710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19711. */
  19712. ellipsoid: Vector3;
  19713. /**
  19714. * Define an offset for the position of the ellipsoid around the camera.
  19715. * This can be helpful to determine the center of the body near the gravity center of the body
  19716. * instead of its head.
  19717. */
  19718. ellipsoidOffset: Vector3;
  19719. /**
  19720. * Enable or disable collisions of the camera with the rest of the scene objects.
  19721. */
  19722. checkCollisions: boolean;
  19723. /**
  19724. * Enable or disable gravity on the camera.
  19725. */
  19726. applyGravity: boolean;
  19727. /**
  19728. * Define the input manager associated to the camera.
  19729. */
  19730. inputs: FreeCameraInputsManager;
  19731. /**
  19732. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19733. * Higher values reduce sensitivity.
  19734. */
  19735. get angularSensibility(): number;
  19736. /**
  19737. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19738. * Higher values reduce sensitivity.
  19739. */
  19740. set angularSensibility(value: number);
  19741. /**
  19742. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19743. */
  19744. get keysUp(): number[];
  19745. set keysUp(value: number[]);
  19746. /**
  19747. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19748. */
  19749. get keysUpward(): number[];
  19750. set keysUpward(value: number[]);
  19751. /**
  19752. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19753. */
  19754. get keysDown(): number[];
  19755. set keysDown(value: number[]);
  19756. /**
  19757. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19758. */
  19759. get keysDownward(): number[];
  19760. set keysDownward(value: number[]);
  19761. /**
  19762. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19763. */
  19764. get keysLeft(): number[];
  19765. set keysLeft(value: number[]);
  19766. /**
  19767. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19768. */
  19769. get keysRight(): number[];
  19770. set keysRight(value: number[]);
  19771. /**
  19772. * Event raised when the camera collide with a mesh in the scene.
  19773. */
  19774. onCollide: (collidedMesh: AbstractMesh) => void;
  19775. private _collider;
  19776. private _needMoveForGravity;
  19777. private _oldPosition;
  19778. private _diffPosition;
  19779. private _newPosition;
  19780. /** @hidden */
  19781. _localDirection: Vector3;
  19782. /** @hidden */
  19783. _transformedDirection: Vector3;
  19784. /**
  19785. * Instantiates a Free Camera.
  19786. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19787. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19788. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19789. * @param name Define the name of the camera in the scene
  19790. * @param position Define the start position of the camera in the scene
  19791. * @param scene Define the scene the camera belongs to
  19792. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19793. */
  19794. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19795. /**
  19796. * Attached controls to the current camera.
  19797. * @param element Defines the element the controls should be listened from
  19798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19799. */
  19800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19801. /**
  19802. * Detach the current controls from the camera.
  19803. * The camera will stop reacting to inputs.
  19804. * @param element Defines the element to stop listening the inputs from
  19805. */
  19806. detachControl(element: HTMLElement): void;
  19807. private _collisionMask;
  19808. /**
  19809. * Define a collision mask to limit the list of object the camera can collide with
  19810. */
  19811. get collisionMask(): number;
  19812. set collisionMask(mask: number);
  19813. /** @hidden */
  19814. _collideWithWorld(displacement: Vector3): void;
  19815. private _onCollisionPositionChange;
  19816. /** @hidden */
  19817. _checkInputs(): void;
  19818. /** @hidden */
  19819. _decideIfNeedsToMove(): boolean;
  19820. /** @hidden */
  19821. _updatePosition(): void;
  19822. /**
  19823. * Destroy the camera and release the current resources hold by it.
  19824. */
  19825. dispose(): void;
  19826. /**
  19827. * Gets the current object class name.
  19828. * @return the class name
  19829. */
  19830. getClassName(): string;
  19831. }
  19832. }
  19833. declare module "babylonjs/Gamepads/gamepad" {
  19834. import { Observable } from "babylonjs/Misc/observable";
  19835. /**
  19836. * Represents a gamepad control stick position
  19837. */
  19838. export class StickValues {
  19839. /**
  19840. * The x component of the control stick
  19841. */
  19842. x: number;
  19843. /**
  19844. * The y component of the control stick
  19845. */
  19846. y: number;
  19847. /**
  19848. * Initializes the gamepad x and y control stick values
  19849. * @param x The x component of the gamepad control stick value
  19850. * @param y The y component of the gamepad control stick value
  19851. */
  19852. constructor(
  19853. /**
  19854. * The x component of the control stick
  19855. */
  19856. x: number,
  19857. /**
  19858. * The y component of the control stick
  19859. */
  19860. y: number);
  19861. }
  19862. /**
  19863. * An interface which manages callbacks for gamepad button changes
  19864. */
  19865. export interface GamepadButtonChanges {
  19866. /**
  19867. * Called when a gamepad has been changed
  19868. */
  19869. changed: boolean;
  19870. /**
  19871. * Called when a gamepad press event has been triggered
  19872. */
  19873. pressChanged: boolean;
  19874. /**
  19875. * Called when a touch event has been triggered
  19876. */
  19877. touchChanged: boolean;
  19878. /**
  19879. * Called when a value has changed
  19880. */
  19881. valueChanged: boolean;
  19882. }
  19883. /**
  19884. * Represents a gamepad
  19885. */
  19886. export class Gamepad {
  19887. /**
  19888. * The id of the gamepad
  19889. */
  19890. id: string;
  19891. /**
  19892. * The index of the gamepad
  19893. */
  19894. index: number;
  19895. /**
  19896. * The browser gamepad
  19897. */
  19898. browserGamepad: any;
  19899. /**
  19900. * Specifies what type of gamepad this represents
  19901. */
  19902. type: number;
  19903. private _leftStick;
  19904. private _rightStick;
  19905. /** @hidden */
  19906. _isConnected: boolean;
  19907. private _leftStickAxisX;
  19908. private _leftStickAxisY;
  19909. private _rightStickAxisX;
  19910. private _rightStickAxisY;
  19911. /**
  19912. * Triggered when the left control stick has been changed
  19913. */
  19914. private _onleftstickchanged;
  19915. /**
  19916. * Triggered when the right control stick has been changed
  19917. */
  19918. private _onrightstickchanged;
  19919. /**
  19920. * Represents a gamepad controller
  19921. */
  19922. static GAMEPAD: number;
  19923. /**
  19924. * Represents a generic controller
  19925. */
  19926. static GENERIC: number;
  19927. /**
  19928. * Represents an XBox controller
  19929. */
  19930. static XBOX: number;
  19931. /**
  19932. * Represents a pose-enabled controller
  19933. */
  19934. static POSE_ENABLED: number;
  19935. /**
  19936. * Represents an Dual Shock controller
  19937. */
  19938. static DUALSHOCK: number;
  19939. /**
  19940. * Specifies whether the left control stick should be Y-inverted
  19941. */
  19942. protected _invertLeftStickY: boolean;
  19943. /**
  19944. * Specifies if the gamepad has been connected
  19945. */
  19946. get isConnected(): boolean;
  19947. /**
  19948. * Initializes the gamepad
  19949. * @param id The id of the gamepad
  19950. * @param index The index of the gamepad
  19951. * @param browserGamepad The browser gamepad
  19952. * @param leftStickX The x component of the left joystick
  19953. * @param leftStickY The y component of the left joystick
  19954. * @param rightStickX The x component of the right joystick
  19955. * @param rightStickY The y component of the right joystick
  19956. */
  19957. constructor(
  19958. /**
  19959. * The id of the gamepad
  19960. */
  19961. id: string,
  19962. /**
  19963. * The index of the gamepad
  19964. */
  19965. index: number,
  19966. /**
  19967. * The browser gamepad
  19968. */
  19969. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19970. /**
  19971. * Callback triggered when the left joystick has changed
  19972. * @param callback
  19973. */
  19974. onleftstickchanged(callback: (values: StickValues) => void): void;
  19975. /**
  19976. * Callback triggered when the right joystick has changed
  19977. * @param callback
  19978. */
  19979. onrightstickchanged(callback: (values: StickValues) => void): void;
  19980. /**
  19981. * Gets the left joystick
  19982. */
  19983. get leftStick(): StickValues;
  19984. /**
  19985. * Sets the left joystick values
  19986. */
  19987. set leftStick(newValues: StickValues);
  19988. /**
  19989. * Gets the right joystick
  19990. */
  19991. get rightStick(): StickValues;
  19992. /**
  19993. * Sets the right joystick value
  19994. */
  19995. set rightStick(newValues: StickValues);
  19996. /**
  19997. * Updates the gamepad joystick positions
  19998. */
  19999. update(): void;
  20000. /**
  20001. * Disposes the gamepad
  20002. */
  20003. dispose(): void;
  20004. }
  20005. /**
  20006. * Represents a generic gamepad
  20007. */
  20008. export class GenericPad extends Gamepad {
  20009. private _buttons;
  20010. private _onbuttondown;
  20011. private _onbuttonup;
  20012. /**
  20013. * Observable triggered when a button has been pressed
  20014. */
  20015. onButtonDownObservable: Observable<number>;
  20016. /**
  20017. * Observable triggered when a button has been released
  20018. */
  20019. onButtonUpObservable: Observable<number>;
  20020. /**
  20021. * Callback triggered when a button has been pressed
  20022. * @param callback Called when a button has been pressed
  20023. */
  20024. onbuttondown(callback: (buttonPressed: number) => void): void;
  20025. /**
  20026. * Callback triggered when a button has been released
  20027. * @param callback Called when a button has been released
  20028. */
  20029. onbuttonup(callback: (buttonReleased: number) => void): void;
  20030. /**
  20031. * Initializes the generic gamepad
  20032. * @param id The id of the generic gamepad
  20033. * @param index The index of the generic gamepad
  20034. * @param browserGamepad The browser gamepad
  20035. */
  20036. constructor(id: string, index: number, browserGamepad: any);
  20037. private _setButtonValue;
  20038. /**
  20039. * Updates the generic gamepad
  20040. */
  20041. update(): void;
  20042. /**
  20043. * Disposes the generic gamepad
  20044. */
  20045. dispose(): void;
  20046. }
  20047. }
  20048. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20049. import { Observable } from "babylonjs/Misc/observable";
  20050. import { Nullable } from "babylonjs/types";
  20051. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20052. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20054. import { Ray } from "babylonjs/Culling/ray";
  20055. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20056. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20057. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20058. /**
  20059. * Defines the types of pose enabled controllers that are supported
  20060. */
  20061. export enum PoseEnabledControllerType {
  20062. /**
  20063. * HTC Vive
  20064. */
  20065. VIVE = 0,
  20066. /**
  20067. * Oculus Rift
  20068. */
  20069. OCULUS = 1,
  20070. /**
  20071. * Windows mixed reality
  20072. */
  20073. WINDOWS = 2,
  20074. /**
  20075. * Samsung gear VR
  20076. */
  20077. GEAR_VR = 3,
  20078. /**
  20079. * Google Daydream
  20080. */
  20081. DAYDREAM = 4,
  20082. /**
  20083. * Generic
  20084. */
  20085. GENERIC = 5
  20086. }
  20087. /**
  20088. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20089. */
  20090. export interface MutableGamepadButton {
  20091. /**
  20092. * Value of the button/trigger
  20093. */
  20094. value: number;
  20095. /**
  20096. * If the button/trigger is currently touched
  20097. */
  20098. touched: boolean;
  20099. /**
  20100. * If the button/trigger is currently pressed
  20101. */
  20102. pressed: boolean;
  20103. }
  20104. /**
  20105. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20106. * @hidden
  20107. */
  20108. export interface ExtendedGamepadButton extends GamepadButton {
  20109. /**
  20110. * If the button/trigger is currently pressed
  20111. */
  20112. readonly pressed: boolean;
  20113. /**
  20114. * If the button/trigger is currently touched
  20115. */
  20116. readonly touched: boolean;
  20117. /**
  20118. * Value of the button/trigger
  20119. */
  20120. readonly value: number;
  20121. }
  20122. /** @hidden */
  20123. export interface _GamePadFactory {
  20124. /**
  20125. * Returns whether or not the current gamepad can be created for this type of controller.
  20126. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20127. * @returns true if it can be created, otherwise false
  20128. */
  20129. canCreate(gamepadInfo: any): boolean;
  20130. /**
  20131. * Creates a new instance of the Gamepad.
  20132. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20133. * @returns the new gamepad instance
  20134. */
  20135. create(gamepadInfo: any): Gamepad;
  20136. }
  20137. /**
  20138. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20139. */
  20140. export class PoseEnabledControllerHelper {
  20141. /** @hidden */
  20142. static _ControllerFactories: _GamePadFactory[];
  20143. /** @hidden */
  20144. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20145. /**
  20146. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20147. * @param vrGamepad the gamepad to initialized
  20148. * @returns a vr controller of the type the gamepad identified as
  20149. */
  20150. static InitiateController(vrGamepad: any): Gamepad;
  20151. }
  20152. /**
  20153. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20154. */
  20155. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20156. /**
  20157. * If the controller is used in a webXR session
  20158. */
  20159. isXR: boolean;
  20160. private _deviceRoomPosition;
  20161. private _deviceRoomRotationQuaternion;
  20162. /**
  20163. * The device position in babylon space
  20164. */
  20165. devicePosition: Vector3;
  20166. /**
  20167. * The device rotation in babylon space
  20168. */
  20169. deviceRotationQuaternion: Quaternion;
  20170. /**
  20171. * The scale factor of the device in babylon space
  20172. */
  20173. deviceScaleFactor: number;
  20174. /**
  20175. * (Likely devicePosition should be used instead) The device position in its room space
  20176. */
  20177. position: Vector3;
  20178. /**
  20179. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20180. */
  20181. rotationQuaternion: Quaternion;
  20182. /**
  20183. * The type of controller (Eg. Windows mixed reality)
  20184. */
  20185. controllerType: PoseEnabledControllerType;
  20186. protected _calculatedPosition: Vector3;
  20187. private _calculatedRotation;
  20188. /**
  20189. * The raw pose from the device
  20190. */
  20191. rawPose: DevicePose;
  20192. private _trackPosition;
  20193. private _maxRotationDistFromHeadset;
  20194. private _draggedRoomRotation;
  20195. /**
  20196. * @hidden
  20197. */
  20198. _disableTrackPosition(fixedPosition: Vector3): void;
  20199. /**
  20200. * Internal, the mesh attached to the controller
  20201. * @hidden
  20202. */
  20203. _mesh: Nullable<AbstractMesh>;
  20204. private _poseControlledCamera;
  20205. private _leftHandSystemQuaternion;
  20206. /**
  20207. * Internal, matrix used to convert room space to babylon space
  20208. * @hidden
  20209. */
  20210. _deviceToWorld: Matrix;
  20211. /**
  20212. * Node to be used when casting a ray from the controller
  20213. * @hidden
  20214. */
  20215. _pointingPoseNode: Nullable<TransformNode>;
  20216. /**
  20217. * Name of the child mesh that can be used to cast a ray from the controller
  20218. */
  20219. static readonly POINTING_POSE: string;
  20220. /**
  20221. * Creates a new PoseEnabledController from a gamepad
  20222. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20223. */
  20224. constructor(browserGamepad: any);
  20225. private _workingMatrix;
  20226. /**
  20227. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20228. */
  20229. update(): void;
  20230. /**
  20231. * Updates only the pose device and mesh without doing any button event checking
  20232. */
  20233. protected _updatePoseAndMesh(): void;
  20234. /**
  20235. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20236. * @param poseData raw pose fromthe device
  20237. */
  20238. updateFromDevice(poseData: DevicePose): void;
  20239. /**
  20240. * @hidden
  20241. */
  20242. _meshAttachedObservable: Observable<AbstractMesh>;
  20243. /**
  20244. * Attaches a mesh to the controller
  20245. * @param mesh the mesh to be attached
  20246. */
  20247. attachToMesh(mesh: AbstractMesh): void;
  20248. /**
  20249. * Attaches the controllers mesh to a camera
  20250. * @param camera the camera the mesh should be attached to
  20251. */
  20252. attachToPoseControlledCamera(camera: TargetCamera): void;
  20253. /**
  20254. * Disposes of the controller
  20255. */
  20256. dispose(): void;
  20257. /**
  20258. * The mesh that is attached to the controller
  20259. */
  20260. get mesh(): Nullable<AbstractMesh>;
  20261. /**
  20262. * Gets the ray of the controller in the direction the controller is pointing
  20263. * @param length the length the resulting ray should be
  20264. * @returns a ray in the direction the controller is pointing
  20265. */
  20266. getForwardRay(length?: number): Ray;
  20267. }
  20268. }
  20269. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20270. import { Observable } from "babylonjs/Misc/observable";
  20271. import { Scene } from "babylonjs/scene";
  20272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20273. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20274. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20275. import { Nullable } from "babylonjs/types";
  20276. /**
  20277. * Defines the WebVRController object that represents controllers tracked in 3D space
  20278. */
  20279. export abstract class WebVRController extends PoseEnabledController {
  20280. /**
  20281. * Internal, the default controller model for the controller
  20282. */
  20283. protected _defaultModel: Nullable<AbstractMesh>;
  20284. /**
  20285. * Fired when the trigger state has changed
  20286. */
  20287. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20288. /**
  20289. * Fired when the main button state has changed
  20290. */
  20291. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20292. /**
  20293. * Fired when the secondary button state has changed
  20294. */
  20295. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20296. /**
  20297. * Fired when the pad state has changed
  20298. */
  20299. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20300. /**
  20301. * Fired when controllers stick values have changed
  20302. */
  20303. onPadValuesChangedObservable: Observable<StickValues>;
  20304. /**
  20305. * Array of button availible on the controller
  20306. */
  20307. protected _buttons: Array<MutableGamepadButton>;
  20308. private _onButtonStateChange;
  20309. /**
  20310. * Fired when a controller button's state has changed
  20311. * @param callback the callback containing the button that was modified
  20312. */
  20313. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20314. /**
  20315. * X and Y axis corresponding to the controllers joystick
  20316. */
  20317. pad: StickValues;
  20318. /**
  20319. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20320. */
  20321. hand: string;
  20322. /**
  20323. * The default controller model for the controller
  20324. */
  20325. get defaultModel(): Nullable<AbstractMesh>;
  20326. /**
  20327. * Creates a new WebVRController from a gamepad
  20328. * @param vrGamepad the gamepad that the WebVRController should be created from
  20329. */
  20330. constructor(vrGamepad: any);
  20331. /**
  20332. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20333. */
  20334. update(): void;
  20335. /**
  20336. * Function to be called when a button is modified
  20337. */
  20338. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20339. /**
  20340. * Loads a mesh and attaches it to the controller
  20341. * @param scene the scene the mesh should be added to
  20342. * @param meshLoaded callback for when the mesh has been loaded
  20343. */
  20344. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20345. private _setButtonValue;
  20346. private _changes;
  20347. private _checkChanges;
  20348. /**
  20349. * Disposes of th webVRCOntroller
  20350. */
  20351. dispose(): void;
  20352. }
  20353. }
  20354. declare module "babylonjs/Lights/hemisphericLight" {
  20355. import { Nullable } from "babylonjs/types";
  20356. import { Scene } from "babylonjs/scene";
  20357. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20358. import { Color3 } from "babylonjs/Maths/math.color";
  20359. import { Effect } from "babylonjs/Materials/effect";
  20360. import { Light } from "babylonjs/Lights/light";
  20361. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20362. /**
  20363. * The HemisphericLight simulates the ambient environment light,
  20364. * so the passed direction is the light reflection direction, not the incoming direction.
  20365. */
  20366. export class HemisphericLight extends Light {
  20367. /**
  20368. * The groundColor is the light in the opposite direction to the one specified during creation.
  20369. * 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.
  20370. */
  20371. groundColor: Color3;
  20372. /**
  20373. * The light reflection direction, not the incoming direction.
  20374. */
  20375. direction: Vector3;
  20376. /**
  20377. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20378. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20379. * The HemisphericLight can't cast shadows.
  20380. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20381. * @param name The friendly name of the light
  20382. * @param direction The direction of the light reflection
  20383. * @param scene The scene the light belongs to
  20384. */
  20385. constructor(name: string, direction: Vector3, scene: Scene);
  20386. protected _buildUniformLayout(): void;
  20387. /**
  20388. * Returns the string "HemisphericLight".
  20389. * @return The class name
  20390. */
  20391. getClassName(): string;
  20392. /**
  20393. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20394. * Returns the updated direction.
  20395. * @param target The target the direction should point to
  20396. * @return The computed direction
  20397. */
  20398. setDirectionToTarget(target: Vector3): Vector3;
  20399. /**
  20400. * Returns the shadow generator associated to the light.
  20401. * @returns Always null for hemispheric lights because it does not support shadows.
  20402. */
  20403. getShadowGenerator(): Nullable<IShadowGenerator>;
  20404. /**
  20405. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20406. * @param effect The effect to update
  20407. * @param lightIndex The index of the light in the effect to update
  20408. * @returns The hemispheric light
  20409. */
  20410. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20411. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20412. /**
  20413. * Computes the world matrix of the node
  20414. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20415. * @param useWasUpdatedFlag defines a reserved property
  20416. * @returns the world matrix
  20417. */
  20418. computeWorldMatrix(): Matrix;
  20419. /**
  20420. * Returns the integer 3.
  20421. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20422. */
  20423. getTypeID(): number;
  20424. /**
  20425. * Prepares the list of defines specific to the light type.
  20426. * @param defines the list of defines
  20427. * @param lightIndex defines the index of the light for the effect
  20428. */
  20429. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20430. }
  20431. }
  20432. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20433. /** @hidden */
  20434. export var vrMultiviewToSingleviewPixelShader: {
  20435. name: string;
  20436. shader: string;
  20437. };
  20438. }
  20439. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20440. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20441. import { Scene } from "babylonjs/scene";
  20442. /**
  20443. * Renders to multiple views with a single draw call
  20444. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20445. */
  20446. export class MultiviewRenderTarget extends RenderTargetTexture {
  20447. /**
  20448. * Creates a multiview render target
  20449. * @param scene scene used with the render target
  20450. * @param size the size of the render target (used for each view)
  20451. */
  20452. constructor(scene: Scene, size?: number | {
  20453. width: number;
  20454. height: number;
  20455. } | {
  20456. ratio: number;
  20457. });
  20458. /**
  20459. * @hidden
  20460. * @param faceIndex the face index, if its a cube texture
  20461. */
  20462. _bindFrameBuffer(faceIndex?: number): void;
  20463. /**
  20464. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20465. * @returns the view count
  20466. */
  20467. getViewCount(): number;
  20468. }
  20469. }
  20470. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20471. import { Camera } from "babylonjs/Cameras/camera";
  20472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20473. import { Nullable } from "babylonjs/types";
  20474. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20475. import { Matrix } from "babylonjs/Maths/math.vector";
  20476. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20477. module "babylonjs/Engines/engine" {
  20478. interface Engine {
  20479. /**
  20480. * Creates a new multiview render target
  20481. * @param width defines the width of the texture
  20482. * @param height defines the height of the texture
  20483. * @returns the created multiview texture
  20484. */
  20485. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20486. /**
  20487. * Binds a multiview framebuffer to be drawn to
  20488. * @param multiviewTexture texture to bind
  20489. */
  20490. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20491. }
  20492. }
  20493. module "babylonjs/Cameras/camera" {
  20494. interface Camera {
  20495. /**
  20496. * @hidden
  20497. * 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)
  20498. */
  20499. _useMultiviewToSingleView: boolean;
  20500. /**
  20501. * @hidden
  20502. * 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)
  20503. */
  20504. _multiviewTexture: Nullable<RenderTargetTexture>;
  20505. /**
  20506. * @hidden
  20507. * ensures the multiview texture of the camera exists and has the specified width/height
  20508. * @param width height to set on the multiview texture
  20509. * @param height width to set on the multiview texture
  20510. */
  20511. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20512. }
  20513. }
  20514. module "babylonjs/scene" {
  20515. interface Scene {
  20516. /** @hidden */
  20517. _transformMatrixR: Matrix;
  20518. /** @hidden */
  20519. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20520. /** @hidden */
  20521. _createMultiviewUbo(): void;
  20522. /** @hidden */
  20523. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20524. /** @hidden */
  20525. _renderMultiviewToSingleView(camera: Camera): void;
  20526. }
  20527. }
  20528. }
  20529. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20530. import { Camera } from "babylonjs/Cameras/camera";
  20531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20532. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20533. import "babylonjs/Engines/Extensions/engine.multiview";
  20534. /**
  20535. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20536. * This will not be used for webXR as it supports displaying texture arrays directly
  20537. */
  20538. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20539. /**
  20540. * Gets a string identifying the name of the class
  20541. * @returns "VRMultiviewToSingleviewPostProcess" string
  20542. */
  20543. getClassName(): string;
  20544. /**
  20545. * Initializes a VRMultiviewToSingleview
  20546. * @param name name of the post process
  20547. * @param camera camera to be applied to
  20548. * @param scaleFactor scaling factor to the size of the output texture
  20549. */
  20550. constructor(name: string, camera: Camera, scaleFactor: number);
  20551. }
  20552. }
  20553. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20554. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20555. import { Nullable } from "babylonjs/types";
  20556. import { Size } from "babylonjs/Maths/math.size";
  20557. import { Observable } from "babylonjs/Misc/observable";
  20558. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20559. /**
  20560. * Interface used to define additional presentation attributes
  20561. */
  20562. export interface IVRPresentationAttributes {
  20563. /**
  20564. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20565. */
  20566. highRefreshRate: boolean;
  20567. /**
  20568. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20569. */
  20570. foveationLevel: number;
  20571. }
  20572. module "babylonjs/Engines/engine" {
  20573. interface Engine {
  20574. /** @hidden */
  20575. _vrDisplay: any;
  20576. /** @hidden */
  20577. _vrSupported: boolean;
  20578. /** @hidden */
  20579. _oldSize: Size;
  20580. /** @hidden */
  20581. _oldHardwareScaleFactor: number;
  20582. /** @hidden */
  20583. _vrExclusivePointerMode: boolean;
  20584. /** @hidden */
  20585. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20586. /** @hidden */
  20587. _onVRDisplayPointerRestricted: () => void;
  20588. /** @hidden */
  20589. _onVRDisplayPointerUnrestricted: () => void;
  20590. /** @hidden */
  20591. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20592. /** @hidden */
  20593. _onVrDisplayDisconnect: Nullable<() => void>;
  20594. /** @hidden */
  20595. _onVrDisplayPresentChange: Nullable<() => void>;
  20596. /**
  20597. * Observable signaled when VR display mode changes
  20598. */
  20599. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20600. /**
  20601. * Observable signaled when VR request present is complete
  20602. */
  20603. onVRRequestPresentComplete: Observable<boolean>;
  20604. /**
  20605. * Observable signaled when VR request present starts
  20606. */
  20607. onVRRequestPresentStart: Observable<Engine>;
  20608. /**
  20609. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20610. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20611. */
  20612. isInVRExclusivePointerMode: boolean;
  20613. /**
  20614. * Gets a boolean indicating if a webVR device was detected
  20615. * @returns true if a webVR device was detected
  20616. */
  20617. isVRDevicePresent(): boolean;
  20618. /**
  20619. * Gets the current webVR device
  20620. * @returns the current webVR device (or null)
  20621. */
  20622. getVRDevice(): any;
  20623. /**
  20624. * Initializes a webVR display and starts listening to display change events
  20625. * The onVRDisplayChangedObservable will be notified upon these changes
  20626. * @returns A promise containing a VRDisplay and if vr is supported
  20627. */
  20628. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20629. /** @hidden */
  20630. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20631. /**
  20632. * Gets or sets the presentation attributes used to configure VR rendering
  20633. */
  20634. vrPresentationAttributes?: IVRPresentationAttributes;
  20635. /**
  20636. * Call this function to switch to webVR mode
  20637. * Will do nothing if webVR is not supported or if there is no webVR device
  20638. * @param options the webvr options provided to the camera. mainly used for multiview
  20639. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20640. */
  20641. enableVR(options: WebVROptions): void;
  20642. /** @hidden */
  20643. _onVRFullScreenTriggered(): void;
  20644. }
  20645. }
  20646. }
  20647. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20648. import { Nullable } from "babylonjs/types";
  20649. import { Observable } from "babylonjs/Misc/observable";
  20650. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20651. import { Scene } from "babylonjs/scene";
  20652. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20653. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20654. import { Node } from "babylonjs/node";
  20655. import { Ray } from "babylonjs/Culling/ray";
  20656. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20657. import "babylonjs/Engines/Extensions/engine.webVR";
  20658. /**
  20659. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20660. * IMPORTANT!! The data is right-hand data.
  20661. * @export
  20662. * @interface DevicePose
  20663. */
  20664. export interface DevicePose {
  20665. /**
  20666. * The position of the device, values in array are [x,y,z].
  20667. */
  20668. readonly position: Nullable<Float32Array>;
  20669. /**
  20670. * The linearVelocity of the device, values in array are [x,y,z].
  20671. */
  20672. readonly linearVelocity: Nullable<Float32Array>;
  20673. /**
  20674. * The linearAcceleration of the device, values in array are [x,y,z].
  20675. */
  20676. readonly linearAcceleration: Nullable<Float32Array>;
  20677. /**
  20678. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20679. */
  20680. readonly orientation: Nullable<Float32Array>;
  20681. /**
  20682. * The angularVelocity of the device, values in array are [x,y,z].
  20683. */
  20684. readonly angularVelocity: Nullable<Float32Array>;
  20685. /**
  20686. * The angularAcceleration of the device, values in array are [x,y,z].
  20687. */
  20688. readonly angularAcceleration: Nullable<Float32Array>;
  20689. }
  20690. /**
  20691. * Interface representing a pose controlled object in Babylon.
  20692. * A pose controlled object has both regular pose values as well as pose values
  20693. * from an external device such as a VR head mounted display
  20694. */
  20695. export interface PoseControlled {
  20696. /**
  20697. * The position of the object in babylon space.
  20698. */
  20699. position: Vector3;
  20700. /**
  20701. * The rotation quaternion of the object in babylon space.
  20702. */
  20703. rotationQuaternion: Quaternion;
  20704. /**
  20705. * The position of the device in babylon space.
  20706. */
  20707. devicePosition?: Vector3;
  20708. /**
  20709. * The rotation quaternion of the device in babylon space.
  20710. */
  20711. deviceRotationQuaternion: Quaternion;
  20712. /**
  20713. * The raw pose coming from the device.
  20714. */
  20715. rawPose: Nullable<DevicePose>;
  20716. /**
  20717. * The scale of the device to be used when translating from device space to babylon space.
  20718. */
  20719. deviceScaleFactor: number;
  20720. /**
  20721. * Updates the poseControlled values based on the input device pose.
  20722. * @param poseData the pose data to update the object with
  20723. */
  20724. updateFromDevice(poseData: DevicePose): void;
  20725. }
  20726. /**
  20727. * Set of options to customize the webVRCamera
  20728. */
  20729. export interface WebVROptions {
  20730. /**
  20731. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20732. */
  20733. trackPosition?: boolean;
  20734. /**
  20735. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20736. */
  20737. positionScale?: number;
  20738. /**
  20739. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20740. */
  20741. displayName?: string;
  20742. /**
  20743. * Should the native controller meshes be initialized. (default: true)
  20744. */
  20745. controllerMeshes?: boolean;
  20746. /**
  20747. * Creating a default HemiLight only on controllers. (default: true)
  20748. */
  20749. defaultLightingOnControllers?: boolean;
  20750. /**
  20751. * If you don't want to use the default VR button of the helper. (default: false)
  20752. */
  20753. useCustomVRButton?: boolean;
  20754. /**
  20755. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20756. */
  20757. customVRButton?: HTMLButtonElement;
  20758. /**
  20759. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20760. */
  20761. rayLength?: number;
  20762. /**
  20763. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20764. */
  20765. defaultHeight?: number;
  20766. /**
  20767. * If multiview should be used if availible (default: false)
  20768. */
  20769. useMultiview?: boolean;
  20770. }
  20771. /**
  20772. * This represents a WebVR camera.
  20773. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20774. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20775. */
  20776. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20777. private webVROptions;
  20778. /**
  20779. * @hidden
  20780. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20781. */
  20782. _vrDevice: any;
  20783. /**
  20784. * The rawPose of the vrDevice.
  20785. */
  20786. rawPose: Nullable<DevicePose>;
  20787. private _onVREnabled;
  20788. private _specsVersion;
  20789. private _attached;
  20790. private _frameData;
  20791. protected _descendants: Array<Node>;
  20792. private _deviceRoomPosition;
  20793. /** @hidden */
  20794. _deviceRoomRotationQuaternion: Quaternion;
  20795. private _standingMatrix;
  20796. /**
  20797. * Represents device position in babylon space.
  20798. */
  20799. devicePosition: Vector3;
  20800. /**
  20801. * Represents device rotation in babylon space.
  20802. */
  20803. deviceRotationQuaternion: Quaternion;
  20804. /**
  20805. * The scale of the device to be used when translating from device space to babylon space.
  20806. */
  20807. deviceScaleFactor: number;
  20808. private _deviceToWorld;
  20809. private _worldToDevice;
  20810. /**
  20811. * References to the webVR controllers for the vrDevice.
  20812. */
  20813. controllers: Array<WebVRController>;
  20814. /**
  20815. * Emits an event when a controller is attached.
  20816. */
  20817. onControllersAttachedObservable: Observable<WebVRController[]>;
  20818. /**
  20819. * Emits an event when a controller's mesh has been loaded;
  20820. */
  20821. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20822. /**
  20823. * Emits an event when the HMD's pose has been updated.
  20824. */
  20825. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20826. private _poseSet;
  20827. /**
  20828. * If the rig cameras be used as parent instead of this camera.
  20829. */
  20830. rigParenting: boolean;
  20831. private _lightOnControllers;
  20832. private _defaultHeight?;
  20833. /**
  20834. * Instantiates a WebVRFreeCamera.
  20835. * @param name The name of the WebVRFreeCamera
  20836. * @param position The starting anchor position for the camera
  20837. * @param scene The scene the camera belongs to
  20838. * @param webVROptions a set of customizable options for the webVRCamera
  20839. */
  20840. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20841. /**
  20842. * Gets the device distance from the ground in meters.
  20843. * @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.
  20844. */
  20845. deviceDistanceToRoomGround(): number;
  20846. /**
  20847. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20848. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20849. */
  20850. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20851. /**
  20852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20853. * @returns A promise with a boolean set to if the standing matrix is supported.
  20854. */
  20855. useStandingMatrixAsync(): Promise<boolean>;
  20856. /**
  20857. * Disposes the camera
  20858. */
  20859. dispose(): void;
  20860. /**
  20861. * Gets a vrController by name.
  20862. * @param name The name of the controller to retreive
  20863. * @returns the controller matching the name specified or null if not found
  20864. */
  20865. getControllerByName(name: string): Nullable<WebVRController>;
  20866. private _leftController;
  20867. /**
  20868. * The controller corresponding to the users left hand.
  20869. */
  20870. get leftController(): Nullable<WebVRController>;
  20871. private _rightController;
  20872. /**
  20873. * The controller corresponding to the users right hand.
  20874. */
  20875. get rightController(): Nullable<WebVRController>;
  20876. /**
  20877. * Casts a ray forward from the vrCamera's gaze.
  20878. * @param length Length of the ray (default: 100)
  20879. * @returns the ray corresponding to the gaze
  20880. */
  20881. getForwardRay(length?: number): Ray;
  20882. /**
  20883. * @hidden
  20884. * Updates the camera based on device's frame data
  20885. */
  20886. _checkInputs(): void;
  20887. /**
  20888. * Updates the poseControlled values based on the input device pose.
  20889. * @param poseData Pose coming from the device
  20890. */
  20891. updateFromDevice(poseData: DevicePose): void;
  20892. private _htmlElementAttached;
  20893. private _detachIfAttached;
  20894. /**
  20895. * WebVR's attach control will start broadcasting frames to the device.
  20896. * Note that in certain browsers (chrome for example) this function must be called
  20897. * within a user-interaction callback. Example:
  20898. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20899. *
  20900. * @param element html element to attach the vrDevice to
  20901. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20902. */
  20903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20904. /**
  20905. * Detaches the camera from the html element and disables VR
  20906. *
  20907. * @param element html element to detach from
  20908. */
  20909. detachControl(element: HTMLElement): void;
  20910. /**
  20911. * @returns the name of this class
  20912. */
  20913. getClassName(): string;
  20914. /**
  20915. * Calls resetPose on the vrDisplay
  20916. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20917. */
  20918. resetToCurrentRotation(): void;
  20919. /**
  20920. * @hidden
  20921. * Updates the rig cameras (left and right eye)
  20922. */
  20923. _updateRigCameras(): void;
  20924. private _workingVector;
  20925. private _oneVector;
  20926. private _workingMatrix;
  20927. private updateCacheCalled;
  20928. private _correctPositionIfNotTrackPosition;
  20929. /**
  20930. * @hidden
  20931. * Updates the cached values of the camera
  20932. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20933. */
  20934. _updateCache(ignoreParentClass?: boolean): void;
  20935. /**
  20936. * @hidden
  20937. * Get current device position in babylon world
  20938. */
  20939. _computeDevicePosition(): void;
  20940. /**
  20941. * Updates the current device position and rotation in the babylon world
  20942. */
  20943. update(): void;
  20944. /**
  20945. * @hidden
  20946. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20947. * @returns an identity matrix
  20948. */
  20949. _getViewMatrix(): Matrix;
  20950. private _tmpMatrix;
  20951. /**
  20952. * This function is called by the two RIG cameras.
  20953. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20954. * @hidden
  20955. */
  20956. _getWebVRViewMatrix(): Matrix;
  20957. /** @hidden */
  20958. _getWebVRProjectionMatrix(): Matrix;
  20959. private _onGamepadConnectedObserver;
  20960. private _onGamepadDisconnectedObserver;
  20961. private _updateCacheWhenTrackingDisabledObserver;
  20962. /**
  20963. * Initializes the controllers and their meshes
  20964. */
  20965. initControllers(): void;
  20966. }
  20967. }
  20968. declare module "babylonjs/Materials/materialHelper" {
  20969. import { Nullable } from "babylonjs/types";
  20970. import { Scene } from "babylonjs/scene";
  20971. import { Engine } from "babylonjs/Engines/engine";
  20972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20973. import { Light } from "babylonjs/Lights/light";
  20974. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20975. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20976. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20978. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20979. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20980. /**
  20981. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20982. *
  20983. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20984. *
  20985. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20986. */
  20987. export class MaterialHelper {
  20988. /**
  20989. * Bind the current view position to an effect.
  20990. * @param effect The effect to be bound
  20991. * @param scene The scene the eyes position is used from
  20992. * @param variableName name of the shader variable that will hold the eye position
  20993. */
  20994. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20995. /**
  20996. * Helps preparing the defines values about the UVs in used in the effect.
  20997. * UVs are shared as much as we can accross channels in the shaders.
  20998. * @param texture The texture we are preparing the UVs for
  20999. * @param defines The defines to update
  21000. * @param key The channel key "diffuse", "specular"... used in the shader
  21001. */
  21002. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21003. /**
  21004. * Binds a texture matrix value to its corrsponding uniform
  21005. * @param texture The texture to bind the matrix for
  21006. * @param uniformBuffer The uniform buffer receivin the data
  21007. * @param key The channel key "diffuse", "specular"... used in the shader
  21008. */
  21009. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21010. /**
  21011. * Gets the current status of the fog (should it be enabled?)
  21012. * @param mesh defines the mesh to evaluate for fog support
  21013. * @param scene defines the hosting scene
  21014. * @returns true if fog must be enabled
  21015. */
  21016. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21017. /**
  21018. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21019. * @param mesh defines the current mesh
  21020. * @param scene defines the current scene
  21021. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21022. * @param pointsCloud defines if point cloud rendering has to be turned on
  21023. * @param fogEnabled defines if fog has to be turned on
  21024. * @param alphaTest defines if alpha testing has to be turned on
  21025. * @param defines defines the current list of defines
  21026. */
  21027. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21028. /**
  21029. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21030. * @param scene defines the current scene
  21031. * @param engine defines the current engine
  21032. * @param defines specifies the list of active defines
  21033. * @param useInstances defines if instances have to be turned on
  21034. * @param useClipPlane defines if clip plane have to be turned on
  21035. * @param useInstances defines if instances have to be turned on
  21036. * @param useThinInstances defines if thin instances have to be turned on
  21037. */
  21038. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21039. /**
  21040. * Prepares the defines for bones
  21041. * @param mesh The mesh containing the geometry data we will draw
  21042. * @param defines The defines to update
  21043. */
  21044. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21045. /**
  21046. * Prepares the defines for morph targets
  21047. * @param mesh The mesh containing the geometry data we will draw
  21048. * @param defines The defines to update
  21049. */
  21050. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21051. /**
  21052. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21053. * @param mesh The mesh containing the geometry data we will draw
  21054. * @param defines The defines to update
  21055. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21056. * @param useBones Precise whether bones should be used or not (override mesh info)
  21057. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21058. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21059. * @returns false if defines are considered not dirty and have not been checked
  21060. */
  21061. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21062. /**
  21063. * Prepares the defines related to multiview
  21064. * @param scene The scene we are intending to draw
  21065. * @param defines The defines to update
  21066. */
  21067. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21068. /**
  21069. * Prepares the defines related to the prepass
  21070. * @param scene The scene we are intending to draw
  21071. * @param defines The defines to update
  21072. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21073. */
  21074. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21075. /**
  21076. * Prepares the defines related to the light information passed in parameter
  21077. * @param scene The scene we are intending to draw
  21078. * @param mesh The mesh the effect is compiling for
  21079. * @param light The light the effect is compiling for
  21080. * @param lightIndex The index of the light
  21081. * @param defines The defines to update
  21082. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21083. * @param state Defines the current state regarding what is needed (normals, etc...)
  21084. */
  21085. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21086. needNormals: boolean;
  21087. needRebuild: boolean;
  21088. shadowEnabled: boolean;
  21089. specularEnabled: boolean;
  21090. lightmapMode: boolean;
  21091. }): void;
  21092. /**
  21093. * Prepares the defines related to the light information passed in parameter
  21094. * @param scene The scene we are intending to draw
  21095. * @param mesh The mesh the effect is compiling for
  21096. * @param defines The defines to update
  21097. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21098. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21099. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21100. * @returns true if normals will be required for the rest of the effect
  21101. */
  21102. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21103. /**
  21104. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21105. * @param lightIndex defines the light index
  21106. * @param uniformsList The uniform list
  21107. * @param samplersList The sampler list
  21108. * @param projectedLightTexture defines if projected texture must be used
  21109. * @param uniformBuffersList defines an optional list of uniform buffers
  21110. */
  21111. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21112. /**
  21113. * Prepares the uniforms and samplers list to be used in the effect
  21114. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21115. * @param samplersList The sampler list
  21116. * @param defines The defines helping in the list generation
  21117. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21118. */
  21119. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21120. /**
  21121. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21122. * @param defines The defines to update while falling back
  21123. * @param fallbacks The authorized effect fallbacks
  21124. * @param maxSimultaneousLights The maximum number of lights allowed
  21125. * @param rank the current rank of the Effect
  21126. * @returns The newly affected rank
  21127. */
  21128. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21129. private static _TmpMorphInfluencers;
  21130. /**
  21131. * Prepares the list of attributes required for morph targets according to the effect defines.
  21132. * @param attribs The current list of supported attribs
  21133. * @param mesh The mesh to prepare the morph targets attributes for
  21134. * @param influencers The number of influencers
  21135. */
  21136. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21137. /**
  21138. * Prepares the list of attributes required for morph targets according to the effect defines.
  21139. * @param attribs The current list of supported attribs
  21140. * @param mesh The mesh to prepare the morph targets attributes for
  21141. * @param defines The current Defines of the effect
  21142. */
  21143. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21144. /**
  21145. * Prepares the list of attributes required for bones according to the effect defines.
  21146. * @param attribs The current list of supported attribs
  21147. * @param mesh The mesh to prepare the bones attributes for
  21148. * @param defines The current Defines of the effect
  21149. * @param fallbacks The current efffect fallback strategy
  21150. */
  21151. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21152. /**
  21153. * Check and prepare the list of attributes required for instances according to the effect defines.
  21154. * @param attribs The current list of supported attribs
  21155. * @param defines The current MaterialDefines of the effect
  21156. */
  21157. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21158. /**
  21159. * Add the list of attributes required for instances to the attribs array.
  21160. * @param attribs The current list of supported attribs
  21161. */
  21162. static PushAttributesForInstances(attribs: string[]): void;
  21163. /**
  21164. * Binds the light information to the effect.
  21165. * @param light The light containing the generator
  21166. * @param effect The effect we are binding the data to
  21167. * @param lightIndex The light index in the effect used to render
  21168. */
  21169. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21170. /**
  21171. * Binds the lights information from the scene to the effect for the given mesh.
  21172. * @param light Light to bind
  21173. * @param lightIndex Light index
  21174. * @param scene The scene where the light belongs to
  21175. * @param effect The effect we are binding the data to
  21176. * @param useSpecular Defines if specular is supported
  21177. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21178. */
  21179. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21180. /**
  21181. * Binds the lights information from the scene to the effect for the given mesh.
  21182. * @param scene The scene the lights belongs to
  21183. * @param mesh The mesh we are binding the information to render
  21184. * @param effect The effect we are binding the data to
  21185. * @param defines The generated defines for the effect
  21186. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21187. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21188. */
  21189. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21190. private static _tempFogColor;
  21191. /**
  21192. * Binds the fog information from the scene to the effect for the given mesh.
  21193. * @param scene The scene the lights belongs to
  21194. * @param mesh The mesh we are binding the information to render
  21195. * @param effect The effect we are binding the data to
  21196. * @param linearSpace Defines if the fog effect is applied in linear space
  21197. */
  21198. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21199. /**
  21200. * Binds the bones information from the mesh to the effect.
  21201. * @param mesh The mesh we are binding the information to render
  21202. * @param effect The effect we are binding the data to
  21203. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21204. */
  21205. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21206. private static _CopyBonesTransformationMatrices;
  21207. /**
  21208. * Binds the morph targets information from the mesh to the effect.
  21209. * @param abstractMesh The mesh we are binding the information to render
  21210. * @param effect The effect we are binding the data to
  21211. */
  21212. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21213. /**
  21214. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21215. * @param defines The generated defines used in the effect
  21216. * @param effect The effect we are binding the data to
  21217. * @param scene The scene we are willing to render with logarithmic scale for
  21218. */
  21219. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21220. /**
  21221. * Binds the clip plane information from the scene to the effect.
  21222. * @param scene The scene the clip plane information are extracted from
  21223. * @param effect The effect we are binding the data to
  21224. */
  21225. static BindClipPlane(effect: Effect, scene: Scene): void;
  21226. }
  21227. }
  21228. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21230. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21231. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21232. import { Nullable } from "babylonjs/types";
  21233. import { Effect } from "babylonjs/Materials/effect";
  21234. import { Matrix } from "babylonjs/Maths/math.vector";
  21235. import { Scene } from "babylonjs/scene";
  21236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21238. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21239. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21240. import { Observable } from "babylonjs/Misc/observable";
  21241. /**
  21242. * Block used to expose an input value
  21243. */
  21244. export class InputBlock extends NodeMaterialBlock {
  21245. private _mode;
  21246. private _associatedVariableName;
  21247. private _storedValue;
  21248. private _valueCallback;
  21249. private _type;
  21250. private _animationType;
  21251. /** Gets or set a value used to limit the range of float values */
  21252. min: number;
  21253. /** Gets or set a value used to limit the range of float values */
  21254. max: number;
  21255. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21256. isBoolean: boolean;
  21257. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21258. matrixMode: number;
  21259. /** @hidden */
  21260. _systemValue: Nullable<NodeMaterialSystemValues>;
  21261. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21262. isConstant: boolean;
  21263. /** Gets or sets the group to use to display this block in the Inspector */
  21264. groupInInspector: string;
  21265. /** Gets an observable raised when the value is changed */
  21266. onValueChangedObservable: Observable<InputBlock>;
  21267. /**
  21268. * Gets or sets the connection point type (default is float)
  21269. */
  21270. get type(): NodeMaterialBlockConnectionPointTypes;
  21271. /**
  21272. * Creates a new InputBlock
  21273. * @param name defines the block name
  21274. * @param target defines the target of that block (Vertex by default)
  21275. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21276. */
  21277. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21278. /**
  21279. * Validates if a name is a reserve word.
  21280. * @param newName the new name to be given to the node.
  21281. * @returns false if the name is a reserve word, else true.
  21282. */
  21283. validateBlockName(newName: string): boolean;
  21284. /**
  21285. * Gets the output component
  21286. */
  21287. get output(): NodeMaterialConnectionPoint;
  21288. /**
  21289. * Set the source of this connection point to a vertex attribute
  21290. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21291. * @returns the current connection point
  21292. */
  21293. setAsAttribute(attributeName?: string): InputBlock;
  21294. /**
  21295. * Set the source of this connection point to a system value
  21296. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21297. * @returns the current connection point
  21298. */
  21299. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21300. /**
  21301. * Gets or sets the value of that point.
  21302. * Please note that this value will be ignored if valueCallback is defined
  21303. */
  21304. get value(): any;
  21305. set value(value: any);
  21306. /**
  21307. * Gets or sets a callback used to get the value of that point.
  21308. * Please note that setting this value will force the connection point to ignore the value property
  21309. */
  21310. get valueCallback(): () => any;
  21311. set valueCallback(value: () => any);
  21312. /**
  21313. * Gets or sets the associated variable name in the shader
  21314. */
  21315. get associatedVariableName(): string;
  21316. set associatedVariableName(value: string);
  21317. /** Gets or sets the type of animation applied to the input */
  21318. get animationType(): AnimatedInputBlockTypes;
  21319. set animationType(value: AnimatedInputBlockTypes);
  21320. /**
  21321. * Gets a boolean indicating that this connection point not defined yet
  21322. */
  21323. get isUndefined(): boolean;
  21324. /**
  21325. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21326. * In this case the connection point name must be the name of the uniform to use.
  21327. * Can only be set on inputs
  21328. */
  21329. get isUniform(): boolean;
  21330. set isUniform(value: boolean);
  21331. /**
  21332. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21333. * In this case the connection point name must be the name of the attribute to use
  21334. * Can only be set on inputs
  21335. */
  21336. get isAttribute(): boolean;
  21337. set isAttribute(value: boolean);
  21338. /**
  21339. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21340. * Can only be set on exit points
  21341. */
  21342. get isVarying(): boolean;
  21343. set isVarying(value: boolean);
  21344. /**
  21345. * Gets a boolean indicating that the current connection point is a system value
  21346. */
  21347. get isSystemValue(): boolean;
  21348. /**
  21349. * Gets or sets the current well known value or null if not defined as a system value
  21350. */
  21351. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21352. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21353. /**
  21354. * Gets the current class name
  21355. * @returns the class name
  21356. */
  21357. getClassName(): string;
  21358. /**
  21359. * Animate the input if animationType !== None
  21360. * @param scene defines the rendering scene
  21361. */
  21362. animate(scene: Scene): void;
  21363. private _emitDefine;
  21364. initialize(state: NodeMaterialBuildState): void;
  21365. /**
  21366. * Set the input block to its default value (based on its type)
  21367. */
  21368. setDefaultValue(): void;
  21369. private _emitConstant;
  21370. /** @hidden */
  21371. get _noContextSwitch(): boolean;
  21372. private _emit;
  21373. /** @hidden */
  21374. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21375. /** @hidden */
  21376. _transmit(effect: Effect, scene: Scene): void;
  21377. protected _buildBlock(state: NodeMaterialBuildState): void;
  21378. protected _dumpPropertiesCode(): string;
  21379. dispose(): void;
  21380. serialize(): any;
  21381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21382. }
  21383. }
  21384. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21385. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21386. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21387. import { Nullable } from "babylonjs/types";
  21388. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21389. import { Observable } from "babylonjs/Misc/observable";
  21390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21391. /**
  21392. * Enum used to define the compatibility state between two connection points
  21393. */
  21394. export enum NodeMaterialConnectionPointCompatibilityStates {
  21395. /** Points are compatibles */
  21396. Compatible = 0,
  21397. /** Points are incompatible because of their types */
  21398. TypeIncompatible = 1,
  21399. /** Points are incompatible because of their targets (vertex vs fragment) */
  21400. TargetIncompatible = 2
  21401. }
  21402. /**
  21403. * Defines the direction of a connection point
  21404. */
  21405. export enum NodeMaterialConnectionPointDirection {
  21406. /** Input */
  21407. Input = 0,
  21408. /** Output */
  21409. Output = 1
  21410. }
  21411. /**
  21412. * Defines a connection point for a block
  21413. */
  21414. export class NodeMaterialConnectionPoint {
  21415. /** @hidden */
  21416. _ownerBlock: NodeMaterialBlock;
  21417. /** @hidden */
  21418. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21419. private _endpoints;
  21420. private _associatedVariableName;
  21421. private _direction;
  21422. /** @hidden */
  21423. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21424. /** @hidden */
  21425. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21426. private _type;
  21427. /** @hidden */
  21428. _enforceAssociatedVariableName: boolean;
  21429. /** Gets the direction of the point */
  21430. get direction(): NodeMaterialConnectionPointDirection;
  21431. /** Indicates that this connection point needs dual validation before being connected to another point */
  21432. needDualDirectionValidation: boolean;
  21433. /**
  21434. * Gets or sets the additional types supported by this connection point
  21435. */
  21436. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21437. /**
  21438. * Gets or sets the additional types excluded by this connection point
  21439. */
  21440. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21441. /**
  21442. * Observable triggered when this point is connected
  21443. */
  21444. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21445. /**
  21446. * Gets or sets the associated variable name in the shader
  21447. */
  21448. get associatedVariableName(): string;
  21449. set associatedVariableName(value: string);
  21450. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21451. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21452. /**
  21453. * Gets or sets the connection point type (default is float)
  21454. */
  21455. get type(): NodeMaterialBlockConnectionPointTypes;
  21456. set type(value: NodeMaterialBlockConnectionPointTypes);
  21457. /**
  21458. * Gets or sets the connection point name
  21459. */
  21460. name: string;
  21461. /**
  21462. * Gets or sets the connection point name
  21463. */
  21464. displayName: string;
  21465. /**
  21466. * Gets or sets a boolean indicating that this connection point can be omitted
  21467. */
  21468. isOptional: boolean;
  21469. /**
  21470. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21471. */
  21472. isExposedOnFrame: boolean;
  21473. /**
  21474. * Gets or sets number indicating the position that the port is exposed to on a frame
  21475. */
  21476. exposedPortPosition: number;
  21477. /**
  21478. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21479. */
  21480. define: string;
  21481. /** @hidden */
  21482. _prioritizeVertex: boolean;
  21483. private _target;
  21484. /** Gets or sets the target of that connection point */
  21485. get target(): NodeMaterialBlockTargets;
  21486. set target(value: NodeMaterialBlockTargets);
  21487. /**
  21488. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21489. */
  21490. get isConnected(): boolean;
  21491. /**
  21492. * Gets a boolean indicating that the current point is connected to an input block
  21493. */
  21494. get isConnectedToInputBlock(): boolean;
  21495. /**
  21496. * Gets a the connected input block (if any)
  21497. */
  21498. get connectInputBlock(): Nullable<InputBlock>;
  21499. /** Get the other side of the connection (if any) */
  21500. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21501. /** Get the block that owns this connection point */
  21502. get ownerBlock(): NodeMaterialBlock;
  21503. /** Get the block connected on the other side of this connection (if any) */
  21504. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21505. /** Get the block connected on the endpoints of this connection (if any) */
  21506. get connectedBlocks(): Array<NodeMaterialBlock>;
  21507. /** Gets the list of connected endpoints */
  21508. get endpoints(): NodeMaterialConnectionPoint[];
  21509. /** Gets a boolean indicating if that output point is connected to at least one input */
  21510. get hasEndpoints(): boolean;
  21511. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21512. get isConnectedInVertexShader(): boolean;
  21513. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21514. get isConnectedInFragmentShader(): boolean;
  21515. /**
  21516. * Creates a block suitable to be used as an input for this input point.
  21517. * If null is returned, a block based on the point type will be created.
  21518. * @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
  21519. */
  21520. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21521. /**
  21522. * Creates a new connection point
  21523. * @param name defines the connection point name
  21524. * @param ownerBlock defines the block hosting this connection point
  21525. * @param direction defines the direction of the connection point
  21526. */
  21527. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21528. /**
  21529. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21530. * @returns the class name
  21531. */
  21532. getClassName(): string;
  21533. /**
  21534. * Gets a boolean indicating if the current point can be connected to another point
  21535. * @param connectionPoint defines the other connection point
  21536. * @returns a boolean
  21537. */
  21538. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21539. /**
  21540. * Gets a number indicating if the current point can be connected to another point
  21541. * @param connectionPoint defines the other connection point
  21542. * @returns a number defining the compatibility state
  21543. */
  21544. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21545. /**
  21546. * Connect this point to another connection point
  21547. * @param connectionPoint defines the other connection point
  21548. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21549. * @returns the current connection point
  21550. */
  21551. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21552. /**
  21553. * Disconnect this point from one of his endpoint
  21554. * @param endpoint defines the other connection point
  21555. * @returns the current connection point
  21556. */
  21557. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21558. /**
  21559. * Serializes this point in a JSON representation
  21560. * @param isInput defines if the connection point is an input (default is true)
  21561. * @returns the serialized point object
  21562. */
  21563. serialize(isInput?: boolean): any;
  21564. /**
  21565. * Release resources
  21566. */
  21567. dispose(): void;
  21568. }
  21569. }
  21570. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21571. /**
  21572. * Enum used to define the material modes
  21573. */
  21574. export enum NodeMaterialModes {
  21575. /** Regular material */
  21576. Material = 0,
  21577. /** For post process */
  21578. PostProcess = 1,
  21579. /** For particle system */
  21580. Particle = 2,
  21581. /** For procedural texture */
  21582. ProceduralTexture = 3
  21583. }
  21584. }
  21585. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21588. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21591. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { Mesh } from "babylonjs/Meshes/mesh";
  21594. import { Nullable } from "babylonjs/types";
  21595. import { Texture } from "babylonjs/Materials/Textures/texture";
  21596. import { Scene } from "babylonjs/scene";
  21597. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21598. /**
  21599. * Block used to read a texture from a sampler
  21600. */
  21601. export class TextureBlock extends NodeMaterialBlock {
  21602. private _defineName;
  21603. private _linearDefineName;
  21604. private _gammaDefineName;
  21605. private _tempTextureRead;
  21606. private _samplerName;
  21607. private _transformedUVName;
  21608. private _textureTransformName;
  21609. private _textureInfoName;
  21610. private _mainUVName;
  21611. private _mainUVDefineName;
  21612. private _fragmentOnly;
  21613. /**
  21614. * Gets or sets the texture associated with the node
  21615. */
  21616. texture: Nullable<Texture>;
  21617. /**
  21618. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21619. */
  21620. convertToGammaSpace: boolean;
  21621. /**
  21622. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21623. */
  21624. convertToLinearSpace: boolean;
  21625. /**
  21626. * Create a new TextureBlock
  21627. * @param name defines the block name
  21628. */
  21629. constructor(name: string, fragmentOnly?: boolean);
  21630. /**
  21631. * Gets the current class name
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Gets the uv input component
  21637. */
  21638. get uv(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Gets the rgba output component
  21641. */
  21642. get rgba(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the rgb output component
  21645. */
  21646. get rgb(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the r output component
  21649. */
  21650. get r(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the g output component
  21653. */
  21654. get g(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the b output component
  21657. */
  21658. get b(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the a output component
  21661. */
  21662. get a(): NodeMaterialConnectionPoint;
  21663. get target(): NodeMaterialBlockTargets;
  21664. autoConfigure(material: NodeMaterial): void;
  21665. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21667. isReady(): boolean;
  21668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21669. private get _isMixed();
  21670. private _injectVertexCode;
  21671. private _writeTextureRead;
  21672. private _writeOutput;
  21673. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21674. protected _dumpPropertiesCode(): string;
  21675. serialize(): any;
  21676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21677. }
  21678. }
  21679. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21680. /** @hidden */
  21681. export var reflectionFunction: {
  21682. name: string;
  21683. shader: string;
  21684. };
  21685. }
  21686. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21692. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21693. import { Effect } from "babylonjs/Materials/effect";
  21694. import { Mesh } from "babylonjs/Meshes/mesh";
  21695. import { Nullable } from "babylonjs/types";
  21696. import { Scene } from "babylonjs/scene";
  21697. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21698. /**
  21699. * Base block used to read a reflection texture from a sampler
  21700. */
  21701. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21702. /** @hidden */
  21703. _define3DName: string;
  21704. /** @hidden */
  21705. _defineCubicName: string;
  21706. /** @hidden */
  21707. _defineExplicitName: string;
  21708. /** @hidden */
  21709. _defineProjectionName: string;
  21710. /** @hidden */
  21711. _defineLocalCubicName: string;
  21712. /** @hidden */
  21713. _defineSphericalName: string;
  21714. /** @hidden */
  21715. _definePlanarName: string;
  21716. /** @hidden */
  21717. _defineEquirectangularName: string;
  21718. /** @hidden */
  21719. _defineMirroredEquirectangularFixedName: string;
  21720. /** @hidden */
  21721. _defineEquirectangularFixedName: string;
  21722. /** @hidden */
  21723. _defineSkyboxName: string;
  21724. /** @hidden */
  21725. _defineOppositeZ: string;
  21726. /** @hidden */
  21727. _cubeSamplerName: string;
  21728. /** @hidden */
  21729. _2DSamplerName: string;
  21730. protected _positionUVWName: string;
  21731. protected _directionWName: string;
  21732. protected _reflectionVectorName: string;
  21733. /** @hidden */
  21734. _reflectionCoordsName: string;
  21735. /** @hidden */
  21736. _reflectionMatrixName: string;
  21737. protected _reflectionColorName: string;
  21738. /**
  21739. * Gets or sets the texture associated with the node
  21740. */
  21741. texture: Nullable<BaseTexture>;
  21742. /**
  21743. * Create a new ReflectionTextureBaseBlock
  21744. * @param name defines the block name
  21745. */
  21746. constructor(name: string);
  21747. /**
  21748. * Gets the current class name
  21749. * @returns the class name
  21750. */
  21751. getClassName(): string;
  21752. /**
  21753. * Gets the world position input component
  21754. */
  21755. abstract get position(): NodeMaterialConnectionPoint;
  21756. /**
  21757. * Gets the world position input component
  21758. */
  21759. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21760. /**
  21761. * Gets the world normal input component
  21762. */
  21763. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21764. /**
  21765. * Gets the world input component
  21766. */
  21767. abstract get world(): NodeMaterialConnectionPoint;
  21768. /**
  21769. * Gets the camera (or eye) position component
  21770. */
  21771. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21772. /**
  21773. * Gets the view input component
  21774. */
  21775. abstract get view(): NodeMaterialConnectionPoint;
  21776. protected _getTexture(): Nullable<BaseTexture>;
  21777. autoConfigure(material: NodeMaterial): void;
  21778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21779. isReady(): boolean;
  21780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21781. /**
  21782. * Gets the code to inject in the vertex shader
  21783. * @param state current state of the node material building
  21784. * @returns the shader code
  21785. */
  21786. handleVertexSide(state: NodeMaterialBuildState): string;
  21787. /**
  21788. * Handles the inits for the fragment code path
  21789. * @param state node material build state
  21790. */
  21791. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21792. /**
  21793. * Generates the reflection coords code for the fragment code path
  21794. * @param worldNormalVarName name of the world normal variable
  21795. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21796. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21797. * @returns the shader code
  21798. */
  21799. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21800. /**
  21801. * Generates the reflection color code for the fragment code path
  21802. * @param lodVarName name of the lod variable
  21803. * @param swizzleLookupTexture swizzle to use for the final color variable
  21804. * @returns the shader code
  21805. */
  21806. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21807. /**
  21808. * Generates the code corresponding to the connected output points
  21809. * @param state node material build state
  21810. * @param varName name of the variable to output
  21811. * @returns the shader code
  21812. */
  21813. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21814. protected _buildBlock(state: NodeMaterialBuildState): this;
  21815. protected _dumpPropertiesCode(): string;
  21816. serialize(): any;
  21817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21818. }
  21819. }
  21820. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21822. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21823. import { Nullable } from "babylonjs/types";
  21824. /**
  21825. * Defines a connection point to be used for points with a custom object type
  21826. */
  21827. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21828. private _blockType;
  21829. private _blockName;
  21830. private _nameForCheking?;
  21831. /**
  21832. * Creates a new connection point
  21833. * @param name defines the connection point name
  21834. * @param ownerBlock defines the block hosting this connection point
  21835. * @param direction defines the direction of the connection point
  21836. */
  21837. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21838. /**
  21839. * Gets a number indicating if the current point can be connected to another point
  21840. * @param connectionPoint defines the other connection point
  21841. * @returns a number defining the compatibility state
  21842. */
  21843. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21844. /**
  21845. * Creates a block suitable to be used as an input for this input point.
  21846. * If null is returned, a block based on the point type will be created.
  21847. * @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
  21848. */
  21849. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21850. }
  21851. }
  21852. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21853. /**
  21854. * Enum defining the type of properties that can be edited in the property pages in the NME
  21855. */
  21856. export enum PropertyTypeForEdition {
  21857. /** property is a boolean */
  21858. Boolean = 0,
  21859. /** property is a float */
  21860. Float = 1,
  21861. /** property is a Vector2 */
  21862. Vector2 = 2,
  21863. /** property is a list of values */
  21864. List = 3
  21865. }
  21866. /**
  21867. * Interface that defines an option in a variable of type list
  21868. */
  21869. export interface IEditablePropertyListOption {
  21870. /** label of the option */
  21871. "label": string;
  21872. /** value of the option */
  21873. "value": number;
  21874. }
  21875. /**
  21876. * Interface that defines the options available for an editable property
  21877. */
  21878. export interface IEditablePropertyOption {
  21879. /** min value */
  21880. "min"?: number;
  21881. /** max value */
  21882. "max"?: number;
  21883. /** notifiers: indicates which actions to take when the property is changed */
  21884. "notifiers"?: {
  21885. /** the material should be rebuilt */
  21886. "rebuild"?: boolean;
  21887. /** the preview should be updated */
  21888. "update"?: boolean;
  21889. };
  21890. /** list of the options for a variable of type list */
  21891. "options"?: IEditablePropertyListOption[];
  21892. }
  21893. /**
  21894. * Interface that describes an editable property
  21895. */
  21896. export interface IPropertyDescriptionForEdition {
  21897. /** name of the property */
  21898. "propertyName": string;
  21899. /** display name of the property */
  21900. "displayName": string;
  21901. /** type of the property */
  21902. "type": PropertyTypeForEdition;
  21903. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21904. "groupName": string;
  21905. /** options for the property */
  21906. "options": IEditablePropertyOption;
  21907. }
  21908. /**
  21909. * Decorator that flags a property in a node material block as being editable
  21910. */
  21911. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21912. }
  21913. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21916. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21918. import { Nullable } from "babylonjs/types";
  21919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21920. import { Mesh } from "babylonjs/Meshes/mesh";
  21921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21922. import { Effect } from "babylonjs/Materials/effect";
  21923. import { Scene } from "babylonjs/scene";
  21924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21925. /**
  21926. * Block used to implement the refraction part of the sub surface module of the PBR material
  21927. */
  21928. export class RefractionBlock extends NodeMaterialBlock {
  21929. /** @hidden */
  21930. _define3DName: string;
  21931. /** @hidden */
  21932. _refractionMatrixName: string;
  21933. /** @hidden */
  21934. _defineLODRefractionAlpha: string;
  21935. /** @hidden */
  21936. _defineLinearSpecularRefraction: string;
  21937. /** @hidden */
  21938. _defineOppositeZ: string;
  21939. /** @hidden */
  21940. _cubeSamplerName: string;
  21941. /** @hidden */
  21942. _2DSamplerName: string;
  21943. /** @hidden */
  21944. _vRefractionMicrosurfaceInfosName: string;
  21945. /** @hidden */
  21946. _vRefractionInfosName: string;
  21947. private _scene;
  21948. /**
  21949. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21950. * Materials half opaque for instance using refraction could benefit from this control.
  21951. */
  21952. linkRefractionWithTransparency: boolean;
  21953. /**
  21954. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21955. */
  21956. invertRefractionY: boolean;
  21957. /**
  21958. * Gets or sets the texture associated with the node
  21959. */
  21960. texture: Nullable<BaseTexture>;
  21961. /**
  21962. * Create a new RefractionBlock
  21963. * @param name defines the block name
  21964. */
  21965. constructor(name: string);
  21966. /**
  21967. * Gets the current class name
  21968. * @returns the class name
  21969. */
  21970. getClassName(): string;
  21971. /**
  21972. * Gets the intensity input component
  21973. */
  21974. get intensity(): NodeMaterialConnectionPoint;
  21975. /**
  21976. * Gets the index of refraction input component
  21977. */
  21978. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21979. /**
  21980. * Gets the tint at distance input component
  21981. */
  21982. get tintAtDistance(): NodeMaterialConnectionPoint;
  21983. /**
  21984. * Gets the view input component
  21985. */
  21986. get view(): NodeMaterialConnectionPoint;
  21987. /**
  21988. * Gets the refraction object output component
  21989. */
  21990. get refraction(): NodeMaterialConnectionPoint;
  21991. /**
  21992. * Returns true if the block has a texture
  21993. */
  21994. get hasTexture(): boolean;
  21995. protected _getTexture(): Nullable<BaseTexture>;
  21996. autoConfigure(material: NodeMaterial): void;
  21997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21998. isReady(): boolean;
  21999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22000. /**
  22001. * Gets the main code of the block (fragment side)
  22002. * @param state current state of the node material building
  22003. * @returns the shader code
  22004. */
  22005. getCode(state: NodeMaterialBuildState): string;
  22006. protected _buildBlock(state: NodeMaterialBuildState): this;
  22007. protected _dumpPropertiesCode(): string;
  22008. serialize(): any;
  22009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22010. }
  22011. }
  22012. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22015. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22018. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22020. import { Nullable } from "babylonjs/types";
  22021. import { Scene } from "babylonjs/scene";
  22022. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22023. /**
  22024. * Base block used as input for post process
  22025. */
  22026. export class CurrentScreenBlock extends NodeMaterialBlock {
  22027. private _samplerName;
  22028. private _linearDefineName;
  22029. private _gammaDefineName;
  22030. private _mainUVName;
  22031. private _tempTextureRead;
  22032. /**
  22033. * Gets or sets the texture associated with the node
  22034. */
  22035. texture: Nullable<BaseTexture>;
  22036. /**
  22037. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22038. */
  22039. convertToGammaSpace: boolean;
  22040. /**
  22041. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22042. */
  22043. convertToLinearSpace: boolean;
  22044. /**
  22045. * Create a new CurrentScreenBlock
  22046. * @param name defines the block name
  22047. */
  22048. constructor(name: string);
  22049. /**
  22050. * Gets the current class name
  22051. * @returns the class name
  22052. */
  22053. getClassName(): string;
  22054. /**
  22055. * Gets the uv input component
  22056. */
  22057. get uv(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the rgba output component
  22060. */
  22061. get rgba(): NodeMaterialConnectionPoint;
  22062. /**
  22063. * Gets the rgb output component
  22064. */
  22065. get rgb(): NodeMaterialConnectionPoint;
  22066. /**
  22067. * Gets the r output component
  22068. */
  22069. get r(): NodeMaterialConnectionPoint;
  22070. /**
  22071. * Gets the g output component
  22072. */
  22073. get g(): NodeMaterialConnectionPoint;
  22074. /**
  22075. * Gets the b output component
  22076. */
  22077. get b(): NodeMaterialConnectionPoint;
  22078. /**
  22079. * Gets the a output component
  22080. */
  22081. get a(): NodeMaterialConnectionPoint;
  22082. /**
  22083. * Initialize the block and prepare the context for build
  22084. * @param state defines the state that will be used for the build
  22085. */
  22086. initialize(state: NodeMaterialBuildState): void;
  22087. get target(): NodeMaterialBlockTargets;
  22088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22089. isReady(): boolean;
  22090. private _injectVertexCode;
  22091. private _writeTextureRead;
  22092. private _writeOutput;
  22093. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22094. serialize(): any;
  22095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22096. }
  22097. }
  22098. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22105. import { Nullable } from "babylonjs/types";
  22106. import { Scene } from "babylonjs/scene";
  22107. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22108. /**
  22109. * Base block used for the particle texture
  22110. */
  22111. export class ParticleTextureBlock extends NodeMaterialBlock {
  22112. private _samplerName;
  22113. private _linearDefineName;
  22114. private _gammaDefineName;
  22115. private _tempTextureRead;
  22116. /**
  22117. * Gets or sets the texture associated with the node
  22118. */
  22119. texture: Nullable<BaseTexture>;
  22120. /**
  22121. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22122. */
  22123. convertToGammaSpace: boolean;
  22124. /**
  22125. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22126. */
  22127. convertToLinearSpace: boolean;
  22128. /**
  22129. * Create a new ParticleTextureBlock
  22130. * @param name defines the block name
  22131. */
  22132. constructor(name: string);
  22133. /**
  22134. * Gets the current class name
  22135. * @returns the class name
  22136. */
  22137. getClassName(): string;
  22138. /**
  22139. * Gets the uv input component
  22140. */
  22141. get uv(): NodeMaterialConnectionPoint;
  22142. /**
  22143. * Gets the rgba output component
  22144. */
  22145. get rgba(): NodeMaterialConnectionPoint;
  22146. /**
  22147. * Gets the rgb output component
  22148. */
  22149. get rgb(): NodeMaterialConnectionPoint;
  22150. /**
  22151. * Gets the r output component
  22152. */
  22153. get r(): NodeMaterialConnectionPoint;
  22154. /**
  22155. * Gets the g output component
  22156. */
  22157. get g(): NodeMaterialConnectionPoint;
  22158. /**
  22159. * Gets the b output component
  22160. */
  22161. get b(): NodeMaterialConnectionPoint;
  22162. /**
  22163. * Gets the a output component
  22164. */
  22165. get a(): NodeMaterialConnectionPoint;
  22166. /**
  22167. * Initialize the block and prepare the context for build
  22168. * @param state defines the state that will be used for the build
  22169. */
  22170. initialize(state: NodeMaterialBuildState): void;
  22171. autoConfigure(material: NodeMaterial): void;
  22172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22173. isReady(): boolean;
  22174. private _writeOutput;
  22175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22176. serialize(): any;
  22177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22178. }
  22179. }
  22180. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22183. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22184. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22185. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22186. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22187. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22188. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22189. import { Scene } from "babylonjs/scene";
  22190. /**
  22191. * Class used to store shared data between 2 NodeMaterialBuildState
  22192. */
  22193. export class NodeMaterialBuildStateSharedData {
  22194. /**
  22195. * Gets the list of emitted varyings
  22196. */
  22197. temps: string[];
  22198. /**
  22199. * Gets the list of emitted varyings
  22200. */
  22201. varyings: string[];
  22202. /**
  22203. * Gets the varying declaration string
  22204. */
  22205. varyingDeclaration: string;
  22206. /**
  22207. * Input blocks
  22208. */
  22209. inputBlocks: InputBlock[];
  22210. /**
  22211. * Input blocks
  22212. */
  22213. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22214. /**
  22215. * Bindable blocks (Blocks that need to set data to the effect)
  22216. */
  22217. bindableBlocks: NodeMaterialBlock[];
  22218. /**
  22219. * List of blocks that can provide a compilation fallback
  22220. */
  22221. blocksWithFallbacks: NodeMaterialBlock[];
  22222. /**
  22223. * List of blocks that can provide a define update
  22224. */
  22225. blocksWithDefines: NodeMaterialBlock[];
  22226. /**
  22227. * List of blocks that can provide a repeatable content
  22228. */
  22229. repeatableContentBlocks: NodeMaterialBlock[];
  22230. /**
  22231. * List of blocks that can provide a dynamic list of uniforms
  22232. */
  22233. dynamicUniformBlocks: NodeMaterialBlock[];
  22234. /**
  22235. * List of blocks that can block the isReady function for the material
  22236. */
  22237. blockingBlocks: NodeMaterialBlock[];
  22238. /**
  22239. * Gets the list of animated inputs
  22240. */
  22241. animatedInputs: InputBlock[];
  22242. /**
  22243. * Build Id used to avoid multiple recompilations
  22244. */
  22245. buildId: number;
  22246. /** List of emitted variables */
  22247. variableNames: {
  22248. [key: string]: number;
  22249. };
  22250. /** List of emitted defines */
  22251. defineNames: {
  22252. [key: string]: number;
  22253. };
  22254. /** Should emit comments? */
  22255. emitComments: boolean;
  22256. /** Emit build activity */
  22257. verbose: boolean;
  22258. /** Gets or sets the hosting scene */
  22259. scene: Scene;
  22260. /**
  22261. * Gets the compilation hints emitted at compilation time
  22262. */
  22263. hints: {
  22264. needWorldViewMatrix: boolean;
  22265. needWorldViewProjectionMatrix: boolean;
  22266. needAlphaBlending: boolean;
  22267. needAlphaTesting: boolean;
  22268. };
  22269. /**
  22270. * List of compilation checks
  22271. */
  22272. checks: {
  22273. emitVertex: boolean;
  22274. emitFragment: boolean;
  22275. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22276. };
  22277. /**
  22278. * Is vertex program allowed to be empty?
  22279. */
  22280. allowEmptyVertexProgram: boolean;
  22281. /** Creates a new shared data */
  22282. constructor();
  22283. /**
  22284. * Emits console errors and exceptions if there is a failing check
  22285. */
  22286. emitErrors(): void;
  22287. }
  22288. }
  22289. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22290. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22291. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22292. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22293. /**
  22294. * Class used to store node based material build state
  22295. */
  22296. export class NodeMaterialBuildState {
  22297. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22298. supportUniformBuffers: boolean;
  22299. /**
  22300. * Gets the list of emitted attributes
  22301. */
  22302. attributes: string[];
  22303. /**
  22304. * Gets the list of emitted uniforms
  22305. */
  22306. uniforms: string[];
  22307. /**
  22308. * Gets the list of emitted constants
  22309. */
  22310. constants: string[];
  22311. /**
  22312. * Gets the list of emitted samplers
  22313. */
  22314. samplers: string[];
  22315. /**
  22316. * Gets the list of emitted functions
  22317. */
  22318. functions: {
  22319. [key: string]: string;
  22320. };
  22321. /**
  22322. * Gets the list of emitted extensions
  22323. */
  22324. extensions: {
  22325. [key: string]: string;
  22326. };
  22327. /**
  22328. * Gets the target of the compilation state
  22329. */
  22330. target: NodeMaterialBlockTargets;
  22331. /**
  22332. * Gets the list of emitted counters
  22333. */
  22334. counters: {
  22335. [key: string]: number;
  22336. };
  22337. /**
  22338. * Shared data between multiple NodeMaterialBuildState instances
  22339. */
  22340. sharedData: NodeMaterialBuildStateSharedData;
  22341. /** @hidden */
  22342. _vertexState: NodeMaterialBuildState;
  22343. /** @hidden */
  22344. _attributeDeclaration: string;
  22345. /** @hidden */
  22346. _uniformDeclaration: string;
  22347. /** @hidden */
  22348. _constantDeclaration: string;
  22349. /** @hidden */
  22350. _samplerDeclaration: string;
  22351. /** @hidden */
  22352. _varyingTransfer: string;
  22353. /** @hidden */
  22354. _injectAtEnd: string;
  22355. private _repeatableContentAnchorIndex;
  22356. /** @hidden */
  22357. _builtCompilationString: string;
  22358. /**
  22359. * Gets the emitted compilation strings
  22360. */
  22361. compilationString: string;
  22362. /**
  22363. * Finalize the compilation strings
  22364. * @param state defines the current compilation state
  22365. */
  22366. finalize(state: NodeMaterialBuildState): void;
  22367. /** @hidden */
  22368. get _repeatableContentAnchor(): string;
  22369. /** @hidden */
  22370. _getFreeVariableName(prefix: string): string;
  22371. /** @hidden */
  22372. _getFreeDefineName(prefix: string): string;
  22373. /** @hidden */
  22374. _excludeVariableName(name: string): void;
  22375. /** @hidden */
  22376. _emit2DSampler(name: string): void;
  22377. /** @hidden */
  22378. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22379. /** @hidden */
  22380. _emitExtension(name: string, extension: string, define?: string): void;
  22381. /** @hidden */
  22382. _emitFunction(name: string, code: string, comments: string): void;
  22383. /** @hidden */
  22384. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22385. replaceStrings?: {
  22386. search: RegExp;
  22387. replace: string;
  22388. }[];
  22389. repeatKey?: string;
  22390. }): string;
  22391. /** @hidden */
  22392. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22393. repeatKey?: string;
  22394. removeAttributes?: boolean;
  22395. removeUniforms?: boolean;
  22396. removeVaryings?: boolean;
  22397. removeIfDef?: boolean;
  22398. replaceStrings?: {
  22399. search: RegExp;
  22400. replace: string;
  22401. }[];
  22402. }, storeKey?: string): void;
  22403. /** @hidden */
  22404. _registerTempVariable(name: string): boolean;
  22405. /** @hidden */
  22406. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22407. /** @hidden */
  22408. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22409. /** @hidden */
  22410. _emitFloat(value: number): string;
  22411. }
  22412. }
  22413. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22414. /**
  22415. * Helper class used to generate session unique ID
  22416. */
  22417. export class UniqueIdGenerator {
  22418. private static _UniqueIdCounter;
  22419. /**
  22420. * Gets an unique (relatively to the current scene) Id
  22421. */
  22422. static get UniqueId(): number;
  22423. }
  22424. }
  22425. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22426. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22428. import { Nullable } from "babylonjs/types";
  22429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22430. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22431. import { Effect } from "babylonjs/Materials/effect";
  22432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22433. import { Mesh } from "babylonjs/Meshes/mesh";
  22434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22435. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22436. import { Scene } from "babylonjs/scene";
  22437. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22438. /**
  22439. * Defines a block that can be used inside a node based material
  22440. */
  22441. export class NodeMaterialBlock {
  22442. private _buildId;
  22443. private _buildTarget;
  22444. private _target;
  22445. private _isFinalMerger;
  22446. private _isInput;
  22447. private _name;
  22448. protected _isUnique: boolean;
  22449. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22450. inputsAreExclusive: boolean;
  22451. /** @hidden */
  22452. _codeVariableName: string;
  22453. /** @hidden */
  22454. _inputs: NodeMaterialConnectionPoint[];
  22455. /** @hidden */
  22456. _outputs: NodeMaterialConnectionPoint[];
  22457. /** @hidden */
  22458. _preparationId: number;
  22459. /**
  22460. * Gets the name of the block
  22461. */
  22462. get name(): string;
  22463. /**
  22464. * Sets the name of the block. Will check if the name is valid.
  22465. */
  22466. set name(newName: string);
  22467. /**
  22468. * Gets or sets the unique id of the node
  22469. */
  22470. uniqueId: number;
  22471. /**
  22472. * Gets or sets the comments associated with this block
  22473. */
  22474. comments: string;
  22475. /**
  22476. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22477. */
  22478. get isUnique(): boolean;
  22479. /**
  22480. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22481. */
  22482. get isFinalMerger(): boolean;
  22483. /**
  22484. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22485. */
  22486. get isInput(): boolean;
  22487. /**
  22488. * Gets or sets the build Id
  22489. */
  22490. get buildId(): number;
  22491. set buildId(value: number);
  22492. /**
  22493. * Gets or sets the target of the block
  22494. */
  22495. get target(): NodeMaterialBlockTargets;
  22496. set target(value: NodeMaterialBlockTargets);
  22497. /**
  22498. * Gets the list of input points
  22499. */
  22500. get inputs(): NodeMaterialConnectionPoint[];
  22501. /** Gets the list of output points */
  22502. get outputs(): NodeMaterialConnectionPoint[];
  22503. /**
  22504. * Find an input by its name
  22505. * @param name defines the name of the input to look for
  22506. * @returns the input or null if not found
  22507. */
  22508. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22509. /**
  22510. * Find an output by its name
  22511. * @param name defines the name of the outputto look for
  22512. * @returns the output or null if not found
  22513. */
  22514. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22515. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22516. visibleInInspector: boolean;
  22517. /**
  22518. * Creates a new NodeMaterialBlock
  22519. * @param name defines the block name
  22520. * @param target defines the target of that block (Vertex by default)
  22521. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22522. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22523. */
  22524. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22525. /**
  22526. * Initialize the block and prepare the context for build
  22527. * @param state defines the state that will be used for the build
  22528. */
  22529. initialize(state: NodeMaterialBuildState): void;
  22530. /**
  22531. * Bind data to effect. Will only be called for blocks with isBindable === true
  22532. * @param effect defines the effect to bind data to
  22533. * @param nodeMaterial defines the hosting NodeMaterial
  22534. * @param mesh defines the mesh that will be rendered
  22535. * @param subMesh defines the submesh that will be rendered
  22536. */
  22537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22538. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22539. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22540. protected _writeFloat(value: number): string;
  22541. /**
  22542. * Gets the current class name e.g. "NodeMaterialBlock"
  22543. * @returns the class name
  22544. */
  22545. getClassName(): string;
  22546. /**
  22547. * Register a new input. Must be called inside a block constructor
  22548. * @param name defines the connection point name
  22549. * @param type defines the connection point type
  22550. * @param isOptional defines a boolean indicating that this input can be omitted
  22551. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22552. * @param point an already created connection point. If not provided, create a new one
  22553. * @returns the current block
  22554. */
  22555. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22556. /**
  22557. * Register a new output. Must be called inside a block constructor
  22558. * @param name defines the connection point name
  22559. * @param type defines the connection point type
  22560. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22561. * @param point an already created connection point. If not provided, create a new one
  22562. * @returns the current block
  22563. */
  22564. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22565. /**
  22566. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22567. * @param forOutput defines an optional connection point to check compatibility with
  22568. * @returns the first available input or null
  22569. */
  22570. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22571. /**
  22572. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22573. * @param forBlock defines an optional block to check compatibility with
  22574. * @returns the first available input or null
  22575. */
  22576. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22577. /**
  22578. * Gets the sibling of the given output
  22579. * @param current defines the current output
  22580. * @returns the next output in the list or null
  22581. */
  22582. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22583. /**
  22584. * Connect current block with another block
  22585. * @param other defines the block to connect with
  22586. * @param options define the various options to help pick the right connections
  22587. * @returns the current block
  22588. */
  22589. connectTo(other: NodeMaterialBlock, options?: {
  22590. input?: string;
  22591. output?: string;
  22592. outputSwizzle?: string;
  22593. }): this | undefined;
  22594. protected _buildBlock(state: NodeMaterialBuildState): void;
  22595. /**
  22596. * Add uniforms, samplers and uniform buffers at compilation time
  22597. * @param state defines the state to update
  22598. * @param nodeMaterial defines the node material requesting the update
  22599. * @param defines defines the material defines to update
  22600. * @param uniformBuffers defines the list of uniform buffer names
  22601. */
  22602. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22603. /**
  22604. * Add potential fallbacks if shader compilation fails
  22605. * @param mesh defines the mesh to be rendered
  22606. * @param fallbacks defines the current prioritized list of fallbacks
  22607. */
  22608. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22609. /**
  22610. * Initialize defines for shader compilation
  22611. * @param mesh defines the mesh to be rendered
  22612. * @param nodeMaterial defines the node material requesting the update
  22613. * @param defines defines the material defines to update
  22614. * @param useInstances specifies that instances should be used
  22615. */
  22616. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22617. /**
  22618. * Update defines for shader compilation
  22619. * @param mesh defines the mesh to be rendered
  22620. * @param nodeMaterial defines the node material requesting the update
  22621. * @param defines defines the material defines to update
  22622. * @param useInstances specifies that instances should be used
  22623. * @param subMesh defines which submesh to render
  22624. */
  22625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22626. /**
  22627. * Lets the block try to connect some inputs automatically
  22628. * @param material defines the hosting NodeMaterial
  22629. */
  22630. autoConfigure(material: NodeMaterial): void;
  22631. /**
  22632. * Function called when a block is declared as repeatable content generator
  22633. * @param vertexShaderState defines the current compilation state for the vertex shader
  22634. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22635. * @param mesh defines the mesh to be rendered
  22636. * @param defines defines the material defines to update
  22637. */
  22638. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22639. /**
  22640. * Checks if the block is ready
  22641. * @param mesh defines the mesh to be rendered
  22642. * @param nodeMaterial defines the node material requesting the update
  22643. * @param defines defines the material defines to update
  22644. * @param useInstances specifies that instances should be used
  22645. * @returns true if the block is ready
  22646. */
  22647. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22648. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22649. private _processBuild;
  22650. /**
  22651. * Validates the new name for the block node.
  22652. * @param newName the new name to be given to the node.
  22653. * @returns false if the name is a reserve word, else true.
  22654. */
  22655. validateBlockName(newName: string): boolean;
  22656. /**
  22657. * Compile the current node and generate the shader code
  22658. * @param state defines the current compilation state (uniforms, samplers, current string)
  22659. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22660. * @returns true if already built
  22661. */
  22662. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22663. protected _inputRename(name: string): string;
  22664. protected _outputRename(name: string): string;
  22665. protected _dumpPropertiesCode(): string;
  22666. /** @hidden */
  22667. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22668. /** @hidden */
  22669. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22670. /**
  22671. * Clone the current block to a new identical block
  22672. * @param scene defines the hosting scene
  22673. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22674. * @returns a copy of the current block
  22675. */
  22676. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22677. /**
  22678. * Serializes this block in a JSON representation
  22679. * @returns the serialized block object
  22680. */
  22681. serialize(): any;
  22682. /** @hidden */
  22683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22684. private _deserializePortDisplayNamesAndExposedOnFrame;
  22685. /**
  22686. * Release resources
  22687. */
  22688. dispose(): void;
  22689. }
  22690. }
  22691. declare module "babylonjs/Materials/pushMaterial" {
  22692. import { Nullable } from "babylonjs/types";
  22693. import { Scene } from "babylonjs/scene";
  22694. import { Matrix } from "babylonjs/Maths/math.vector";
  22695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22696. import { Mesh } from "babylonjs/Meshes/mesh";
  22697. import { Material } from "babylonjs/Materials/material";
  22698. import { Effect } from "babylonjs/Materials/effect";
  22699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22700. /**
  22701. * Base class of materials working in push mode in babylon JS
  22702. * @hidden
  22703. */
  22704. export class PushMaterial extends Material {
  22705. protected _activeEffect: Effect;
  22706. protected _normalMatrix: Matrix;
  22707. constructor(name: string, scene: Scene);
  22708. getEffect(): Effect;
  22709. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22710. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22711. /**
  22712. * Binds the given world matrix to the active effect
  22713. *
  22714. * @param world the matrix to bind
  22715. */
  22716. bindOnlyWorldMatrix(world: Matrix): void;
  22717. /**
  22718. * Binds the given normal matrix to the active effect
  22719. *
  22720. * @param normalMatrix the matrix to bind
  22721. */
  22722. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22723. bind(world: Matrix, mesh?: Mesh): void;
  22724. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22725. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22726. }
  22727. }
  22728. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22730. /**
  22731. * Root class for all node material optimizers
  22732. */
  22733. export class NodeMaterialOptimizer {
  22734. /**
  22735. * Function used to optimize a NodeMaterial graph
  22736. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22737. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22738. */
  22739. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22740. }
  22741. }
  22742. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22746. import { Scene } from "babylonjs/scene";
  22747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22748. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22749. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22750. /**
  22751. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22752. */
  22753. export class TransformBlock extends NodeMaterialBlock {
  22754. /**
  22755. * Defines the value to use to complement W value to transform it to a Vector4
  22756. */
  22757. complementW: number;
  22758. /**
  22759. * Defines the value to use to complement z value to transform it to a Vector4
  22760. */
  22761. complementZ: number;
  22762. /**
  22763. * Creates a new TransformBlock
  22764. * @param name defines the block name
  22765. */
  22766. constructor(name: string);
  22767. /**
  22768. * Gets the current class name
  22769. * @returns the class name
  22770. */
  22771. getClassName(): string;
  22772. /**
  22773. * Gets the vector input
  22774. */
  22775. get vector(): NodeMaterialConnectionPoint;
  22776. /**
  22777. * Gets the output component
  22778. */
  22779. get output(): NodeMaterialConnectionPoint;
  22780. /**
  22781. * Gets the xyz output component
  22782. */
  22783. get xyz(): NodeMaterialConnectionPoint;
  22784. /**
  22785. * Gets the matrix transform input
  22786. */
  22787. get transform(): NodeMaterialConnectionPoint;
  22788. protected _buildBlock(state: NodeMaterialBuildState): this;
  22789. /**
  22790. * Update defines for shader compilation
  22791. * @param mesh defines the mesh to be rendered
  22792. * @param nodeMaterial defines the node material requesting the update
  22793. * @param defines defines the material defines to update
  22794. * @param useInstances specifies that instances should be used
  22795. * @param subMesh defines which submesh to render
  22796. */
  22797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22798. serialize(): any;
  22799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22800. protected _dumpPropertiesCode(): string;
  22801. }
  22802. }
  22803. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22807. /**
  22808. * Block used to output the vertex position
  22809. */
  22810. export class VertexOutputBlock extends NodeMaterialBlock {
  22811. /**
  22812. * Creates a new VertexOutputBlock
  22813. * @param name defines the block name
  22814. */
  22815. constructor(name: string);
  22816. /**
  22817. * Gets the current class name
  22818. * @returns the class name
  22819. */
  22820. getClassName(): string;
  22821. /**
  22822. * Gets the vector input component
  22823. */
  22824. get vector(): NodeMaterialConnectionPoint;
  22825. protected _buildBlock(state: NodeMaterialBuildState): this;
  22826. }
  22827. }
  22828. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22832. /**
  22833. * Block used to output the final color
  22834. */
  22835. export class FragmentOutputBlock extends NodeMaterialBlock {
  22836. /**
  22837. * Create a new FragmentOutputBlock
  22838. * @param name defines the block name
  22839. */
  22840. constructor(name: string);
  22841. /**
  22842. * Gets the current class name
  22843. * @returns the class name
  22844. */
  22845. getClassName(): string;
  22846. /**
  22847. * Gets the rgba input component
  22848. */
  22849. get rgba(): NodeMaterialConnectionPoint;
  22850. /**
  22851. * Gets the rgb input component
  22852. */
  22853. get rgb(): NodeMaterialConnectionPoint;
  22854. /**
  22855. * Gets the a input component
  22856. */
  22857. get a(): NodeMaterialConnectionPoint;
  22858. protected _buildBlock(state: NodeMaterialBuildState): this;
  22859. }
  22860. }
  22861. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22865. /**
  22866. * Block used for the particle ramp gradient section
  22867. */
  22868. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22869. /**
  22870. * Create a new ParticleRampGradientBlock
  22871. * @param name defines the block name
  22872. */
  22873. constructor(name: string);
  22874. /**
  22875. * Gets the current class name
  22876. * @returns the class name
  22877. */
  22878. getClassName(): string;
  22879. /**
  22880. * Gets the color input component
  22881. */
  22882. get color(): NodeMaterialConnectionPoint;
  22883. /**
  22884. * Gets the rampColor output component
  22885. */
  22886. get rampColor(): NodeMaterialConnectionPoint;
  22887. /**
  22888. * Initialize the block and prepare the context for build
  22889. * @param state defines the state that will be used for the build
  22890. */
  22891. initialize(state: NodeMaterialBuildState): void;
  22892. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22893. }
  22894. }
  22895. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22899. /**
  22900. * Block used for the particle blend multiply section
  22901. */
  22902. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22903. /**
  22904. * Create a new ParticleBlendMultiplyBlock
  22905. * @param name defines the block name
  22906. */
  22907. constructor(name: string);
  22908. /**
  22909. * Gets the current class name
  22910. * @returns the class name
  22911. */
  22912. getClassName(): string;
  22913. /**
  22914. * Gets the color input component
  22915. */
  22916. get color(): NodeMaterialConnectionPoint;
  22917. /**
  22918. * Gets the alphaTexture input component
  22919. */
  22920. get alphaTexture(): NodeMaterialConnectionPoint;
  22921. /**
  22922. * Gets the alphaColor input component
  22923. */
  22924. get alphaColor(): NodeMaterialConnectionPoint;
  22925. /**
  22926. * Gets the blendColor output component
  22927. */
  22928. get blendColor(): NodeMaterialConnectionPoint;
  22929. /**
  22930. * Initialize the block and prepare the context for build
  22931. * @param state defines the state that will be used for the build
  22932. */
  22933. initialize(state: NodeMaterialBuildState): void;
  22934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22935. }
  22936. }
  22937. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22941. /**
  22942. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22943. */
  22944. export class VectorMergerBlock extends NodeMaterialBlock {
  22945. /**
  22946. * Create a new VectorMergerBlock
  22947. * @param name defines the block name
  22948. */
  22949. constructor(name: string);
  22950. /**
  22951. * Gets the current class name
  22952. * @returns the class name
  22953. */
  22954. getClassName(): string;
  22955. /**
  22956. * Gets the xyz component (input)
  22957. */
  22958. get xyzIn(): NodeMaterialConnectionPoint;
  22959. /**
  22960. * Gets the xy component (input)
  22961. */
  22962. get xyIn(): NodeMaterialConnectionPoint;
  22963. /**
  22964. * Gets the x component (input)
  22965. */
  22966. get x(): NodeMaterialConnectionPoint;
  22967. /**
  22968. * Gets the y component (input)
  22969. */
  22970. get y(): NodeMaterialConnectionPoint;
  22971. /**
  22972. * Gets the z component (input)
  22973. */
  22974. get z(): NodeMaterialConnectionPoint;
  22975. /**
  22976. * Gets the w component (input)
  22977. */
  22978. get w(): NodeMaterialConnectionPoint;
  22979. /**
  22980. * Gets the xyzw component (output)
  22981. */
  22982. get xyzw(): NodeMaterialConnectionPoint;
  22983. /**
  22984. * Gets the xyz component (output)
  22985. */
  22986. get xyzOut(): NodeMaterialConnectionPoint;
  22987. /**
  22988. * Gets the xy component (output)
  22989. */
  22990. get xyOut(): NodeMaterialConnectionPoint;
  22991. /**
  22992. * Gets the xy component (output)
  22993. * @deprecated Please use xyOut instead.
  22994. */
  22995. get xy(): NodeMaterialConnectionPoint;
  22996. /**
  22997. * Gets the xyz component (output)
  22998. * @deprecated Please use xyzOut instead.
  22999. */
  23000. get xyz(): NodeMaterialConnectionPoint;
  23001. protected _buildBlock(state: NodeMaterialBuildState): this;
  23002. }
  23003. }
  23004. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23008. import { Vector2 } from "babylonjs/Maths/math.vector";
  23009. import { Scene } from "babylonjs/scene";
  23010. /**
  23011. * Block used to remap a float from a range to a new one
  23012. */
  23013. export class RemapBlock extends NodeMaterialBlock {
  23014. /**
  23015. * Gets or sets the source range
  23016. */
  23017. sourceRange: Vector2;
  23018. /**
  23019. * Gets or sets the target range
  23020. */
  23021. targetRange: Vector2;
  23022. /**
  23023. * Creates a new RemapBlock
  23024. * @param name defines the block name
  23025. */
  23026. constructor(name: string);
  23027. /**
  23028. * Gets the current class name
  23029. * @returns the class name
  23030. */
  23031. getClassName(): string;
  23032. /**
  23033. * Gets the input component
  23034. */
  23035. get input(): NodeMaterialConnectionPoint;
  23036. /**
  23037. * Gets the source min input component
  23038. */
  23039. get sourceMin(): NodeMaterialConnectionPoint;
  23040. /**
  23041. * Gets the source max input component
  23042. */
  23043. get sourceMax(): NodeMaterialConnectionPoint;
  23044. /**
  23045. * Gets the target min input component
  23046. */
  23047. get targetMin(): NodeMaterialConnectionPoint;
  23048. /**
  23049. * Gets the target max input component
  23050. */
  23051. get targetMax(): NodeMaterialConnectionPoint;
  23052. /**
  23053. * Gets the output component
  23054. */
  23055. get output(): NodeMaterialConnectionPoint;
  23056. protected _buildBlock(state: NodeMaterialBuildState): this;
  23057. protected _dumpPropertiesCode(): string;
  23058. serialize(): any;
  23059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23060. }
  23061. }
  23062. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23066. /**
  23067. * Block used to multiply 2 values
  23068. */
  23069. export class MultiplyBlock extends NodeMaterialBlock {
  23070. /**
  23071. * Creates a new MultiplyBlock
  23072. * @param name defines the block name
  23073. */
  23074. constructor(name: string);
  23075. /**
  23076. * Gets the current class name
  23077. * @returns the class name
  23078. */
  23079. getClassName(): string;
  23080. /**
  23081. * Gets the left operand input component
  23082. */
  23083. get left(): NodeMaterialConnectionPoint;
  23084. /**
  23085. * Gets the right operand input component
  23086. */
  23087. get right(): NodeMaterialConnectionPoint;
  23088. /**
  23089. * Gets the output component
  23090. */
  23091. get output(): NodeMaterialConnectionPoint;
  23092. protected _buildBlock(state: NodeMaterialBuildState): this;
  23093. }
  23094. }
  23095. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23099. /**
  23100. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23101. */
  23102. export class ColorSplitterBlock extends NodeMaterialBlock {
  23103. /**
  23104. * Create a new ColorSplitterBlock
  23105. * @param name defines the block name
  23106. */
  23107. constructor(name: string);
  23108. /**
  23109. * Gets the current class name
  23110. * @returns the class name
  23111. */
  23112. getClassName(): string;
  23113. /**
  23114. * Gets the rgba component (input)
  23115. */
  23116. get rgba(): NodeMaterialConnectionPoint;
  23117. /**
  23118. * Gets the rgb component (input)
  23119. */
  23120. get rgbIn(): NodeMaterialConnectionPoint;
  23121. /**
  23122. * Gets the rgb component (output)
  23123. */
  23124. get rgbOut(): NodeMaterialConnectionPoint;
  23125. /**
  23126. * Gets the r component (output)
  23127. */
  23128. get r(): NodeMaterialConnectionPoint;
  23129. /**
  23130. * Gets the g component (output)
  23131. */
  23132. get g(): NodeMaterialConnectionPoint;
  23133. /**
  23134. * Gets the b component (output)
  23135. */
  23136. get b(): NodeMaterialConnectionPoint;
  23137. /**
  23138. * Gets the a component (output)
  23139. */
  23140. get a(): NodeMaterialConnectionPoint;
  23141. protected _inputRename(name: string): string;
  23142. protected _outputRename(name: string): string;
  23143. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23144. }
  23145. }
  23146. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23150. import { Scene } from "babylonjs/scene";
  23151. /**
  23152. * Operations supported by the Trigonometry block
  23153. */
  23154. export enum TrigonometryBlockOperations {
  23155. /** Cos */
  23156. Cos = 0,
  23157. /** Sin */
  23158. Sin = 1,
  23159. /** Abs */
  23160. Abs = 2,
  23161. /** Exp */
  23162. Exp = 3,
  23163. /** Exp2 */
  23164. Exp2 = 4,
  23165. /** Round */
  23166. Round = 5,
  23167. /** Floor */
  23168. Floor = 6,
  23169. /** Ceiling */
  23170. Ceiling = 7,
  23171. /** Square root */
  23172. Sqrt = 8,
  23173. /** Log */
  23174. Log = 9,
  23175. /** Tangent */
  23176. Tan = 10,
  23177. /** Arc tangent */
  23178. ArcTan = 11,
  23179. /** Arc cosinus */
  23180. ArcCos = 12,
  23181. /** Arc sinus */
  23182. ArcSin = 13,
  23183. /** Fraction */
  23184. Fract = 14,
  23185. /** Sign */
  23186. Sign = 15,
  23187. /** To radians (from degrees) */
  23188. Radians = 16,
  23189. /** To degrees (from radians) */
  23190. Degrees = 17
  23191. }
  23192. /**
  23193. * Block used to apply trigonometry operation to floats
  23194. */
  23195. export class TrigonometryBlock extends NodeMaterialBlock {
  23196. /**
  23197. * Gets or sets the operation applied by the block
  23198. */
  23199. operation: TrigonometryBlockOperations;
  23200. /**
  23201. * Creates a new TrigonometryBlock
  23202. * @param name defines the block name
  23203. */
  23204. constructor(name: string);
  23205. /**
  23206. * Gets the current class name
  23207. * @returns the class name
  23208. */
  23209. getClassName(): string;
  23210. /**
  23211. * Gets the input component
  23212. */
  23213. get input(): NodeMaterialConnectionPoint;
  23214. /**
  23215. * Gets the output component
  23216. */
  23217. get output(): NodeMaterialConnectionPoint;
  23218. protected _buildBlock(state: NodeMaterialBuildState): this;
  23219. serialize(): any;
  23220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23221. protected _dumpPropertiesCode(): string;
  23222. }
  23223. }
  23224. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23226. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23227. import { Scene } from "babylonjs/scene";
  23228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23229. import { Matrix } from "babylonjs/Maths/math.vector";
  23230. import { Mesh } from "babylonjs/Meshes/mesh";
  23231. import { Engine } from "babylonjs/Engines/engine";
  23232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23233. import { Observable } from "babylonjs/Misc/observable";
  23234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23235. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23236. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23237. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23238. import { Nullable } from "babylonjs/types";
  23239. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23240. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23241. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23242. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23243. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23244. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23245. import { Effect } from "babylonjs/Materials/effect";
  23246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23247. import { Camera } from "babylonjs/Cameras/camera";
  23248. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23249. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23250. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23251. /**
  23252. * Interface used to configure the node material editor
  23253. */
  23254. export interface INodeMaterialEditorOptions {
  23255. /** Define the URl to load node editor script */
  23256. editorURL?: string;
  23257. }
  23258. /** @hidden */
  23259. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23260. NORMAL: boolean;
  23261. TANGENT: boolean;
  23262. UV1: boolean;
  23263. /** BONES */
  23264. NUM_BONE_INFLUENCERS: number;
  23265. BonesPerMesh: number;
  23266. BONETEXTURE: boolean;
  23267. /** MORPH TARGETS */
  23268. MORPHTARGETS: boolean;
  23269. MORPHTARGETS_NORMAL: boolean;
  23270. MORPHTARGETS_TANGENT: boolean;
  23271. MORPHTARGETS_UV: boolean;
  23272. NUM_MORPH_INFLUENCERS: number;
  23273. /** IMAGE PROCESSING */
  23274. IMAGEPROCESSING: boolean;
  23275. VIGNETTE: boolean;
  23276. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23277. VIGNETTEBLENDMODEOPAQUE: boolean;
  23278. TONEMAPPING: boolean;
  23279. TONEMAPPING_ACES: boolean;
  23280. CONTRAST: boolean;
  23281. EXPOSURE: boolean;
  23282. COLORCURVES: boolean;
  23283. COLORGRADING: boolean;
  23284. COLORGRADING3D: boolean;
  23285. SAMPLER3DGREENDEPTH: boolean;
  23286. SAMPLER3DBGRMAP: boolean;
  23287. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23288. /** MISC. */
  23289. BUMPDIRECTUV: number;
  23290. constructor();
  23291. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23292. }
  23293. /**
  23294. * Class used to configure NodeMaterial
  23295. */
  23296. export interface INodeMaterialOptions {
  23297. /**
  23298. * Defines if blocks should emit comments
  23299. */
  23300. emitComments: boolean;
  23301. }
  23302. /**
  23303. * Class used to create a node based material built by assembling shader blocks
  23304. */
  23305. export class NodeMaterial extends PushMaterial {
  23306. private static _BuildIdGenerator;
  23307. private _options;
  23308. private _vertexCompilationState;
  23309. private _fragmentCompilationState;
  23310. private _sharedData;
  23311. private _buildId;
  23312. private _buildWasSuccessful;
  23313. private _cachedWorldViewMatrix;
  23314. private _cachedWorldViewProjectionMatrix;
  23315. private _optimizers;
  23316. private _animationFrame;
  23317. /** Define the Url to load node editor script */
  23318. static EditorURL: string;
  23319. /** Define the Url to load snippets */
  23320. static SnippetUrl: string;
  23321. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23322. static IgnoreTexturesAtLoadTime: boolean;
  23323. private BJSNODEMATERIALEDITOR;
  23324. /** Get the inspector from bundle or global */
  23325. private _getGlobalNodeMaterialEditor;
  23326. /**
  23327. * Snippet ID if the material was created from the snippet server
  23328. */
  23329. snippetId: string;
  23330. /**
  23331. * Gets or sets data used by visual editor
  23332. * @see https://nme.babylonjs.com
  23333. */
  23334. editorData: any;
  23335. /**
  23336. * 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)
  23337. */
  23338. ignoreAlpha: boolean;
  23339. /**
  23340. * Defines the maximum number of lights that can be used in the material
  23341. */
  23342. maxSimultaneousLights: number;
  23343. /**
  23344. * Observable raised when the material is built
  23345. */
  23346. onBuildObservable: Observable<NodeMaterial>;
  23347. /**
  23348. * Gets or sets the root nodes of the material vertex shader
  23349. */
  23350. _vertexOutputNodes: NodeMaterialBlock[];
  23351. /**
  23352. * Gets or sets the root nodes of the material fragment (pixel) shader
  23353. */
  23354. _fragmentOutputNodes: NodeMaterialBlock[];
  23355. /** Gets or sets options to control the node material overall behavior */
  23356. get options(): INodeMaterialOptions;
  23357. set options(options: INodeMaterialOptions);
  23358. /**
  23359. * Default configuration related to image processing available in the standard Material.
  23360. */
  23361. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23362. /**
  23363. * Gets the image processing configuration used either in this material.
  23364. */
  23365. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23366. /**
  23367. * Sets the Default image processing configuration used either in the this material.
  23368. *
  23369. * If sets to null, the scene one is in use.
  23370. */
  23371. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23372. /**
  23373. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23374. */
  23375. attachedBlocks: NodeMaterialBlock[];
  23376. /**
  23377. * Specifies the mode of the node material
  23378. * @hidden
  23379. */
  23380. _mode: NodeMaterialModes;
  23381. /**
  23382. * Gets the mode property
  23383. */
  23384. get mode(): NodeMaterialModes;
  23385. /**
  23386. * Create a new node based material
  23387. * @param name defines the material name
  23388. * @param scene defines the hosting scene
  23389. * @param options defines creation option
  23390. */
  23391. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23392. /**
  23393. * Gets the current class name of the material e.g. "NodeMaterial"
  23394. * @returns the class name
  23395. */
  23396. getClassName(): string;
  23397. /**
  23398. * Keep track of the image processing observer to allow dispose and replace.
  23399. */
  23400. private _imageProcessingObserver;
  23401. /**
  23402. * Attaches a new image processing configuration to the Standard Material.
  23403. * @param configuration
  23404. */
  23405. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23406. /**
  23407. * Get a block by its name
  23408. * @param name defines the name of the block to retrieve
  23409. * @returns the required block or null if not found
  23410. */
  23411. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23412. /**
  23413. * Get a block by its name
  23414. * @param predicate defines the predicate used to find the good candidate
  23415. * @returns the required block or null if not found
  23416. */
  23417. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23418. /**
  23419. * Get an input block by its name
  23420. * @param predicate defines the predicate used to find the good candidate
  23421. * @returns the required input block or null if not found
  23422. */
  23423. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23424. /**
  23425. * Gets the list of input blocks attached to this material
  23426. * @returns an array of InputBlocks
  23427. */
  23428. getInputBlocks(): InputBlock[];
  23429. /**
  23430. * Adds a new optimizer to the list of optimizers
  23431. * @param optimizer defines the optimizers to add
  23432. * @returns the current material
  23433. */
  23434. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23435. /**
  23436. * Remove an optimizer from the list of optimizers
  23437. * @param optimizer defines the optimizers to remove
  23438. * @returns the current material
  23439. */
  23440. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23441. /**
  23442. * Add a new block to the list of output nodes
  23443. * @param node defines the node to add
  23444. * @returns the current material
  23445. */
  23446. addOutputNode(node: NodeMaterialBlock): this;
  23447. /**
  23448. * Remove a block from the list of root nodes
  23449. * @param node defines the node to remove
  23450. * @returns the current material
  23451. */
  23452. removeOutputNode(node: NodeMaterialBlock): this;
  23453. private _addVertexOutputNode;
  23454. private _removeVertexOutputNode;
  23455. private _addFragmentOutputNode;
  23456. private _removeFragmentOutputNode;
  23457. /**
  23458. * Specifies if the material will require alpha blending
  23459. * @returns a boolean specifying if alpha blending is needed
  23460. */
  23461. needAlphaBlending(): boolean;
  23462. /**
  23463. * Specifies if this material should be rendered in alpha test mode
  23464. * @returns a boolean specifying if an alpha test is needed.
  23465. */
  23466. needAlphaTesting(): boolean;
  23467. private _initializeBlock;
  23468. private _resetDualBlocks;
  23469. /**
  23470. * Remove a block from the current node material
  23471. * @param block defines the block to remove
  23472. */
  23473. removeBlock(block: NodeMaterialBlock): void;
  23474. /**
  23475. * Build the material and generates the inner effect
  23476. * @param verbose defines if the build should log activity
  23477. */
  23478. build(verbose?: boolean): void;
  23479. /**
  23480. * Runs an otpimization phase to try to improve the shader code
  23481. */
  23482. optimize(): void;
  23483. private _prepareDefinesForAttributes;
  23484. /**
  23485. * Create a post process from the material
  23486. * @param camera The camera to apply the render pass to.
  23487. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23489. * @param engine The engine which the post process will be applied. (default: current engine)
  23490. * @param reusable If the post process can be reused on the same frame. (default: false)
  23491. * @param textureType Type of textures used when performing the post process. (default: 0)
  23492. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23493. * @returns the post process created
  23494. */
  23495. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23496. /**
  23497. * Create the post process effect from the material
  23498. * @param postProcess The post process to create the effect for
  23499. */
  23500. createEffectForPostProcess(postProcess: PostProcess): void;
  23501. private _createEffectForPostProcess;
  23502. /**
  23503. * Create a new procedural texture based on this node material
  23504. * @param size defines the size of the texture
  23505. * @param scene defines the hosting scene
  23506. * @returns the new procedural texture attached to this node material
  23507. */
  23508. createProceduralTexture(size: number | {
  23509. width: number;
  23510. height: number;
  23511. layers?: number;
  23512. }, scene: Scene): Nullable<ProceduralTexture>;
  23513. private _createEffectForParticles;
  23514. private _checkInternals;
  23515. /**
  23516. * Create the effect to be used as the custom effect for a particle system
  23517. * @param particleSystem Particle system to create the effect for
  23518. * @param onCompiled defines a function to call when the effect creation is successful
  23519. * @param onError defines a function to call when the effect creation has failed
  23520. */
  23521. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23522. private _processDefines;
  23523. /**
  23524. * Get if the submesh is ready to be used and all its information available.
  23525. * Child classes can use it to update shaders
  23526. * @param mesh defines the mesh to check
  23527. * @param subMesh defines which submesh to check
  23528. * @param useInstances specifies that instances should be used
  23529. * @returns a boolean indicating that the submesh is ready or not
  23530. */
  23531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23532. /**
  23533. * Get a string representing the shaders built by the current node graph
  23534. */
  23535. get compiledShaders(): string;
  23536. /**
  23537. * Binds the world matrix to the material
  23538. * @param world defines the world transformation matrix
  23539. */
  23540. bindOnlyWorldMatrix(world: Matrix): void;
  23541. /**
  23542. * Binds the submesh to this material by preparing the effect and shader to draw
  23543. * @param world defines the world transformation matrix
  23544. * @param mesh defines the mesh containing the submesh
  23545. * @param subMesh defines the submesh to bind the material to
  23546. */
  23547. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23548. /**
  23549. * Gets the active textures from the material
  23550. * @returns an array of textures
  23551. */
  23552. getActiveTextures(): BaseTexture[];
  23553. /**
  23554. * Gets the list of texture blocks
  23555. * @returns an array of texture blocks
  23556. */
  23557. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23558. /**
  23559. * Specifies if the material uses a texture
  23560. * @param texture defines the texture to check against the material
  23561. * @returns a boolean specifying if the material uses the texture
  23562. */
  23563. hasTexture(texture: BaseTexture): boolean;
  23564. /**
  23565. * Disposes the material
  23566. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23567. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23568. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23569. */
  23570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23571. /** Creates the node editor window. */
  23572. private _createNodeEditor;
  23573. /**
  23574. * Launch the node material editor
  23575. * @param config Define the configuration of the editor
  23576. * @return a promise fulfilled when the node editor is visible
  23577. */
  23578. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23579. /**
  23580. * Clear the current material
  23581. */
  23582. clear(): void;
  23583. /**
  23584. * Clear the current material and set it to a default state
  23585. */
  23586. setToDefault(): void;
  23587. /**
  23588. * Clear the current material and set it to a default state for post process
  23589. */
  23590. setToDefaultPostProcess(): void;
  23591. /**
  23592. * Clear the current material and set it to a default state for procedural texture
  23593. */
  23594. setToDefaultProceduralTexture(): void;
  23595. /**
  23596. * Clear the current material and set it to a default state for particle
  23597. */
  23598. setToDefaultParticle(): void;
  23599. /**
  23600. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23601. * @param url defines the url to load from
  23602. * @returns a promise that will fullfil when the material is fully loaded
  23603. */
  23604. loadAsync(url: string): Promise<void>;
  23605. private _gatherBlocks;
  23606. /**
  23607. * Generate a string containing the code declaration required to create an equivalent of this material
  23608. * @returns a string
  23609. */
  23610. generateCode(): string;
  23611. /**
  23612. * Serializes this material in a JSON representation
  23613. * @returns the serialized material object
  23614. */
  23615. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23616. private _restoreConnections;
  23617. /**
  23618. * Clear the current graph and load a new one from a serialization object
  23619. * @param source defines the JSON representation of the material
  23620. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23621. * @param merge defines whether or not the source must be merged or replace the current content
  23622. */
  23623. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23624. /**
  23625. * Makes a duplicate of the current material.
  23626. * @param name - name to use for the new material.
  23627. */
  23628. clone(name: string): NodeMaterial;
  23629. /**
  23630. * Creates a node material from parsed material data
  23631. * @param source defines the JSON representation of the material
  23632. * @param scene defines the hosting scene
  23633. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23634. * @returns a new node material
  23635. */
  23636. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23637. /**
  23638. * Creates a node material from a snippet saved in a remote file
  23639. * @param name defines the name of the material to create
  23640. * @param url defines the url to load from
  23641. * @param scene defines the hosting scene
  23642. * @returns a promise that will resolve to the new node material
  23643. */
  23644. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23645. /**
  23646. * Creates a node material from a snippet saved by the node material editor
  23647. * @param snippetId defines the snippet to load
  23648. * @param scene defines the hosting scene
  23649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23650. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23651. * @returns a promise that will resolve to the new node material
  23652. */
  23653. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23654. /**
  23655. * Creates a new node material set to default basic configuration
  23656. * @param name defines the name of the material
  23657. * @param scene defines the hosting scene
  23658. * @returns a new NodeMaterial
  23659. */
  23660. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23661. }
  23662. }
  23663. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23665. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23666. import { Nullable } from "babylonjs/types";
  23667. module "babylonjs/Engines/thinEngine" {
  23668. interface ThinEngine {
  23669. /**
  23670. * Unbind a list of render target textures from the webGL context
  23671. * This is used only when drawBuffer extension or webGL2 are active
  23672. * @param textures defines the render target textures to unbind
  23673. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23674. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23675. */
  23676. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23677. /**
  23678. * Create a multi render target texture
  23679. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23680. * @param size defines the size of the texture
  23681. * @param options defines the creation options
  23682. * @returns the cube texture as an InternalTexture
  23683. */
  23684. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23685. /**
  23686. * Update the sample count for a given multiple render target texture
  23687. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23688. * @param textures defines the textures to update
  23689. * @param samples defines the sample count to set
  23690. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23691. */
  23692. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23693. /**
  23694. * Select a subsets of attachments to draw to.
  23695. * @param attachments gl attachments
  23696. */
  23697. bindAttachments(attachments: number[]): void;
  23698. /**
  23699. * Creates a layout object to draw/clear on specific textures in a MRT
  23700. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23701. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23702. */
  23703. buildTextureLayout(textureStatus: boolean[]): number[];
  23704. /**
  23705. * Restores the webgl state to only draw on the main color attachment
  23706. */
  23707. restoreSingleAttachment(): void;
  23708. }
  23709. }
  23710. }
  23711. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23712. import { Scene } from "babylonjs/scene";
  23713. import { Engine } from "babylonjs/Engines/engine";
  23714. import { Texture } from "babylonjs/Materials/Textures/texture";
  23715. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23716. import "babylonjs/Engines/Extensions/engine.multiRender";
  23717. /**
  23718. * Creation options of the multi render target texture.
  23719. */
  23720. export interface IMultiRenderTargetOptions {
  23721. /**
  23722. * Define if the texture needs to create mip maps after render.
  23723. */
  23724. generateMipMaps?: boolean;
  23725. /**
  23726. * Define the types of all the draw buffers we want to create
  23727. */
  23728. types?: number[];
  23729. /**
  23730. * Define the sampling modes of all the draw buffers we want to create
  23731. */
  23732. samplingModes?: number[];
  23733. /**
  23734. * Define if a depth buffer is required
  23735. */
  23736. generateDepthBuffer?: boolean;
  23737. /**
  23738. * Define if a stencil buffer is required
  23739. */
  23740. generateStencilBuffer?: boolean;
  23741. /**
  23742. * Define if a depth texture is required instead of a depth buffer
  23743. */
  23744. generateDepthTexture?: boolean;
  23745. /**
  23746. * Define the number of desired draw buffers
  23747. */
  23748. textureCount?: number;
  23749. /**
  23750. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23751. */
  23752. doNotChangeAspectRatio?: boolean;
  23753. /**
  23754. * Define the default type of the buffers we are creating
  23755. */
  23756. defaultType?: number;
  23757. }
  23758. /**
  23759. * A multi render target, like a render target provides the ability to render to a texture.
  23760. * Unlike the render target, it can render to several draw buffers in one draw.
  23761. * This is specially interesting in deferred rendering or for any effects requiring more than
  23762. * just one color from a single pass.
  23763. */
  23764. export class MultiRenderTarget extends RenderTargetTexture {
  23765. private _internalTextures;
  23766. private _textures;
  23767. private _multiRenderTargetOptions;
  23768. private _count;
  23769. /**
  23770. * Get if draw buffers are currently supported by the used hardware and browser.
  23771. */
  23772. get isSupported(): boolean;
  23773. /**
  23774. * Get the list of textures generated by the multi render target.
  23775. */
  23776. get textures(): Texture[];
  23777. /**
  23778. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23779. */
  23780. get count(): number;
  23781. /**
  23782. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23783. */
  23784. get depthTexture(): Texture;
  23785. /**
  23786. * Set the wrapping mode on U of all the textures we are rendering to.
  23787. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23788. */
  23789. set wrapU(wrap: number);
  23790. /**
  23791. * Set the wrapping mode on V of all the textures we are rendering to.
  23792. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23793. */
  23794. set wrapV(wrap: number);
  23795. /**
  23796. * Instantiate a new multi render target texture.
  23797. * A multi render target, like a render target provides the ability to render to a texture.
  23798. * Unlike the render target, it can render to several draw buffers in one draw.
  23799. * This is specially interesting in deferred rendering or for any effects requiring more than
  23800. * just one color from a single pass.
  23801. * @param name Define the name of the texture
  23802. * @param size Define the size of the buffers to render to
  23803. * @param count Define the number of target we are rendering into
  23804. * @param scene Define the scene the texture belongs to
  23805. * @param options Define the options used to create the multi render target
  23806. */
  23807. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23808. private _initTypes;
  23809. /** @hidden */
  23810. _rebuild(forceFullRebuild?: boolean): void;
  23811. private _createInternalTextures;
  23812. private _createTextures;
  23813. /**
  23814. * Replaces a texture within the MRT.
  23815. * @param texture The new texture to insert in the MRT
  23816. * @param index The index of the texture to replace
  23817. */
  23818. replaceTexture(texture: Texture, index: number): void;
  23819. /**
  23820. * Define the number of samples used if MSAA is enabled.
  23821. */
  23822. get samples(): number;
  23823. set samples(value: number);
  23824. /**
  23825. * Resize all the textures in the multi render target.
  23826. * Be careful as it will recreate all the data in the new texture.
  23827. * @param size Define the new size
  23828. */
  23829. resize(size: any): void;
  23830. /**
  23831. * Changes the number of render targets in this MRT
  23832. * Be careful as it will recreate all the data in the new texture.
  23833. * @param count new texture count
  23834. * @param options Specifies texture types and sampling modes for new textures
  23835. */
  23836. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23837. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23838. /**
  23839. * Dispose the render targets and their associated resources
  23840. */
  23841. dispose(): void;
  23842. /**
  23843. * Release all the underlying texture used as draw buffers.
  23844. */
  23845. releaseInternalTextures(): void;
  23846. }
  23847. }
  23848. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23849. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23850. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23851. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23852. /** @hidden */
  23853. export var imageProcessingPixelShader: {
  23854. name: string;
  23855. shader: string;
  23856. };
  23857. }
  23858. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23859. import { Nullable } from "babylonjs/types";
  23860. import { Color4 } from "babylonjs/Maths/math.color";
  23861. import { Camera } from "babylonjs/Cameras/camera";
  23862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23863. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23864. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23865. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23866. import { Engine } from "babylonjs/Engines/engine";
  23867. import "babylonjs/Shaders/imageProcessing.fragment";
  23868. import "babylonjs/Shaders/postprocess.vertex";
  23869. /**
  23870. * ImageProcessingPostProcess
  23871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23872. */
  23873. export class ImageProcessingPostProcess extends PostProcess {
  23874. /**
  23875. * Default configuration related to image processing available in the PBR Material.
  23876. */
  23877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23878. /**
  23879. * Gets the image processing configuration used either in this material.
  23880. */
  23881. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23882. /**
  23883. * Sets the Default image processing configuration used either in the this material.
  23884. *
  23885. * If sets to null, the scene one is in use.
  23886. */
  23887. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23888. /**
  23889. * Keep track of the image processing observer to allow dispose and replace.
  23890. */
  23891. private _imageProcessingObserver;
  23892. /**
  23893. * Attaches a new image processing configuration to the PBR Material.
  23894. * @param configuration
  23895. */
  23896. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23897. /**
  23898. * If the post process is supported.
  23899. */
  23900. get isSupported(): boolean;
  23901. /**
  23902. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23903. */
  23904. get colorCurves(): Nullable<ColorCurves>;
  23905. /**
  23906. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23907. */
  23908. set colorCurves(value: Nullable<ColorCurves>);
  23909. /**
  23910. * Gets wether the color curves effect is enabled.
  23911. */
  23912. get colorCurvesEnabled(): boolean;
  23913. /**
  23914. * Sets wether the color curves effect is enabled.
  23915. */
  23916. set colorCurvesEnabled(value: boolean);
  23917. /**
  23918. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23919. */
  23920. get colorGradingTexture(): Nullable<BaseTexture>;
  23921. /**
  23922. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23923. */
  23924. set colorGradingTexture(value: Nullable<BaseTexture>);
  23925. /**
  23926. * Gets wether the color grading effect is enabled.
  23927. */
  23928. get colorGradingEnabled(): boolean;
  23929. /**
  23930. * Gets wether the color grading effect is enabled.
  23931. */
  23932. set colorGradingEnabled(value: boolean);
  23933. /**
  23934. * Gets exposure used in the effect.
  23935. */
  23936. get exposure(): number;
  23937. /**
  23938. * Sets exposure used in the effect.
  23939. */
  23940. set exposure(value: number);
  23941. /**
  23942. * Gets wether tonemapping is enabled or not.
  23943. */
  23944. get toneMappingEnabled(): boolean;
  23945. /**
  23946. * Sets wether tonemapping is enabled or not
  23947. */
  23948. set toneMappingEnabled(value: boolean);
  23949. /**
  23950. * Gets the type of tone mapping effect.
  23951. */
  23952. get toneMappingType(): number;
  23953. /**
  23954. * Sets the type of tone mapping effect.
  23955. */
  23956. set toneMappingType(value: number);
  23957. /**
  23958. * Gets contrast used in the effect.
  23959. */
  23960. get contrast(): number;
  23961. /**
  23962. * Sets contrast used in the effect.
  23963. */
  23964. set contrast(value: number);
  23965. /**
  23966. * Gets Vignette stretch size.
  23967. */
  23968. get vignetteStretch(): number;
  23969. /**
  23970. * Sets Vignette stretch size.
  23971. */
  23972. set vignetteStretch(value: number);
  23973. /**
  23974. * Gets Vignette centre X Offset.
  23975. */
  23976. get vignetteCentreX(): number;
  23977. /**
  23978. * Sets Vignette centre X Offset.
  23979. */
  23980. set vignetteCentreX(value: number);
  23981. /**
  23982. * Gets Vignette centre Y Offset.
  23983. */
  23984. get vignetteCentreY(): number;
  23985. /**
  23986. * Sets Vignette centre Y Offset.
  23987. */
  23988. set vignetteCentreY(value: number);
  23989. /**
  23990. * Gets Vignette weight or intensity of the vignette effect.
  23991. */
  23992. get vignetteWeight(): number;
  23993. /**
  23994. * Sets Vignette weight or intensity of the vignette effect.
  23995. */
  23996. set vignetteWeight(value: number);
  23997. /**
  23998. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23999. * if vignetteEnabled is set to true.
  24000. */
  24001. get vignetteColor(): Color4;
  24002. /**
  24003. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24004. * if vignetteEnabled is set to true.
  24005. */
  24006. set vignetteColor(value: Color4);
  24007. /**
  24008. * Gets Camera field of view used by the Vignette effect.
  24009. */
  24010. get vignetteCameraFov(): number;
  24011. /**
  24012. * Sets Camera field of view used by the Vignette effect.
  24013. */
  24014. set vignetteCameraFov(value: number);
  24015. /**
  24016. * Gets the vignette blend mode allowing different kind of effect.
  24017. */
  24018. get vignetteBlendMode(): number;
  24019. /**
  24020. * Sets the vignette blend mode allowing different kind of effect.
  24021. */
  24022. set vignetteBlendMode(value: number);
  24023. /**
  24024. * Gets wether the vignette effect is enabled.
  24025. */
  24026. get vignetteEnabled(): boolean;
  24027. /**
  24028. * Sets wether the vignette effect is enabled.
  24029. */
  24030. set vignetteEnabled(value: boolean);
  24031. private _fromLinearSpace;
  24032. /**
  24033. * Gets wether the input of the processing is in Gamma or Linear Space.
  24034. */
  24035. get fromLinearSpace(): boolean;
  24036. /**
  24037. * Sets wether the input of the processing is in Gamma or Linear Space.
  24038. */
  24039. set fromLinearSpace(value: boolean);
  24040. /**
  24041. * Defines cache preventing GC.
  24042. */
  24043. private _defines;
  24044. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24045. /**
  24046. * "ImageProcessingPostProcess"
  24047. * @returns "ImageProcessingPostProcess"
  24048. */
  24049. getClassName(): string;
  24050. /**
  24051. * @hidden
  24052. */
  24053. _updateParameters(): void;
  24054. dispose(camera?: Camera): void;
  24055. }
  24056. }
  24057. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24058. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24059. /**
  24060. * Interface for defining prepass effects in the prepass post-process pipeline
  24061. */
  24062. export interface PrePassEffectConfiguration {
  24063. /**
  24064. * Name of the effect
  24065. */
  24066. name: string;
  24067. /**
  24068. * Post process to attach for this effect
  24069. */
  24070. postProcess?: PostProcess;
  24071. /**
  24072. * Textures required in the MRT
  24073. */
  24074. texturesRequired: number[];
  24075. /**
  24076. * Is the effect enabled
  24077. */
  24078. enabled: boolean;
  24079. /**
  24080. * Disposes the effect configuration
  24081. */
  24082. dispose?: () => void;
  24083. /**
  24084. * Creates the associated post process
  24085. */
  24086. createPostProcess?: () => PostProcess;
  24087. }
  24088. }
  24089. declare module "babylonjs/Materials/fresnelParameters" {
  24090. import { DeepImmutable } from "babylonjs/types";
  24091. import { Color3 } from "babylonjs/Maths/math.color";
  24092. /**
  24093. * Options to be used when creating a FresnelParameters.
  24094. */
  24095. export type IFresnelParametersCreationOptions = {
  24096. /**
  24097. * Define the color used on edges (grazing angle)
  24098. */
  24099. leftColor?: Color3;
  24100. /**
  24101. * Define the color used on center
  24102. */
  24103. rightColor?: Color3;
  24104. /**
  24105. * Define bias applied to computed fresnel term
  24106. */
  24107. bias?: number;
  24108. /**
  24109. * Defined the power exponent applied to fresnel term
  24110. */
  24111. power?: number;
  24112. /**
  24113. * Define if the fresnel effect is enable or not.
  24114. */
  24115. isEnabled?: boolean;
  24116. };
  24117. /**
  24118. * Serialized format for FresnelParameters.
  24119. */
  24120. export type IFresnelParametersSerialized = {
  24121. /**
  24122. * Define the color used on edges (grazing angle) [as an array]
  24123. */
  24124. leftColor: number[];
  24125. /**
  24126. * Define the color used on center [as an array]
  24127. */
  24128. rightColor: number[];
  24129. /**
  24130. * Define bias applied to computed fresnel term
  24131. */
  24132. bias: number;
  24133. /**
  24134. * Defined the power exponent applied to fresnel term
  24135. */
  24136. power?: number;
  24137. /**
  24138. * Define if the fresnel effect is enable or not.
  24139. */
  24140. isEnabled: boolean;
  24141. };
  24142. /**
  24143. * This represents all the required information to add a fresnel effect on a material:
  24144. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24145. */
  24146. export class FresnelParameters {
  24147. private _isEnabled;
  24148. /**
  24149. * Define if the fresnel effect is enable or not.
  24150. */
  24151. get isEnabled(): boolean;
  24152. set isEnabled(value: boolean);
  24153. /**
  24154. * Define the color used on edges (grazing angle)
  24155. */
  24156. leftColor: Color3;
  24157. /**
  24158. * Define the color used on center
  24159. */
  24160. rightColor: Color3;
  24161. /**
  24162. * Define bias applied to computed fresnel term
  24163. */
  24164. bias: number;
  24165. /**
  24166. * Defined the power exponent applied to fresnel term
  24167. */
  24168. power: number;
  24169. /**
  24170. * Creates a new FresnelParameters object.
  24171. *
  24172. * @param options provide your own settings to optionally to override defaults
  24173. */
  24174. constructor(options?: IFresnelParametersCreationOptions);
  24175. /**
  24176. * Clones the current fresnel and its valuues
  24177. * @returns a clone fresnel configuration
  24178. */
  24179. clone(): FresnelParameters;
  24180. /**
  24181. * Determines equality between FresnelParameters objects
  24182. * @param otherFresnelParameters defines the second operand
  24183. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24184. */
  24185. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24186. /**
  24187. * Serializes the current fresnel parameters to a JSON representation.
  24188. * @return the JSON serialization
  24189. */
  24190. serialize(): IFresnelParametersSerialized;
  24191. /**
  24192. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24193. * @param parsedFresnelParameters Define the JSON representation
  24194. * @returns the parsed parameters
  24195. */
  24196. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24197. }
  24198. }
  24199. declare module "babylonjs/Materials/materialFlags" {
  24200. /**
  24201. * This groups all the flags used to control the materials channel.
  24202. */
  24203. export class MaterialFlags {
  24204. private static _DiffuseTextureEnabled;
  24205. /**
  24206. * Are diffuse textures enabled in the application.
  24207. */
  24208. static get DiffuseTextureEnabled(): boolean;
  24209. static set DiffuseTextureEnabled(value: boolean);
  24210. private static _DetailTextureEnabled;
  24211. /**
  24212. * Are detail textures enabled in the application.
  24213. */
  24214. static get DetailTextureEnabled(): boolean;
  24215. static set DetailTextureEnabled(value: boolean);
  24216. private static _AmbientTextureEnabled;
  24217. /**
  24218. * Are ambient textures enabled in the application.
  24219. */
  24220. static get AmbientTextureEnabled(): boolean;
  24221. static set AmbientTextureEnabled(value: boolean);
  24222. private static _OpacityTextureEnabled;
  24223. /**
  24224. * Are opacity textures enabled in the application.
  24225. */
  24226. static get OpacityTextureEnabled(): boolean;
  24227. static set OpacityTextureEnabled(value: boolean);
  24228. private static _ReflectionTextureEnabled;
  24229. /**
  24230. * Are reflection textures enabled in the application.
  24231. */
  24232. static get ReflectionTextureEnabled(): boolean;
  24233. static set ReflectionTextureEnabled(value: boolean);
  24234. private static _EmissiveTextureEnabled;
  24235. /**
  24236. * Are emissive textures enabled in the application.
  24237. */
  24238. static get EmissiveTextureEnabled(): boolean;
  24239. static set EmissiveTextureEnabled(value: boolean);
  24240. private static _SpecularTextureEnabled;
  24241. /**
  24242. * Are specular textures enabled in the application.
  24243. */
  24244. static get SpecularTextureEnabled(): boolean;
  24245. static set SpecularTextureEnabled(value: boolean);
  24246. private static _BumpTextureEnabled;
  24247. /**
  24248. * Are bump textures enabled in the application.
  24249. */
  24250. static get BumpTextureEnabled(): boolean;
  24251. static set BumpTextureEnabled(value: boolean);
  24252. private static _LightmapTextureEnabled;
  24253. /**
  24254. * Are lightmap textures enabled in the application.
  24255. */
  24256. static get LightmapTextureEnabled(): boolean;
  24257. static set LightmapTextureEnabled(value: boolean);
  24258. private static _RefractionTextureEnabled;
  24259. /**
  24260. * Are refraction textures enabled in the application.
  24261. */
  24262. static get RefractionTextureEnabled(): boolean;
  24263. static set RefractionTextureEnabled(value: boolean);
  24264. private static _ColorGradingTextureEnabled;
  24265. /**
  24266. * Are color grading textures enabled in the application.
  24267. */
  24268. static get ColorGradingTextureEnabled(): boolean;
  24269. static set ColorGradingTextureEnabled(value: boolean);
  24270. private static _FresnelEnabled;
  24271. /**
  24272. * Are fresnels enabled in the application.
  24273. */
  24274. static get FresnelEnabled(): boolean;
  24275. static set FresnelEnabled(value: boolean);
  24276. private static _ClearCoatTextureEnabled;
  24277. /**
  24278. * Are clear coat textures enabled in the application.
  24279. */
  24280. static get ClearCoatTextureEnabled(): boolean;
  24281. static set ClearCoatTextureEnabled(value: boolean);
  24282. private static _ClearCoatBumpTextureEnabled;
  24283. /**
  24284. * Are clear coat bump textures enabled in the application.
  24285. */
  24286. static get ClearCoatBumpTextureEnabled(): boolean;
  24287. static set ClearCoatBumpTextureEnabled(value: boolean);
  24288. private static _ClearCoatTintTextureEnabled;
  24289. /**
  24290. * Are clear coat tint textures enabled in the application.
  24291. */
  24292. static get ClearCoatTintTextureEnabled(): boolean;
  24293. static set ClearCoatTintTextureEnabled(value: boolean);
  24294. private static _SheenTextureEnabled;
  24295. /**
  24296. * Are sheen textures enabled in the application.
  24297. */
  24298. static get SheenTextureEnabled(): boolean;
  24299. static set SheenTextureEnabled(value: boolean);
  24300. private static _AnisotropicTextureEnabled;
  24301. /**
  24302. * Are anisotropic textures enabled in the application.
  24303. */
  24304. static get AnisotropicTextureEnabled(): boolean;
  24305. static set AnisotropicTextureEnabled(value: boolean);
  24306. private static _ThicknessTextureEnabled;
  24307. /**
  24308. * Are thickness textures enabled in the application.
  24309. */
  24310. static get ThicknessTextureEnabled(): boolean;
  24311. static set ThicknessTextureEnabled(value: boolean);
  24312. }
  24313. }
  24314. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24315. /** @hidden */
  24316. export var defaultFragmentDeclaration: {
  24317. name: string;
  24318. shader: string;
  24319. };
  24320. }
  24321. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24322. /** @hidden */
  24323. export var defaultUboDeclaration: {
  24324. name: string;
  24325. shader: string;
  24326. };
  24327. }
  24328. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24329. /** @hidden */
  24330. export var prePassDeclaration: {
  24331. name: string;
  24332. shader: string;
  24333. };
  24334. }
  24335. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24336. /** @hidden */
  24337. export var lightFragmentDeclaration: {
  24338. name: string;
  24339. shader: string;
  24340. };
  24341. }
  24342. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24343. /** @hidden */
  24344. export var lightUboDeclaration: {
  24345. name: string;
  24346. shader: string;
  24347. };
  24348. }
  24349. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24350. /** @hidden */
  24351. export var lightsFragmentFunctions: {
  24352. name: string;
  24353. shader: string;
  24354. };
  24355. }
  24356. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24357. /** @hidden */
  24358. export var shadowsFragmentFunctions: {
  24359. name: string;
  24360. shader: string;
  24361. };
  24362. }
  24363. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24364. /** @hidden */
  24365. export var fresnelFunction: {
  24366. name: string;
  24367. shader: string;
  24368. };
  24369. }
  24370. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24371. /** @hidden */
  24372. export var bumpFragmentMainFunctions: {
  24373. name: string;
  24374. shader: string;
  24375. };
  24376. }
  24377. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24378. /** @hidden */
  24379. export var bumpFragmentFunctions: {
  24380. name: string;
  24381. shader: string;
  24382. };
  24383. }
  24384. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24385. /** @hidden */
  24386. export var logDepthDeclaration: {
  24387. name: string;
  24388. shader: string;
  24389. };
  24390. }
  24391. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24392. /** @hidden */
  24393. export var bumpFragment: {
  24394. name: string;
  24395. shader: string;
  24396. };
  24397. }
  24398. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24399. /** @hidden */
  24400. export var depthPrePass: {
  24401. name: string;
  24402. shader: string;
  24403. };
  24404. }
  24405. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24406. /** @hidden */
  24407. export var lightFragment: {
  24408. name: string;
  24409. shader: string;
  24410. };
  24411. }
  24412. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24413. /** @hidden */
  24414. export var logDepthFragment: {
  24415. name: string;
  24416. shader: string;
  24417. };
  24418. }
  24419. declare module "babylonjs/Shaders/default.fragment" {
  24420. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24421. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24422. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24423. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24424. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24425. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24426. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24427. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24428. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24429. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24430. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24431. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24432. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24433. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24434. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24435. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24436. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24437. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24438. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24439. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24440. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24441. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24442. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24443. /** @hidden */
  24444. export var defaultPixelShader: {
  24445. name: string;
  24446. shader: string;
  24447. };
  24448. }
  24449. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24450. /** @hidden */
  24451. export var defaultVertexDeclaration: {
  24452. name: string;
  24453. shader: string;
  24454. };
  24455. }
  24456. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24457. /** @hidden */
  24458. export var prePassVertexDeclaration: {
  24459. name: string;
  24460. shader: string;
  24461. };
  24462. }
  24463. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24464. /** @hidden */
  24465. export var bumpVertexDeclaration: {
  24466. name: string;
  24467. shader: string;
  24468. };
  24469. }
  24470. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24471. /** @hidden */
  24472. export var prePassVertex: {
  24473. name: string;
  24474. shader: string;
  24475. };
  24476. }
  24477. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24478. /** @hidden */
  24479. export var bumpVertex: {
  24480. name: string;
  24481. shader: string;
  24482. };
  24483. }
  24484. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24485. /** @hidden */
  24486. export var fogVertex: {
  24487. name: string;
  24488. shader: string;
  24489. };
  24490. }
  24491. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24492. /** @hidden */
  24493. export var shadowsVertex: {
  24494. name: string;
  24495. shader: string;
  24496. };
  24497. }
  24498. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24499. /** @hidden */
  24500. export var pointCloudVertex: {
  24501. name: string;
  24502. shader: string;
  24503. };
  24504. }
  24505. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24506. /** @hidden */
  24507. export var logDepthVertex: {
  24508. name: string;
  24509. shader: string;
  24510. };
  24511. }
  24512. declare module "babylonjs/Shaders/default.vertex" {
  24513. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24514. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24515. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24516. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24517. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24518. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24519. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24521. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24522. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24523. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24524. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24526. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24528. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24529. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24530. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24531. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24532. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24533. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24534. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24535. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24536. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24537. /** @hidden */
  24538. export var defaultVertexShader: {
  24539. name: string;
  24540. shader: string;
  24541. };
  24542. }
  24543. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24544. import { Nullable } from "babylonjs/types";
  24545. import { Scene } from "babylonjs/scene";
  24546. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24547. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24548. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24549. /**
  24550. * @hidden
  24551. */
  24552. export interface IMaterialDetailMapDefines {
  24553. DETAIL: boolean;
  24554. DETAILDIRECTUV: number;
  24555. DETAIL_NORMALBLENDMETHOD: number;
  24556. /** @hidden */
  24557. _areTexturesDirty: boolean;
  24558. }
  24559. /**
  24560. * Define the code related to the detail map parameters of a material
  24561. *
  24562. * Inspired from:
  24563. * 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
  24564. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24565. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24566. */
  24567. export class DetailMapConfiguration {
  24568. private _texture;
  24569. /**
  24570. * The detail texture of the material.
  24571. */
  24572. texture: Nullable<BaseTexture>;
  24573. /**
  24574. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24575. * Bigger values mean stronger blending
  24576. */
  24577. diffuseBlendLevel: number;
  24578. /**
  24579. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24580. * Bigger values mean stronger blending. Only used with PBR materials
  24581. */
  24582. roughnessBlendLevel: number;
  24583. /**
  24584. * Defines how strong the bump effect from the detail map is
  24585. * Bigger values mean stronger effect
  24586. */
  24587. bumpLevel: number;
  24588. private _normalBlendMethod;
  24589. /**
  24590. * The method used to blend the bump and detail normals together
  24591. */
  24592. normalBlendMethod: number;
  24593. private _isEnabled;
  24594. /**
  24595. * Enable or disable the detail map on this material
  24596. */
  24597. isEnabled: boolean;
  24598. /** @hidden */
  24599. private _internalMarkAllSubMeshesAsTexturesDirty;
  24600. /** @hidden */
  24601. _markAllSubMeshesAsTexturesDirty(): void;
  24602. /**
  24603. * Instantiate a new detail map
  24604. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24605. */
  24606. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24607. /**
  24608. * Gets whether the submesh is ready to be used or not.
  24609. * @param defines the list of "defines" to update.
  24610. * @param scene defines the scene the material belongs to.
  24611. * @returns - boolean indicating that the submesh is ready or not.
  24612. */
  24613. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24614. /**
  24615. * Update the defines for detail map usage
  24616. * @param defines the list of "defines" to update.
  24617. * @param scene defines the scene the material belongs to.
  24618. */
  24619. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24620. /**
  24621. * Binds the material data.
  24622. * @param uniformBuffer defines the Uniform buffer to fill in.
  24623. * @param scene defines the scene the material belongs to.
  24624. * @param isFrozen defines whether the material is frozen or not.
  24625. */
  24626. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24627. /**
  24628. * Checks to see if a texture is used in the material.
  24629. * @param texture - Base texture to use.
  24630. * @returns - Boolean specifying if a texture is used in the material.
  24631. */
  24632. hasTexture(texture: BaseTexture): boolean;
  24633. /**
  24634. * Returns an array of the actively used textures.
  24635. * @param activeTextures Array of BaseTextures
  24636. */
  24637. getActiveTextures(activeTextures: BaseTexture[]): void;
  24638. /**
  24639. * Returns the animatable textures.
  24640. * @param animatables Array of animatable textures.
  24641. */
  24642. getAnimatables(animatables: IAnimatable[]): void;
  24643. /**
  24644. * Disposes the resources of the material.
  24645. * @param forceDisposeTextures - Forces the disposal of all textures.
  24646. */
  24647. dispose(forceDisposeTextures?: boolean): void;
  24648. /**
  24649. * Get the current class name useful for serialization or dynamic coding.
  24650. * @returns "DetailMap"
  24651. */
  24652. getClassName(): string;
  24653. /**
  24654. * Add the required uniforms to the current list.
  24655. * @param uniforms defines the current uniform list.
  24656. */
  24657. static AddUniforms(uniforms: string[]): void;
  24658. /**
  24659. * Add the required samplers to the current list.
  24660. * @param samplers defines the current sampler list.
  24661. */
  24662. static AddSamplers(samplers: string[]): void;
  24663. /**
  24664. * Add the required uniforms to the current buffer.
  24665. * @param uniformBuffer defines the current uniform buffer.
  24666. */
  24667. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24668. /**
  24669. * Makes a duplicate of the current instance into another one.
  24670. * @param detailMap define the instance where to copy the info
  24671. */
  24672. copyTo(detailMap: DetailMapConfiguration): void;
  24673. /**
  24674. * Serializes this detail map instance
  24675. * @returns - An object with the serialized instance.
  24676. */
  24677. serialize(): any;
  24678. /**
  24679. * Parses a detail map setting from a serialized object.
  24680. * @param source - Serialized object.
  24681. * @param scene Defines the scene we are parsing for
  24682. * @param rootUrl Defines the rootUrl to load from
  24683. */
  24684. parse(source: any, scene: Scene, rootUrl: string): void;
  24685. }
  24686. }
  24687. declare module "babylonjs/Materials/standardMaterial" {
  24688. import { SmartArray } from "babylonjs/Misc/smartArray";
  24689. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24690. import { Nullable } from "babylonjs/types";
  24691. import { Scene } from "babylonjs/scene";
  24692. import { Matrix } from "babylonjs/Maths/math.vector";
  24693. import { Color3 } from "babylonjs/Maths/math.color";
  24694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24696. import { Mesh } from "babylonjs/Meshes/mesh";
  24697. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24698. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24699. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24700. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24701. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24702. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24705. import "babylonjs/Shaders/default.fragment";
  24706. import "babylonjs/Shaders/default.vertex";
  24707. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24708. /** @hidden */
  24709. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24710. MAINUV1: boolean;
  24711. MAINUV2: boolean;
  24712. DIFFUSE: boolean;
  24713. DIFFUSEDIRECTUV: number;
  24714. DETAIL: boolean;
  24715. DETAILDIRECTUV: number;
  24716. DETAIL_NORMALBLENDMETHOD: number;
  24717. AMBIENT: boolean;
  24718. AMBIENTDIRECTUV: number;
  24719. OPACITY: boolean;
  24720. OPACITYDIRECTUV: number;
  24721. OPACITYRGB: boolean;
  24722. REFLECTION: boolean;
  24723. EMISSIVE: boolean;
  24724. EMISSIVEDIRECTUV: number;
  24725. SPECULAR: boolean;
  24726. SPECULARDIRECTUV: number;
  24727. BUMP: boolean;
  24728. BUMPDIRECTUV: number;
  24729. PARALLAX: boolean;
  24730. PARALLAXOCCLUSION: boolean;
  24731. SPECULAROVERALPHA: boolean;
  24732. CLIPPLANE: boolean;
  24733. CLIPPLANE2: boolean;
  24734. CLIPPLANE3: boolean;
  24735. CLIPPLANE4: boolean;
  24736. CLIPPLANE5: boolean;
  24737. CLIPPLANE6: boolean;
  24738. ALPHATEST: boolean;
  24739. DEPTHPREPASS: boolean;
  24740. ALPHAFROMDIFFUSE: boolean;
  24741. POINTSIZE: boolean;
  24742. FOG: boolean;
  24743. SPECULARTERM: boolean;
  24744. DIFFUSEFRESNEL: boolean;
  24745. OPACITYFRESNEL: boolean;
  24746. REFLECTIONFRESNEL: boolean;
  24747. REFRACTIONFRESNEL: boolean;
  24748. EMISSIVEFRESNEL: boolean;
  24749. FRESNEL: boolean;
  24750. NORMAL: boolean;
  24751. UV1: boolean;
  24752. UV2: boolean;
  24753. VERTEXCOLOR: boolean;
  24754. VERTEXALPHA: boolean;
  24755. NUM_BONE_INFLUENCERS: number;
  24756. BonesPerMesh: number;
  24757. BONETEXTURE: boolean;
  24758. BONES_VELOCITY_ENABLED: boolean;
  24759. INSTANCES: boolean;
  24760. THIN_INSTANCES: boolean;
  24761. GLOSSINESS: boolean;
  24762. ROUGHNESS: boolean;
  24763. EMISSIVEASILLUMINATION: boolean;
  24764. LINKEMISSIVEWITHDIFFUSE: boolean;
  24765. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24766. LIGHTMAP: boolean;
  24767. LIGHTMAPDIRECTUV: number;
  24768. OBJECTSPACE_NORMALMAP: boolean;
  24769. USELIGHTMAPASSHADOWMAP: boolean;
  24770. REFLECTIONMAP_3D: boolean;
  24771. REFLECTIONMAP_SPHERICAL: boolean;
  24772. REFLECTIONMAP_PLANAR: boolean;
  24773. REFLECTIONMAP_CUBIC: boolean;
  24774. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24775. REFLECTIONMAP_PROJECTION: boolean;
  24776. REFLECTIONMAP_SKYBOX: boolean;
  24777. REFLECTIONMAP_EXPLICIT: boolean;
  24778. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24779. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24780. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24781. INVERTCUBICMAP: boolean;
  24782. LOGARITHMICDEPTH: boolean;
  24783. REFRACTION: boolean;
  24784. REFRACTIONMAP_3D: boolean;
  24785. REFLECTIONOVERALPHA: boolean;
  24786. TWOSIDEDLIGHTING: boolean;
  24787. SHADOWFLOAT: boolean;
  24788. MORPHTARGETS: boolean;
  24789. MORPHTARGETS_NORMAL: boolean;
  24790. MORPHTARGETS_TANGENT: boolean;
  24791. MORPHTARGETS_UV: boolean;
  24792. NUM_MORPH_INFLUENCERS: number;
  24793. NONUNIFORMSCALING: boolean;
  24794. PREMULTIPLYALPHA: boolean;
  24795. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24796. ALPHABLEND: boolean;
  24797. PREPASS: boolean;
  24798. PREPASS_IRRADIANCE: boolean;
  24799. PREPASS_IRRADIANCE_INDEX: number;
  24800. PREPASS_ALBEDO: boolean;
  24801. PREPASS_ALBEDO_INDEX: number;
  24802. PREPASS_DEPTHNORMAL: boolean;
  24803. PREPASS_DEPTHNORMAL_INDEX: number;
  24804. PREPASS_POSITION: boolean;
  24805. PREPASS_POSITION_INDEX: number;
  24806. PREPASS_VELOCITY: boolean;
  24807. PREPASS_VELOCITY_INDEX: number;
  24808. PREPASS_REFLECTIVITY: boolean;
  24809. PREPASS_REFLECTIVITY_INDEX: number;
  24810. SCENE_MRT_COUNT: number;
  24811. RGBDLIGHTMAP: boolean;
  24812. RGBDREFLECTION: boolean;
  24813. RGBDREFRACTION: boolean;
  24814. IMAGEPROCESSING: boolean;
  24815. VIGNETTE: boolean;
  24816. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24817. VIGNETTEBLENDMODEOPAQUE: boolean;
  24818. TONEMAPPING: boolean;
  24819. TONEMAPPING_ACES: boolean;
  24820. CONTRAST: boolean;
  24821. COLORCURVES: boolean;
  24822. COLORGRADING: boolean;
  24823. COLORGRADING3D: boolean;
  24824. SAMPLER3DGREENDEPTH: boolean;
  24825. SAMPLER3DBGRMAP: boolean;
  24826. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24827. MULTIVIEW: boolean;
  24828. /**
  24829. * If the reflection texture on this material is in linear color space
  24830. * @hidden
  24831. */
  24832. IS_REFLECTION_LINEAR: boolean;
  24833. /**
  24834. * If the refraction texture on this material is in linear color space
  24835. * @hidden
  24836. */
  24837. IS_REFRACTION_LINEAR: boolean;
  24838. EXPOSURE: boolean;
  24839. constructor();
  24840. setReflectionMode(modeToEnable: string): void;
  24841. }
  24842. /**
  24843. * This is the default material used in Babylon. It is the best trade off between quality
  24844. * and performances.
  24845. * @see https://doc.babylonjs.com/babylon101/materials
  24846. */
  24847. export class StandardMaterial extends PushMaterial {
  24848. private _diffuseTexture;
  24849. /**
  24850. * The basic texture of the material as viewed under a light.
  24851. */
  24852. diffuseTexture: Nullable<BaseTexture>;
  24853. private _ambientTexture;
  24854. /**
  24855. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24856. */
  24857. ambientTexture: Nullable<BaseTexture>;
  24858. private _opacityTexture;
  24859. /**
  24860. * Define the transparency of the material from a texture.
  24861. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24862. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24863. */
  24864. opacityTexture: Nullable<BaseTexture>;
  24865. private _reflectionTexture;
  24866. /**
  24867. * Define the texture used to display the reflection.
  24868. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24869. */
  24870. reflectionTexture: Nullable<BaseTexture>;
  24871. private _emissiveTexture;
  24872. /**
  24873. * Define texture of the material as if self lit.
  24874. * This will be mixed in the final result even in the absence of light.
  24875. */
  24876. emissiveTexture: Nullable<BaseTexture>;
  24877. private _specularTexture;
  24878. /**
  24879. * Define how the color and intensity of the highlight given by the light in the material.
  24880. */
  24881. specularTexture: Nullable<BaseTexture>;
  24882. private _bumpTexture;
  24883. /**
  24884. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24885. * 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.
  24886. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24887. */
  24888. bumpTexture: Nullable<BaseTexture>;
  24889. private _lightmapTexture;
  24890. /**
  24891. * Complex lighting can be computationally expensive to compute at runtime.
  24892. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24893. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24894. */
  24895. lightmapTexture: Nullable<BaseTexture>;
  24896. private _refractionTexture;
  24897. /**
  24898. * Define the texture used to display the refraction.
  24899. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24900. */
  24901. refractionTexture: Nullable<BaseTexture>;
  24902. /**
  24903. * The color of the material lit by the environmental background lighting.
  24904. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24905. */
  24906. ambientColor: Color3;
  24907. /**
  24908. * The basic color of the material as viewed under a light.
  24909. */
  24910. diffuseColor: Color3;
  24911. /**
  24912. * Define how the color and intensity of the highlight given by the light in the material.
  24913. */
  24914. specularColor: Color3;
  24915. /**
  24916. * Define the color of the material as if self lit.
  24917. * This will be mixed in the final result even in the absence of light.
  24918. */
  24919. emissiveColor: Color3;
  24920. /**
  24921. * Defines how sharp are the highlights in the material.
  24922. * The bigger the value the sharper giving a more glossy feeling to the result.
  24923. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24924. */
  24925. specularPower: number;
  24926. private _useAlphaFromDiffuseTexture;
  24927. /**
  24928. * Does the transparency come from the diffuse texture alpha channel.
  24929. */
  24930. useAlphaFromDiffuseTexture: boolean;
  24931. private _useEmissiveAsIllumination;
  24932. /**
  24933. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24934. */
  24935. useEmissiveAsIllumination: boolean;
  24936. private _linkEmissiveWithDiffuse;
  24937. /**
  24938. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24939. * the emissive level when the final color is close to one.
  24940. */
  24941. linkEmissiveWithDiffuse: boolean;
  24942. private _useSpecularOverAlpha;
  24943. /**
  24944. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24945. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24946. */
  24947. useSpecularOverAlpha: boolean;
  24948. private _useReflectionOverAlpha;
  24949. /**
  24950. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24951. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24952. */
  24953. useReflectionOverAlpha: boolean;
  24954. private _disableLighting;
  24955. /**
  24956. * Does lights from the scene impacts this material.
  24957. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24958. */
  24959. disableLighting: boolean;
  24960. private _useObjectSpaceNormalMap;
  24961. /**
  24962. * Allows using an object space normal map (instead of tangent space).
  24963. */
  24964. useObjectSpaceNormalMap: boolean;
  24965. private _useParallax;
  24966. /**
  24967. * Is parallax enabled or not.
  24968. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24969. */
  24970. useParallax: boolean;
  24971. private _useParallaxOcclusion;
  24972. /**
  24973. * Is parallax occlusion enabled or not.
  24974. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24975. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24976. */
  24977. useParallaxOcclusion: boolean;
  24978. /**
  24979. * 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.
  24980. */
  24981. parallaxScaleBias: number;
  24982. private _roughness;
  24983. /**
  24984. * Helps to define how blurry the reflections should appears in the material.
  24985. */
  24986. roughness: number;
  24987. /**
  24988. * In case of refraction, define the value of the index of refraction.
  24989. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24990. */
  24991. indexOfRefraction: number;
  24992. /**
  24993. * Invert the refraction texture alongside the y axis.
  24994. * It can be useful with procedural textures or probe for instance.
  24995. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24996. */
  24997. invertRefractionY: boolean;
  24998. /**
  24999. * Defines the alpha limits in alpha test mode.
  25000. */
  25001. alphaCutOff: number;
  25002. private _useLightmapAsShadowmap;
  25003. /**
  25004. * In case of light mapping, define whether the map contains light or shadow informations.
  25005. */
  25006. useLightmapAsShadowmap: boolean;
  25007. private _diffuseFresnelParameters;
  25008. /**
  25009. * Define the diffuse fresnel parameters of the material.
  25010. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25011. */
  25012. diffuseFresnelParameters: FresnelParameters;
  25013. private _opacityFresnelParameters;
  25014. /**
  25015. * Define the opacity fresnel parameters of the material.
  25016. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25017. */
  25018. opacityFresnelParameters: FresnelParameters;
  25019. private _reflectionFresnelParameters;
  25020. /**
  25021. * Define the reflection fresnel parameters of the material.
  25022. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25023. */
  25024. reflectionFresnelParameters: FresnelParameters;
  25025. private _refractionFresnelParameters;
  25026. /**
  25027. * Define the refraction fresnel parameters of the material.
  25028. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25029. */
  25030. refractionFresnelParameters: FresnelParameters;
  25031. private _emissiveFresnelParameters;
  25032. /**
  25033. * Define the emissive fresnel parameters of the material.
  25034. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25035. */
  25036. emissiveFresnelParameters: FresnelParameters;
  25037. private _useReflectionFresnelFromSpecular;
  25038. /**
  25039. * If true automatically deducts the fresnels values from the material specularity.
  25040. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25041. */
  25042. useReflectionFresnelFromSpecular: boolean;
  25043. private _useGlossinessFromSpecularMapAlpha;
  25044. /**
  25045. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25046. */
  25047. useGlossinessFromSpecularMapAlpha: boolean;
  25048. private _maxSimultaneousLights;
  25049. /**
  25050. * Defines the maximum number of lights that can be used in the material
  25051. */
  25052. maxSimultaneousLights: number;
  25053. private _invertNormalMapX;
  25054. /**
  25055. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25056. */
  25057. invertNormalMapX: boolean;
  25058. private _invertNormalMapY;
  25059. /**
  25060. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25061. */
  25062. invertNormalMapY: boolean;
  25063. private _twoSidedLighting;
  25064. /**
  25065. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25066. */
  25067. twoSidedLighting: boolean;
  25068. /**
  25069. * Default configuration related to image processing available in the standard Material.
  25070. */
  25071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25072. /**
  25073. * Gets the image processing configuration used either in this material.
  25074. */
  25075. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25076. /**
  25077. * Sets the Default image processing configuration used either in the this material.
  25078. *
  25079. * If sets to null, the scene one is in use.
  25080. */
  25081. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25082. /**
  25083. * Keep track of the image processing observer to allow dispose and replace.
  25084. */
  25085. private _imageProcessingObserver;
  25086. /**
  25087. * Attaches a new image processing configuration to the Standard Material.
  25088. * @param configuration
  25089. */
  25090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25091. /**
  25092. * Defines additionnal PrePass parameters for the material.
  25093. */
  25094. readonly prePassConfiguration: PrePassConfiguration;
  25095. /**
  25096. * Gets wether the color curves effect is enabled.
  25097. */
  25098. get cameraColorCurvesEnabled(): boolean;
  25099. /**
  25100. * Sets wether the color curves effect is enabled.
  25101. */
  25102. set cameraColorCurvesEnabled(value: boolean);
  25103. /**
  25104. * Gets wether the color grading effect is enabled.
  25105. */
  25106. get cameraColorGradingEnabled(): boolean;
  25107. /**
  25108. * Gets wether the color grading effect is enabled.
  25109. */
  25110. set cameraColorGradingEnabled(value: boolean);
  25111. /**
  25112. * Gets wether tonemapping is enabled or not.
  25113. */
  25114. get cameraToneMappingEnabled(): boolean;
  25115. /**
  25116. * Sets wether tonemapping is enabled or not
  25117. */
  25118. set cameraToneMappingEnabled(value: boolean);
  25119. /**
  25120. * The camera exposure used on this material.
  25121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25122. * This corresponds to a photographic exposure.
  25123. */
  25124. get cameraExposure(): number;
  25125. /**
  25126. * The camera exposure used on this material.
  25127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25128. * This corresponds to a photographic exposure.
  25129. */
  25130. set cameraExposure(value: number);
  25131. /**
  25132. * Gets The camera contrast used on this material.
  25133. */
  25134. get cameraContrast(): number;
  25135. /**
  25136. * Sets The camera contrast used on this material.
  25137. */
  25138. set cameraContrast(value: number);
  25139. /**
  25140. * Gets the Color Grading 2D Lookup Texture.
  25141. */
  25142. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25143. /**
  25144. * Sets the Color Grading 2D Lookup Texture.
  25145. */
  25146. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25147. /**
  25148. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25149. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25150. * 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;
  25151. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25152. */
  25153. get cameraColorCurves(): Nullable<ColorCurves>;
  25154. /**
  25155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25157. * 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;
  25158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25159. */
  25160. set cameraColorCurves(value: Nullable<ColorCurves>);
  25161. /**
  25162. * Can this material render to several textures at once
  25163. */
  25164. get canRenderToMRT(): boolean;
  25165. /**
  25166. * Defines the detail map parameters for the material.
  25167. */
  25168. readonly detailMap: DetailMapConfiguration;
  25169. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25170. protected _worldViewProjectionMatrix: Matrix;
  25171. protected _globalAmbientColor: Color3;
  25172. protected _useLogarithmicDepth: boolean;
  25173. protected _rebuildInParallel: boolean;
  25174. /**
  25175. * Instantiates a new standard material.
  25176. * This is the default material used in Babylon. It is the best trade off between quality
  25177. * and performances.
  25178. * @see https://doc.babylonjs.com/babylon101/materials
  25179. * @param name Define the name of the material in the scene
  25180. * @param scene Define the scene the material belong to
  25181. */
  25182. constructor(name: string, scene: Scene);
  25183. /**
  25184. * Gets a boolean indicating that current material needs to register RTT
  25185. */
  25186. get hasRenderTargetTextures(): boolean;
  25187. /**
  25188. * Gets the current class name of the material e.g. "StandardMaterial"
  25189. * Mainly use in serialization.
  25190. * @returns the class name
  25191. */
  25192. getClassName(): string;
  25193. /**
  25194. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25195. * You can try switching to logarithmic depth.
  25196. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25197. */
  25198. get useLogarithmicDepth(): boolean;
  25199. set useLogarithmicDepth(value: boolean);
  25200. /**
  25201. * Specifies if the material will require alpha blending
  25202. * @returns a boolean specifying if alpha blending is needed
  25203. */
  25204. needAlphaBlending(): boolean;
  25205. /**
  25206. * Specifies if this material should be rendered in alpha test mode
  25207. * @returns a boolean specifying if an alpha test is needed.
  25208. */
  25209. needAlphaTesting(): boolean;
  25210. /**
  25211. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25212. */
  25213. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25214. /**
  25215. * Specifies whether or not there is a usable alpha channel for transparency.
  25216. */
  25217. protected _hasAlphaChannel(): boolean;
  25218. /**
  25219. * Get the texture used for alpha test purpose.
  25220. * @returns the diffuse texture in case of the standard material.
  25221. */
  25222. getAlphaTestTexture(): Nullable<BaseTexture>;
  25223. /**
  25224. * Get if the submesh is ready to be used and all its information available.
  25225. * Child classes can use it to update shaders
  25226. * @param mesh defines the mesh to check
  25227. * @param subMesh defines which submesh to check
  25228. * @param useInstances specifies that instances should be used
  25229. * @returns a boolean indicating that the submesh is ready or not
  25230. */
  25231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25232. /**
  25233. * Builds the material UBO layouts.
  25234. * Used internally during the effect preparation.
  25235. */
  25236. buildUniformLayout(): void;
  25237. /**
  25238. * Unbinds the material from the mesh
  25239. */
  25240. unbind(): void;
  25241. /**
  25242. * Binds the submesh to this material by preparing the effect and shader to draw
  25243. * @param world defines the world transformation matrix
  25244. * @param mesh defines the mesh containing the submesh
  25245. * @param subMesh defines the submesh to bind the material to
  25246. */
  25247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25248. /**
  25249. * Get the list of animatables in the material.
  25250. * @returns the list of animatables object used in the material
  25251. */
  25252. getAnimatables(): IAnimatable[];
  25253. /**
  25254. * Gets the active textures from the material
  25255. * @returns an array of textures
  25256. */
  25257. getActiveTextures(): BaseTexture[];
  25258. /**
  25259. * Specifies if the material uses a texture
  25260. * @param texture defines the texture to check against the material
  25261. * @returns a boolean specifying if the material uses the texture
  25262. */
  25263. hasTexture(texture: BaseTexture): boolean;
  25264. /**
  25265. * Disposes the material
  25266. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25267. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25268. */
  25269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25270. /**
  25271. * Makes a duplicate of the material, and gives it a new name
  25272. * @param name defines the new name for the duplicated material
  25273. * @returns the cloned material
  25274. */
  25275. clone(name: string): StandardMaterial;
  25276. /**
  25277. * Serializes this material in a JSON representation
  25278. * @returns the serialized material object
  25279. */
  25280. serialize(): any;
  25281. /**
  25282. * Creates a standard material from parsed material data
  25283. * @param source defines the JSON representation of the material
  25284. * @param scene defines the hosting scene
  25285. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25286. * @returns a new standard material
  25287. */
  25288. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25289. /**
  25290. * Are diffuse textures enabled in the application.
  25291. */
  25292. static get DiffuseTextureEnabled(): boolean;
  25293. static set DiffuseTextureEnabled(value: boolean);
  25294. /**
  25295. * Are detail textures enabled in the application.
  25296. */
  25297. static get DetailTextureEnabled(): boolean;
  25298. static set DetailTextureEnabled(value: boolean);
  25299. /**
  25300. * Are ambient textures enabled in the application.
  25301. */
  25302. static get AmbientTextureEnabled(): boolean;
  25303. static set AmbientTextureEnabled(value: boolean);
  25304. /**
  25305. * Are opacity textures enabled in the application.
  25306. */
  25307. static get OpacityTextureEnabled(): boolean;
  25308. static set OpacityTextureEnabled(value: boolean);
  25309. /**
  25310. * Are reflection textures enabled in the application.
  25311. */
  25312. static get ReflectionTextureEnabled(): boolean;
  25313. static set ReflectionTextureEnabled(value: boolean);
  25314. /**
  25315. * Are emissive textures enabled in the application.
  25316. */
  25317. static get EmissiveTextureEnabled(): boolean;
  25318. static set EmissiveTextureEnabled(value: boolean);
  25319. /**
  25320. * Are specular textures enabled in the application.
  25321. */
  25322. static get SpecularTextureEnabled(): boolean;
  25323. static set SpecularTextureEnabled(value: boolean);
  25324. /**
  25325. * Are bump textures enabled in the application.
  25326. */
  25327. static get BumpTextureEnabled(): boolean;
  25328. static set BumpTextureEnabled(value: boolean);
  25329. /**
  25330. * Are lightmap textures enabled in the application.
  25331. */
  25332. static get LightmapTextureEnabled(): boolean;
  25333. static set LightmapTextureEnabled(value: boolean);
  25334. /**
  25335. * Are refraction textures enabled in the application.
  25336. */
  25337. static get RefractionTextureEnabled(): boolean;
  25338. static set RefractionTextureEnabled(value: boolean);
  25339. /**
  25340. * Are color grading textures enabled in the application.
  25341. */
  25342. static get ColorGradingTextureEnabled(): boolean;
  25343. static set ColorGradingTextureEnabled(value: boolean);
  25344. /**
  25345. * Are fresnels enabled in the application.
  25346. */
  25347. static get FresnelEnabled(): boolean;
  25348. static set FresnelEnabled(value: boolean);
  25349. }
  25350. }
  25351. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25353. /** @hidden */
  25354. export var rgbdDecodePixelShader: {
  25355. name: string;
  25356. shader: string;
  25357. };
  25358. }
  25359. declare module "babylonjs/Misc/rgbdTextureTools" {
  25360. import "babylonjs/Shaders/rgbdDecode.fragment";
  25361. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25362. import { Texture } from "babylonjs/Materials/Textures/texture";
  25363. /**
  25364. * Class used to host RGBD texture specific utilities
  25365. */
  25366. export class RGBDTextureTools {
  25367. /**
  25368. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25369. * @param texture the texture to expand.
  25370. */
  25371. static ExpandRGBDTexture(texture: Texture): void;
  25372. }
  25373. }
  25374. declare module "babylonjs/Misc/brdfTextureTools" {
  25375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25376. import { Scene } from "babylonjs/scene";
  25377. /**
  25378. * Class used to host texture specific utilities
  25379. */
  25380. export class BRDFTextureTools {
  25381. /**
  25382. * Prevents texture cache collision
  25383. */
  25384. private static _instanceNumber;
  25385. /**
  25386. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25387. * @param scene defines the hosting scene
  25388. * @returns the environment BRDF texture
  25389. */
  25390. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25391. private static _environmentBRDFBase64Texture;
  25392. }
  25393. }
  25394. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25395. import { Nullable } from "babylonjs/types";
  25396. import { Color3 } from "babylonjs/Maths/math.color";
  25397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25398. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25399. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25400. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25402. import { Engine } from "babylonjs/Engines/engine";
  25403. import { Scene } from "babylonjs/scene";
  25404. /**
  25405. * @hidden
  25406. */
  25407. export interface IMaterialClearCoatDefines {
  25408. CLEARCOAT: boolean;
  25409. CLEARCOAT_DEFAULTIOR: boolean;
  25410. CLEARCOAT_TEXTURE: boolean;
  25411. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25412. CLEARCOAT_TEXTUREDIRECTUV: number;
  25413. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25414. CLEARCOAT_BUMP: boolean;
  25415. CLEARCOAT_BUMPDIRECTUV: number;
  25416. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25417. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25418. CLEARCOAT_REMAP_F0: boolean;
  25419. CLEARCOAT_TINT: boolean;
  25420. CLEARCOAT_TINT_TEXTURE: boolean;
  25421. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25422. /** @hidden */
  25423. _areTexturesDirty: boolean;
  25424. }
  25425. /**
  25426. * Define the code related to the clear coat parameters of the pbr material.
  25427. */
  25428. export class PBRClearCoatConfiguration {
  25429. /**
  25430. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25431. * The default fits with a polyurethane material.
  25432. */
  25433. private static readonly _DefaultIndexOfRefraction;
  25434. private _isEnabled;
  25435. /**
  25436. * Defines if the clear coat is enabled in the material.
  25437. */
  25438. isEnabled: boolean;
  25439. /**
  25440. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25441. */
  25442. intensity: number;
  25443. /**
  25444. * Defines the clear coat layer roughness.
  25445. */
  25446. roughness: number;
  25447. private _indexOfRefraction;
  25448. /**
  25449. * Defines the index of refraction of the clear coat.
  25450. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25451. * The default fits with a polyurethane material.
  25452. * Changing the default value is more performance intensive.
  25453. */
  25454. indexOfRefraction: number;
  25455. private _texture;
  25456. /**
  25457. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25458. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25459. * if textureRoughness is not empty, else no texture roughness is used
  25460. */
  25461. texture: Nullable<BaseTexture>;
  25462. private _useRoughnessFromMainTexture;
  25463. /**
  25464. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25465. * If false, the green channel from textureRoughness is used for roughness
  25466. */
  25467. useRoughnessFromMainTexture: boolean;
  25468. private _textureRoughness;
  25469. /**
  25470. * Stores the clear coat roughness in a texture (green channel)
  25471. * Not used if useRoughnessFromMainTexture is true
  25472. */
  25473. textureRoughness: Nullable<BaseTexture>;
  25474. private _remapF0OnInterfaceChange;
  25475. /**
  25476. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25477. */
  25478. remapF0OnInterfaceChange: boolean;
  25479. private _bumpTexture;
  25480. /**
  25481. * Define the clear coat specific bump texture.
  25482. */
  25483. bumpTexture: Nullable<BaseTexture>;
  25484. private _isTintEnabled;
  25485. /**
  25486. * Defines if the clear coat tint is enabled in the material.
  25487. */
  25488. isTintEnabled: boolean;
  25489. /**
  25490. * Defines the clear coat tint of the material.
  25491. * This is only use if tint is enabled
  25492. */
  25493. tintColor: Color3;
  25494. /**
  25495. * Defines the distance at which the tint color should be found in the
  25496. * clear coat media.
  25497. * This is only use if tint is enabled
  25498. */
  25499. tintColorAtDistance: number;
  25500. /**
  25501. * Defines the clear coat layer thickness.
  25502. * This is only use if tint is enabled
  25503. */
  25504. tintThickness: number;
  25505. private _tintTexture;
  25506. /**
  25507. * Stores the clear tint values in a texture.
  25508. * rgb is tint
  25509. * a is a thickness factor
  25510. */
  25511. tintTexture: Nullable<BaseTexture>;
  25512. /** @hidden */
  25513. private _internalMarkAllSubMeshesAsTexturesDirty;
  25514. /** @hidden */
  25515. _markAllSubMeshesAsTexturesDirty(): void;
  25516. /**
  25517. * Instantiate a new istance of clear coat configuration.
  25518. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25519. */
  25520. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25521. /**
  25522. * Gets wehter the submesh is ready to be used or not.
  25523. * @param defines the list of "defines" to update.
  25524. * @param scene defines the scene the material belongs to.
  25525. * @param engine defines the engine the material belongs to.
  25526. * @param disableBumpMap defines wether the material disables bump or not.
  25527. * @returns - boolean indicating that the submesh is ready or not.
  25528. */
  25529. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25530. /**
  25531. * Checks to see if a texture is used in the material.
  25532. * @param defines the list of "defines" to update.
  25533. * @param scene defines the scene to the material belongs to.
  25534. */
  25535. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25536. /**
  25537. * Binds the material data.
  25538. * @param uniformBuffer defines the Uniform buffer to fill in.
  25539. * @param scene defines the scene the material belongs to.
  25540. * @param engine defines the engine the material belongs to.
  25541. * @param disableBumpMap defines wether the material disables bump or not.
  25542. * @param isFrozen defines wether the material is frozen or not.
  25543. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25544. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25545. * @param subMesh the submesh to bind data for
  25546. */
  25547. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25548. /**
  25549. * Checks to see if a texture is used in the material.
  25550. * @param texture - Base texture to use.
  25551. * @returns - Boolean specifying if a texture is used in the material.
  25552. */
  25553. hasTexture(texture: BaseTexture): boolean;
  25554. /**
  25555. * Returns an array of the actively used textures.
  25556. * @param activeTextures Array of BaseTextures
  25557. */
  25558. getActiveTextures(activeTextures: BaseTexture[]): void;
  25559. /**
  25560. * Returns the animatable textures.
  25561. * @param animatables Array of animatable textures.
  25562. */
  25563. getAnimatables(animatables: IAnimatable[]): void;
  25564. /**
  25565. * Disposes the resources of the material.
  25566. * @param forceDisposeTextures - Forces the disposal of all textures.
  25567. */
  25568. dispose(forceDisposeTextures?: boolean): void;
  25569. /**
  25570. * Get the current class name of the texture useful for serialization or dynamic coding.
  25571. * @returns "PBRClearCoatConfiguration"
  25572. */
  25573. getClassName(): string;
  25574. /**
  25575. * Add fallbacks to the effect fallbacks list.
  25576. * @param defines defines the Base texture to use.
  25577. * @param fallbacks defines the current fallback list.
  25578. * @param currentRank defines the current fallback rank.
  25579. * @returns the new fallback rank.
  25580. */
  25581. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25582. /**
  25583. * Add the required uniforms to the current list.
  25584. * @param uniforms defines the current uniform list.
  25585. */
  25586. static AddUniforms(uniforms: string[]): void;
  25587. /**
  25588. * Add the required samplers to the current list.
  25589. * @param samplers defines the current sampler list.
  25590. */
  25591. static AddSamplers(samplers: string[]): void;
  25592. /**
  25593. * Add the required uniforms to the current buffer.
  25594. * @param uniformBuffer defines the current uniform buffer.
  25595. */
  25596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25597. /**
  25598. * Makes a duplicate of the current configuration into another one.
  25599. * @param clearCoatConfiguration define the config where to copy the info
  25600. */
  25601. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25602. /**
  25603. * Serializes this clear coat configuration.
  25604. * @returns - An object with the serialized config.
  25605. */
  25606. serialize(): any;
  25607. /**
  25608. * Parses a anisotropy Configuration from a serialized object.
  25609. * @param source - Serialized object.
  25610. * @param scene Defines the scene we are parsing for
  25611. * @param rootUrl Defines the rootUrl to load from
  25612. */
  25613. parse(source: any, scene: Scene, rootUrl: string): void;
  25614. }
  25615. }
  25616. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25617. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25619. import { Vector2 } from "babylonjs/Maths/math.vector";
  25620. import { Scene } from "babylonjs/scene";
  25621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25622. import { Nullable } from "babylonjs/types";
  25623. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25624. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25625. /**
  25626. * @hidden
  25627. */
  25628. export interface IMaterialAnisotropicDefines {
  25629. ANISOTROPIC: boolean;
  25630. ANISOTROPIC_TEXTURE: boolean;
  25631. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25632. MAINUV1: boolean;
  25633. _areTexturesDirty: boolean;
  25634. _needUVs: boolean;
  25635. }
  25636. /**
  25637. * Define the code related to the anisotropic parameters of the pbr material.
  25638. */
  25639. export class PBRAnisotropicConfiguration {
  25640. private _isEnabled;
  25641. /**
  25642. * Defines if the anisotropy is enabled in the material.
  25643. */
  25644. isEnabled: boolean;
  25645. /**
  25646. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25647. */
  25648. intensity: number;
  25649. /**
  25650. * Defines if the effect is along the tangents, bitangents or in between.
  25651. * By default, the effect is "strectching" the highlights along the tangents.
  25652. */
  25653. direction: Vector2;
  25654. private _texture;
  25655. /**
  25656. * Stores the anisotropy values in a texture.
  25657. * rg is direction (like normal from -1 to 1)
  25658. * b is a intensity
  25659. */
  25660. texture: Nullable<BaseTexture>;
  25661. /** @hidden */
  25662. private _internalMarkAllSubMeshesAsTexturesDirty;
  25663. /** @hidden */
  25664. _markAllSubMeshesAsTexturesDirty(): void;
  25665. /**
  25666. * Instantiate a new istance of anisotropy configuration.
  25667. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25668. */
  25669. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25670. /**
  25671. * Specifies that the submesh is ready to be used.
  25672. * @param defines the list of "defines" to update.
  25673. * @param scene defines the scene the material belongs to.
  25674. * @returns - boolean indicating that the submesh is ready or not.
  25675. */
  25676. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25677. /**
  25678. * Checks to see if a texture is used in the material.
  25679. * @param defines the list of "defines" to update.
  25680. * @param mesh the mesh we are preparing the defines for.
  25681. * @param scene defines the scene the material belongs to.
  25682. */
  25683. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25684. /**
  25685. * Binds the material data.
  25686. * @param uniformBuffer defines the Uniform buffer to fill in.
  25687. * @param scene defines the scene the material belongs to.
  25688. * @param isFrozen defines wether the material is frozen or not.
  25689. */
  25690. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25691. /**
  25692. * Checks to see if a texture is used in the material.
  25693. * @param texture - Base texture to use.
  25694. * @returns - Boolean specifying if a texture is used in the material.
  25695. */
  25696. hasTexture(texture: BaseTexture): boolean;
  25697. /**
  25698. * Returns an array of the actively used textures.
  25699. * @param activeTextures Array of BaseTextures
  25700. */
  25701. getActiveTextures(activeTextures: BaseTexture[]): void;
  25702. /**
  25703. * Returns the animatable textures.
  25704. * @param animatables Array of animatable textures.
  25705. */
  25706. getAnimatables(animatables: IAnimatable[]): void;
  25707. /**
  25708. * Disposes the resources of the material.
  25709. * @param forceDisposeTextures - Forces the disposal of all textures.
  25710. */
  25711. dispose(forceDisposeTextures?: boolean): void;
  25712. /**
  25713. * Get the current class name of the texture useful for serialization or dynamic coding.
  25714. * @returns "PBRAnisotropicConfiguration"
  25715. */
  25716. getClassName(): string;
  25717. /**
  25718. * Add fallbacks to the effect fallbacks list.
  25719. * @param defines defines the Base texture to use.
  25720. * @param fallbacks defines the current fallback list.
  25721. * @param currentRank defines the current fallback rank.
  25722. * @returns the new fallback rank.
  25723. */
  25724. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25725. /**
  25726. * Add the required uniforms to the current list.
  25727. * @param uniforms defines the current uniform list.
  25728. */
  25729. static AddUniforms(uniforms: string[]): void;
  25730. /**
  25731. * Add the required uniforms to the current buffer.
  25732. * @param uniformBuffer defines the current uniform buffer.
  25733. */
  25734. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25735. /**
  25736. * Add the required samplers to the current list.
  25737. * @param samplers defines the current sampler list.
  25738. */
  25739. static AddSamplers(samplers: string[]): void;
  25740. /**
  25741. * Makes a duplicate of the current configuration into another one.
  25742. * @param anisotropicConfiguration define the config where to copy the info
  25743. */
  25744. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25745. /**
  25746. * Serializes this anisotropy configuration.
  25747. * @returns - An object with the serialized config.
  25748. */
  25749. serialize(): any;
  25750. /**
  25751. * Parses a anisotropy Configuration from a serialized object.
  25752. * @param source - Serialized object.
  25753. * @param scene Defines the scene we are parsing for
  25754. * @param rootUrl Defines the rootUrl to load from
  25755. */
  25756. parse(source: any, scene: Scene, rootUrl: string): void;
  25757. }
  25758. }
  25759. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25760. import { Scene } from "babylonjs/scene";
  25761. /**
  25762. * @hidden
  25763. */
  25764. export interface IMaterialBRDFDefines {
  25765. BRDF_V_HEIGHT_CORRELATED: boolean;
  25766. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25767. SPHERICAL_HARMONICS: boolean;
  25768. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25769. /** @hidden */
  25770. _areMiscDirty: boolean;
  25771. }
  25772. /**
  25773. * Define the code related to the BRDF parameters of the pbr material.
  25774. */
  25775. export class PBRBRDFConfiguration {
  25776. /**
  25777. * Default value used for the energy conservation.
  25778. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25779. */
  25780. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25781. /**
  25782. * Default value used for the Smith Visibility Height Correlated mode.
  25783. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25784. */
  25785. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25786. /**
  25787. * Default value used for the IBL diffuse part.
  25788. * This can help switching back to the polynomials mode globally which is a tiny bit
  25789. * less GPU intensive at the drawback of a lower quality.
  25790. */
  25791. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25792. /**
  25793. * Default value used for activating energy conservation for the specular workflow.
  25794. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25795. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25796. */
  25797. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25798. private _useEnergyConservation;
  25799. /**
  25800. * Defines if the material uses energy conservation.
  25801. */
  25802. useEnergyConservation: boolean;
  25803. private _useSmithVisibilityHeightCorrelated;
  25804. /**
  25805. * LEGACY Mode set to false
  25806. * Defines if the material uses height smith correlated visibility term.
  25807. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25808. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25809. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25810. * Not relying on height correlated will also disable energy conservation.
  25811. */
  25812. useSmithVisibilityHeightCorrelated: boolean;
  25813. private _useSphericalHarmonics;
  25814. /**
  25815. * LEGACY Mode set to false
  25816. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25817. * diffuse part of the IBL.
  25818. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25819. * to the ground truth.
  25820. */
  25821. useSphericalHarmonics: boolean;
  25822. private _useSpecularGlossinessInputEnergyConservation;
  25823. /**
  25824. * Defines if the material uses energy conservation, when the specular workflow is active.
  25825. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25826. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25827. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25828. */
  25829. useSpecularGlossinessInputEnergyConservation: boolean;
  25830. /** @hidden */
  25831. private _internalMarkAllSubMeshesAsMiscDirty;
  25832. /** @hidden */
  25833. _markAllSubMeshesAsMiscDirty(): void;
  25834. /**
  25835. * Instantiate a new istance of clear coat configuration.
  25836. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25837. */
  25838. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25839. /**
  25840. * Checks to see if a texture is used in the material.
  25841. * @param defines the list of "defines" to update.
  25842. */
  25843. prepareDefines(defines: IMaterialBRDFDefines): void;
  25844. /**
  25845. * Get the current class name of the texture useful for serialization or dynamic coding.
  25846. * @returns "PBRClearCoatConfiguration"
  25847. */
  25848. getClassName(): string;
  25849. /**
  25850. * Makes a duplicate of the current configuration into another one.
  25851. * @param brdfConfiguration define the config where to copy the info
  25852. */
  25853. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25854. /**
  25855. * Serializes this BRDF configuration.
  25856. * @returns - An object with the serialized config.
  25857. */
  25858. serialize(): any;
  25859. /**
  25860. * Parses a anisotropy Configuration from a serialized object.
  25861. * @param source - Serialized object.
  25862. * @param scene Defines the scene we are parsing for
  25863. * @param rootUrl Defines the rootUrl to load from
  25864. */
  25865. parse(source: any, scene: Scene, rootUrl: string): void;
  25866. }
  25867. }
  25868. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25869. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25870. import { Color3 } from "babylonjs/Maths/math.color";
  25871. import { Scene } from "babylonjs/scene";
  25872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25873. import { Nullable } from "babylonjs/types";
  25874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25875. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25877. /**
  25878. * @hidden
  25879. */
  25880. export interface IMaterialSheenDefines {
  25881. SHEEN: boolean;
  25882. SHEEN_TEXTURE: boolean;
  25883. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25884. SHEEN_TEXTUREDIRECTUV: number;
  25885. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25886. SHEEN_LINKWITHALBEDO: boolean;
  25887. SHEEN_ROUGHNESS: boolean;
  25888. SHEEN_ALBEDOSCALING: boolean;
  25889. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25890. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25891. /** @hidden */
  25892. _areTexturesDirty: boolean;
  25893. }
  25894. /**
  25895. * Define the code related to the Sheen parameters of the pbr material.
  25896. */
  25897. export class PBRSheenConfiguration {
  25898. private _isEnabled;
  25899. /**
  25900. * Defines if the material uses sheen.
  25901. */
  25902. isEnabled: boolean;
  25903. private _linkSheenWithAlbedo;
  25904. /**
  25905. * Defines if the sheen is linked to the sheen color.
  25906. */
  25907. linkSheenWithAlbedo: boolean;
  25908. /**
  25909. * Defines the sheen intensity.
  25910. */
  25911. intensity: number;
  25912. /**
  25913. * Defines the sheen color.
  25914. */
  25915. color: Color3;
  25916. private _texture;
  25917. /**
  25918. * Stores the sheen tint values in a texture.
  25919. * rgb is tint
  25920. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25921. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25922. */
  25923. texture: Nullable<BaseTexture>;
  25924. private _useRoughnessFromMainTexture;
  25925. /**
  25926. * Indicates that the alpha channel of the texture property will be used for roughness.
  25927. * Has no effect if the roughness (and texture!) property is not defined
  25928. */
  25929. useRoughnessFromMainTexture: boolean;
  25930. private _roughness;
  25931. /**
  25932. * Defines the sheen roughness.
  25933. * It is not taken into account if linkSheenWithAlbedo is true.
  25934. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25935. */
  25936. roughness: Nullable<number>;
  25937. private _textureRoughness;
  25938. /**
  25939. * Stores the sheen roughness in a texture.
  25940. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25941. */
  25942. textureRoughness: Nullable<BaseTexture>;
  25943. private _albedoScaling;
  25944. /**
  25945. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25946. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25947. * making it easier to setup and tweak the effect
  25948. */
  25949. albedoScaling: boolean;
  25950. /** @hidden */
  25951. private _internalMarkAllSubMeshesAsTexturesDirty;
  25952. /** @hidden */
  25953. _markAllSubMeshesAsTexturesDirty(): void;
  25954. /**
  25955. * Instantiate a new istance of clear coat configuration.
  25956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25957. */
  25958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25959. /**
  25960. * Specifies that the submesh is ready to be used.
  25961. * @param defines the list of "defines" to update.
  25962. * @param scene defines the scene the material belongs to.
  25963. * @returns - boolean indicating that the submesh is ready or not.
  25964. */
  25965. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25966. /**
  25967. * Checks to see if a texture is used in the material.
  25968. * @param defines the list of "defines" to update.
  25969. * @param scene defines the scene the material belongs to.
  25970. */
  25971. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25972. /**
  25973. * Binds the material data.
  25974. * @param uniformBuffer defines the Uniform buffer to fill in.
  25975. * @param scene defines the scene the material belongs to.
  25976. * @param isFrozen defines wether the material is frozen or not.
  25977. * @param subMesh the submesh to bind data for
  25978. */
  25979. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25980. /**
  25981. * Checks to see if a texture is used in the material.
  25982. * @param texture - Base texture to use.
  25983. * @returns - Boolean specifying if a texture is used in the material.
  25984. */
  25985. hasTexture(texture: BaseTexture): boolean;
  25986. /**
  25987. * Returns an array of the actively used textures.
  25988. * @param activeTextures Array of BaseTextures
  25989. */
  25990. getActiveTextures(activeTextures: BaseTexture[]): void;
  25991. /**
  25992. * Returns the animatable textures.
  25993. * @param animatables Array of animatable textures.
  25994. */
  25995. getAnimatables(animatables: IAnimatable[]): void;
  25996. /**
  25997. * Disposes the resources of the material.
  25998. * @param forceDisposeTextures - Forces the disposal of all textures.
  25999. */
  26000. dispose(forceDisposeTextures?: boolean): void;
  26001. /**
  26002. * Get the current class name of the texture useful for serialization or dynamic coding.
  26003. * @returns "PBRSheenConfiguration"
  26004. */
  26005. getClassName(): string;
  26006. /**
  26007. * Add fallbacks to the effect fallbacks list.
  26008. * @param defines defines the Base texture to use.
  26009. * @param fallbacks defines the current fallback list.
  26010. * @param currentRank defines the current fallback rank.
  26011. * @returns the new fallback rank.
  26012. */
  26013. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26014. /**
  26015. * Add the required uniforms to the current list.
  26016. * @param uniforms defines the current uniform list.
  26017. */
  26018. static AddUniforms(uniforms: string[]): void;
  26019. /**
  26020. * Add the required uniforms to the current buffer.
  26021. * @param uniformBuffer defines the current uniform buffer.
  26022. */
  26023. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26024. /**
  26025. * Add the required samplers to the current list.
  26026. * @param samplers defines the current sampler list.
  26027. */
  26028. static AddSamplers(samplers: string[]): void;
  26029. /**
  26030. * Makes a duplicate of the current configuration into another one.
  26031. * @param sheenConfiguration define the config where to copy the info
  26032. */
  26033. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26034. /**
  26035. * Serializes this BRDF configuration.
  26036. * @returns - An object with the serialized config.
  26037. */
  26038. serialize(): any;
  26039. /**
  26040. * Parses a anisotropy Configuration from a serialized object.
  26041. * @param source - Serialized object.
  26042. * @param scene Defines the scene we are parsing for
  26043. * @param rootUrl Defines the rootUrl to load from
  26044. */
  26045. parse(source: any, scene: Scene, rootUrl: string): void;
  26046. }
  26047. }
  26048. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26049. import { Nullable } from "babylonjs/types";
  26050. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26051. import { Color3 } from "babylonjs/Maths/math.color";
  26052. import { SmartArray } from "babylonjs/Misc/smartArray";
  26053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26055. import { Effect } from "babylonjs/Materials/effect";
  26056. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26057. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26058. import { Engine } from "babylonjs/Engines/engine";
  26059. import { Scene } from "babylonjs/scene";
  26060. /**
  26061. * @hidden
  26062. */
  26063. export interface IMaterialSubSurfaceDefines {
  26064. SUBSURFACE: boolean;
  26065. SS_REFRACTION: boolean;
  26066. SS_TRANSLUCENCY: boolean;
  26067. SS_SCATTERING: boolean;
  26068. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26069. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26070. SS_REFRACTIONMAP_3D: boolean;
  26071. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26072. SS_LODINREFRACTIONALPHA: boolean;
  26073. SS_GAMMAREFRACTION: boolean;
  26074. SS_RGBDREFRACTION: boolean;
  26075. SS_LINEARSPECULARREFRACTION: boolean;
  26076. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26077. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26078. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26079. /** @hidden */
  26080. _areTexturesDirty: boolean;
  26081. }
  26082. /**
  26083. * Define the code related to the sub surface parameters of the pbr material.
  26084. */
  26085. export class PBRSubSurfaceConfiguration {
  26086. private _isRefractionEnabled;
  26087. /**
  26088. * Defines if the refraction is enabled in the material.
  26089. */
  26090. isRefractionEnabled: boolean;
  26091. private _isTranslucencyEnabled;
  26092. /**
  26093. * Defines if the translucency is enabled in the material.
  26094. */
  26095. isTranslucencyEnabled: boolean;
  26096. private _isScatteringEnabled;
  26097. /**
  26098. * Defines if the sub surface scattering is enabled in the material.
  26099. */
  26100. isScatteringEnabled: boolean;
  26101. private _scatteringDiffusionProfileIndex;
  26102. /**
  26103. * Diffusion profile for subsurface scattering.
  26104. * Useful for better scattering in the skins or foliages.
  26105. */
  26106. get scatteringDiffusionProfile(): Nullable<Color3>;
  26107. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26108. /**
  26109. * Defines the refraction intensity of the material.
  26110. * The refraction when enabled replaces the Diffuse part of the material.
  26111. * The intensity helps transitionning between diffuse and refraction.
  26112. */
  26113. refractionIntensity: number;
  26114. /**
  26115. * Defines the translucency intensity of the material.
  26116. * When translucency has been enabled, this defines how much of the "translucency"
  26117. * is addded to the diffuse part of the material.
  26118. */
  26119. translucencyIntensity: number;
  26120. /**
  26121. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26122. */
  26123. useAlbedoToTintRefraction: boolean;
  26124. private _thicknessTexture;
  26125. /**
  26126. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26127. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26128. * 0 would mean minimumThickness
  26129. * 1 would mean maximumThickness
  26130. * The other channels might be use as a mask to vary the different effects intensity.
  26131. */
  26132. thicknessTexture: Nullable<BaseTexture>;
  26133. private _refractionTexture;
  26134. /**
  26135. * Defines the texture to use for refraction.
  26136. */
  26137. refractionTexture: Nullable<BaseTexture>;
  26138. private _indexOfRefraction;
  26139. /**
  26140. * Index of refraction of the material base layer.
  26141. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26142. *
  26143. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26144. *
  26145. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26146. */
  26147. indexOfRefraction: number;
  26148. private _volumeIndexOfRefraction;
  26149. /**
  26150. * Index of refraction of the material's volume.
  26151. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26152. *
  26153. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26154. * the volume will use the same IOR as the surface.
  26155. */
  26156. get volumeIndexOfRefraction(): number;
  26157. set volumeIndexOfRefraction(value: number);
  26158. private _invertRefractionY;
  26159. /**
  26160. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26161. */
  26162. invertRefractionY: boolean;
  26163. private _linkRefractionWithTransparency;
  26164. /**
  26165. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26166. * Materials half opaque for instance using refraction could benefit from this control.
  26167. */
  26168. linkRefractionWithTransparency: boolean;
  26169. /**
  26170. * Defines the minimum thickness stored in the thickness map.
  26171. * If no thickness map is defined, this value will be used to simulate thickness.
  26172. */
  26173. minimumThickness: number;
  26174. /**
  26175. * Defines the maximum thickness stored in the thickness map.
  26176. */
  26177. maximumThickness: number;
  26178. /**
  26179. * Defines the volume tint of the material.
  26180. * This is used for both translucency and scattering.
  26181. */
  26182. tintColor: Color3;
  26183. /**
  26184. * Defines the distance at which the tint color should be found in the media.
  26185. * This is used for refraction only.
  26186. */
  26187. tintColorAtDistance: number;
  26188. /**
  26189. * Defines how far each channel transmit through the media.
  26190. * It is defined as a color to simplify it selection.
  26191. */
  26192. diffusionDistance: Color3;
  26193. private _useMaskFromThicknessTexture;
  26194. /**
  26195. * Stores the intensity of the different subsurface effects in the thickness texture.
  26196. * * the green channel is the translucency intensity.
  26197. * * the blue channel is the scattering intensity.
  26198. * * the alpha channel is the refraction intensity.
  26199. */
  26200. useMaskFromThicknessTexture: boolean;
  26201. private _scene;
  26202. /** @hidden */
  26203. private _internalMarkAllSubMeshesAsTexturesDirty;
  26204. private _internalMarkScenePrePassDirty;
  26205. /** @hidden */
  26206. _markAllSubMeshesAsTexturesDirty(): void;
  26207. /** @hidden */
  26208. _markScenePrePassDirty(): void;
  26209. /**
  26210. * Instantiate a new istance of sub surface configuration.
  26211. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26212. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26213. * @param scene The scene
  26214. */
  26215. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26216. /**
  26217. * Gets wehter the submesh is ready to be used or not.
  26218. * @param defines the list of "defines" to update.
  26219. * @param scene defines the scene the material belongs to.
  26220. * @returns - boolean indicating that the submesh is ready or not.
  26221. */
  26222. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26223. /**
  26224. * Checks to see if a texture is used in the material.
  26225. * @param defines the list of "defines" to update.
  26226. * @param scene defines the scene to the material belongs to.
  26227. */
  26228. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26229. /**
  26230. * Binds the material data.
  26231. * @param uniformBuffer defines the Uniform buffer to fill in.
  26232. * @param scene defines the scene the material belongs to.
  26233. * @param engine defines the engine the material belongs to.
  26234. * @param isFrozen defines whether the material is frozen or not.
  26235. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26236. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26237. */
  26238. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26239. /**
  26240. * Unbinds the material from the mesh.
  26241. * @param activeEffect defines the effect that should be unbound from.
  26242. * @returns true if unbound, otherwise false
  26243. */
  26244. unbind(activeEffect: Effect): boolean;
  26245. /**
  26246. * Returns the texture used for refraction or null if none is used.
  26247. * @param scene defines the scene the material belongs to.
  26248. * @returns - Refraction texture if present. If no refraction texture and refraction
  26249. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26250. */
  26251. private _getRefractionTexture;
  26252. /**
  26253. * Returns true if alpha blending should be disabled.
  26254. */
  26255. get disableAlphaBlending(): boolean;
  26256. /**
  26257. * Fills the list of render target textures.
  26258. * @param renderTargets the list of render targets to update
  26259. */
  26260. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26261. /**
  26262. * Checks to see if a texture is used in the material.
  26263. * @param texture - Base texture to use.
  26264. * @returns - Boolean specifying if a texture is used in the material.
  26265. */
  26266. hasTexture(texture: BaseTexture): boolean;
  26267. /**
  26268. * Gets a boolean indicating that current material needs to register RTT
  26269. * @returns true if this uses a render target otherwise false.
  26270. */
  26271. hasRenderTargetTextures(): boolean;
  26272. /**
  26273. * Returns an array of the actively used textures.
  26274. * @param activeTextures Array of BaseTextures
  26275. */
  26276. getActiveTextures(activeTextures: BaseTexture[]): void;
  26277. /**
  26278. * Returns the animatable textures.
  26279. * @param animatables Array of animatable textures.
  26280. */
  26281. getAnimatables(animatables: IAnimatable[]): void;
  26282. /**
  26283. * Disposes the resources of the material.
  26284. * @param forceDisposeTextures - Forces the disposal of all textures.
  26285. */
  26286. dispose(forceDisposeTextures?: boolean): void;
  26287. /**
  26288. * Get the current class name of the texture useful for serialization or dynamic coding.
  26289. * @returns "PBRSubSurfaceConfiguration"
  26290. */
  26291. getClassName(): string;
  26292. /**
  26293. * Add fallbacks to the effect fallbacks list.
  26294. * @param defines defines the Base texture to use.
  26295. * @param fallbacks defines the current fallback list.
  26296. * @param currentRank defines the current fallback rank.
  26297. * @returns the new fallback rank.
  26298. */
  26299. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26300. /**
  26301. * Add the required uniforms to the current list.
  26302. * @param uniforms defines the current uniform list.
  26303. */
  26304. static AddUniforms(uniforms: string[]): void;
  26305. /**
  26306. * Add the required samplers to the current list.
  26307. * @param samplers defines the current sampler list.
  26308. */
  26309. static AddSamplers(samplers: string[]): void;
  26310. /**
  26311. * Add the required uniforms to the current buffer.
  26312. * @param uniformBuffer defines the current uniform buffer.
  26313. */
  26314. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26315. /**
  26316. * Makes a duplicate of the current configuration into another one.
  26317. * @param configuration define the config where to copy the info
  26318. */
  26319. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26320. /**
  26321. * Serializes this Sub Surface configuration.
  26322. * @returns - An object with the serialized config.
  26323. */
  26324. serialize(): any;
  26325. /**
  26326. * Parses a anisotropy Configuration from a serialized object.
  26327. * @param source - Serialized object.
  26328. * @param scene Defines the scene we are parsing for
  26329. * @param rootUrl Defines the rootUrl to load from
  26330. */
  26331. parse(source: any, scene: Scene, rootUrl: string): void;
  26332. }
  26333. }
  26334. declare module "babylonjs/Maths/sphericalPolynomial" {
  26335. import { Vector3 } from "babylonjs/Maths/math.vector";
  26336. import { Color3 } from "babylonjs/Maths/math.color";
  26337. /**
  26338. * Class representing spherical harmonics coefficients to the 3rd degree
  26339. */
  26340. export class SphericalHarmonics {
  26341. /**
  26342. * Defines whether or not the harmonics have been prescaled for rendering.
  26343. */
  26344. preScaled: boolean;
  26345. /**
  26346. * The l0,0 coefficients of the spherical harmonics
  26347. */
  26348. l00: Vector3;
  26349. /**
  26350. * The l1,-1 coefficients of the spherical harmonics
  26351. */
  26352. l1_1: Vector3;
  26353. /**
  26354. * The l1,0 coefficients of the spherical harmonics
  26355. */
  26356. l10: Vector3;
  26357. /**
  26358. * The l1,1 coefficients of the spherical harmonics
  26359. */
  26360. l11: Vector3;
  26361. /**
  26362. * The l2,-2 coefficients of the spherical harmonics
  26363. */
  26364. l2_2: Vector3;
  26365. /**
  26366. * The l2,-1 coefficients of the spherical harmonics
  26367. */
  26368. l2_1: Vector3;
  26369. /**
  26370. * The l2,0 coefficients of the spherical harmonics
  26371. */
  26372. l20: Vector3;
  26373. /**
  26374. * The l2,1 coefficients of the spherical harmonics
  26375. */
  26376. l21: Vector3;
  26377. /**
  26378. * The l2,2 coefficients of the spherical harmonics
  26379. */
  26380. l22: Vector3;
  26381. /**
  26382. * Adds a light to the spherical harmonics
  26383. * @param direction the direction of the light
  26384. * @param color the color of the light
  26385. * @param deltaSolidAngle the delta solid angle of the light
  26386. */
  26387. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26388. /**
  26389. * Scales the spherical harmonics by the given amount
  26390. * @param scale the amount to scale
  26391. */
  26392. scaleInPlace(scale: number): void;
  26393. /**
  26394. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26395. *
  26396. * ```
  26397. * E_lm = A_l * L_lm
  26398. * ```
  26399. *
  26400. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26401. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26402. * the scaling factors are given in equation 9.
  26403. */
  26404. convertIncidentRadianceToIrradiance(): void;
  26405. /**
  26406. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26407. *
  26408. * ```
  26409. * L = (1/pi) * E * rho
  26410. * ```
  26411. *
  26412. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26413. */
  26414. convertIrradianceToLambertianRadiance(): void;
  26415. /**
  26416. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26417. * required operations at run time.
  26418. *
  26419. * This is simply done by scaling back the SH with Ylm constants parameter.
  26420. * The trigonometric part being applied by the shader at run time.
  26421. */
  26422. preScaleForRendering(): void;
  26423. /**
  26424. * Constructs a spherical harmonics from an array.
  26425. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26426. * @returns the spherical harmonics
  26427. */
  26428. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26429. /**
  26430. * Gets the spherical harmonics from polynomial
  26431. * @param polynomial the spherical polynomial
  26432. * @returns the spherical harmonics
  26433. */
  26434. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26435. }
  26436. /**
  26437. * Class representing spherical polynomial coefficients to the 3rd degree
  26438. */
  26439. export class SphericalPolynomial {
  26440. private _harmonics;
  26441. /**
  26442. * The spherical harmonics used to create the polynomials.
  26443. */
  26444. get preScaledHarmonics(): SphericalHarmonics;
  26445. /**
  26446. * The x coefficients of the spherical polynomial
  26447. */
  26448. x: Vector3;
  26449. /**
  26450. * The y coefficients of the spherical polynomial
  26451. */
  26452. y: Vector3;
  26453. /**
  26454. * The z coefficients of the spherical polynomial
  26455. */
  26456. z: Vector3;
  26457. /**
  26458. * The xx coefficients of the spherical polynomial
  26459. */
  26460. xx: Vector3;
  26461. /**
  26462. * The yy coefficients of the spherical polynomial
  26463. */
  26464. yy: Vector3;
  26465. /**
  26466. * The zz coefficients of the spherical polynomial
  26467. */
  26468. zz: Vector3;
  26469. /**
  26470. * The xy coefficients of the spherical polynomial
  26471. */
  26472. xy: Vector3;
  26473. /**
  26474. * The yz coefficients of the spherical polynomial
  26475. */
  26476. yz: Vector3;
  26477. /**
  26478. * The zx coefficients of the spherical polynomial
  26479. */
  26480. zx: Vector3;
  26481. /**
  26482. * Adds an ambient color to the spherical polynomial
  26483. * @param color the color to add
  26484. */
  26485. addAmbient(color: Color3): void;
  26486. /**
  26487. * Scales the spherical polynomial by the given amount
  26488. * @param scale the amount to scale
  26489. */
  26490. scaleInPlace(scale: number): void;
  26491. /**
  26492. * Gets the spherical polynomial from harmonics
  26493. * @param harmonics the spherical harmonics
  26494. * @returns the spherical polynomial
  26495. */
  26496. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26497. /**
  26498. * Constructs a spherical polynomial from an array.
  26499. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26500. * @returns the spherical polynomial
  26501. */
  26502. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26503. }
  26504. }
  26505. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26506. import { Nullable } from "babylonjs/types";
  26507. /**
  26508. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26509. */
  26510. export interface CubeMapInfo {
  26511. /**
  26512. * The pixel array for the front face.
  26513. * This is stored in format, left to right, up to down format.
  26514. */
  26515. front: Nullable<ArrayBufferView>;
  26516. /**
  26517. * The pixel array for the back face.
  26518. * This is stored in format, left to right, up to down format.
  26519. */
  26520. back: Nullable<ArrayBufferView>;
  26521. /**
  26522. * The pixel array for the left face.
  26523. * This is stored in format, left to right, up to down format.
  26524. */
  26525. left: Nullable<ArrayBufferView>;
  26526. /**
  26527. * The pixel array for the right face.
  26528. * This is stored in format, left to right, up to down format.
  26529. */
  26530. right: Nullable<ArrayBufferView>;
  26531. /**
  26532. * The pixel array for the up face.
  26533. * This is stored in format, left to right, up to down format.
  26534. */
  26535. up: Nullable<ArrayBufferView>;
  26536. /**
  26537. * The pixel array for the down face.
  26538. * This is stored in format, left to right, up to down format.
  26539. */
  26540. down: Nullable<ArrayBufferView>;
  26541. /**
  26542. * The size of the cubemap stored.
  26543. *
  26544. * Each faces will be size * size pixels.
  26545. */
  26546. size: number;
  26547. /**
  26548. * The format of the texture.
  26549. *
  26550. * RGBA, RGB.
  26551. */
  26552. format: number;
  26553. /**
  26554. * The type of the texture data.
  26555. *
  26556. * UNSIGNED_INT, FLOAT.
  26557. */
  26558. type: number;
  26559. /**
  26560. * Specifies whether the texture is in gamma space.
  26561. */
  26562. gammaSpace: boolean;
  26563. }
  26564. /**
  26565. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26566. */
  26567. export class PanoramaToCubeMapTools {
  26568. private static FACE_LEFT;
  26569. private static FACE_RIGHT;
  26570. private static FACE_FRONT;
  26571. private static FACE_BACK;
  26572. private static FACE_DOWN;
  26573. private static FACE_UP;
  26574. /**
  26575. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26576. *
  26577. * @param float32Array The source data.
  26578. * @param inputWidth The width of the input panorama.
  26579. * @param inputHeight The height of the input panorama.
  26580. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26581. * @return The cubemap data
  26582. */
  26583. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26584. private static CreateCubemapTexture;
  26585. private static CalcProjectionSpherical;
  26586. }
  26587. }
  26588. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26589. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26591. import { Nullable } from "babylonjs/types";
  26592. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26593. /**
  26594. * Helper class dealing with the extraction of spherical polynomial dataArray
  26595. * from a cube map.
  26596. */
  26597. export class CubeMapToSphericalPolynomialTools {
  26598. private static FileFaces;
  26599. /**
  26600. * Converts a texture to the according Spherical Polynomial data.
  26601. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26602. *
  26603. * @param texture The texture to extract the information from.
  26604. * @return The Spherical Polynomial data.
  26605. */
  26606. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26607. /**
  26608. * Converts a cubemap to the according Spherical Polynomial data.
  26609. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26610. *
  26611. * @param cubeInfo The Cube map to extract the information from.
  26612. * @return The Spherical Polynomial data.
  26613. */
  26614. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26615. }
  26616. }
  26617. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26618. import { Nullable } from "babylonjs/types";
  26619. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26620. module "babylonjs/Materials/Textures/baseTexture" {
  26621. interface BaseTexture {
  26622. /**
  26623. * Get the polynomial representation of the texture data.
  26624. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26625. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26626. */
  26627. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26628. }
  26629. }
  26630. }
  26631. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26632. /** @hidden */
  26633. export var pbrFragmentDeclaration: {
  26634. name: string;
  26635. shader: string;
  26636. };
  26637. }
  26638. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26639. /** @hidden */
  26640. export var pbrUboDeclaration: {
  26641. name: string;
  26642. shader: string;
  26643. };
  26644. }
  26645. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26646. /** @hidden */
  26647. export var pbrFragmentExtraDeclaration: {
  26648. name: string;
  26649. shader: string;
  26650. };
  26651. }
  26652. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26653. /** @hidden */
  26654. export var pbrFragmentSamplersDeclaration: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26660. /** @hidden */
  26661. export var subSurfaceScatteringFunctions: {
  26662. name: string;
  26663. shader: string;
  26664. };
  26665. }
  26666. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26667. /** @hidden */
  26668. export var importanceSampling: {
  26669. name: string;
  26670. shader: string;
  26671. };
  26672. }
  26673. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26674. /** @hidden */
  26675. export var pbrHelperFunctions: {
  26676. name: string;
  26677. shader: string;
  26678. };
  26679. }
  26680. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26681. /** @hidden */
  26682. export var harmonicsFunctions: {
  26683. name: string;
  26684. shader: string;
  26685. };
  26686. }
  26687. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26688. /** @hidden */
  26689. export var pbrDirectLightingSetupFunctions: {
  26690. name: string;
  26691. shader: string;
  26692. };
  26693. }
  26694. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26695. /** @hidden */
  26696. export var pbrDirectLightingFalloffFunctions: {
  26697. name: string;
  26698. shader: string;
  26699. };
  26700. }
  26701. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26702. /** @hidden */
  26703. export var pbrBRDFFunctions: {
  26704. name: string;
  26705. shader: string;
  26706. };
  26707. }
  26708. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26709. /** @hidden */
  26710. export var hdrFilteringFunctions: {
  26711. name: string;
  26712. shader: string;
  26713. };
  26714. }
  26715. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26716. /** @hidden */
  26717. export var pbrDirectLightingFunctions: {
  26718. name: string;
  26719. shader: string;
  26720. };
  26721. }
  26722. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26723. /** @hidden */
  26724. export var pbrIBLFunctions: {
  26725. name: string;
  26726. shader: string;
  26727. };
  26728. }
  26729. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26730. /** @hidden */
  26731. export var pbrBlockAlbedoOpacity: {
  26732. name: string;
  26733. shader: string;
  26734. };
  26735. }
  26736. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26737. /** @hidden */
  26738. export var pbrBlockReflectivity: {
  26739. name: string;
  26740. shader: string;
  26741. };
  26742. }
  26743. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26744. /** @hidden */
  26745. export var pbrBlockAmbientOcclusion: {
  26746. name: string;
  26747. shader: string;
  26748. };
  26749. }
  26750. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26751. /** @hidden */
  26752. export var pbrBlockAlphaFresnel: {
  26753. name: string;
  26754. shader: string;
  26755. };
  26756. }
  26757. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26758. /** @hidden */
  26759. export var pbrBlockAnisotropic: {
  26760. name: string;
  26761. shader: string;
  26762. };
  26763. }
  26764. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26765. /** @hidden */
  26766. export var pbrBlockReflection: {
  26767. name: string;
  26768. shader: string;
  26769. };
  26770. }
  26771. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26772. /** @hidden */
  26773. export var pbrBlockSheen: {
  26774. name: string;
  26775. shader: string;
  26776. };
  26777. }
  26778. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26779. /** @hidden */
  26780. export var pbrBlockClearcoat: {
  26781. name: string;
  26782. shader: string;
  26783. };
  26784. }
  26785. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26786. /** @hidden */
  26787. export var pbrBlockSubSurface: {
  26788. name: string;
  26789. shader: string;
  26790. };
  26791. }
  26792. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26793. /** @hidden */
  26794. export var pbrBlockNormalGeometric: {
  26795. name: string;
  26796. shader: string;
  26797. };
  26798. }
  26799. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26800. /** @hidden */
  26801. export var pbrBlockNormalFinal: {
  26802. name: string;
  26803. shader: string;
  26804. };
  26805. }
  26806. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26807. /** @hidden */
  26808. export var pbrBlockLightmapInit: {
  26809. name: string;
  26810. shader: string;
  26811. };
  26812. }
  26813. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26814. /** @hidden */
  26815. export var pbrBlockGeometryInfo: {
  26816. name: string;
  26817. shader: string;
  26818. };
  26819. }
  26820. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26821. /** @hidden */
  26822. export var pbrBlockReflectance0: {
  26823. name: string;
  26824. shader: string;
  26825. };
  26826. }
  26827. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26828. /** @hidden */
  26829. export var pbrBlockReflectance: {
  26830. name: string;
  26831. shader: string;
  26832. };
  26833. }
  26834. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26835. /** @hidden */
  26836. export var pbrBlockDirectLighting: {
  26837. name: string;
  26838. shader: string;
  26839. };
  26840. }
  26841. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26842. /** @hidden */
  26843. export var pbrBlockFinalLitComponents: {
  26844. name: string;
  26845. shader: string;
  26846. };
  26847. }
  26848. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26849. /** @hidden */
  26850. export var pbrBlockFinalUnlitComponents: {
  26851. name: string;
  26852. shader: string;
  26853. };
  26854. }
  26855. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26856. /** @hidden */
  26857. export var pbrBlockFinalColorComposition: {
  26858. name: string;
  26859. shader: string;
  26860. };
  26861. }
  26862. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26863. /** @hidden */
  26864. export var pbrBlockImageProcessing: {
  26865. name: string;
  26866. shader: string;
  26867. };
  26868. }
  26869. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26870. /** @hidden */
  26871. export var pbrDebug: {
  26872. name: string;
  26873. shader: string;
  26874. };
  26875. }
  26876. declare module "babylonjs/Shaders/pbr.fragment" {
  26877. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26878. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26879. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26880. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26881. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26882. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26883. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26884. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26885. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26886. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26887. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26889. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26890. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26891. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26892. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26893. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26894. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26895. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26896. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26897. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26898. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26899. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26900. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26901. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26902. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26903. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26904. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26905. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26906. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26907. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26908. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26909. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26910. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26911. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26912. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26913. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26914. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26915. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26916. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26917. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26918. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26919. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26920. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26921. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26922. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26923. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26924. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26925. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26926. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26927. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26928. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26929. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26930. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26931. /** @hidden */
  26932. export var pbrPixelShader: {
  26933. name: string;
  26934. shader: string;
  26935. };
  26936. }
  26937. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26938. /** @hidden */
  26939. export var pbrVertexDeclaration: {
  26940. name: string;
  26941. shader: string;
  26942. };
  26943. }
  26944. declare module "babylonjs/Shaders/pbr.vertex" {
  26945. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26946. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26947. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26948. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26949. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26950. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26951. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26952. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26953. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26954. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26955. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26956. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26957. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26959. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26960. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26961. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26962. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26963. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26964. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26965. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26966. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26967. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26968. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26969. /** @hidden */
  26970. export var pbrVertexShader: {
  26971. name: string;
  26972. shader: string;
  26973. };
  26974. }
  26975. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26976. import { Nullable } from "babylonjs/types";
  26977. import { Scene } from "babylonjs/scene";
  26978. import { Matrix } from "babylonjs/Maths/math.vector";
  26979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26981. import { Mesh } from "babylonjs/Meshes/mesh";
  26982. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26983. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26984. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26985. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26986. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26987. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26988. import { Color3 } from "babylonjs/Maths/math.color";
  26989. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26990. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26991. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26992. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26994. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26995. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  26996. import "babylonjs/Shaders/pbr.fragment";
  26997. import "babylonjs/Shaders/pbr.vertex";
  26998. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  26999. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27000. /**
  27001. * Manages the defines for the PBR Material.
  27002. * @hidden
  27003. */
  27004. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27005. PBR: boolean;
  27006. NUM_SAMPLES: string;
  27007. REALTIME_FILTERING: boolean;
  27008. MAINUV1: boolean;
  27009. MAINUV2: boolean;
  27010. UV1: boolean;
  27011. UV2: boolean;
  27012. ALBEDO: boolean;
  27013. GAMMAALBEDO: boolean;
  27014. ALBEDODIRECTUV: number;
  27015. VERTEXCOLOR: boolean;
  27016. DETAIL: boolean;
  27017. DETAILDIRECTUV: number;
  27018. DETAIL_NORMALBLENDMETHOD: number;
  27019. AMBIENT: boolean;
  27020. AMBIENTDIRECTUV: number;
  27021. AMBIENTINGRAYSCALE: boolean;
  27022. OPACITY: boolean;
  27023. VERTEXALPHA: boolean;
  27024. OPACITYDIRECTUV: number;
  27025. OPACITYRGB: boolean;
  27026. ALPHATEST: boolean;
  27027. DEPTHPREPASS: boolean;
  27028. ALPHABLEND: boolean;
  27029. ALPHAFROMALBEDO: boolean;
  27030. ALPHATESTVALUE: string;
  27031. SPECULAROVERALPHA: boolean;
  27032. RADIANCEOVERALPHA: boolean;
  27033. ALPHAFRESNEL: boolean;
  27034. LINEARALPHAFRESNEL: boolean;
  27035. PREMULTIPLYALPHA: boolean;
  27036. EMISSIVE: boolean;
  27037. EMISSIVEDIRECTUV: number;
  27038. REFLECTIVITY: boolean;
  27039. REFLECTIVITYDIRECTUV: number;
  27040. SPECULARTERM: boolean;
  27041. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27042. MICROSURFACEAUTOMATIC: boolean;
  27043. LODBASEDMICROSFURACE: boolean;
  27044. MICROSURFACEMAP: boolean;
  27045. MICROSURFACEMAPDIRECTUV: number;
  27046. METALLICWORKFLOW: boolean;
  27047. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27048. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27049. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27050. AOSTOREINMETALMAPRED: boolean;
  27051. METALLIC_REFLECTANCE: boolean;
  27052. METALLIC_REFLECTANCEDIRECTUV: number;
  27053. ENVIRONMENTBRDF: boolean;
  27054. ENVIRONMENTBRDF_RGBD: boolean;
  27055. NORMAL: boolean;
  27056. TANGENT: boolean;
  27057. BUMP: boolean;
  27058. BUMPDIRECTUV: number;
  27059. OBJECTSPACE_NORMALMAP: boolean;
  27060. PARALLAX: boolean;
  27061. PARALLAXOCCLUSION: boolean;
  27062. NORMALXYSCALE: boolean;
  27063. LIGHTMAP: boolean;
  27064. LIGHTMAPDIRECTUV: number;
  27065. USELIGHTMAPASSHADOWMAP: boolean;
  27066. GAMMALIGHTMAP: boolean;
  27067. RGBDLIGHTMAP: boolean;
  27068. REFLECTION: boolean;
  27069. REFLECTIONMAP_3D: boolean;
  27070. REFLECTIONMAP_SPHERICAL: boolean;
  27071. REFLECTIONMAP_PLANAR: boolean;
  27072. REFLECTIONMAP_CUBIC: boolean;
  27073. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27074. REFLECTIONMAP_PROJECTION: boolean;
  27075. REFLECTIONMAP_SKYBOX: boolean;
  27076. REFLECTIONMAP_EXPLICIT: boolean;
  27077. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27078. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27079. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27080. INVERTCUBICMAP: boolean;
  27081. USESPHERICALFROMREFLECTIONMAP: boolean;
  27082. USEIRRADIANCEMAP: boolean;
  27083. SPHERICAL_HARMONICS: boolean;
  27084. USESPHERICALINVERTEX: boolean;
  27085. REFLECTIONMAP_OPPOSITEZ: boolean;
  27086. LODINREFLECTIONALPHA: boolean;
  27087. GAMMAREFLECTION: boolean;
  27088. RGBDREFLECTION: boolean;
  27089. LINEARSPECULARREFLECTION: boolean;
  27090. RADIANCEOCCLUSION: boolean;
  27091. HORIZONOCCLUSION: boolean;
  27092. INSTANCES: boolean;
  27093. THIN_INSTANCES: boolean;
  27094. PREPASS: boolean;
  27095. PREPASS_IRRADIANCE: boolean;
  27096. PREPASS_IRRADIANCE_INDEX: number;
  27097. PREPASS_ALBEDO: boolean;
  27098. PREPASS_ALBEDO_INDEX: number;
  27099. PREPASS_DEPTHNORMAL: boolean;
  27100. PREPASS_DEPTHNORMAL_INDEX: number;
  27101. PREPASS_POSITION: boolean;
  27102. PREPASS_POSITION_INDEX: number;
  27103. PREPASS_VELOCITY: boolean;
  27104. PREPASS_VELOCITY_INDEX: number;
  27105. PREPASS_REFLECTIVITY: boolean;
  27106. PREPASS_REFLECTIVITY_INDEX: number;
  27107. SCENE_MRT_COUNT: number;
  27108. NUM_BONE_INFLUENCERS: number;
  27109. BonesPerMesh: number;
  27110. BONETEXTURE: boolean;
  27111. BONES_VELOCITY_ENABLED: boolean;
  27112. NONUNIFORMSCALING: boolean;
  27113. MORPHTARGETS: boolean;
  27114. MORPHTARGETS_NORMAL: boolean;
  27115. MORPHTARGETS_TANGENT: boolean;
  27116. MORPHTARGETS_UV: boolean;
  27117. NUM_MORPH_INFLUENCERS: number;
  27118. IMAGEPROCESSING: boolean;
  27119. VIGNETTE: boolean;
  27120. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27121. VIGNETTEBLENDMODEOPAQUE: boolean;
  27122. TONEMAPPING: boolean;
  27123. TONEMAPPING_ACES: boolean;
  27124. CONTRAST: boolean;
  27125. COLORCURVES: boolean;
  27126. COLORGRADING: boolean;
  27127. COLORGRADING3D: boolean;
  27128. SAMPLER3DGREENDEPTH: boolean;
  27129. SAMPLER3DBGRMAP: boolean;
  27130. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27131. EXPOSURE: boolean;
  27132. MULTIVIEW: boolean;
  27133. USEPHYSICALLIGHTFALLOFF: boolean;
  27134. USEGLTFLIGHTFALLOFF: boolean;
  27135. TWOSIDEDLIGHTING: boolean;
  27136. SHADOWFLOAT: boolean;
  27137. CLIPPLANE: boolean;
  27138. CLIPPLANE2: boolean;
  27139. CLIPPLANE3: boolean;
  27140. CLIPPLANE4: boolean;
  27141. CLIPPLANE5: boolean;
  27142. CLIPPLANE6: boolean;
  27143. POINTSIZE: boolean;
  27144. FOG: boolean;
  27145. LOGARITHMICDEPTH: boolean;
  27146. FORCENORMALFORWARD: boolean;
  27147. SPECULARAA: boolean;
  27148. CLEARCOAT: boolean;
  27149. CLEARCOAT_DEFAULTIOR: boolean;
  27150. CLEARCOAT_TEXTURE: boolean;
  27151. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27152. CLEARCOAT_TEXTUREDIRECTUV: number;
  27153. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27154. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27155. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27156. CLEARCOAT_BUMP: boolean;
  27157. CLEARCOAT_BUMPDIRECTUV: number;
  27158. CLEARCOAT_REMAP_F0: boolean;
  27159. CLEARCOAT_TINT: boolean;
  27160. CLEARCOAT_TINT_TEXTURE: boolean;
  27161. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27162. ANISOTROPIC: boolean;
  27163. ANISOTROPIC_TEXTURE: boolean;
  27164. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27165. BRDF_V_HEIGHT_CORRELATED: boolean;
  27166. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27167. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27168. SHEEN: boolean;
  27169. SHEEN_TEXTURE: boolean;
  27170. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27171. SHEEN_TEXTUREDIRECTUV: number;
  27172. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27173. SHEEN_LINKWITHALBEDO: boolean;
  27174. SHEEN_ROUGHNESS: boolean;
  27175. SHEEN_ALBEDOSCALING: boolean;
  27176. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27177. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27178. SUBSURFACE: boolean;
  27179. SS_REFRACTION: boolean;
  27180. SS_TRANSLUCENCY: boolean;
  27181. SS_SCATTERING: boolean;
  27182. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27183. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27184. SS_REFRACTIONMAP_3D: boolean;
  27185. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27186. SS_LODINREFRACTIONALPHA: boolean;
  27187. SS_GAMMAREFRACTION: boolean;
  27188. SS_RGBDREFRACTION: boolean;
  27189. SS_LINEARSPECULARREFRACTION: boolean;
  27190. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27191. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27192. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27193. UNLIT: boolean;
  27194. DEBUGMODE: number;
  27195. /**
  27196. * Initializes the PBR Material defines.
  27197. */
  27198. constructor();
  27199. /**
  27200. * Resets the PBR Material defines.
  27201. */
  27202. reset(): void;
  27203. }
  27204. /**
  27205. * The Physically based material base class of BJS.
  27206. *
  27207. * This offers the main features of a standard PBR material.
  27208. * For more information, please refer to the documentation :
  27209. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27210. */
  27211. export abstract class PBRBaseMaterial extends PushMaterial {
  27212. /**
  27213. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27214. */
  27215. static readonly PBRMATERIAL_OPAQUE: number;
  27216. /**
  27217. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27218. */
  27219. static readonly PBRMATERIAL_ALPHATEST: number;
  27220. /**
  27221. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27222. */
  27223. static readonly PBRMATERIAL_ALPHABLEND: number;
  27224. /**
  27225. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27226. * They are also discarded below the alpha cutoff threshold to improve performances.
  27227. */
  27228. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27229. /**
  27230. * Defines the default value of how much AO map is occluding the analytical lights
  27231. * (point spot...).
  27232. */
  27233. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27234. /**
  27235. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27236. */
  27237. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27238. /**
  27239. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27240. * to enhance interoperability with other engines.
  27241. */
  27242. static readonly LIGHTFALLOFF_GLTF: number;
  27243. /**
  27244. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27245. * to enhance interoperability with other materials.
  27246. */
  27247. static readonly LIGHTFALLOFF_STANDARD: number;
  27248. /**
  27249. * Intensity of the direct lights e.g. the four lights available in your scene.
  27250. * This impacts both the direct diffuse and specular highlights.
  27251. */
  27252. protected _directIntensity: number;
  27253. /**
  27254. * Intensity of the emissive part of the material.
  27255. * This helps controlling the emissive effect without modifying the emissive color.
  27256. */
  27257. protected _emissiveIntensity: number;
  27258. /**
  27259. * Intensity of the environment e.g. how much the environment will light the object
  27260. * either through harmonics for rough material or through the refelction for shiny ones.
  27261. */
  27262. protected _environmentIntensity: number;
  27263. /**
  27264. * This is a special control allowing the reduction of the specular highlights coming from the
  27265. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27266. */
  27267. protected _specularIntensity: number;
  27268. /**
  27269. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27270. */
  27271. private _lightingInfos;
  27272. /**
  27273. * Debug Control allowing disabling the bump map on this material.
  27274. */
  27275. protected _disableBumpMap: boolean;
  27276. /**
  27277. * AKA Diffuse Texture in standard nomenclature.
  27278. */
  27279. protected _albedoTexture: Nullable<BaseTexture>;
  27280. /**
  27281. * AKA Occlusion Texture in other nomenclature.
  27282. */
  27283. protected _ambientTexture: Nullable<BaseTexture>;
  27284. /**
  27285. * AKA Occlusion Texture Intensity in other nomenclature.
  27286. */
  27287. protected _ambientTextureStrength: number;
  27288. /**
  27289. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27290. * 1 means it completely occludes it
  27291. * 0 mean it has no impact
  27292. */
  27293. protected _ambientTextureImpactOnAnalyticalLights: number;
  27294. /**
  27295. * Stores the alpha values in a texture.
  27296. */
  27297. protected _opacityTexture: Nullable<BaseTexture>;
  27298. /**
  27299. * Stores the reflection values in a texture.
  27300. */
  27301. protected _reflectionTexture: Nullable<BaseTexture>;
  27302. /**
  27303. * Stores the emissive values in a texture.
  27304. */
  27305. protected _emissiveTexture: Nullable<BaseTexture>;
  27306. /**
  27307. * AKA Specular texture in other nomenclature.
  27308. */
  27309. protected _reflectivityTexture: Nullable<BaseTexture>;
  27310. /**
  27311. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27312. */
  27313. protected _metallicTexture: Nullable<BaseTexture>;
  27314. /**
  27315. * Specifies the metallic scalar of the metallic/roughness workflow.
  27316. * Can also be used to scale the metalness values of the metallic texture.
  27317. */
  27318. protected _metallic: Nullable<number>;
  27319. /**
  27320. * Specifies the roughness scalar of the metallic/roughness workflow.
  27321. * Can also be used to scale the roughness values of the metallic texture.
  27322. */
  27323. protected _roughness: Nullable<number>;
  27324. /**
  27325. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27326. * By default the indexOfrefraction is used to compute F0;
  27327. *
  27328. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27329. *
  27330. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27331. * F90 = metallicReflectanceColor;
  27332. */
  27333. protected _metallicF0Factor: number;
  27334. /**
  27335. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27336. * By default the F90 is always 1;
  27337. *
  27338. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27339. *
  27340. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27341. * F90 = metallicReflectanceColor;
  27342. */
  27343. protected _metallicReflectanceColor: Color3;
  27344. /**
  27345. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27346. * This is multiply against the scalar values defined in the material.
  27347. */
  27348. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27349. /**
  27350. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27351. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27352. */
  27353. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27354. /**
  27355. * Stores surface normal data used to displace a mesh in a texture.
  27356. */
  27357. protected _bumpTexture: Nullable<BaseTexture>;
  27358. /**
  27359. * Stores the pre-calculated light information of a mesh in a texture.
  27360. */
  27361. protected _lightmapTexture: Nullable<BaseTexture>;
  27362. /**
  27363. * The color of a material in ambient lighting.
  27364. */
  27365. protected _ambientColor: Color3;
  27366. /**
  27367. * AKA Diffuse Color in other nomenclature.
  27368. */
  27369. protected _albedoColor: Color3;
  27370. /**
  27371. * AKA Specular Color in other nomenclature.
  27372. */
  27373. protected _reflectivityColor: Color3;
  27374. /**
  27375. * The color applied when light is reflected from a material.
  27376. */
  27377. protected _reflectionColor: Color3;
  27378. /**
  27379. * The color applied when light is emitted from a material.
  27380. */
  27381. protected _emissiveColor: Color3;
  27382. /**
  27383. * AKA Glossiness in other nomenclature.
  27384. */
  27385. protected _microSurface: number;
  27386. /**
  27387. * Specifies that the material will use the light map as a show map.
  27388. */
  27389. protected _useLightmapAsShadowmap: boolean;
  27390. /**
  27391. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27392. * makes the reflect vector face the model (under horizon).
  27393. */
  27394. protected _useHorizonOcclusion: boolean;
  27395. /**
  27396. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27397. * too much the area relying on ambient texture to define their ambient occlusion.
  27398. */
  27399. protected _useRadianceOcclusion: boolean;
  27400. /**
  27401. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27402. */
  27403. protected _useAlphaFromAlbedoTexture: boolean;
  27404. /**
  27405. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27406. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27407. */
  27408. protected _useSpecularOverAlpha: boolean;
  27409. /**
  27410. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27411. */
  27412. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27413. /**
  27414. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27415. */
  27416. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27417. /**
  27418. * Specifies if the metallic texture contains the roughness information in its green channel.
  27419. */
  27420. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27421. /**
  27422. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27423. */
  27424. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27425. /**
  27426. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27427. */
  27428. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27429. /**
  27430. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27431. */
  27432. protected _useAmbientInGrayScale: boolean;
  27433. /**
  27434. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27435. * The material will try to infer what glossiness each pixel should be.
  27436. */
  27437. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27438. /**
  27439. * Defines the falloff type used in this material.
  27440. * It by default is Physical.
  27441. */
  27442. protected _lightFalloff: number;
  27443. /**
  27444. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27445. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27446. */
  27447. protected _useRadianceOverAlpha: boolean;
  27448. /**
  27449. * Allows using an object space normal map (instead of tangent space).
  27450. */
  27451. protected _useObjectSpaceNormalMap: boolean;
  27452. /**
  27453. * Allows using the bump map in parallax mode.
  27454. */
  27455. protected _useParallax: boolean;
  27456. /**
  27457. * Allows using the bump map in parallax occlusion mode.
  27458. */
  27459. protected _useParallaxOcclusion: boolean;
  27460. /**
  27461. * Controls the scale bias of the parallax mode.
  27462. */
  27463. protected _parallaxScaleBias: number;
  27464. /**
  27465. * If sets to true, disables all the lights affecting the material.
  27466. */
  27467. protected _disableLighting: boolean;
  27468. /**
  27469. * Number of Simultaneous lights allowed on the material.
  27470. */
  27471. protected _maxSimultaneousLights: number;
  27472. /**
  27473. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27474. */
  27475. protected _invertNormalMapX: boolean;
  27476. /**
  27477. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27478. */
  27479. protected _invertNormalMapY: boolean;
  27480. /**
  27481. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27482. */
  27483. protected _twoSidedLighting: boolean;
  27484. /**
  27485. * Defines the alpha limits in alpha test mode.
  27486. */
  27487. protected _alphaCutOff: number;
  27488. /**
  27489. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27490. */
  27491. protected _forceAlphaTest: boolean;
  27492. /**
  27493. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27494. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27495. */
  27496. protected _useAlphaFresnel: boolean;
  27497. /**
  27498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27499. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27500. */
  27501. protected _useLinearAlphaFresnel: boolean;
  27502. /**
  27503. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27504. * from cos thetav and roughness:
  27505. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27506. */
  27507. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27508. /**
  27509. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27510. */
  27511. protected _forceIrradianceInFragment: boolean;
  27512. private _realTimeFiltering;
  27513. /**
  27514. * Enables realtime filtering on the texture.
  27515. */
  27516. get realTimeFiltering(): boolean;
  27517. set realTimeFiltering(b: boolean);
  27518. private _realTimeFilteringQuality;
  27519. /**
  27520. * Quality switch for realtime filtering
  27521. */
  27522. get realTimeFilteringQuality(): number;
  27523. set realTimeFilteringQuality(n: number);
  27524. /**
  27525. * Can this material render to several textures at once
  27526. */
  27527. get canRenderToMRT(): boolean;
  27528. /**
  27529. * Force normal to face away from face.
  27530. */
  27531. protected _forceNormalForward: boolean;
  27532. /**
  27533. * Enables specular anti aliasing in the PBR shader.
  27534. * It will both interacts on the Geometry for analytical and IBL lighting.
  27535. * It also prefilter the roughness map based on the bump values.
  27536. */
  27537. protected _enableSpecularAntiAliasing: boolean;
  27538. /**
  27539. * Default configuration related to image processing available in the PBR Material.
  27540. */
  27541. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27542. /**
  27543. * Keep track of the image processing observer to allow dispose and replace.
  27544. */
  27545. private _imageProcessingObserver;
  27546. /**
  27547. * Attaches a new image processing configuration to the PBR Material.
  27548. * @param configuration
  27549. */
  27550. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27551. /**
  27552. * Stores the available render targets.
  27553. */
  27554. private _renderTargets;
  27555. /**
  27556. * Sets the global ambient color for the material used in lighting calculations.
  27557. */
  27558. private _globalAmbientColor;
  27559. /**
  27560. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27561. */
  27562. private _useLogarithmicDepth;
  27563. /**
  27564. * If set to true, no lighting calculations will be applied.
  27565. */
  27566. private _unlit;
  27567. private _debugMode;
  27568. /**
  27569. * @hidden
  27570. * This is reserved for the inspector.
  27571. * Defines the material debug mode.
  27572. * It helps seeing only some components of the material while troubleshooting.
  27573. */
  27574. debugMode: number;
  27575. /**
  27576. * @hidden
  27577. * This is reserved for the inspector.
  27578. * Specify from where on screen the debug mode should start.
  27579. * The value goes from -1 (full screen) to 1 (not visible)
  27580. * It helps with side by side comparison against the final render
  27581. * This defaults to -1
  27582. */
  27583. private debugLimit;
  27584. /**
  27585. * @hidden
  27586. * This is reserved for the inspector.
  27587. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27588. * You can use the factor to better multiply the final value.
  27589. */
  27590. private debugFactor;
  27591. /**
  27592. * Defines the clear coat layer parameters for the material.
  27593. */
  27594. readonly clearCoat: PBRClearCoatConfiguration;
  27595. /**
  27596. * Defines the anisotropic parameters for the material.
  27597. */
  27598. readonly anisotropy: PBRAnisotropicConfiguration;
  27599. /**
  27600. * Defines the BRDF parameters for the material.
  27601. */
  27602. readonly brdf: PBRBRDFConfiguration;
  27603. /**
  27604. * Defines the Sheen parameters for the material.
  27605. */
  27606. readonly sheen: PBRSheenConfiguration;
  27607. /**
  27608. * Defines the SubSurface parameters for the material.
  27609. */
  27610. readonly subSurface: PBRSubSurfaceConfiguration;
  27611. /**
  27612. * Defines additionnal PrePass parameters for the material.
  27613. */
  27614. readonly prePassConfiguration: PrePassConfiguration;
  27615. /**
  27616. * Defines the detail map parameters for the material.
  27617. */
  27618. readonly detailMap: DetailMapConfiguration;
  27619. protected _rebuildInParallel: boolean;
  27620. /**
  27621. * Instantiates a new PBRMaterial instance.
  27622. *
  27623. * @param name The material name
  27624. * @param scene The scene the material will be use in.
  27625. */
  27626. constructor(name: string, scene: Scene);
  27627. /**
  27628. * Gets a boolean indicating that current material needs to register RTT
  27629. */
  27630. get hasRenderTargetTextures(): boolean;
  27631. /**
  27632. * Gets the name of the material class.
  27633. */
  27634. getClassName(): string;
  27635. /**
  27636. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27637. */
  27638. get useLogarithmicDepth(): boolean;
  27639. /**
  27640. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27641. */
  27642. set useLogarithmicDepth(value: boolean);
  27643. /**
  27644. * Returns true if alpha blending should be disabled.
  27645. */
  27646. protected get _disableAlphaBlending(): boolean;
  27647. /**
  27648. * Specifies whether or not this material should be rendered in alpha blend mode.
  27649. */
  27650. needAlphaBlending(): boolean;
  27651. /**
  27652. * Specifies whether or not this material should be rendered in alpha test mode.
  27653. */
  27654. needAlphaTesting(): boolean;
  27655. /**
  27656. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27657. */
  27658. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27659. /**
  27660. * Specifies whether or not there is a usable alpha channel for transparency.
  27661. */
  27662. protected _hasAlphaChannel(): boolean;
  27663. /**
  27664. * Gets the texture used for the alpha test.
  27665. */
  27666. getAlphaTestTexture(): Nullable<BaseTexture>;
  27667. /**
  27668. * Specifies that the submesh is ready to be used.
  27669. * @param mesh - BJS mesh.
  27670. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27671. * @param useInstances - Specifies that instances should be used.
  27672. * @returns - boolean indicating that the submesh is ready or not.
  27673. */
  27674. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27675. /**
  27676. * Specifies if the material uses metallic roughness workflow.
  27677. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27678. */
  27679. isMetallicWorkflow(): boolean;
  27680. private _prepareEffect;
  27681. private _prepareDefines;
  27682. /**
  27683. * Force shader compilation
  27684. */
  27685. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27686. /**
  27687. * Initializes the uniform buffer layout for the shader.
  27688. */
  27689. buildUniformLayout(): void;
  27690. /**
  27691. * Unbinds the material from the mesh
  27692. */
  27693. unbind(): void;
  27694. /**
  27695. * Binds the submesh data.
  27696. * @param world - The world matrix.
  27697. * @param mesh - The BJS mesh.
  27698. * @param subMesh - A submesh of the BJS mesh.
  27699. */
  27700. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27701. /**
  27702. * Returns the animatable textures.
  27703. * @returns - Array of animatable textures.
  27704. */
  27705. getAnimatables(): IAnimatable[];
  27706. /**
  27707. * Returns the texture used for reflections.
  27708. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27709. */
  27710. private _getReflectionTexture;
  27711. /**
  27712. * Returns an array of the actively used textures.
  27713. * @returns - Array of BaseTextures
  27714. */
  27715. getActiveTextures(): BaseTexture[];
  27716. /**
  27717. * Checks to see if a texture is used in the material.
  27718. * @param texture - Base texture to use.
  27719. * @returns - Boolean specifying if a texture is used in the material.
  27720. */
  27721. hasTexture(texture: BaseTexture): boolean;
  27722. /**
  27723. * Sets the required values to the prepass renderer.
  27724. * @param prePassRenderer defines the prepass renderer to setup
  27725. */
  27726. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27727. /**
  27728. * Disposes the resources of the material.
  27729. * @param forceDisposeEffect - Forces the disposal of effects.
  27730. * @param forceDisposeTextures - Forces the disposal of all textures.
  27731. */
  27732. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27733. }
  27734. }
  27735. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27736. import { Nullable } from "babylonjs/types";
  27737. import { Scene } from "babylonjs/scene";
  27738. import { Color3 } from "babylonjs/Maths/math.color";
  27739. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27740. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27742. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27743. /**
  27744. * The Physically based material of BJS.
  27745. *
  27746. * This offers the main features of a standard PBR material.
  27747. * For more information, please refer to the documentation :
  27748. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27749. */
  27750. export class PBRMaterial extends PBRBaseMaterial {
  27751. /**
  27752. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27753. */
  27754. static readonly PBRMATERIAL_OPAQUE: number;
  27755. /**
  27756. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27757. */
  27758. static readonly PBRMATERIAL_ALPHATEST: number;
  27759. /**
  27760. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27761. */
  27762. static readonly PBRMATERIAL_ALPHABLEND: number;
  27763. /**
  27764. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27765. * They are also discarded below the alpha cutoff threshold to improve performances.
  27766. */
  27767. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27768. /**
  27769. * Defines the default value of how much AO map is occluding the analytical lights
  27770. * (point spot...).
  27771. */
  27772. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27773. /**
  27774. * Intensity of the direct lights e.g. the four lights available in your scene.
  27775. * This impacts both the direct diffuse and specular highlights.
  27776. */
  27777. directIntensity: number;
  27778. /**
  27779. * Intensity of the emissive part of the material.
  27780. * This helps controlling the emissive effect without modifying the emissive color.
  27781. */
  27782. emissiveIntensity: number;
  27783. /**
  27784. * Intensity of the environment e.g. how much the environment will light the object
  27785. * either through harmonics for rough material or through the refelction for shiny ones.
  27786. */
  27787. environmentIntensity: number;
  27788. /**
  27789. * This is a special control allowing the reduction of the specular highlights coming from the
  27790. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27791. */
  27792. specularIntensity: number;
  27793. /**
  27794. * Debug Control allowing disabling the bump map on this material.
  27795. */
  27796. disableBumpMap: boolean;
  27797. /**
  27798. * AKA Diffuse Texture in standard nomenclature.
  27799. */
  27800. albedoTexture: BaseTexture;
  27801. /**
  27802. * AKA Occlusion Texture in other nomenclature.
  27803. */
  27804. ambientTexture: BaseTexture;
  27805. /**
  27806. * AKA Occlusion Texture Intensity in other nomenclature.
  27807. */
  27808. ambientTextureStrength: number;
  27809. /**
  27810. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27811. * 1 means it completely occludes it
  27812. * 0 mean it has no impact
  27813. */
  27814. ambientTextureImpactOnAnalyticalLights: number;
  27815. /**
  27816. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27817. */
  27818. opacityTexture: BaseTexture;
  27819. /**
  27820. * Stores the reflection values in a texture.
  27821. */
  27822. reflectionTexture: Nullable<BaseTexture>;
  27823. /**
  27824. * Stores the emissive values in a texture.
  27825. */
  27826. emissiveTexture: BaseTexture;
  27827. /**
  27828. * AKA Specular texture in other nomenclature.
  27829. */
  27830. reflectivityTexture: BaseTexture;
  27831. /**
  27832. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27833. */
  27834. metallicTexture: BaseTexture;
  27835. /**
  27836. * Specifies the metallic scalar of the metallic/roughness workflow.
  27837. * Can also be used to scale the metalness values of the metallic texture.
  27838. */
  27839. metallic: Nullable<number>;
  27840. /**
  27841. * Specifies the roughness scalar of the metallic/roughness workflow.
  27842. * Can also be used to scale the roughness values of the metallic texture.
  27843. */
  27844. roughness: Nullable<number>;
  27845. /**
  27846. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27847. * By default the indexOfrefraction is used to compute F0;
  27848. *
  27849. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27850. *
  27851. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27852. * F90 = metallicReflectanceColor;
  27853. */
  27854. metallicF0Factor: number;
  27855. /**
  27856. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27857. * By default the F90 is always 1;
  27858. *
  27859. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27860. *
  27861. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27862. * F90 = metallicReflectanceColor;
  27863. */
  27864. metallicReflectanceColor: Color3;
  27865. /**
  27866. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27867. * This is multiply against the scalar values defined in the material.
  27868. */
  27869. metallicReflectanceTexture: Nullable<BaseTexture>;
  27870. /**
  27871. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27872. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27873. */
  27874. microSurfaceTexture: BaseTexture;
  27875. /**
  27876. * Stores surface normal data used to displace a mesh in a texture.
  27877. */
  27878. bumpTexture: BaseTexture;
  27879. /**
  27880. * Stores the pre-calculated light information of a mesh in a texture.
  27881. */
  27882. lightmapTexture: BaseTexture;
  27883. /**
  27884. * Stores the refracted light information in a texture.
  27885. */
  27886. get refractionTexture(): Nullable<BaseTexture>;
  27887. set refractionTexture(value: Nullable<BaseTexture>);
  27888. /**
  27889. * The color of a material in ambient lighting.
  27890. */
  27891. ambientColor: Color3;
  27892. /**
  27893. * AKA Diffuse Color in other nomenclature.
  27894. */
  27895. albedoColor: Color3;
  27896. /**
  27897. * AKA Specular Color in other nomenclature.
  27898. */
  27899. reflectivityColor: Color3;
  27900. /**
  27901. * The color reflected from the material.
  27902. */
  27903. reflectionColor: Color3;
  27904. /**
  27905. * The color emitted from the material.
  27906. */
  27907. emissiveColor: Color3;
  27908. /**
  27909. * AKA Glossiness in other nomenclature.
  27910. */
  27911. microSurface: number;
  27912. /**
  27913. * Index of refraction of the material base layer.
  27914. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27915. *
  27916. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27917. *
  27918. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27919. */
  27920. get indexOfRefraction(): number;
  27921. set indexOfRefraction(value: number);
  27922. /**
  27923. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27924. */
  27925. get invertRefractionY(): boolean;
  27926. set invertRefractionY(value: boolean);
  27927. /**
  27928. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27929. * Materials half opaque for instance using refraction could benefit from this control.
  27930. */
  27931. get linkRefractionWithTransparency(): boolean;
  27932. set linkRefractionWithTransparency(value: boolean);
  27933. /**
  27934. * If true, the light map contains occlusion information instead of lighting info.
  27935. */
  27936. useLightmapAsShadowmap: boolean;
  27937. /**
  27938. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27939. */
  27940. useAlphaFromAlbedoTexture: boolean;
  27941. /**
  27942. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27943. */
  27944. forceAlphaTest: boolean;
  27945. /**
  27946. * Defines the alpha limits in alpha test mode.
  27947. */
  27948. alphaCutOff: number;
  27949. /**
  27950. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27951. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27952. */
  27953. useSpecularOverAlpha: boolean;
  27954. /**
  27955. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27956. */
  27957. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27958. /**
  27959. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27960. */
  27961. useRoughnessFromMetallicTextureAlpha: boolean;
  27962. /**
  27963. * Specifies if the metallic texture contains the roughness information in its green channel.
  27964. */
  27965. useRoughnessFromMetallicTextureGreen: boolean;
  27966. /**
  27967. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27968. */
  27969. useMetallnessFromMetallicTextureBlue: boolean;
  27970. /**
  27971. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27972. */
  27973. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27974. /**
  27975. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27976. */
  27977. useAmbientInGrayScale: boolean;
  27978. /**
  27979. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27980. * The material will try to infer what glossiness each pixel should be.
  27981. */
  27982. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27983. /**
  27984. * BJS is using an harcoded light falloff based on a manually sets up range.
  27985. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27986. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27987. */
  27988. get usePhysicalLightFalloff(): boolean;
  27989. /**
  27990. * BJS is using an harcoded light falloff based on a manually sets up range.
  27991. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27992. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27993. */
  27994. set usePhysicalLightFalloff(value: boolean);
  27995. /**
  27996. * In order to support the falloff compatibility with gltf, a special mode has been added
  27997. * to reproduce the gltf light falloff.
  27998. */
  27999. get useGLTFLightFalloff(): boolean;
  28000. /**
  28001. * In order to support the falloff compatibility with gltf, a special mode has been added
  28002. * to reproduce the gltf light falloff.
  28003. */
  28004. set useGLTFLightFalloff(value: boolean);
  28005. /**
  28006. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28007. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28008. */
  28009. useRadianceOverAlpha: boolean;
  28010. /**
  28011. * Allows using an object space normal map (instead of tangent space).
  28012. */
  28013. useObjectSpaceNormalMap: boolean;
  28014. /**
  28015. * Allows using the bump map in parallax mode.
  28016. */
  28017. useParallax: boolean;
  28018. /**
  28019. * Allows using the bump map in parallax occlusion mode.
  28020. */
  28021. useParallaxOcclusion: boolean;
  28022. /**
  28023. * Controls the scale bias of the parallax mode.
  28024. */
  28025. parallaxScaleBias: number;
  28026. /**
  28027. * If sets to true, disables all the lights affecting the material.
  28028. */
  28029. disableLighting: boolean;
  28030. /**
  28031. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28032. */
  28033. forceIrradianceInFragment: boolean;
  28034. /**
  28035. * Number of Simultaneous lights allowed on the material.
  28036. */
  28037. maxSimultaneousLights: number;
  28038. /**
  28039. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28040. */
  28041. invertNormalMapX: boolean;
  28042. /**
  28043. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28044. */
  28045. invertNormalMapY: boolean;
  28046. /**
  28047. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28048. */
  28049. twoSidedLighting: boolean;
  28050. /**
  28051. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28052. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28053. */
  28054. useAlphaFresnel: boolean;
  28055. /**
  28056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28057. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28058. */
  28059. useLinearAlphaFresnel: boolean;
  28060. /**
  28061. * Let user defines the brdf lookup texture used for IBL.
  28062. * A default 8bit version is embedded but you could point at :
  28063. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28064. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28065. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28066. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28067. */
  28068. environmentBRDFTexture: Nullable<BaseTexture>;
  28069. /**
  28070. * Force normal to face away from face.
  28071. */
  28072. forceNormalForward: boolean;
  28073. /**
  28074. * Enables specular anti aliasing in the PBR shader.
  28075. * It will both interacts on the Geometry for analytical and IBL lighting.
  28076. * It also prefilter the roughness map based on the bump values.
  28077. */
  28078. enableSpecularAntiAliasing: boolean;
  28079. /**
  28080. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28081. * makes the reflect vector face the model (under horizon).
  28082. */
  28083. useHorizonOcclusion: boolean;
  28084. /**
  28085. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28086. * too much the area relying on ambient texture to define their ambient occlusion.
  28087. */
  28088. useRadianceOcclusion: boolean;
  28089. /**
  28090. * If set to true, no lighting calculations will be applied.
  28091. */
  28092. unlit: boolean;
  28093. /**
  28094. * Gets the image processing configuration used either in this material.
  28095. */
  28096. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28097. /**
  28098. * Sets the Default image processing configuration used either in the this material.
  28099. *
  28100. * If sets to null, the scene one is in use.
  28101. */
  28102. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28103. /**
  28104. * Gets wether the color curves effect is enabled.
  28105. */
  28106. get cameraColorCurvesEnabled(): boolean;
  28107. /**
  28108. * Sets wether the color curves effect is enabled.
  28109. */
  28110. set cameraColorCurvesEnabled(value: boolean);
  28111. /**
  28112. * Gets wether the color grading effect is enabled.
  28113. */
  28114. get cameraColorGradingEnabled(): boolean;
  28115. /**
  28116. * Gets wether the color grading effect is enabled.
  28117. */
  28118. set cameraColorGradingEnabled(value: boolean);
  28119. /**
  28120. * Gets wether tonemapping is enabled or not.
  28121. */
  28122. get cameraToneMappingEnabled(): boolean;
  28123. /**
  28124. * Sets wether tonemapping is enabled or not
  28125. */
  28126. set cameraToneMappingEnabled(value: boolean);
  28127. /**
  28128. * The camera exposure used on this material.
  28129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28130. * This corresponds to a photographic exposure.
  28131. */
  28132. get cameraExposure(): number;
  28133. /**
  28134. * The camera exposure used on this material.
  28135. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28136. * This corresponds to a photographic exposure.
  28137. */
  28138. set cameraExposure(value: number);
  28139. /**
  28140. * Gets The camera contrast used on this material.
  28141. */
  28142. get cameraContrast(): number;
  28143. /**
  28144. * Sets The camera contrast used on this material.
  28145. */
  28146. set cameraContrast(value: number);
  28147. /**
  28148. * Gets the Color Grading 2D Lookup Texture.
  28149. */
  28150. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28151. /**
  28152. * Sets the Color Grading 2D Lookup Texture.
  28153. */
  28154. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28155. /**
  28156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28158. * 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;
  28159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28160. */
  28161. get cameraColorCurves(): Nullable<ColorCurves>;
  28162. /**
  28163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28165. * 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;
  28166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28167. */
  28168. set cameraColorCurves(value: Nullable<ColorCurves>);
  28169. /**
  28170. * Instantiates a new PBRMaterial instance.
  28171. *
  28172. * @param name The material name
  28173. * @param scene The scene the material will be use in.
  28174. */
  28175. constructor(name: string, scene: Scene);
  28176. /**
  28177. * Returns the name of this material class.
  28178. */
  28179. getClassName(): string;
  28180. /**
  28181. * Makes a duplicate of the current material.
  28182. * @param name - name to use for the new material.
  28183. */
  28184. clone(name: string): PBRMaterial;
  28185. /**
  28186. * Serializes this PBR Material.
  28187. * @returns - An object with the serialized material.
  28188. */
  28189. serialize(): any;
  28190. /**
  28191. * Parses a PBR Material from a serialized object.
  28192. * @param source - Serialized object.
  28193. * @param scene - BJS scene instance.
  28194. * @param rootUrl - url for the scene object
  28195. * @returns - PBRMaterial
  28196. */
  28197. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28198. }
  28199. }
  28200. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28201. /** @hidden */
  28202. export var mrtFragmentDeclaration: {
  28203. name: string;
  28204. shader: string;
  28205. };
  28206. }
  28207. declare module "babylonjs/Shaders/geometry.fragment" {
  28208. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28209. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28210. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28211. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28212. /** @hidden */
  28213. export var geometryPixelShader: {
  28214. name: string;
  28215. shader: string;
  28216. };
  28217. }
  28218. declare module "babylonjs/Shaders/geometry.vertex" {
  28219. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28221. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28222. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28223. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28224. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28225. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28226. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28227. /** @hidden */
  28228. export var geometryVertexShader: {
  28229. name: string;
  28230. shader: string;
  28231. };
  28232. }
  28233. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28234. import { Matrix } from "babylonjs/Maths/math.vector";
  28235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28237. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28238. import { Effect } from "babylonjs/Materials/effect";
  28239. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28240. import { Scene } from "babylonjs/scene";
  28241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28242. import { Nullable } from "babylonjs/types";
  28243. import "babylonjs/Shaders/geometry.fragment";
  28244. import "babylonjs/Shaders/geometry.vertex";
  28245. /** @hidden */
  28246. interface ISavedTransformationMatrix {
  28247. world: Matrix;
  28248. viewProjection: Matrix;
  28249. }
  28250. /**
  28251. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28252. */
  28253. export class GeometryBufferRenderer {
  28254. /**
  28255. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28256. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28257. */
  28258. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28259. /**
  28260. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28261. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28262. */
  28263. static readonly POSITION_TEXTURE_TYPE: number;
  28264. /**
  28265. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28266. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28267. */
  28268. static readonly VELOCITY_TEXTURE_TYPE: number;
  28269. /**
  28270. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28271. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28272. */
  28273. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28274. /**
  28275. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28276. * in order to compute objects velocities when enableVelocity is set to "true"
  28277. * @hidden
  28278. */
  28279. _previousTransformationMatrices: {
  28280. [index: number]: ISavedTransformationMatrix;
  28281. };
  28282. /**
  28283. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28284. * in order to compute objects velocities when enableVelocity is set to "true"
  28285. * @hidden
  28286. */
  28287. _previousBonesTransformationMatrices: {
  28288. [index: number]: Float32Array;
  28289. };
  28290. /**
  28291. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28292. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28293. */
  28294. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28295. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28296. renderTransparentMeshes: boolean;
  28297. private _scene;
  28298. private _resizeObserver;
  28299. private _multiRenderTarget;
  28300. private _ratio;
  28301. private _enablePosition;
  28302. private _enableVelocity;
  28303. private _enableReflectivity;
  28304. private _positionIndex;
  28305. private _velocityIndex;
  28306. private _reflectivityIndex;
  28307. private _depthNormalIndex;
  28308. private _linkedWithPrePass;
  28309. private _prePassRenderer;
  28310. private _attachments;
  28311. protected _effect: Effect;
  28312. protected _cachedDefines: string;
  28313. /**
  28314. * @hidden
  28315. * Sets up internal structures to share outputs with PrePassRenderer
  28316. * This method should only be called by the PrePassRenderer itself
  28317. */
  28318. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28319. /**
  28320. * @hidden
  28321. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28322. * This method should only be called by the PrePassRenderer itself
  28323. */
  28324. _unlinkPrePassRenderer(): void;
  28325. /**
  28326. * @hidden
  28327. * Resets the geometry buffer layout
  28328. */
  28329. _resetLayout(): void;
  28330. /**
  28331. * @hidden
  28332. * Replaces a texture in the geometry buffer renderer
  28333. * Useful when linking textures of the prepass renderer
  28334. */
  28335. _forceTextureType(geometryBufferType: number, index: number): void;
  28336. /**
  28337. * @hidden
  28338. * Sets texture attachments
  28339. * Useful when linking textures of the prepass renderer
  28340. */
  28341. _setAttachments(attachments: number[]): void;
  28342. /**
  28343. * @hidden
  28344. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28345. * Useful when linking textures of the prepass renderer
  28346. */
  28347. _linkInternalTexture(internalTexture: InternalTexture): void;
  28348. /**
  28349. * Gets the render list (meshes to be rendered) used in the G buffer.
  28350. */
  28351. get renderList(): Nullable<AbstractMesh[]>;
  28352. /**
  28353. * Set the render list (meshes to be rendered) used in the G buffer.
  28354. */
  28355. set renderList(meshes: Nullable<AbstractMesh[]>);
  28356. /**
  28357. * Gets wether or not G buffer are supported by the running hardware.
  28358. * This requires draw buffer supports
  28359. */
  28360. get isSupported(): boolean;
  28361. /**
  28362. * Returns the index of the given texture type in the G-Buffer textures array
  28363. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28364. * @returns the index of the given texture type in the G-Buffer textures array
  28365. */
  28366. getTextureIndex(textureType: number): number;
  28367. /**
  28368. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28369. */
  28370. get enablePosition(): boolean;
  28371. /**
  28372. * Sets whether or not objects positions are enabled for the G buffer.
  28373. */
  28374. set enablePosition(enable: boolean);
  28375. /**
  28376. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28377. */
  28378. get enableVelocity(): boolean;
  28379. /**
  28380. * Sets wether or not objects velocities are enabled for the G buffer.
  28381. */
  28382. set enableVelocity(enable: boolean);
  28383. /**
  28384. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28385. */
  28386. get enableReflectivity(): boolean;
  28387. /**
  28388. * Sets wether or not objects roughness are enabled for the G buffer.
  28389. */
  28390. set enableReflectivity(enable: boolean);
  28391. /**
  28392. * Gets the scene associated with the buffer.
  28393. */
  28394. get scene(): Scene;
  28395. /**
  28396. * Gets the ratio used by the buffer during its creation.
  28397. * How big is the buffer related to the main canvas.
  28398. */
  28399. get ratio(): number;
  28400. /** @hidden */
  28401. static _SceneComponentInitialization: (scene: Scene) => void;
  28402. /**
  28403. * Creates a new G Buffer for the scene
  28404. * @param scene The scene the buffer belongs to
  28405. * @param ratio How big is the buffer related to the main canvas.
  28406. */
  28407. constructor(scene: Scene, ratio?: number);
  28408. /**
  28409. * Checks wether everything is ready to render a submesh to the G buffer.
  28410. * @param subMesh the submesh to check readiness for
  28411. * @param useInstances is the mesh drawn using instance or not
  28412. * @returns true if ready otherwise false
  28413. */
  28414. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28415. /**
  28416. * Gets the current underlying G Buffer.
  28417. * @returns the buffer
  28418. */
  28419. getGBuffer(): MultiRenderTarget;
  28420. /**
  28421. * Gets the number of samples used to render the buffer (anti aliasing).
  28422. */
  28423. get samples(): number;
  28424. /**
  28425. * Sets the number of samples used to render the buffer (anti aliasing).
  28426. */
  28427. set samples(value: number);
  28428. /**
  28429. * Disposes the renderer and frees up associated resources.
  28430. */
  28431. dispose(): void;
  28432. private _assignRenderTargetIndices;
  28433. protected _createRenderTargets(): void;
  28434. private _copyBonesTransformationMatrices;
  28435. }
  28436. }
  28437. declare module "babylonjs/Rendering/prePassRenderer" {
  28438. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28439. import { Scene } from "babylonjs/scene";
  28440. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28441. import { Effect } from "babylonjs/Materials/effect";
  28442. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28444. import { Material } from "babylonjs/Materials/material";
  28445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28446. /**
  28447. * Renders a pre pass of the scene
  28448. * This means every mesh in the scene will be rendered to a render target texture
  28449. * And then this texture will be composited to the rendering canvas with post processes
  28450. * It is necessary for effects like subsurface scattering or deferred shading
  28451. */
  28452. export class PrePassRenderer {
  28453. /** @hidden */
  28454. static _SceneComponentInitialization: (scene: Scene) => void;
  28455. private _textureFormats;
  28456. /**
  28457. * To save performance, we can excluded skinned meshes from the prepass
  28458. */
  28459. excludedSkinnedMesh: AbstractMesh[];
  28460. /**
  28461. * Force material to be excluded from the prepass
  28462. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28463. * and you don't want a material to show in the effect.
  28464. */
  28465. excludedMaterials: Material[];
  28466. private _textureIndices;
  28467. private _scene;
  28468. private _engine;
  28469. private _isDirty;
  28470. /**
  28471. * Number of textures in the multi render target texture where the scene is directly rendered
  28472. */
  28473. mrtCount: number;
  28474. /**
  28475. * The render target where the scene is directly rendered
  28476. */
  28477. prePassRT: MultiRenderTarget;
  28478. private _multiRenderAttachments;
  28479. private _defaultAttachments;
  28480. private _clearAttachments;
  28481. private _postProcesses;
  28482. private readonly _clearColor;
  28483. /**
  28484. * Image processing post process for composition
  28485. */
  28486. imageProcessingPostProcess: ImageProcessingPostProcess;
  28487. /**
  28488. * Configuration for prepass effects
  28489. */
  28490. private _effectConfigurations;
  28491. private _mrtFormats;
  28492. private _mrtLayout;
  28493. private _enabled;
  28494. /**
  28495. * Indicates if the prepass is enabled
  28496. */
  28497. get enabled(): boolean;
  28498. /**
  28499. * How many samples are used for MSAA of the scene render target
  28500. */
  28501. get samples(): number;
  28502. set samples(n: number);
  28503. private _geometryBuffer;
  28504. private _useGeometryBufferFallback;
  28505. /**
  28506. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28507. */
  28508. get useGeometryBufferFallback(): boolean;
  28509. set useGeometryBufferFallback(value: boolean);
  28510. /**
  28511. * Instanciates a prepass renderer
  28512. * @param scene The scene
  28513. */
  28514. constructor(scene: Scene);
  28515. private _initializeAttachments;
  28516. private _createCompositionEffect;
  28517. /**
  28518. * Indicates if rendering a prepass is supported
  28519. */
  28520. get isSupported(): boolean;
  28521. /**
  28522. * Sets the proper output textures to draw in the engine.
  28523. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28524. * @param subMesh Submesh on which the effect is applied
  28525. */
  28526. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28527. /**
  28528. * @hidden
  28529. */
  28530. _beforeCameraDraw(): void;
  28531. /**
  28532. * @hidden
  28533. */
  28534. _afterCameraDraw(): void;
  28535. private _checkRTSize;
  28536. private _bindFrameBuffer;
  28537. /**
  28538. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28539. */
  28540. clear(): void;
  28541. private _setState;
  28542. private _updateGeometryBufferLayout;
  28543. /**
  28544. * Adds an effect configuration to the prepass.
  28545. * If an effect has already been added, it won't add it twice and will return the configuration
  28546. * already present.
  28547. * @param cfg the effect configuration
  28548. * @return the effect configuration now used by the prepass
  28549. */
  28550. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28551. /**
  28552. * Returns the index of a texture in the multi render target texture array.
  28553. * @param type Texture type
  28554. * @return The index
  28555. */
  28556. getIndex(type: number): number;
  28557. private _enable;
  28558. private _disable;
  28559. private _resetLayout;
  28560. private _resetPostProcessChain;
  28561. private _bindPostProcessChain;
  28562. /**
  28563. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28564. */
  28565. markAsDirty(): void;
  28566. /**
  28567. * Enables a texture on the MultiRenderTarget for prepass
  28568. */
  28569. private _enableTextures;
  28570. private _update;
  28571. private _markAllMaterialsAsPrePassDirty;
  28572. /**
  28573. * Disposes the prepass renderer.
  28574. */
  28575. dispose(): void;
  28576. }
  28577. }
  28578. declare module "babylonjs/PostProcesses/postProcess" {
  28579. import { Nullable } from "babylonjs/types";
  28580. import { SmartArray } from "babylonjs/Misc/smartArray";
  28581. import { Observable } from "babylonjs/Misc/observable";
  28582. import { Vector2 } from "babylonjs/Maths/math.vector";
  28583. import { Camera } from "babylonjs/Cameras/camera";
  28584. import { Effect } from "babylonjs/Materials/effect";
  28585. import "babylonjs/Shaders/postprocess.vertex";
  28586. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28587. import { Engine } from "babylonjs/Engines/engine";
  28588. import { Color4 } from "babylonjs/Maths/math.color";
  28589. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28590. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28591. import { Scene } from "babylonjs/scene";
  28592. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28593. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28594. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28595. /**
  28596. * Size options for a post process
  28597. */
  28598. export type PostProcessOptions = {
  28599. width: number;
  28600. height: number;
  28601. };
  28602. /**
  28603. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28604. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28605. */
  28606. export class PostProcess {
  28607. /**
  28608. * Gets or sets the unique id of the post process
  28609. */
  28610. uniqueId: number;
  28611. /** Name of the PostProcess. */
  28612. name: string;
  28613. /**
  28614. * Width of the texture to apply the post process on
  28615. */
  28616. width: number;
  28617. /**
  28618. * Height of the texture to apply the post process on
  28619. */
  28620. height: number;
  28621. /**
  28622. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28623. */
  28624. nodeMaterialSource: Nullable<NodeMaterial>;
  28625. /**
  28626. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28627. * @hidden
  28628. */
  28629. _outputTexture: Nullable<InternalTexture>;
  28630. /**
  28631. * Sampling mode used by the shader
  28632. * See https://doc.babylonjs.com/classes/3.1/texture
  28633. */
  28634. renderTargetSamplingMode: number;
  28635. /**
  28636. * Clear color to use when screen clearing
  28637. */
  28638. clearColor: Color4;
  28639. /**
  28640. * If the buffer needs to be cleared before applying the post process. (default: true)
  28641. * Should be set to false if shader will overwrite all previous pixels.
  28642. */
  28643. autoClear: boolean;
  28644. /**
  28645. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28646. */
  28647. alphaMode: number;
  28648. /**
  28649. * Sets the setAlphaBlendConstants of the babylon engine
  28650. */
  28651. alphaConstants: Color4;
  28652. /**
  28653. * Animations to be used for the post processing
  28654. */
  28655. animations: import("babylonjs/Animations/animation").Animation[];
  28656. /**
  28657. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28658. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28659. */
  28660. enablePixelPerfectMode: boolean;
  28661. /**
  28662. * Force the postprocess to be applied without taking in account viewport
  28663. */
  28664. forceFullscreenViewport: boolean;
  28665. /**
  28666. * List of inspectable custom properties (used by the Inspector)
  28667. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28668. */
  28669. inspectableCustomProperties: IInspectable[];
  28670. /**
  28671. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28672. *
  28673. * | Value | Type | Description |
  28674. * | ----- | ----------------------------------- | ----------- |
  28675. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28676. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28677. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28678. *
  28679. */
  28680. scaleMode: number;
  28681. /**
  28682. * Force textures to be a power of two (default: false)
  28683. */
  28684. alwaysForcePOT: boolean;
  28685. private _samples;
  28686. /**
  28687. * Number of sample textures (default: 1)
  28688. */
  28689. get samples(): number;
  28690. set samples(n: number);
  28691. /**
  28692. * Modify the scale of the post process to be the same as the viewport (default: false)
  28693. */
  28694. adaptScaleToCurrentViewport: boolean;
  28695. private _camera;
  28696. protected _scene: Scene;
  28697. private _engine;
  28698. private _options;
  28699. private _reusable;
  28700. private _textureType;
  28701. private _textureFormat;
  28702. /**
  28703. * Smart array of input and output textures for the post process.
  28704. * @hidden
  28705. */
  28706. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28707. /**
  28708. * The index in _textures that corresponds to the output texture.
  28709. * @hidden
  28710. */
  28711. _currentRenderTextureInd: number;
  28712. private _effect;
  28713. private _samplers;
  28714. private _fragmentUrl;
  28715. private _vertexUrl;
  28716. private _parameters;
  28717. private _scaleRatio;
  28718. protected _indexParameters: any;
  28719. private _shareOutputWithPostProcess;
  28720. private _texelSize;
  28721. private _forcedOutputTexture;
  28722. /**
  28723. * Prepass configuration in case this post process needs a texture from prepass
  28724. * @hidden
  28725. */
  28726. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28727. /**
  28728. * Returns the fragment url or shader name used in the post process.
  28729. * @returns the fragment url or name in the shader store.
  28730. */
  28731. getEffectName(): string;
  28732. /**
  28733. * An event triggered when the postprocess is activated.
  28734. */
  28735. onActivateObservable: Observable<Camera>;
  28736. private _onActivateObserver;
  28737. /**
  28738. * A function that is added to the onActivateObservable
  28739. */
  28740. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28741. /**
  28742. * An event triggered when the postprocess changes its size.
  28743. */
  28744. onSizeChangedObservable: Observable<PostProcess>;
  28745. private _onSizeChangedObserver;
  28746. /**
  28747. * A function that is added to the onSizeChangedObservable
  28748. */
  28749. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28750. /**
  28751. * An event triggered when the postprocess applies its effect.
  28752. */
  28753. onApplyObservable: Observable<Effect>;
  28754. private _onApplyObserver;
  28755. /**
  28756. * A function that is added to the onApplyObservable
  28757. */
  28758. set onApply(callback: (effect: Effect) => void);
  28759. /**
  28760. * An event triggered before rendering the postprocess
  28761. */
  28762. onBeforeRenderObservable: Observable<Effect>;
  28763. private _onBeforeRenderObserver;
  28764. /**
  28765. * A function that is added to the onBeforeRenderObservable
  28766. */
  28767. set onBeforeRender(callback: (effect: Effect) => void);
  28768. /**
  28769. * An event triggered after rendering the postprocess
  28770. */
  28771. onAfterRenderObservable: Observable<Effect>;
  28772. private _onAfterRenderObserver;
  28773. /**
  28774. * A function that is added to the onAfterRenderObservable
  28775. */
  28776. set onAfterRender(callback: (efect: Effect) => void);
  28777. /**
  28778. * 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
  28779. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28780. */
  28781. get inputTexture(): InternalTexture;
  28782. set inputTexture(value: InternalTexture);
  28783. /**
  28784. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28785. * the only way to unset it is to use this function to restore its internal state
  28786. */
  28787. restoreDefaultInputTexture(): void;
  28788. /**
  28789. * Gets the camera which post process is applied to.
  28790. * @returns The camera the post process is applied to.
  28791. */
  28792. getCamera(): Camera;
  28793. /**
  28794. * Gets the texel size of the postprocess.
  28795. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28796. */
  28797. get texelSize(): Vector2;
  28798. /**
  28799. * Creates a new instance PostProcess
  28800. * @param name The name of the PostProcess.
  28801. * @param fragmentUrl The url of the fragment shader to be used.
  28802. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28803. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28804. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28805. * @param camera The camera to apply the render pass to.
  28806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28807. * @param engine The engine which the post process will be applied. (default: current engine)
  28808. * @param reusable If the post process can be reused on the same frame. (default: false)
  28809. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28810. * @param textureType Type of textures used when performing the post process. (default: 0)
  28811. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28812. * @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
  28813. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28814. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28815. */
  28816. 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);
  28817. /**
  28818. * Gets a string identifying the name of the class
  28819. * @returns "PostProcess" string
  28820. */
  28821. getClassName(): string;
  28822. /**
  28823. * Gets the engine which this post process belongs to.
  28824. * @returns The engine the post process was enabled with.
  28825. */
  28826. getEngine(): Engine;
  28827. /**
  28828. * The effect that is created when initializing the post process.
  28829. * @returns The created effect corresponding the the postprocess.
  28830. */
  28831. getEffect(): Effect;
  28832. /**
  28833. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28834. * @param postProcess The post process to share the output with.
  28835. * @returns This post process.
  28836. */
  28837. shareOutputWith(postProcess: PostProcess): PostProcess;
  28838. /**
  28839. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28840. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28841. */
  28842. useOwnOutput(): void;
  28843. /**
  28844. * Updates the effect with the current post process compile time values and recompiles the shader.
  28845. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28846. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28847. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28848. * @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
  28849. * @param onCompiled Called when the shader has been compiled.
  28850. * @param onError Called if there is an error when compiling a shader.
  28851. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28852. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28853. */
  28854. 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;
  28855. /**
  28856. * The post process is reusable if it can be used multiple times within one frame.
  28857. * @returns If the post process is reusable
  28858. */
  28859. isReusable(): boolean;
  28860. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28861. markTextureDirty(): void;
  28862. /**
  28863. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28864. * 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.
  28865. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28866. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28867. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28868. * @returns The target texture that was bound to be written to.
  28869. */
  28870. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28871. /**
  28872. * If the post process is supported.
  28873. */
  28874. get isSupported(): boolean;
  28875. /**
  28876. * The aspect ratio of the output texture.
  28877. */
  28878. get aspectRatio(): number;
  28879. /**
  28880. * Get a value indicating if the post-process is ready to be used
  28881. * @returns true if the post-process is ready (shader is compiled)
  28882. */
  28883. isReady(): boolean;
  28884. /**
  28885. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28886. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28887. */
  28888. apply(): Nullable<Effect>;
  28889. private _disposeTextures;
  28890. /**
  28891. * Sets the required values to the prepass renderer.
  28892. * @param prePassRenderer defines the prepass renderer to setup.
  28893. * @returns true if the pre pass is needed.
  28894. */
  28895. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28896. /**
  28897. * Disposes the post process.
  28898. * @param camera The camera to dispose the post process on.
  28899. */
  28900. dispose(camera?: Camera): void;
  28901. /**
  28902. * Serializes the particle system to a JSON object
  28903. * @returns the JSON object
  28904. */
  28905. serialize(): any;
  28906. /**
  28907. * Creates a material from parsed material data
  28908. * @param parsedPostProcess defines parsed post process data
  28909. * @param scene defines the hosting scene
  28910. * @param rootUrl defines the root URL to use to load textures
  28911. * @returns a new post process
  28912. */
  28913. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28914. }
  28915. }
  28916. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28917. /** @hidden */
  28918. export var kernelBlurVaryingDeclaration: {
  28919. name: string;
  28920. shader: string;
  28921. };
  28922. }
  28923. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28924. /** @hidden */
  28925. export var kernelBlurFragment: {
  28926. name: string;
  28927. shader: string;
  28928. };
  28929. }
  28930. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28931. /** @hidden */
  28932. export var kernelBlurFragment2: {
  28933. name: string;
  28934. shader: string;
  28935. };
  28936. }
  28937. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28938. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28939. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28940. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28941. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28942. /** @hidden */
  28943. export var kernelBlurPixelShader: {
  28944. name: string;
  28945. shader: string;
  28946. };
  28947. }
  28948. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28949. /** @hidden */
  28950. export var kernelBlurVertex: {
  28951. name: string;
  28952. shader: string;
  28953. };
  28954. }
  28955. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28956. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28957. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28958. /** @hidden */
  28959. export var kernelBlurVertexShader: {
  28960. name: string;
  28961. shader: string;
  28962. };
  28963. }
  28964. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28965. import { Vector2 } from "babylonjs/Maths/math.vector";
  28966. import { Nullable } from "babylonjs/types";
  28967. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28968. import { Camera } from "babylonjs/Cameras/camera";
  28969. import { Effect } from "babylonjs/Materials/effect";
  28970. import { Engine } from "babylonjs/Engines/engine";
  28971. import "babylonjs/Shaders/kernelBlur.fragment";
  28972. import "babylonjs/Shaders/kernelBlur.vertex";
  28973. import { Scene } from "babylonjs/scene";
  28974. /**
  28975. * The Blur Post Process which blurs an image based on a kernel and direction.
  28976. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28977. */
  28978. export class BlurPostProcess extends PostProcess {
  28979. private blockCompilation;
  28980. protected _kernel: number;
  28981. protected _idealKernel: number;
  28982. protected _packedFloat: boolean;
  28983. private _staticDefines;
  28984. /** The direction in which to blur the image. */
  28985. direction: Vector2;
  28986. /**
  28987. * Sets the length in pixels of the blur sample region
  28988. */
  28989. set kernel(v: number);
  28990. /**
  28991. * Gets the length in pixels of the blur sample region
  28992. */
  28993. get kernel(): number;
  28994. /**
  28995. * Sets wether or not the blur needs to unpack/repack floats
  28996. */
  28997. set packedFloat(v: boolean);
  28998. /**
  28999. * Gets wether or not the blur is unpacking/repacking floats
  29000. */
  29001. get packedFloat(): boolean;
  29002. /**
  29003. * Gets a string identifying the name of the class
  29004. * @returns "BlurPostProcess" string
  29005. */
  29006. getClassName(): string;
  29007. /**
  29008. * Creates a new instance BlurPostProcess
  29009. * @param name The name of the effect.
  29010. * @param direction The direction in which to blur the image.
  29011. * @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.
  29012. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29013. * @param camera The camera to apply the render pass to.
  29014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29015. * @param engine The engine which the post process will be applied. (default: current engine)
  29016. * @param reusable If the post process can be reused on the same frame. (default: false)
  29017. * @param textureType Type of textures used when performing the post process. (default: 0)
  29018. * @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)
  29019. */
  29020. 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);
  29021. /**
  29022. * Updates the effect with the current post process compile time values and recompiles the shader.
  29023. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29024. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29025. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29026. * @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
  29027. * @param onCompiled Called when the shader has been compiled.
  29028. * @param onError Called if there is an error when compiling a shader.
  29029. */
  29030. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29031. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29032. /**
  29033. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29034. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29035. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29036. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29037. * The gaps between physical kernels are compensated for in the weighting of the samples
  29038. * @param idealKernel Ideal blur kernel.
  29039. * @return Nearest best kernel.
  29040. */
  29041. protected _nearestBestKernel(idealKernel: number): number;
  29042. /**
  29043. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29044. * @param x The point on the Gaussian distribution to sample.
  29045. * @return the value of the Gaussian function at x.
  29046. */
  29047. protected _gaussianWeight(x: number): number;
  29048. /**
  29049. * Generates a string that can be used as a floating point number in GLSL.
  29050. * @param x Value to print.
  29051. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29052. * @return GLSL float string.
  29053. */
  29054. protected _glslFloat(x: number, decimalFigures?: number): string;
  29055. /** @hidden */
  29056. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29057. }
  29058. }
  29059. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29060. import { Scene } from "babylonjs/scene";
  29061. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29062. import { Plane } from "babylonjs/Maths/math.plane";
  29063. /**
  29064. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29065. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29066. * You can then easily use it as a reflectionTexture on a flat surface.
  29067. * In case the surface is not a plane, please consider relying on reflection probes.
  29068. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29069. */
  29070. export class MirrorTexture extends RenderTargetTexture {
  29071. private scene;
  29072. /**
  29073. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29074. * 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.
  29075. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29076. */
  29077. mirrorPlane: Plane;
  29078. /**
  29079. * Define the blur ratio used to blur the reflection if needed.
  29080. */
  29081. set blurRatio(value: number);
  29082. get blurRatio(): number;
  29083. /**
  29084. * Define the adaptive blur kernel used to blur the reflection if needed.
  29085. * This will autocompute the closest best match for the `blurKernel`
  29086. */
  29087. set adaptiveBlurKernel(value: number);
  29088. /**
  29089. * Define the blur kernel used to blur the reflection if needed.
  29090. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29091. */
  29092. set blurKernel(value: number);
  29093. /**
  29094. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29095. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29096. */
  29097. set blurKernelX(value: number);
  29098. get blurKernelX(): number;
  29099. /**
  29100. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29101. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29102. */
  29103. set blurKernelY(value: number);
  29104. get blurKernelY(): number;
  29105. private _autoComputeBlurKernel;
  29106. protected _onRatioRescale(): void;
  29107. private _updateGammaSpace;
  29108. private _imageProcessingConfigChangeObserver;
  29109. private _transformMatrix;
  29110. private _mirrorMatrix;
  29111. private _savedViewMatrix;
  29112. private _blurX;
  29113. private _blurY;
  29114. private _adaptiveBlurKernel;
  29115. private _blurKernelX;
  29116. private _blurKernelY;
  29117. private _blurRatio;
  29118. /**
  29119. * Instantiates a Mirror Texture.
  29120. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29121. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29122. * You can then easily use it as a reflectionTexture on a flat surface.
  29123. * In case the surface is not a plane, please consider relying on reflection probes.
  29124. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29125. * @param name
  29126. * @param size
  29127. * @param scene
  29128. * @param generateMipMaps
  29129. * @param type
  29130. * @param samplingMode
  29131. * @param generateDepthBuffer
  29132. */
  29133. constructor(name: string, size: number | {
  29134. width: number;
  29135. height: number;
  29136. } | {
  29137. ratio: number;
  29138. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29139. private _preparePostProcesses;
  29140. /**
  29141. * Clone the mirror texture.
  29142. * @returns the cloned texture
  29143. */
  29144. clone(): MirrorTexture;
  29145. /**
  29146. * Serialize the texture to a JSON representation you could use in Parse later on
  29147. * @returns the serialized JSON representation
  29148. */
  29149. serialize(): any;
  29150. /**
  29151. * Dispose the texture and release its associated resources.
  29152. */
  29153. dispose(): void;
  29154. }
  29155. }
  29156. declare module "babylonjs/Materials/Textures/texture" {
  29157. import { Observable } from "babylonjs/Misc/observable";
  29158. import { Nullable } from "babylonjs/types";
  29159. import { Matrix } from "babylonjs/Maths/math.vector";
  29160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29161. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29162. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29163. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29164. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29165. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29166. import { Scene } from "babylonjs/scene";
  29167. /**
  29168. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29169. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29170. */
  29171. export class Texture extends BaseTexture {
  29172. /**
  29173. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29174. */
  29175. static SerializeBuffers: boolean;
  29176. /** @hidden */
  29177. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29178. /** @hidden */
  29179. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29180. /** @hidden */
  29181. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29182. /** nearest is mag = nearest and min = nearest and mip = linear */
  29183. static readonly NEAREST_SAMPLINGMODE: number;
  29184. /** nearest is mag = nearest and min = nearest and mip = linear */
  29185. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29187. static readonly BILINEAR_SAMPLINGMODE: number;
  29188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29189. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29190. /** Trilinear is mag = linear and min = linear and mip = linear */
  29191. static readonly TRILINEAR_SAMPLINGMODE: number;
  29192. /** Trilinear is mag = linear and min = linear and mip = linear */
  29193. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29194. /** mag = nearest and min = nearest and mip = nearest */
  29195. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29196. /** mag = nearest and min = linear and mip = nearest */
  29197. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29198. /** mag = nearest and min = linear and mip = linear */
  29199. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29200. /** mag = nearest and min = linear and mip = none */
  29201. static readonly NEAREST_LINEAR: number;
  29202. /** mag = nearest and min = nearest and mip = none */
  29203. static readonly NEAREST_NEAREST: number;
  29204. /** mag = linear and min = nearest and mip = nearest */
  29205. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29206. /** mag = linear and min = nearest and mip = linear */
  29207. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29208. /** mag = linear and min = linear and mip = none */
  29209. static readonly LINEAR_LINEAR: number;
  29210. /** mag = linear and min = nearest and mip = none */
  29211. static readonly LINEAR_NEAREST: number;
  29212. /** Explicit coordinates mode */
  29213. static readonly EXPLICIT_MODE: number;
  29214. /** Spherical coordinates mode */
  29215. static readonly SPHERICAL_MODE: number;
  29216. /** Planar coordinates mode */
  29217. static readonly PLANAR_MODE: number;
  29218. /** Cubic coordinates mode */
  29219. static readonly CUBIC_MODE: number;
  29220. /** Projection coordinates mode */
  29221. static readonly PROJECTION_MODE: number;
  29222. /** Inverse Cubic coordinates mode */
  29223. static readonly SKYBOX_MODE: number;
  29224. /** Inverse Cubic coordinates mode */
  29225. static readonly INVCUBIC_MODE: number;
  29226. /** Equirectangular coordinates mode */
  29227. static readonly EQUIRECTANGULAR_MODE: number;
  29228. /** Equirectangular Fixed coordinates mode */
  29229. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29230. /** Equirectangular Fixed Mirrored coordinates mode */
  29231. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29232. /** Texture is not repeating outside of 0..1 UVs */
  29233. static readonly CLAMP_ADDRESSMODE: number;
  29234. /** Texture is repeating outside of 0..1 UVs */
  29235. static readonly WRAP_ADDRESSMODE: number;
  29236. /** Texture is repeating and mirrored */
  29237. static readonly MIRROR_ADDRESSMODE: number;
  29238. /**
  29239. * 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
  29240. */
  29241. static UseSerializedUrlIfAny: boolean;
  29242. /**
  29243. * Define the url of the texture.
  29244. */
  29245. url: Nullable<string>;
  29246. /**
  29247. * Define an offset on the texture to offset the u coordinates of the UVs
  29248. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29249. */
  29250. uOffset: number;
  29251. /**
  29252. * Define an offset on the texture to offset the v coordinates of the UVs
  29253. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29254. */
  29255. vOffset: number;
  29256. /**
  29257. * Define an offset on the texture to scale the u coordinates of the UVs
  29258. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29259. */
  29260. uScale: number;
  29261. /**
  29262. * Define an offset on the texture to scale the v coordinates of the UVs
  29263. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29264. */
  29265. vScale: number;
  29266. /**
  29267. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29268. * @see https://doc.babylonjs.com/how_to/more_materials
  29269. */
  29270. uAng: number;
  29271. /**
  29272. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29273. * @see https://doc.babylonjs.com/how_to/more_materials
  29274. */
  29275. vAng: number;
  29276. /**
  29277. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29278. * @see https://doc.babylonjs.com/how_to/more_materials
  29279. */
  29280. wAng: number;
  29281. /**
  29282. * Defines the center of rotation (U)
  29283. */
  29284. uRotationCenter: number;
  29285. /**
  29286. * Defines the center of rotation (V)
  29287. */
  29288. vRotationCenter: number;
  29289. /**
  29290. * Defines the center of rotation (W)
  29291. */
  29292. wRotationCenter: number;
  29293. /**
  29294. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29295. */
  29296. homogeneousRotationInUVTransform: boolean;
  29297. /**
  29298. * Are mip maps generated for this texture or not.
  29299. */
  29300. get noMipmap(): boolean;
  29301. /**
  29302. * List of inspectable custom properties (used by the Inspector)
  29303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29304. */
  29305. inspectableCustomProperties: Nullable<IInspectable[]>;
  29306. private _noMipmap;
  29307. /** @hidden */
  29308. _invertY: boolean;
  29309. private _rowGenerationMatrix;
  29310. private _cachedTextureMatrix;
  29311. private _projectionModeMatrix;
  29312. private _t0;
  29313. private _t1;
  29314. private _t2;
  29315. private _cachedUOffset;
  29316. private _cachedVOffset;
  29317. private _cachedUScale;
  29318. private _cachedVScale;
  29319. private _cachedUAng;
  29320. private _cachedVAng;
  29321. private _cachedWAng;
  29322. private _cachedProjectionMatrixId;
  29323. private _cachedURotationCenter;
  29324. private _cachedVRotationCenter;
  29325. private _cachedWRotationCenter;
  29326. private _cachedHomogeneousRotationInUVTransform;
  29327. private _cachedCoordinatesMode;
  29328. /** @hidden */
  29329. protected _initialSamplingMode: number;
  29330. /** @hidden */
  29331. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29332. private _deleteBuffer;
  29333. protected _format: Nullable<number>;
  29334. private _delayedOnLoad;
  29335. private _delayedOnError;
  29336. private _mimeType?;
  29337. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29338. get mimeType(): string | undefined;
  29339. /**
  29340. * Observable triggered once the texture has been loaded.
  29341. */
  29342. onLoadObservable: Observable<Texture>;
  29343. protected _isBlocking: boolean;
  29344. /**
  29345. * Is the texture preventing material to render while loading.
  29346. * If false, a default texture will be used instead of the loading one during the preparation step.
  29347. */
  29348. set isBlocking(value: boolean);
  29349. get isBlocking(): boolean;
  29350. /**
  29351. * Get the current sampling mode associated with the texture.
  29352. */
  29353. get samplingMode(): number;
  29354. /**
  29355. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29356. */
  29357. get invertY(): boolean;
  29358. /**
  29359. * Instantiates a new texture.
  29360. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29361. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29362. * @param url defines the url of the picture to load as a texture
  29363. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29364. * @param noMipmap defines if the texture will require mip maps or not
  29365. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29366. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29367. * @param onLoad defines a callback triggered when the texture has been loaded
  29368. * @param onError defines a callback triggered when an error occurred during the loading session
  29369. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29370. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29371. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29372. * @param mimeType defines an optional mime type information
  29373. */
  29374. 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);
  29375. /**
  29376. * Update the url (and optional buffer) of this texture if url was null during construction.
  29377. * @param url the url of the texture
  29378. * @param buffer the buffer of the texture (defaults to null)
  29379. * @param onLoad callback called when the texture is loaded (defaults to null)
  29380. */
  29381. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29382. /**
  29383. * Finish the loading sequence of a texture flagged as delayed load.
  29384. * @hidden
  29385. */
  29386. delayLoad(): void;
  29387. private _prepareRowForTextureGeneration;
  29388. /**
  29389. * Checks if the texture has the same transform matrix than another texture
  29390. * @param texture texture to check against
  29391. * @returns true if the transforms are the same, else false
  29392. */
  29393. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29394. /**
  29395. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29396. * @returns the transform matrix of the texture.
  29397. */
  29398. getTextureMatrix(uBase?: number): Matrix;
  29399. /**
  29400. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29401. * @returns The reflection texture transform
  29402. */
  29403. getReflectionTextureMatrix(): Matrix;
  29404. /**
  29405. * Clones the texture.
  29406. * @returns the cloned texture
  29407. */
  29408. clone(): Texture;
  29409. /**
  29410. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29411. * @returns The JSON representation of the texture
  29412. */
  29413. serialize(): any;
  29414. /**
  29415. * Get the current class name of the texture useful for serialization or dynamic coding.
  29416. * @returns "Texture"
  29417. */
  29418. getClassName(): string;
  29419. /**
  29420. * Dispose the texture and release its associated resources.
  29421. */
  29422. dispose(): void;
  29423. /**
  29424. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29425. * @param parsedTexture Define the JSON representation of the texture
  29426. * @param scene Define the scene the parsed texture should be instantiated in
  29427. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29428. * @returns The parsed texture if successful
  29429. */
  29430. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29431. /**
  29432. * Creates a texture from its base 64 representation.
  29433. * @param data Define the base64 payload without the data: prefix
  29434. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29435. * @param scene Define the scene the texture should belong to
  29436. * @param noMipmap Forces the texture to not create mip map information if true
  29437. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29438. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29439. * @param onLoad define a callback triggered when the texture has been loaded
  29440. * @param onError define a callback triggered when an error occurred during the loading session
  29441. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29442. * @returns the created texture
  29443. */
  29444. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29445. /**
  29446. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29447. * @param data Define the base64 payload without the data: prefix
  29448. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29449. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29450. * @param scene Define the scene the texture should belong to
  29451. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29452. * @param noMipmap Forces the texture to not create mip map information if true
  29453. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29454. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29455. * @param onLoad define a callback triggered when the texture has been loaded
  29456. * @param onError define a callback triggered when an error occurred during the loading session
  29457. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29458. * @returns the created texture
  29459. */
  29460. 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;
  29461. }
  29462. }
  29463. declare module "babylonjs/PostProcesses/postProcessManager" {
  29464. import { Nullable } from "babylonjs/types";
  29465. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29466. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29467. import { Scene } from "babylonjs/scene";
  29468. /**
  29469. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29470. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29471. */
  29472. export class PostProcessManager {
  29473. private _scene;
  29474. private _indexBuffer;
  29475. private _vertexBuffers;
  29476. /**
  29477. * Creates a new instance PostProcess
  29478. * @param scene The scene that the post process is associated with.
  29479. */
  29480. constructor(scene: Scene);
  29481. private _prepareBuffers;
  29482. private _buildIndexBuffer;
  29483. /**
  29484. * Rebuilds the vertex buffers of the manager.
  29485. * @hidden
  29486. */
  29487. _rebuild(): void;
  29488. /**
  29489. * Prepares a frame to be run through a post process.
  29490. * @param sourceTexture The input texture to the post procesess. (default: null)
  29491. * @param postProcesses An array of post processes to be run. (default: null)
  29492. * @returns True if the post processes were able to be run.
  29493. * @hidden
  29494. */
  29495. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29496. /**
  29497. * Manually render a set of post processes to a texture.
  29498. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29499. * @param postProcesses An array of post processes to be run.
  29500. * @param targetTexture The target texture to render to.
  29501. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29502. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29503. * @param lodLevel defines which lod of the texture to render to
  29504. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29505. */
  29506. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29507. /**
  29508. * Finalize the result of the output of the postprocesses.
  29509. * @param doNotPresent If true the result will not be displayed to the screen.
  29510. * @param targetTexture The target texture to render to.
  29511. * @param faceIndex The index of the face to bind the target texture to.
  29512. * @param postProcesses The array of post processes to render.
  29513. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29514. * @hidden
  29515. */
  29516. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29517. /**
  29518. * Disposes of the post process manager.
  29519. */
  29520. dispose(): void;
  29521. }
  29522. }
  29523. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29524. import { Observable } from "babylonjs/Misc/observable";
  29525. import { SmartArray } from "babylonjs/Misc/smartArray";
  29526. import { Nullable, Immutable } from "babylonjs/types";
  29527. import { Camera } from "babylonjs/Cameras/camera";
  29528. import { Scene } from "babylonjs/scene";
  29529. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29530. import { Color4 } from "babylonjs/Maths/math.color";
  29531. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29533. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29534. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29535. import { Texture } from "babylonjs/Materials/Textures/texture";
  29536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29537. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29538. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29539. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29540. import { Engine } from "babylonjs/Engines/engine";
  29541. /**
  29542. * This Helps creating a texture that will be created from a camera in your scene.
  29543. * It is basically a dynamic texture that could be used to create special effects for instance.
  29544. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29545. */
  29546. export class RenderTargetTexture extends Texture {
  29547. /**
  29548. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29549. */
  29550. static readonly REFRESHRATE_RENDER_ONCE: number;
  29551. /**
  29552. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29553. */
  29554. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29555. /**
  29556. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29557. * the central point of your effect and can save a lot of performances.
  29558. */
  29559. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29560. /**
  29561. * Use this predicate to dynamically define the list of mesh you want to render.
  29562. * If set, the renderList property will be overwritten.
  29563. */
  29564. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29565. private _renderList;
  29566. /**
  29567. * Use this list to define the list of mesh you want to render.
  29568. */
  29569. get renderList(): Nullable<Array<AbstractMesh>>;
  29570. set renderList(value: Nullable<Array<AbstractMesh>>);
  29571. /**
  29572. * Use this function to overload the renderList array at rendering time.
  29573. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29574. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29575. * the cube (if the RTT is a cube, else layerOrFace=0).
  29576. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29577. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29578. * hold dummy elements!
  29579. */
  29580. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29581. private _hookArray;
  29582. /**
  29583. * Define if particles should be rendered in your texture.
  29584. */
  29585. renderParticles: boolean;
  29586. /**
  29587. * Define if sprites should be rendered in your texture.
  29588. */
  29589. renderSprites: boolean;
  29590. /**
  29591. * Define the camera used to render the texture.
  29592. */
  29593. activeCamera: Nullable<Camera>;
  29594. /**
  29595. * Override the mesh isReady function with your own one.
  29596. */
  29597. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29598. /**
  29599. * Override the render function of the texture with your own one.
  29600. */
  29601. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29602. /**
  29603. * Define if camera post processes should be use while rendering the texture.
  29604. */
  29605. useCameraPostProcesses: boolean;
  29606. /**
  29607. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29608. */
  29609. ignoreCameraViewport: boolean;
  29610. private _postProcessManager;
  29611. private _postProcesses;
  29612. private _resizeObserver;
  29613. /**
  29614. * An event triggered when the texture is unbind.
  29615. */
  29616. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29617. /**
  29618. * An event triggered when the texture is unbind.
  29619. */
  29620. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29621. private _onAfterUnbindObserver;
  29622. /**
  29623. * Set a after unbind callback in the texture.
  29624. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29625. */
  29626. set onAfterUnbind(callback: () => void);
  29627. /**
  29628. * An event triggered before rendering the texture
  29629. */
  29630. onBeforeRenderObservable: Observable<number>;
  29631. private _onBeforeRenderObserver;
  29632. /**
  29633. * Set a before render callback in the texture.
  29634. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29635. */
  29636. set onBeforeRender(callback: (faceIndex: number) => void);
  29637. /**
  29638. * An event triggered after rendering the texture
  29639. */
  29640. onAfterRenderObservable: Observable<number>;
  29641. private _onAfterRenderObserver;
  29642. /**
  29643. * Set a after render callback in the texture.
  29644. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29645. */
  29646. set onAfterRender(callback: (faceIndex: number) => void);
  29647. /**
  29648. * An event triggered after the texture clear
  29649. */
  29650. onClearObservable: Observable<Engine>;
  29651. private _onClearObserver;
  29652. /**
  29653. * Set a clear callback in the texture.
  29654. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29655. */
  29656. set onClear(callback: (Engine: Engine) => void);
  29657. /**
  29658. * An event triggered when the texture is resized.
  29659. */
  29660. onResizeObservable: Observable<RenderTargetTexture>;
  29661. /**
  29662. * Define the clear color of the Render Target if it should be different from the scene.
  29663. */
  29664. clearColor: Color4;
  29665. protected _size: number | {
  29666. width: number;
  29667. height: number;
  29668. layers?: number;
  29669. };
  29670. protected _initialSizeParameter: number | {
  29671. width: number;
  29672. height: number;
  29673. } | {
  29674. ratio: number;
  29675. };
  29676. protected _sizeRatio: Nullable<number>;
  29677. /** @hidden */
  29678. _generateMipMaps: boolean;
  29679. protected _renderingManager: RenderingManager;
  29680. /** @hidden */
  29681. _waitingRenderList?: string[];
  29682. protected _doNotChangeAspectRatio: boolean;
  29683. protected _currentRefreshId: number;
  29684. protected _refreshRate: number;
  29685. protected _textureMatrix: Matrix;
  29686. protected _samples: number;
  29687. protected _renderTargetOptions: RenderTargetCreationOptions;
  29688. /**
  29689. * Gets render target creation options that were used.
  29690. */
  29691. get renderTargetOptions(): RenderTargetCreationOptions;
  29692. protected _onRatioRescale(): void;
  29693. /**
  29694. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29695. * It must define where the camera used to render the texture is set
  29696. */
  29697. boundingBoxPosition: Vector3;
  29698. private _boundingBoxSize;
  29699. /**
  29700. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29701. * When defined, the cubemap will switch to local mode
  29702. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29703. * @example https://www.babylonjs-playground.com/#RNASML
  29704. */
  29705. set boundingBoxSize(value: Vector3);
  29706. get boundingBoxSize(): Vector3;
  29707. /**
  29708. * In case the RTT has been created with a depth texture, get the associated
  29709. * depth texture.
  29710. * Otherwise, return null.
  29711. */
  29712. get depthStencilTexture(): Nullable<InternalTexture>;
  29713. /**
  29714. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29715. * or used a shadow, depth texture...
  29716. * @param name The friendly name of the texture
  29717. * @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)
  29718. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29719. * @param generateMipMaps True if mip maps need to be generated after render.
  29720. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29721. * @param type The type of the buffer in the RTT (int, half float, float...)
  29722. * @param isCube True if a cube texture needs to be created
  29723. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29724. * @param generateDepthBuffer True to generate a depth buffer
  29725. * @param generateStencilBuffer True to generate a stencil buffer
  29726. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29727. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29728. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29729. */
  29730. constructor(name: string, size: number | {
  29731. width: number;
  29732. height: number;
  29733. layers?: number;
  29734. } | {
  29735. ratio: number;
  29736. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29737. /**
  29738. * Creates a depth stencil texture.
  29739. * This is only available in WebGL 2 or with the depth texture extension available.
  29740. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29741. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29742. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29743. */
  29744. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29745. private _processSizeParameter;
  29746. /**
  29747. * Define the number of samples to use in case of MSAA.
  29748. * It defaults to one meaning no MSAA has been enabled.
  29749. */
  29750. get samples(): number;
  29751. set samples(value: number);
  29752. /**
  29753. * Resets the refresh counter of the texture and start bak from scratch.
  29754. * Could be useful to regenerate the texture if it is setup to render only once.
  29755. */
  29756. resetRefreshCounter(): void;
  29757. /**
  29758. * Define the refresh rate of the texture or the rendering frequency.
  29759. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29760. */
  29761. get refreshRate(): number;
  29762. set refreshRate(value: number);
  29763. /**
  29764. * Adds a post process to the render target rendering passes.
  29765. * @param postProcess define the post process to add
  29766. */
  29767. addPostProcess(postProcess: PostProcess): void;
  29768. /**
  29769. * Clear all the post processes attached to the render target
  29770. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29771. */
  29772. clearPostProcesses(dispose?: boolean): void;
  29773. /**
  29774. * Remove one of the post process from the list of attached post processes to the texture
  29775. * @param postProcess define the post process to remove from the list
  29776. */
  29777. removePostProcess(postProcess: PostProcess): void;
  29778. /** @hidden */
  29779. _shouldRender(): boolean;
  29780. /**
  29781. * Gets the actual render size of the texture.
  29782. * @returns the width of the render size
  29783. */
  29784. getRenderSize(): number;
  29785. /**
  29786. * Gets the actual render width of the texture.
  29787. * @returns the width of the render size
  29788. */
  29789. getRenderWidth(): number;
  29790. /**
  29791. * Gets the actual render height of the texture.
  29792. * @returns the height of the render size
  29793. */
  29794. getRenderHeight(): number;
  29795. /**
  29796. * Gets the actual number of layers of the texture.
  29797. * @returns the number of layers
  29798. */
  29799. getRenderLayers(): number;
  29800. /**
  29801. * Get if the texture can be rescaled or not.
  29802. */
  29803. get canRescale(): boolean;
  29804. /**
  29805. * Resize the texture using a ratio.
  29806. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29807. */
  29808. scale(ratio: number): void;
  29809. /**
  29810. * Get the texture reflection matrix used to rotate/transform the reflection.
  29811. * @returns the reflection matrix
  29812. */
  29813. getReflectionTextureMatrix(): Matrix;
  29814. /**
  29815. * Resize the texture to a new desired size.
  29816. * Be carrefull as it will recreate all the data in the new texture.
  29817. * @param size Define the new size. It can be:
  29818. * - a number for squared texture,
  29819. * - an object containing { width: number, height: number }
  29820. * - or an object containing a ratio { ratio: number }
  29821. */
  29822. resize(size: number | {
  29823. width: number;
  29824. height: number;
  29825. } | {
  29826. ratio: number;
  29827. }): void;
  29828. private _defaultRenderListPrepared;
  29829. /**
  29830. * Renders all the objects from the render list into the texture.
  29831. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29832. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29833. */
  29834. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29835. private _bestReflectionRenderTargetDimension;
  29836. private _prepareRenderingManager;
  29837. /**
  29838. * @hidden
  29839. * @param faceIndex face index to bind to if this is a cubetexture
  29840. * @param layer defines the index of the texture to bind in the array
  29841. */
  29842. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29843. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29844. private renderToTarget;
  29845. /**
  29846. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29847. * This allowed control for front to back rendering or reversly depending of the special needs.
  29848. *
  29849. * @param renderingGroupId The rendering group id corresponding to its index
  29850. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29851. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29852. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29853. */
  29854. 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;
  29855. /**
  29856. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29857. *
  29858. * @param renderingGroupId The rendering group id corresponding to its index
  29859. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29860. */
  29861. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29862. /**
  29863. * Clones the texture.
  29864. * @returns the cloned texture
  29865. */
  29866. clone(): RenderTargetTexture;
  29867. /**
  29868. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29869. * @returns The JSON representation of the texture
  29870. */
  29871. serialize(): any;
  29872. /**
  29873. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29874. */
  29875. disposeFramebufferObjects(): void;
  29876. /**
  29877. * Dispose the texture and release its associated resources.
  29878. */
  29879. dispose(): void;
  29880. /** @hidden */
  29881. _rebuild(): void;
  29882. /**
  29883. * Clear the info related to rendering groups preventing retention point in material dispose.
  29884. */
  29885. freeRenderingGroups(): void;
  29886. /**
  29887. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29888. * @returns the view count
  29889. */
  29890. getViewCount(): number;
  29891. }
  29892. }
  29893. declare module "babylonjs/Misc/guid" {
  29894. /**
  29895. * Class used to manipulate GUIDs
  29896. */
  29897. export class GUID {
  29898. /**
  29899. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29900. * Be aware Math.random() could cause collisions, but:
  29901. * "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"
  29902. * @returns a pseudo random id
  29903. */
  29904. static RandomId(): string;
  29905. }
  29906. }
  29907. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29908. import { Nullable } from "babylonjs/types";
  29909. import { Scene } from "babylonjs/scene";
  29910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29911. import { Material } from "babylonjs/Materials/material";
  29912. import { Effect } from "babylonjs/Materials/effect";
  29913. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29914. /**
  29915. * Options to be used when creating a shadow depth material
  29916. */
  29917. export interface IIOptionShadowDepthMaterial {
  29918. /** Variables in the vertex shader code that need to have their names remapped.
  29919. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29920. * "var_name" should be either: worldPos or vNormalW
  29921. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29922. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29923. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29924. */
  29925. remappedVariables?: string[];
  29926. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29927. standalone?: boolean;
  29928. }
  29929. /**
  29930. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29931. */
  29932. export class ShadowDepthWrapper {
  29933. private _scene;
  29934. private _options?;
  29935. private _baseMaterial;
  29936. private _onEffectCreatedObserver;
  29937. private _subMeshToEffect;
  29938. private _subMeshToDepthEffect;
  29939. private _meshes;
  29940. /** @hidden */
  29941. _matriceNames: any;
  29942. /** Gets the standalone status of the wrapper */
  29943. get standalone(): boolean;
  29944. /** Gets the base material the wrapper is built upon */
  29945. get baseMaterial(): Material;
  29946. /**
  29947. * Instantiate a new shadow depth wrapper.
  29948. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29949. * generate the shadow depth map. For more information, please refer to the documentation:
  29950. * https://doc.babylonjs.com/babylon101/shadows
  29951. * @param baseMaterial Material to wrap
  29952. * @param scene Define the scene the material belongs to
  29953. * @param options Options used to create the wrapper
  29954. */
  29955. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29956. /**
  29957. * Gets the effect to use to generate the depth map
  29958. * @param subMesh subMesh to get the effect for
  29959. * @param shadowGenerator shadow generator to get the effect for
  29960. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29961. */
  29962. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29963. /**
  29964. * Specifies that the submesh is ready to be used for depth rendering
  29965. * @param subMesh submesh to check
  29966. * @param defines the list of defines to take into account when checking the effect
  29967. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29968. * @param useInstances specifies that instances should be used
  29969. * @returns a boolean indicating that the submesh is ready or not
  29970. */
  29971. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29972. /**
  29973. * Disposes the resources
  29974. */
  29975. dispose(): void;
  29976. private _makeEffect;
  29977. }
  29978. }
  29979. declare module "babylonjs/Materials/material" {
  29980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29981. import { SmartArray } from "babylonjs/Misc/smartArray";
  29982. import { Observable } from "babylonjs/Misc/observable";
  29983. import { Nullable } from "babylonjs/types";
  29984. import { Scene } from "babylonjs/scene";
  29985. import { Matrix } from "babylonjs/Maths/math.vector";
  29986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29989. import { Effect } from "babylonjs/Materials/effect";
  29990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29992. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29993. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29994. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  29995. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  29996. import { Mesh } from "babylonjs/Meshes/mesh";
  29997. import { Animation } from "babylonjs/Animations/animation";
  29998. /**
  29999. * Options for compiling materials.
  30000. */
  30001. export interface IMaterialCompilationOptions {
  30002. /**
  30003. * Defines whether clip planes are enabled.
  30004. */
  30005. clipPlane: boolean;
  30006. /**
  30007. * Defines whether instances are enabled.
  30008. */
  30009. useInstances: boolean;
  30010. }
  30011. /**
  30012. * Options passed when calling customShaderNameResolve
  30013. */
  30014. export interface ICustomShaderNameResolveOptions {
  30015. /**
  30016. * 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
  30017. */
  30018. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30019. }
  30020. /**
  30021. * Base class for the main features of a material in Babylon.js
  30022. */
  30023. export class Material implements IAnimatable {
  30024. /**
  30025. * Returns the triangle fill mode
  30026. */
  30027. static readonly TriangleFillMode: number;
  30028. /**
  30029. * Returns the wireframe mode
  30030. */
  30031. static readonly WireFrameFillMode: number;
  30032. /**
  30033. * Returns the point fill mode
  30034. */
  30035. static readonly PointFillMode: number;
  30036. /**
  30037. * Returns the point list draw mode
  30038. */
  30039. static readonly PointListDrawMode: number;
  30040. /**
  30041. * Returns the line list draw mode
  30042. */
  30043. static readonly LineListDrawMode: number;
  30044. /**
  30045. * Returns the line loop draw mode
  30046. */
  30047. static readonly LineLoopDrawMode: number;
  30048. /**
  30049. * Returns the line strip draw mode
  30050. */
  30051. static readonly LineStripDrawMode: number;
  30052. /**
  30053. * Returns the triangle strip draw mode
  30054. */
  30055. static readonly TriangleStripDrawMode: number;
  30056. /**
  30057. * Returns the triangle fan draw mode
  30058. */
  30059. static readonly TriangleFanDrawMode: number;
  30060. /**
  30061. * Stores the clock-wise side orientation
  30062. */
  30063. static readonly ClockWiseSideOrientation: number;
  30064. /**
  30065. * Stores the counter clock-wise side orientation
  30066. */
  30067. static readonly CounterClockWiseSideOrientation: number;
  30068. /**
  30069. * The dirty texture flag value
  30070. */
  30071. static readonly TextureDirtyFlag: number;
  30072. /**
  30073. * The dirty light flag value
  30074. */
  30075. static readonly LightDirtyFlag: number;
  30076. /**
  30077. * The dirty fresnel flag value
  30078. */
  30079. static readonly FresnelDirtyFlag: number;
  30080. /**
  30081. * The dirty attribute flag value
  30082. */
  30083. static readonly AttributesDirtyFlag: number;
  30084. /**
  30085. * The dirty misc flag value
  30086. */
  30087. static readonly MiscDirtyFlag: number;
  30088. /**
  30089. * The dirty prepass flag value
  30090. */
  30091. static readonly PrePassDirtyFlag: number;
  30092. /**
  30093. * The all dirty flag value
  30094. */
  30095. static readonly AllDirtyFlag: number;
  30096. /**
  30097. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30098. */
  30099. static readonly MATERIAL_OPAQUE: number;
  30100. /**
  30101. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30102. */
  30103. static readonly MATERIAL_ALPHATEST: number;
  30104. /**
  30105. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30106. */
  30107. static readonly MATERIAL_ALPHABLEND: number;
  30108. /**
  30109. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30110. * They are also discarded below the alpha cutoff threshold to improve performances.
  30111. */
  30112. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30113. /**
  30114. * The Whiteout method is used to blend normals.
  30115. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30116. */
  30117. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30118. /**
  30119. * The Reoriented Normal Mapping method is used to blend normals.
  30120. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30121. */
  30122. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30123. /**
  30124. * Custom callback helping to override the default shader used in the material.
  30125. */
  30126. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30127. /**
  30128. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30129. */
  30130. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30131. /**
  30132. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30133. * This means that the material can keep using a previous shader while a new one is being compiled.
  30134. * This is mostly used when shader parallel compilation is supported (true by default)
  30135. */
  30136. allowShaderHotSwapping: boolean;
  30137. /**
  30138. * The ID of the material
  30139. */
  30140. id: string;
  30141. /**
  30142. * Gets or sets the unique id of the material
  30143. */
  30144. uniqueId: number;
  30145. /**
  30146. * The name of the material
  30147. */
  30148. name: string;
  30149. /**
  30150. * Gets or sets user defined metadata
  30151. */
  30152. metadata: any;
  30153. /**
  30154. * For internal use only. Please do not use.
  30155. */
  30156. reservedDataStore: any;
  30157. /**
  30158. * Specifies if the ready state should be checked on each call
  30159. */
  30160. checkReadyOnEveryCall: boolean;
  30161. /**
  30162. * Specifies if the ready state should be checked once
  30163. */
  30164. checkReadyOnlyOnce: boolean;
  30165. /**
  30166. * The state of the material
  30167. */
  30168. state: string;
  30169. /**
  30170. * If the material can be rendered to several textures with MRT extension
  30171. */
  30172. get canRenderToMRT(): boolean;
  30173. /**
  30174. * The alpha value of the material
  30175. */
  30176. protected _alpha: number;
  30177. /**
  30178. * List of inspectable custom properties (used by the Inspector)
  30179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30180. */
  30181. inspectableCustomProperties: IInspectable[];
  30182. /**
  30183. * Sets the alpha value of the material
  30184. */
  30185. set alpha(value: number);
  30186. /**
  30187. * Gets the alpha value of the material
  30188. */
  30189. get alpha(): number;
  30190. /**
  30191. * Specifies if back face culling is enabled
  30192. */
  30193. protected _backFaceCulling: boolean;
  30194. /**
  30195. * Sets the back-face culling state
  30196. */
  30197. set backFaceCulling(value: boolean);
  30198. /**
  30199. * Gets the back-face culling state
  30200. */
  30201. get backFaceCulling(): boolean;
  30202. /**
  30203. * Stores the value for side orientation
  30204. */
  30205. sideOrientation: number;
  30206. /**
  30207. * Callback triggered when the material is compiled
  30208. */
  30209. onCompiled: Nullable<(effect: Effect) => void>;
  30210. /**
  30211. * Callback triggered when an error occurs
  30212. */
  30213. onError: Nullable<(effect: Effect, errors: string) => void>;
  30214. /**
  30215. * Callback triggered to get the render target textures
  30216. */
  30217. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30218. /**
  30219. * Gets a boolean indicating that current material needs to register RTT
  30220. */
  30221. get hasRenderTargetTextures(): boolean;
  30222. /**
  30223. * Specifies if the material should be serialized
  30224. */
  30225. doNotSerialize: boolean;
  30226. /**
  30227. * @hidden
  30228. */
  30229. _storeEffectOnSubMeshes: boolean;
  30230. /**
  30231. * Stores the animations for the material
  30232. */
  30233. animations: Nullable<Array<Animation>>;
  30234. /**
  30235. * An event triggered when the material is disposed
  30236. */
  30237. onDisposeObservable: Observable<Material>;
  30238. /**
  30239. * An observer which watches for dispose events
  30240. */
  30241. private _onDisposeObserver;
  30242. private _onUnBindObservable;
  30243. /**
  30244. * Called during a dispose event
  30245. */
  30246. set onDispose(callback: () => void);
  30247. private _onBindObservable;
  30248. /**
  30249. * An event triggered when the material is bound
  30250. */
  30251. get onBindObservable(): Observable<AbstractMesh>;
  30252. /**
  30253. * An observer which watches for bind events
  30254. */
  30255. private _onBindObserver;
  30256. /**
  30257. * Called during a bind event
  30258. */
  30259. set onBind(callback: (Mesh: AbstractMesh) => void);
  30260. /**
  30261. * An event triggered when the material is unbound
  30262. */
  30263. get onUnBindObservable(): Observable<Material>;
  30264. protected _onEffectCreatedObservable: Nullable<Observable<{
  30265. effect: Effect;
  30266. subMesh: Nullable<SubMesh>;
  30267. }>>;
  30268. /**
  30269. * An event triggered when the effect is (re)created
  30270. */
  30271. get onEffectCreatedObservable(): Observable<{
  30272. effect: Effect;
  30273. subMesh: Nullable<SubMesh>;
  30274. }>;
  30275. /**
  30276. * Stores the value of the alpha mode
  30277. */
  30278. private _alphaMode;
  30279. /**
  30280. * Sets the value of the alpha mode.
  30281. *
  30282. * | Value | Type | Description |
  30283. * | --- | --- | --- |
  30284. * | 0 | ALPHA_DISABLE | |
  30285. * | 1 | ALPHA_ADD | |
  30286. * | 2 | ALPHA_COMBINE | |
  30287. * | 3 | ALPHA_SUBTRACT | |
  30288. * | 4 | ALPHA_MULTIPLY | |
  30289. * | 5 | ALPHA_MAXIMIZED | |
  30290. * | 6 | ALPHA_ONEONE | |
  30291. * | 7 | ALPHA_PREMULTIPLIED | |
  30292. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30293. * | 9 | ALPHA_INTERPOLATE | |
  30294. * | 10 | ALPHA_SCREENMODE | |
  30295. *
  30296. */
  30297. set alphaMode(value: number);
  30298. /**
  30299. * Gets the value of the alpha mode
  30300. */
  30301. get alphaMode(): number;
  30302. /**
  30303. * Stores the state of the need depth pre-pass value
  30304. */
  30305. private _needDepthPrePass;
  30306. /**
  30307. * Sets the need depth pre-pass value
  30308. */
  30309. set needDepthPrePass(value: boolean);
  30310. /**
  30311. * Gets the depth pre-pass value
  30312. */
  30313. get needDepthPrePass(): boolean;
  30314. /**
  30315. * Specifies if depth writing should be disabled
  30316. */
  30317. disableDepthWrite: boolean;
  30318. /**
  30319. * Specifies if color writing should be disabled
  30320. */
  30321. disableColorWrite: boolean;
  30322. /**
  30323. * Specifies if depth writing should be forced
  30324. */
  30325. forceDepthWrite: boolean;
  30326. /**
  30327. * Specifies the depth function that should be used. 0 means the default engine function
  30328. */
  30329. depthFunction: number;
  30330. /**
  30331. * Specifies if there should be a separate pass for culling
  30332. */
  30333. separateCullingPass: boolean;
  30334. /**
  30335. * Stores the state specifing if fog should be enabled
  30336. */
  30337. private _fogEnabled;
  30338. /**
  30339. * Sets the state for enabling fog
  30340. */
  30341. set fogEnabled(value: boolean);
  30342. /**
  30343. * Gets the value of the fog enabled state
  30344. */
  30345. get fogEnabled(): boolean;
  30346. /**
  30347. * Stores the size of points
  30348. */
  30349. pointSize: number;
  30350. /**
  30351. * Stores the z offset value
  30352. */
  30353. zOffset: number;
  30354. get wireframe(): boolean;
  30355. /**
  30356. * Sets the state of wireframe mode
  30357. */
  30358. set wireframe(value: boolean);
  30359. /**
  30360. * Gets the value specifying if point clouds are enabled
  30361. */
  30362. get pointsCloud(): boolean;
  30363. /**
  30364. * Sets the state of point cloud mode
  30365. */
  30366. set pointsCloud(value: boolean);
  30367. /**
  30368. * Gets the material fill mode
  30369. */
  30370. get fillMode(): number;
  30371. /**
  30372. * Sets the material fill mode
  30373. */
  30374. set fillMode(value: number);
  30375. /**
  30376. * @hidden
  30377. * Stores the effects for the material
  30378. */
  30379. _effect: Nullable<Effect>;
  30380. /**
  30381. * Specifies if uniform buffers should be used
  30382. */
  30383. private _useUBO;
  30384. /**
  30385. * Stores a reference to the scene
  30386. */
  30387. private _scene;
  30388. /**
  30389. * Stores the fill mode state
  30390. */
  30391. private _fillMode;
  30392. /**
  30393. * Specifies if the depth write state should be cached
  30394. */
  30395. private _cachedDepthWriteState;
  30396. /**
  30397. * Specifies if the color write state should be cached
  30398. */
  30399. private _cachedColorWriteState;
  30400. /**
  30401. * Specifies if the depth function state should be cached
  30402. */
  30403. private _cachedDepthFunctionState;
  30404. /**
  30405. * Stores the uniform buffer
  30406. */
  30407. protected _uniformBuffer: UniformBuffer;
  30408. /** @hidden */
  30409. _indexInSceneMaterialArray: number;
  30410. /** @hidden */
  30411. meshMap: Nullable<{
  30412. [id: string]: AbstractMesh | undefined;
  30413. }>;
  30414. /**
  30415. * Creates a material instance
  30416. * @param name defines the name of the material
  30417. * @param scene defines the scene to reference
  30418. * @param doNotAdd specifies if the material should be added to the scene
  30419. */
  30420. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30421. /**
  30422. * Returns a string representation of the current material
  30423. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30424. * @returns a string with material information
  30425. */
  30426. toString(fullDetails?: boolean): string;
  30427. /**
  30428. * Gets the class name of the material
  30429. * @returns a string with the class name of the material
  30430. */
  30431. getClassName(): string;
  30432. /**
  30433. * Specifies if updates for the material been locked
  30434. */
  30435. get isFrozen(): boolean;
  30436. /**
  30437. * Locks updates for the material
  30438. */
  30439. freeze(): void;
  30440. /**
  30441. * Unlocks updates for the material
  30442. */
  30443. unfreeze(): void;
  30444. /**
  30445. * Specifies if the material is ready to be used
  30446. * @param mesh defines the mesh to check
  30447. * @param useInstances specifies if instances should be used
  30448. * @returns a boolean indicating if the material is ready to be used
  30449. */
  30450. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30451. /**
  30452. * Specifies that the submesh is ready to be used
  30453. * @param mesh defines the mesh to check
  30454. * @param subMesh defines which submesh to check
  30455. * @param useInstances specifies that instances should be used
  30456. * @returns a boolean indicating that the submesh is ready or not
  30457. */
  30458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30459. /**
  30460. * Returns the material effect
  30461. * @returns the effect associated with the material
  30462. */
  30463. getEffect(): Nullable<Effect>;
  30464. /**
  30465. * Returns the current scene
  30466. * @returns a Scene
  30467. */
  30468. getScene(): Scene;
  30469. /**
  30470. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30471. */
  30472. protected _forceAlphaTest: boolean;
  30473. /**
  30474. * The transparency mode of the material.
  30475. */
  30476. protected _transparencyMode: Nullable<number>;
  30477. /**
  30478. * Gets the current transparency mode.
  30479. */
  30480. get transparencyMode(): Nullable<number>;
  30481. /**
  30482. * Sets the transparency mode of the material.
  30483. *
  30484. * | Value | Type | Description |
  30485. * | ----- | ----------------------------------- | ----------- |
  30486. * | 0 | OPAQUE | |
  30487. * | 1 | ALPHATEST | |
  30488. * | 2 | ALPHABLEND | |
  30489. * | 3 | ALPHATESTANDBLEND | |
  30490. *
  30491. */
  30492. set transparencyMode(value: Nullable<number>);
  30493. /**
  30494. * Returns true if alpha blending should be disabled.
  30495. */
  30496. protected get _disableAlphaBlending(): boolean;
  30497. /**
  30498. * Specifies whether or not this material should be rendered in alpha blend mode.
  30499. * @returns a boolean specifying if alpha blending is needed
  30500. */
  30501. needAlphaBlending(): boolean;
  30502. /**
  30503. * Specifies if the mesh will require alpha blending
  30504. * @param mesh defines the mesh to check
  30505. * @returns a boolean specifying if alpha blending is needed for the mesh
  30506. */
  30507. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30508. /**
  30509. * Specifies whether or not this material should be rendered in alpha test mode.
  30510. * @returns a boolean specifying if an alpha test is needed.
  30511. */
  30512. needAlphaTesting(): boolean;
  30513. /**
  30514. * Specifies if material alpha testing should be turned on for the mesh
  30515. * @param mesh defines the mesh to check
  30516. */
  30517. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30518. /**
  30519. * Gets the texture used for the alpha test
  30520. * @returns the texture to use for alpha testing
  30521. */
  30522. getAlphaTestTexture(): Nullable<BaseTexture>;
  30523. /**
  30524. * Marks the material to indicate that it needs to be re-calculated
  30525. */
  30526. markDirty(): void;
  30527. /** @hidden */
  30528. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30529. /**
  30530. * Binds the material to the mesh
  30531. * @param world defines the world transformation matrix
  30532. * @param mesh defines the mesh to bind the material to
  30533. */
  30534. bind(world: Matrix, mesh?: Mesh): void;
  30535. /**
  30536. * Binds the submesh to the material
  30537. * @param world defines the world transformation matrix
  30538. * @param mesh defines the mesh containing the submesh
  30539. * @param subMesh defines the submesh to bind the material to
  30540. */
  30541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30542. /**
  30543. * Binds the world matrix to the material
  30544. * @param world defines the world transformation matrix
  30545. */
  30546. bindOnlyWorldMatrix(world: Matrix): void;
  30547. /**
  30548. * Binds the scene's uniform buffer to the effect.
  30549. * @param effect defines the effect to bind to the scene uniform buffer
  30550. * @param sceneUbo defines the uniform buffer storing scene data
  30551. */
  30552. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30553. /**
  30554. * Binds the view matrix to the effect
  30555. * @param effect defines the effect to bind the view matrix to
  30556. */
  30557. bindView(effect: Effect): void;
  30558. /**
  30559. * Binds the view projection matrix to the effect
  30560. * @param effect defines the effect to bind the view projection matrix to
  30561. */
  30562. bindViewProjection(effect: Effect): void;
  30563. /**
  30564. * Processes to execute after binding the material to a mesh
  30565. * @param mesh defines the rendered mesh
  30566. */
  30567. protected _afterBind(mesh?: Mesh): void;
  30568. /**
  30569. * Unbinds the material from the mesh
  30570. */
  30571. unbind(): void;
  30572. /**
  30573. * Gets the active textures from the material
  30574. * @returns an array of textures
  30575. */
  30576. getActiveTextures(): BaseTexture[];
  30577. /**
  30578. * Specifies if the material uses a texture
  30579. * @param texture defines the texture to check against the material
  30580. * @returns a boolean specifying if the material uses the texture
  30581. */
  30582. hasTexture(texture: BaseTexture): boolean;
  30583. /**
  30584. * Makes a duplicate of the material, and gives it a new name
  30585. * @param name defines the new name for the duplicated material
  30586. * @returns the cloned material
  30587. */
  30588. clone(name: string): Nullable<Material>;
  30589. /**
  30590. * Gets the meshes bound to the material
  30591. * @returns an array of meshes bound to the material
  30592. */
  30593. getBindedMeshes(): AbstractMesh[];
  30594. /**
  30595. * Force shader compilation
  30596. * @param mesh defines the mesh associated with this material
  30597. * @param onCompiled defines a function to execute once the material is compiled
  30598. * @param options defines the options to configure the compilation
  30599. * @param onError defines a function to execute if the material fails compiling
  30600. */
  30601. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30602. /**
  30603. * Force shader compilation
  30604. * @param mesh defines the mesh that will use this material
  30605. * @param options defines additional options for compiling the shaders
  30606. * @returns a promise that resolves when the compilation completes
  30607. */
  30608. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30609. private static readonly _AllDirtyCallBack;
  30610. private static readonly _ImageProcessingDirtyCallBack;
  30611. private static readonly _TextureDirtyCallBack;
  30612. private static readonly _FresnelDirtyCallBack;
  30613. private static readonly _MiscDirtyCallBack;
  30614. private static readonly _PrePassDirtyCallBack;
  30615. private static readonly _LightsDirtyCallBack;
  30616. private static readonly _AttributeDirtyCallBack;
  30617. private static _FresnelAndMiscDirtyCallBack;
  30618. private static _TextureAndMiscDirtyCallBack;
  30619. private static readonly _DirtyCallbackArray;
  30620. private static readonly _RunDirtyCallBacks;
  30621. /**
  30622. * Marks a define in the material to indicate that it needs to be re-computed
  30623. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30624. */
  30625. markAsDirty(flag: number): void;
  30626. /**
  30627. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30628. * @param func defines a function which checks material defines against the submeshes
  30629. */
  30630. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30631. /**
  30632. * Indicates that the scene should check if the rendering now needs a prepass
  30633. */
  30634. protected _markScenePrePassDirty(): void;
  30635. /**
  30636. * Indicates that we need to re-calculated for all submeshes
  30637. */
  30638. protected _markAllSubMeshesAsAllDirty(): void;
  30639. /**
  30640. * Indicates that image processing needs to be re-calculated for all submeshes
  30641. */
  30642. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30643. /**
  30644. * Indicates that textures need to be re-calculated for all submeshes
  30645. */
  30646. protected _markAllSubMeshesAsTexturesDirty(): void;
  30647. /**
  30648. * Indicates that fresnel needs to be re-calculated for all submeshes
  30649. */
  30650. protected _markAllSubMeshesAsFresnelDirty(): void;
  30651. /**
  30652. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30653. */
  30654. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30655. /**
  30656. * Indicates that lights need to be re-calculated for all submeshes
  30657. */
  30658. protected _markAllSubMeshesAsLightsDirty(): void;
  30659. /**
  30660. * Indicates that attributes need to be re-calculated for all submeshes
  30661. */
  30662. protected _markAllSubMeshesAsAttributesDirty(): void;
  30663. /**
  30664. * Indicates that misc needs to be re-calculated for all submeshes
  30665. */
  30666. protected _markAllSubMeshesAsMiscDirty(): void;
  30667. /**
  30668. * Indicates that prepass needs to be re-calculated for all submeshes
  30669. */
  30670. protected _markAllSubMeshesAsPrePassDirty(): void;
  30671. /**
  30672. * Indicates that textures and misc need to be re-calculated for all submeshes
  30673. */
  30674. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30675. /**
  30676. * Sets the required values to the prepass renderer.
  30677. * @param prePassRenderer defines the prepass renderer to setup.
  30678. * @returns true if the pre pass is needed.
  30679. */
  30680. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30681. /**
  30682. * Disposes the material
  30683. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30684. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30685. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30686. */
  30687. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30688. /** @hidden */
  30689. private releaseVertexArrayObject;
  30690. /**
  30691. * Serializes this material
  30692. * @returns the serialized material object
  30693. */
  30694. serialize(): any;
  30695. /**
  30696. * Creates a material from parsed material data
  30697. * @param parsedMaterial defines parsed material data
  30698. * @param scene defines the hosting scene
  30699. * @param rootUrl defines the root URL to use to load textures
  30700. * @returns a new material
  30701. */
  30702. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30703. }
  30704. }
  30705. declare module "babylonjs/Materials/multiMaterial" {
  30706. import { Nullable } from "babylonjs/types";
  30707. import { Scene } from "babylonjs/scene";
  30708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30709. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30711. import { Material } from "babylonjs/Materials/material";
  30712. /**
  30713. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30714. * separate meshes. This can be use to improve performances.
  30715. * @see https://doc.babylonjs.com/how_to/multi_materials
  30716. */
  30717. export class MultiMaterial extends Material {
  30718. private _subMaterials;
  30719. /**
  30720. * Gets or Sets the list of Materials used within the multi material.
  30721. * They need to be ordered according to the submeshes order in the associated mesh
  30722. */
  30723. get subMaterials(): Nullable<Material>[];
  30724. set subMaterials(value: Nullable<Material>[]);
  30725. /**
  30726. * Function used to align with Node.getChildren()
  30727. * @returns the list of Materials used within the multi material
  30728. */
  30729. getChildren(): Nullable<Material>[];
  30730. /**
  30731. * Instantiates a new Multi Material
  30732. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30733. * separate meshes. This can be use to improve performances.
  30734. * @see https://doc.babylonjs.com/how_to/multi_materials
  30735. * @param name Define the name in the scene
  30736. * @param scene Define the scene the material belongs to
  30737. */
  30738. constructor(name: string, scene: Scene);
  30739. private _hookArray;
  30740. /**
  30741. * Get one of the submaterial by its index in the submaterials array
  30742. * @param index The index to look the sub material at
  30743. * @returns The Material if the index has been defined
  30744. */
  30745. getSubMaterial(index: number): Nullable<Material>;
  30746. /**
  30747. * Get the list of active textures for the whole sub materials list.
  30748. * @returns All the textures that will be used during the rendering
  30749. */
  30750. getActiveTextures(): BaseTexture[];
  30751. /**
  30752. * Gets the current class name of the material e.g. "MultiMaterial"
  30753. * Mainly use in serialization.
  30754. * @returns the class name
  30755. */
  30756. getClassName(): string;
  30757. /**
  30758. * Checks if the material is ready to render the requested sub mesh
  30759. * @param mesh Define the mesh the submesh belongs to
  30760. * @param subMesh Define the sub mesh to look readyness for
  30761. * @param useInstances Define whether or not the material is used with instances
  30762. * @returns true if ready, otherwise false
  30763. */
  30764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30765. /**
  30766. * Clones the current material and its related sub materials
  30767. * @param name Define the name of the newly cloned material
  30768. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30769. * @returns the cloned material
  30770. */
  30771. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30772. /**
  30773. * Serializes the materials into a JSON representation.
  30774. * @returns the JSON representation
  30775. */
  30776. serialize(): any;
  30777. /**
  30778. * Dispose the material and release its associated resources
  30779. * @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)
  30780. * @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)
  30781. * @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)
  30782. */
  30783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30784. /**
  30785. * Creates a MultiMaterial from parsed MultiMaterial data.
  30786. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30787. * @param scene defines the hosting scene
  30788. * @returns a new MultiMaterial
  30789. */
  30790. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30791. }
  30792. }
  30793. declare module "babylonjs/Meshes/subMesh" {
  30794. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30796. import { Engine } from "babylonjs/Engines/engine";
  30797. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30798. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30799. import { Effect } from "babylonjs/Materials/effect";
  30800. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30801. import { Plane } from "babylonjs/Maths/math.plane";
  30802. import { Collider } from "babylonjs/Collisions/collider";
  30803. import { Material } from "babylonjs/Materials/material";
  30804. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30806. import { Mesh } from "babylonjs/Meshes/mesh";
  30807. import { Ray } from "babylonjs/Culling/ray";
  30808. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30809. /**
  30810. * Defines a subdivision inside a mesh
  30811. */
  30812. export class SubMesh implements ICullable {
  30813. /** the material index to use */
  30814. materialIndex: number;
  30815. /** vertex index start */
  30816. verticesStart: number;
  30817. /** vertices count */
  30818. verticesCount: number;
  30819. /** index start */
  30820. indexStart: number;
  30821. /** indices count */
  30822. indexCount: number;
  30823. /** @hidden */
  30824. _materialDefines: Nullable<MaterialDefines>;
  30825. /** @hidden */
  30826. _materialEffect: Nullable<Effect>;
  30827. /** @hidden */
  30828. _effectOverride: Nullable<Effect>;
  30829. /**
  30830. * Gets material defines used by the effect associated to the sub mesh
  30831. */
  30832. get materialDefines(): Nullable<MaterialDefines>;
  30833. /**
  30834. * Sets material defines used by the effect associated to the sub mesh
  30835. */
  30836. set materialDefines(defines: Nullable<MaterialDefines>);
  30837. /**
  30838. * Gets associated effect
  30839. */
  30840. get effect(): Nullable<Effect>;
  30841. /**
  30842. * Sets associated effect (effect used to render this submesh)
  30843. * @param effect defines the effect to associate with
  30844. * @param defines defines the set of defines used to compile this effect
  30845. */
  30846. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30847. /** @hidden */
  30848. _linesIndexCount: number;
  30849. private _mesh;
  30850. private _renderingMesh;
  30851. private _boundingInfo;
  30852. private _linesIndexBuffer;
  30853. /** @hidden */
  30854. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30855. /** @hidden */
  30856. _trianglePlanes: Plane[];
  30857. /** @hidden */
  30858. _lastColliderTransformMatrix: Nullable<Matrix>;
  30859. /** @hidden */
  30860. _renderId: number;
  30861. /** @hidden */
  30862. _alphaIndex: number;
  30863. /** @hidden */
  30864. _distanceToCamera: number;
  30865. /** @hidden */
  30866. _id: number;
  30867. private _currentMaterial;
  30868. /**
  30869. * Add a new submesh to a mesh
  30870. * @param materialIndex defines the material index to use
  30871. * @param verticesStart defines vertex index start
  30872. * @param verticesCount defines vertices count
  30873. * @param indexStart defines index start
  30874. * @param indexCount defines indices count
  30875. * @param mesh defines the parent mesh
  30876. * @param renderingMesh defines an optional rendering mesh
  30877. * @param createBoundingBox defines if bounding box should be created for this submesh
  30878. * @returns the new submesh
  30879. */
  30880. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30881. /**
  30882. * Creates a new submesh
  30883. * @param materialIndex defines the material index to use
  30884. * @param verticesStart defines vertex index start
  30885. * @param verticesCount defines vertices count
  30886. * @param indexStart defines index start
  30887. * @param indexCount defines indices count
  30888. * @param mesh defines the parent mesh
  30889. * @param renderingMesh defines an optional rendering mesh
  30890. * @param createBoundingBox defines if bounding box should be created for this submesh
  30891. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30892. */
  30893. constructor(
  30894. /** the material index to use */
  30895. materialIndex: number,
  30896. /** vertex index start */
  30897. verticesStart: number,
  30898. /** vertices count */
  30899. verticesCount: number,
  30900. /** index start */
  30901. indexStart: number,
  30902. /** indices count */
  30903. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30904. /**
  30905. * Returns true if this submesh covers the entire parent mesh
  30906. * @ignorenaming
  30907. */
  30908. get IsGlobal(): boolean;
  30909. /**
  30910. * Returns the submesh BoudingInfo object
  30911. * @returns current bounding info (or mesh's one if the submesh is global)
  30912. */
  30913. getBoundingInfo(): BoundingInfo;
  30914. /**
  30915. * Sets the submesh BoundingInfo
  30916. * @param boundingInfo defines the new bounding info to use
  30917. * @returns the SubMesh
  30918. */
  30919. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30920. /**
  30921. * Returns the mesh of the current submesh
  30922. * @return the parent mesh
  30923. */
  30924. getMesh(): AbstractMesh;
  30925. /**
  30926. * Returns the rendering mesh of the submesh
  30927. * @returns the rendering mesh (could be different from parent mesh)
  30928. */
  30929. getRenderingMesh(): Mesh;
  30930. /**
  30931. * Returns the replacement mesh of the submesh
  30932. * @returns the replacement mesh (could be different from parent mesh)
  30933. */
  30934. getReplacementMesh(): Nullable<AbstractMesh>;
  30935. /**
  30936. * Returns the effective mesh of the submesh
  30937. * @returns the effective mesh (could be different from parent mesh)
  30938. */
  30939. getEffectiveMesh(): AbstractMesh;
  30940. /**
  30941. * Returns the submesh material
  30942. * @returns null or the current material
  30943. */
  30944. getMaterial(): Nullable<Material>;
  30945. private _IsMultiMaterial;
  30946. /**
  30947. * Sets a new updated BoundingInfo object to the submesh
  30948. * @param data defines an optional position array to use to determine the bounding info
  30949. * @returns the SubMesh
  30950. */
  30951. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30952. /** @hidden */
  30953. _checkCollision(collider: Collider): boolean;
  30954. /**
  30955. * Updates the submesh BoundingInfo
  30956. * @param world defines the world matrix to use to update the bounding info
  30957. * @returns the submesh
  30958. */
  30959. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30960. /**
  30961. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30962. * @param frustumPlanes defines the frustum planes
  30963. * @returns true if the submesh is intersecting with the frustum
  30964. */
  30965. isInFrustum(frustumPlanes: Plane[]): boolean;
  30966. /**
  30967. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30968. * @param frustumPlanes defines the frustum planes
  30969. * @returns true if the submesh is inside the frustum
  30970. */
  30971. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30972. /**
  30973. * Renders the submesh
  30974. * @param enableAlphaMode defines if alpha needs to be used
  30975. * @returns the submesh
  30976. */
  30977. render(enableAlphaMode: boolean): SubMesh;
  30978. /**
  30979. * @hidden
  30980. */
  30981. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30982. /**
  30983. * Checks if the submesh intersects with a ray
  30984. * @param ray defines the ray to test
  30985. * @returns true is the passed ray intersects the submesh bounding box
  30986. */
  30987. canIntersects(ray: Ray): boolean;
  30988. /**
  30989. * Intersects current submesh with a ray
  30990. * @param ray defines the ray to test
  30991. * @param positions defines mesh's positions array
  30992. * @param indices defines mesh's indices array
  30993. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30995. * @returns intersection info or null if no intersection
  30996. */
  30997. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30998. /** @hidden */
  30999. private _intersectLines;
  31000. /** @hidden */
  31001. private _intersectUnIndexedLines;
  31002. /** @hidden */
  31003. private _intersectTriangles;
  31004. /** @hidden */
  31005. private _intersectUnIndexedTriangles;
  31006. /** @hidden */
  31007. _rebuild(): void;
  31008. /**
  31009. * Creates a new submesh from the passed mesh
  31010. * @param newMesh defines the new hosting mesh
  31011. * @param newRenderingMesh defines an optional rendering mesh
  31012. * @returns the new submesh
  31013. */
  31014. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31015. /**
  31016. * Release associated resources
  31017. */
  31018. dispose(): void;
  31019. /**
  31020. * Gets the class name
  31021. * @returns the string "SubMesh".
  31022. */
  31023. getClassName(): string;
  31024. /**
  31025. * Creates a new submesh from indices data
  31026. * @param materialIndex the index of the main mesh material
  31027. * @param startIndex the index where to start the copy in the mesh indices array
  31028. * @param indexCount the number of indices to copy then from the startIndex
  31029. * @param mesh the main mesh to create the submesh from
  31030. * @param renderingMesh the optional rendering mesh
  31031. * @returns a new submesh
  31032. */
  31033. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31034. }
  31035. }
  31036. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31037. /**
  31038. * Class used to represent data loading progression
  31039. */
  31040. export class SceneLoaderFlags {
  31041. private static _ForceFullSceneLoadingForIncremental;
  31042. private static _ShowLoadingScreen;
  31043. private static _CleanBoneMatrixWeights;
  31044. private static _loggingLevel;
  31045. /**
  31046. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31047. */
  31048. static get ForceFullSceneLoadingForIncremental(): boolean;
  31049. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31050. /**
  31051. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31052. */
  31053. static get ShowLoadingScreen(): boolean;
  31054. static set ShowLoadingScreen(value: boolean);
  31055. /**
  31056. * Defines the current logging level (while loading the scene)
  31057. * @ignorenaming
  31058. */
  31059. static get loggingLevel(): number;
  31060. static set loggingLevel(value: number);
  31061. /**
  31062. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31063. */
  31064. static get CleanBoneMatrixWeights(): boolean;
  31065. static set CleanBoneMatrixWeights(value: boolean);
  31066. }
  31067. }
  31068. declare module "babylonjs/Meshes/geometry" {
  31069. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31070. import { Scene } from "babylonjs/scene";
  31071. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31072. import { Engine } from "babylonjs/Engines/engine";
  31073. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31074. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31075. import { Effect } from "babylonjs/Materials/effect";
  31076. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31078. import { Mesh } from "babylonjs/Meshes/mesh";
  31079. /**
  31080. * Class used to store geometry data (vertex buffers + index buffer)
  31081. */
  31082. export class Geometry implements IGetSetVerticesData {
  31083. /**
  31084. * Gets or sets the ID of the geometry
  31085. */
  31086. id: string;
  31087. /**
  31088. * Gets or sets the unique ID of the geometry
  31089. */
  31090. uniqueId: number;
  31091. /**
  31092. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31093. */
  31094. delayLoadState: number;
  31095. /**
  31096. * Gets the file containing the data to load when running in delay load state
  31097. */
  31098. delayLoadingFile: Nullable<string>;
  31099. /**
  31100. * Callback called when the geometry is updated
  31101. */
  31102. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31103. private _scene;
  31104. private _engine;
  31105. private _meshes;
  31106. private _totalVertices;
  31107. /** @hidden */
  31108. _indices: IndicesArray;
  31109. /** @hidden */
  31110. _vertexBuffers: {
  31111. [key: string]: VertexBuffer;
  31112. };
  31113. private _isDisposed;
  31114. private _extend;
  31115. private _boundingBias;
  31116. /** @hidden */
  31117. _delayInfo: Array<string>;
  31118. private _indexBuffer;
  31119. private _indexBufferIsUpdatable;
  31120. /** @hidden */
  31121. _boundingInfo: Nullable<BoundingInfo>;
  31122. /** @hidden */
  31123. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31124. /** @hidden */
  31125. _softwareSkinningFrameId: number;
  31126. private _vertexArrayObjects;
  31127. private _updatable;
  31128. /** @hidden */
  31129. _positions: Nullable<Vector3[]>;
  31130. /**
  31131. * 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
  31132. */
  31133. get boundingBias(): Vector2;
  31134. /**
  31135. * 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
  31136. */
  31137. set boundingBias(value: Vector2);
  31138. /**
  31139. * Static function used to attach a new empty geometry to a mesh
  31140. * @param mesh defines the mesh to attach the geometry to
  31141. * @returns the new Geometry
  31142. */
  31143. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31144. /** Get the list of meshes using this geometry */
  31145. get meshes(): Mesh[];
  31146. /**
  31147. * 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
  31148. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31149. */
  31150. useBoundingInfoFromGeometry: boolean;
  31151. /**
  31152. * Creates a new geometry
  31153. * @param id defines the unique ID
  31154. * @param scene defines the hosting scene
  31155. * @param vertexData defines the VertexData used to get geometry data
  31156. * @param updatable defines if geometry must be updatable (false by default)
  31157. * @param mesh defines the mesh that will be associated with the geometry
  31158. */
  31159. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31160. /**
  31161. * Gets the current extend of the geometry
  31162. */
  31163. get extend(): {
  31164. minimum: Vector3;
  31165. maximum: Vector3;
  31166. };
  31167. /**
  31168. * Gets the hosting scene
  31169. * @returns the hosting Scene
  31170. */
  31171. getScene(): Scene;
  31172. /**
  31173. * Gets the hosting engine
  31174. * @returns the hosting Engine
  31175. */
  31176. getEngine(): Engine;
  31177. /**
  31178. * Defines if the geometry is ready to use
  31179. * @returns true if the geometry is ready to be used
  31180. */
  31181. isReady(): boolean;
  31182. /**
  31183. * Gets a value indicating that the geometry should not be serialized
  31184. */
  31185. get doNotSerialize(): boolean;
  31186. /** @hidden */
  31187. _rebuild(): void;
  31188. /**
  31189. * Affects all geometry data in one call
  31190. * @param vertexData defines the geometry data
  31191. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31192. */
  31193. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31194. /**
  31195. * Set specific vertex data
  31196. * @param kind defines the data kind (Position, normal, etc...)
  31197. * @param data defines the vertex data to use
  31198. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31199. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31200. */
  31201. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31202. /**
  31203. * Removes a specific vertex data
  31204. * @param kind defines the data kind (Position, normal, etc...)
  31205. */
  31206. removeVerticesData(kind: string): void;
  31207. /**
  31208. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31209. * @param buffer defines the vertex buffer to use
  31210. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31211. */
  31212. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31213. /**
  31214. * Update a specific vertex buffer
  31215. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31216. * It will do nothing if the buffer is not updatable
  31217. * @param kind defines the data kind (Position, normal, etc...)
  31218. * @param data defines the data to use
  31219. * @param offset defines the offset in the target buffer where to store the data
  31220. * @param useBytes set to true if the offset is in bytes
  31221. */
  31222. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31223. /**
  31224. * Update a specific vertex buffer
  31225. * This function will create a new buffer if the current one is not updatable
  31226. * @param kind defines the data kind (Position, normal, etc...)
  31227. * @param data defines the data to use
  31228. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31229. */
  31230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31231. private _updateBoundingInfo;
  31232. /** @hidden */
  31233. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31234. /**
  31235. * Gets total number of vertices
  31236. * @returns the total number of vertices
  31237. */
  31238. getTotalVertices(): number;
  31239. /**
  31240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31241. * @param kind defines the data kind (Position, normal, etc...)
  31242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31244. * @returns a float array containing vertex data
  31245. */
  31246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31247. /**
  31248. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31249. * @param kind defines the data kind (Position, normal, etc...)
  31250. * @returns true if the vertex buffer with the specified kind is updatable
  31251. */
  31252. isVertexBufferUpdatable(kind: string): boolean;
  31253. /**
  31254. * Gets a specific vertex buffer
  31255. * @param kind defines the data kind (Position, normal, etc...)
  31256. * @returns a VertexBuffer
  31257. */
  31258. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31259. /**
  31260. * Returns all vertex buffers
  31261. * @return an object holding all vertex buffers indexed by kind
  31262. */
  31263. getVertexBuffers(): Nullable<{
  31264. [key: string]: VertexBuffer;
  31265. }>;
  31266. /**
  31267. * Gets a boolean indicating if specific vertex buffer is present
  31268. * @param kind defines the data kind (Position, normal, etc...)
  31269. * @returns true if data is present
  31270. */
  31271. isVerticesDataPresent(kind: string): boolean;
  31272. /**
  31273. * Gets a list of all attached data kinds (Position, normal, etc...)
  31274. * @returns a list of string containing all kinds
  31275. */
  31276. getVerticesDataKinds(): string[];
  31277. /**
  31278. * Update index buffer
  31279. * @param indices defines the indices to store in the index buffer
  31280. * @param offset defines the offset in the target buffer where to store the data
  31281. * @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)
  31282. */
  31283. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31284. /**
  31285. * Creates a new index buffer
  31286. * @param indices defines the indices to store in the index buffer
  31287. * @param totalVertices defines the total number of vertices (could be null)
  31288. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31289. */
  31290. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31291. /**
  31292. * Return the total number of indices
  31293. * @returns the total number of indices
  31294. */
  31295. getTotalIndices(): number;
  31296. /**
  31297. * Gets the index buffer array
  31298. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31300. * @returns the index buffer array
  31301. */
  31302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31303. /**
  31304. * Gets the index buffer
  31305. * @return the index buffer
  31306. */
  31307. getIndexBuffer(): Nullable<DataBuffer>;
  31308. /** @hidden */
  31309. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31310. /**
  31311. * Release the associated resources for a specific mesh
  31312. * @param mesh defines the source mesh
  31313. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31314. */
  31315. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31316. /**
  31317. * Apply current geometry to a given mesh
  31318. * @param mesh defines the mesh to apply geometry to
  31319. */
  31320. applyToMesh(mesh: Mesh): void;
  31321. private _updateExtend;
  31322. private _applyToMesh;
  31323. private notifyUpdate;
  31324. /**
  31325. * Load the geometry if it was flagged as delay loaded
  31326. * @param scene defines the hosting scene
  31327. * @param onLoaded defines a callback called when the geometry is loaded
  31328. */
  31329. load(scene: Scene, onLoaded?: () => void): void;
  31330. private _queueLoad;
  31331. /**
  31332. * Invert the geometry to move from a right handed system to a left handed one.
  31333. */
  31334. toLeftHanded(): void;
  31335. /** @hidden */
  31336. _resetPointsArrayCache(): void;
  31337. /** @hidden */
  31338. _generatePointsArray(): boolean;
  31339. /**
  31340. * Gets a value indicating if the geometry is disposed
  31341. * @returns true if the geometry was disposed
  31342. */
  31343. isDisposed(): boolean;
  31344. private _disposeVertexArrayObjects;
  31345. /**
  31346. * Free all associated resources
  31347. */
  31348. dispose(): void;
  31349. /**
  31350. * Clone the current geometry into a new geometry
  31351. * @param id defines the unique ID of the new geometry
  31352. * @returns a new geometry object
  31353. */
  31354. copy(id: string): Geometry;
  31355. /**
  31356. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31357. * @return a JSON representation of the current geometry data (without the vertices data)
  31358. */
  31359. serialize(): any;
  31360. private toNumberArray;
  31361. /**
  31362. * Serialize all vertices data into a JSON oject
  31363. * @returns a JSON representation of the current geometry data
  31364. */
  31365. serializeVerticeData(): any;
  31366. /**
  31367. * Extracts a clone of a mesh geometry
  31368. * @param mesh defines the source mesh
  31369. * @param id defines the unique ID of the new geometry object
  31370. * @returns the new geometry object
  31371. */
  31372. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31373. /**
  31374. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31376. * Be aware Math.random() could cause collisions, but:
  31377. * "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"
  31378. * @returns a string containing a new GUID
  31379. */
  31380. static RandomId(): string;
  31381. /** @hidden */
  31382. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31383. private static _CleanMatricesWeights;
  31384. /**
  31385. * Create a new geometry from persisted data (Using .babylon file format)
  31386. * @param parsedVertexData defines the persisted data
  31387. * @param scene defines the hosting scene
  31388. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31389. * @returns the new geometry object
  31390. */
  31391. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31392. }
  31393. }
  31394. declare module "babylonjs/Meshes/mesh.vertexData" {
  31395. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31396. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31397. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31398. import { Geometry } from "babylonjs/Meshes/geometry";
  31399. import { Mesh } from "babylonjs/Meshes/mesh";
  31400. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31401. /**
  31402. * Define an interface for all classes that will get and set the data on vertices
  31403. */
  31404. export interface IGetSetVerticesData {
  31405. /**
  31406. * Gets a boolean indicating if specific vertex data is present
  31407. * @param kind defines the vertex data kind to use
  31408. * @returns true is data kind is present
  31409. */
  31410. isVerticesDataPresent(kind: string): boolean;
  31411. /**
  31412. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31413. * @param kind defines the data kind (Position, normal, etc...)
  31414. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31415. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31416. * @returns a float array containing vertex data
  31417. */
  31418. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31419. /**
  31420. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31421. * @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.
  31422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31423. * @returns the indices array or an empty array if the mesh has no geometry
  31424. */
  31425. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31426. /**
  31427. * Set specific vertex data
  31428. * @param kind defines the data kind (Position, normal, etc...)
  31429. * @param data defines the vertex data to use
  31430. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31431. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31432. */
  31433. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31434. /**
  31435. * Update a specific associated vertex buffer
  31436. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31437. * - VertexBuffer.PositionKind
  31438. * - VertexBuffer.UVKind
  31439. * - VertexBuffer.UV2Kind
  31440. * - VertexBuffer.UV3Kind
  31441. * - VertexBuffer.UV4Kind
  31442. * - VertexBuffer.UV5Kind
  31443. * - VertexBuffer.UV6Kind
  31444. * - VertexBuffer.ColorKind
  31445. * - VertexBuffer.MatricesIndicesKind
  31446. * - VertexBuffer.MatricesIndicesExtraKind
  31447. * - VertexBuffer.MatricesWeightsKind
  31448. * - VertexBuffer.MatricesWeightsExtraKind
  31449. * @param data defines the data source
  31450. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31451. * @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)
  31452. */
  31453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31454. /**
  31455. * Creates a new index buffer
  31456. * @param indices defines the indices to store in the index buffer
  31457. * @param totalVertices defines the total number of vertices (could be null)
  31458. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31459. */
  31460. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31461. }
  31462. /**
  31463. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31464. */
  31465. export class VertexData {
  31466. /**
  31467. * Mesh side orientation : usually the external or front surface
  31468. */
  31469. static readonly FRONTSIDE: number;
  31470. /**
  31471. * Mesh side orientation : usually the internal or back surface
  31472. */
  31473. static readonly BACKSIDE: number;
  31474. /**
  31475. * Mesh side orientation : both internal and external or front and back surfaces
  31476. */
  31477. static readonly DOUBLESIDE: number;
  31478. /**
  31479. * Mesh side orientation : by default, `FRONTSIDE`
  31480. */
  31481. static readonly DEFAULTSIDE: number;
  31482. /**
  31483. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31484. */
  31485. positions: Nullable<FloatArray>;
  31486. /**
  31487. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31488. */
  31489. normals: Nullable<FloatArray>;
  31490. /**
  31491. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31492. */
  31493. tangents: Nullable<FloatArray>;
  31494. /**
  31495. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31496. */
  31497. uvs: Nullable<FloatArray>;
  31498. /**
  31499. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31500. */
  31501. uvs2: Nullable<FloatArray>;
  31502. /**
  31503. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31504. */
  31505. uvs3: Nullable<FloatArray>;
  31506. /**
  31507. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31508. */
  31509. uvs4: Nullable<FloatArray>;
  31510. /**
  31511. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31512. */
  31513. uvs5: Nullable<FloatArray>;
  31514. /**
  31515. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31516. */
  31517. uvs6: Nullable<FloatArray>;
  31518. /**
  31519. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31520. */
  31521. colors: Nullable<FloatArray>;
  31522. /**
  31523. * 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).
  31524. */
  31525. matricesIndices: Nullable<FloatArray>;
  31526. /**
  31527. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31528. */
  31529. matricesWeights: Nullable<FloatArray>;
  31530. /**
  31531. * An array extending the number of possible indices
  31532. */
  31533. matricesIndicesExtra: Nullable<FloatArray>;
  31534. /**
  31535. * An array extending the number of possible weights when the number of indices is extended
  31536. */
  31537. matricesWeightsExtra: Nullable<FloatArray>;
  31538. /**
  31539. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31540. */
  31541. indices: Nullable<IndicesArray>;
  31542. /**
  31543. * Uses the passed data array to set the set the values for the specified kind of data
  31544. * @param data a linear array of floating numbers
  31545. * @param kind the type of data that is being set, eg positions, colors etc
  31546. */
  31547. set(data: FloatArray, kind: string): void;
  31548. /**
  31549. * Associates the vertexData to the passed Mesh.
  31550. * Sets it as updatable or not (default `false`)
  31551. * @param mesh the mesh the vertexData is applied to
  31552. * @param updatable when used and having the value true allows new data to update the vertexData
  31553. * @returns the VertexData
  31554. */
  31555. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31556. /**
  31557. * Associates the vertexData to the passed Geometry.
  31558. * Sets it as updatable or not (default `false`)
  31559. * @param geometry the geometry the vertexData is applied to
  31560. * @param updatable when used and having the value true allows new data to update the vertexData
  31561. * @returns VertexData
  31562. */
  31563. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31564. /**
  31565. * Updates the associated mesh
  31566. * @param mesh the mesh to be updated
  31567. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31568. * @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
  31569. * @returns VertexData
  31570. */
  31571. updateMesh(mesh: Mesh): VertexData;
  31572. /**
  31573. * Updates the associated geometry
  31574. * @param geometry the geometry to be updated
  31575. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31576. * @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
  31577. * @returns VertexData.
  31578. */
  31579. updateGeometry(geometry: Geometry): VertexData;
  31580. private _applyTo;
  31581. private _update;
  31582. /**
  31583. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31584. * @param matrix the transforming matrix
  31585. * @returns the VertexData
  31586. */
  31587. transform(matrix: Matrix): VertexData;
  31588. /**
  31589. * Merges the passed VertexData into the current one
  31590. * @param other the VertexData to be merged into the current one
  31591. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31592. * @returns the modified VertexData
  31593. */
  31594. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31595. private _mergeElement;
  31596. private _validate;
  31597. /**
  31598. * Serializes the VertexData
  31599. * @returns a serialized object
  31600. */
  31601. serialize(): any;
  31602. /**
  31603. * Extracts the vertexData from a mesh
  31604. * @param mesh the mesh from which to extract the VertexData
  31605. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31606. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31607. * @returns the object VertexData associated to the passed mesh
  31608. */
  31609. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31610. /**
  31611. * Extracts the vertexData from the geometry
  31612. * @param geometry the geometry from which to extract the VertexData
  31613. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31614. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31615. * @returns the object VertexData associated to the passed mesh
  31616. */
  31617. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31618. private static _ExtractFrom;
  31619. /**
  31620. * Creates the VertexData for a Ribbon
  31621. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31622. * * pathArray array of paths, each of which an array of successive Vector3
  31623. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31624. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31625. * * 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
  31626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31627. * * 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)
  31628. * * 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)
  31629. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31630. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31631. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31632. * @returns the VertexData of the ribbon
  31633. */
  31634. static CreateRibbon(options: {
  31635. pathArray: Vector3[][];
  31636. closeArray?: boolean;
  31637. closePath?: boolean;
  31638. offset?: number;
  31639. sideOrientation?: number;
  31640. frontUVs?: Vector4;
  31641. backUVs?: Vector4;
  31642. invertUV?: boolean;
  31643. uvs?: Vector2[];
  31644. colors?: Color4[];
  31645. }): VertexData;
  31646. /**
  31647. * Creates the VertexData for a box
  31648. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31649. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31650. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31651. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31652. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31653. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31654. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31656. * * 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)
  31657. * * 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)
  31658. * @returns the VertexData of the box
  31659. */
  31660. static CreateBox(options: {
  31661. size?: number;
  31662. width?: number;
  31663. height?: number;
  31664. depth?: number;
  31665. faceUV?: Vector4[];
  31666. faceColors?: Color4[];
  31667. sideOrientation?: number;
  31668. frontUVs?: Vector4;
  31669. backUVs?: Vector4;
  31670. }): VertexData;
  31671. /**
  31672. * Creates the VertexData for a tiled box
  31673. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31674. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31675. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31676. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31678. * @returns the VertexData of the box
  31679. */
  31680. static CreateTiledBox(options: {
  31681. pattern?: number;
  31682. width?: number;
  31683. height?: number;
  31684. depth?: number;
  31685. tileSize?: number;
  31686. tileWidth?: number;
  31687. tileHeight?: number;
  31688. alignHorizontal?: number;
  31689. alignVertical?: number;
  31690. faceUV?: Vector4[];
  31691. faceColors?: Color4[];
  31692. sideOrientation?: number;
  31693. }): VertexData;
  31694. /**
  31695. * Creates the VertexData for a tiled plane
  31696. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31697. * * pattern a limited pattern arrangement depending on the number
  31698. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31699. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31700. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31701. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31702. * * 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)
  31703. * * 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)
  31704. * @returns the VertexData of the tiled plane
  31705. */
  31706. static CreateTiledPlane(options: {
  31707. pattern?: number;
  31708. tileSize?: number;
  31709. tileWidth?: number;
  31710. tileHeight?: number;
  31711. size?: number;
  31712. width?: number;
  31713. height?: number;
  31714. alignHorizontal?: number;
  31715. alignVertical?: number;
  31716. sideOrientation?: number;
  31717. frontUVs?: Vector4;
  31718. backUVs?: Vector4;
  31719. }): VertexData;
  31720. /**
  31721. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31722. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31723. * * segments sets the number of horizontal strips optional, default 32
  31724. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31725. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31726. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31727. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31728. * * 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
  31729. * * 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
  31730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31731. * * 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)
  31732. * * 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)
  31733. * @returns the VertexData of the ellipsoid
  31734. */
  31735. static CreateSphere(options: {
  31736. segments?: number;
  31737. diameter?: number;
  31738. diameterX?: number;
  31739. diameterY?: number;
  31740. diameterZ?: number;
  31741. arc?: number;
  31742. slice?: number;
  31743. sideOrientation?: number;
  31744. frontUVs?: Vector4;
  31745. backUVs?: Vector4;
  31746. }): VertexData;
  31747. /**
  31748. * Creates the VertexData for a cylinder, cone or prism
  31749. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31750. * * height sets the height (y direction) of the cylinder, optional, default 2
  31751. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31752. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31753. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31754. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31755. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31756. * * 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
  31757. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31758. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31759. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31760. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31762. * * 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)
  31763. * * 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)
  31764. * @returns the VertexData of the cylinder, cone or prism
  31765. */
  31766. static CreateCylinder(options: {
  31767. height?: number;
  31768. diameterTop?: number;
  31769. diameterBottom?: number;
  31770. diameter?: number;
  31771. tessellation?: number;
  31772. subdivisions?: number;
  31773. arc?: number;
  31774. faceColors?: Color4[];
  31775. faceUV?: Vector4[];
  31776. hasRings?: boolean;
  31777. enclose?: boolean;
  31778. sideOrientation?: number;
  31779. frontUVs?: Vector4;
  31780. backUVs?: Vector4;
  31781. }): VertexData;
  31782. /**
  31783. * Creates the VertexData for a torus
  31784. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31785. * * diameter the diameter of the torus, optional default 1
  31786. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31787. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31789. * * 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)
  31790. * * 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)
  31791. * @returns the VertexData of the torus
  31792. */
  31793. static CreateTorus(options: {
  31794. diameter?: number;
  31795. thickness?: number;
  31796. tessellation?: number;
  31797. sideOrientation?: number;
  31798. frontUVs?: Vector4;
  31799. backUVs?: Vector4;
  31800. }): VertexData;
  31801. /**
  31802. * Creates the VertexData of the LineSystem
  31803. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31804. * - lines an array of lines, each line being an array of successive Vector3
  31805. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31806. * @returns the VertexData of the LineSystem
  31807. */
  31808. static CreateLineSystem(options: {
  31809. lines: Vector3[][];
  31810. colors?: Nullable<Color4[][]>;
  31811. }): VertexData;
  31812. /**
  31813. * Create the VertexData for a DashedLines
  31814. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31815. * - points an array successive Vector3
  31816. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31817. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31818. * - dashNb the intended total number of dashes, optional, default 200
  31819. * @returns the VertexData for the DashedLines
  31820. */
  31821. static CreateDashedLines(options: {
  31822. points: Vector3[];
  31823. dashSize?: number;
  31824. gapSize?: number;
  31825. dashNb?: number;
  31826. }): VertexData;
  31827. /**
  31828. * Creates the VertexData for a Ground
  31829. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31830. * - width the width (x direction) of the ground, optional, default 1
  31831. * - height the height (z direction) of the ground, optional, default 1
  31832. * - subdivisions the number of subdivisions per side, optional, default 1
  31833. * @returns the VertexData of the Ground
  31834. */
  31835. static CreateGround(options: {
  31836. width?: number;
  31837. height?: number;
  31838. subdivisions?: number;
  31839. subdivisionsX?: number;
  31840. subdivisionsY?: number;
  31841. }): VertexData;
  31842. /**
  31843. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31844. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31845. * * xmin the ground minimum X coordinate, optional, default -1
  31846. * * zmin the ground minimum Z coordinate, optional, default -1
  31847. * * xmax the ground maximum X coordinate, optional, default 1
  31848. * * zmax the ground maximum Z coordinate, optional, default 1
  31849. * * 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}
  31850. * * 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}
  31851. * @returns the VertexData of the TiledGround
  31852. */
  31853. static CreateTiledGround(options: {
  31854. xmin: number;
  31855. zmin: number;
  31856. xmax: number;
  31857. zmax: number;
  31858. subdivisions?: {
  31859. w: number;
  31860. h: number;
  31861. };
  31862. precision?: {
  31863. w: number;
  31864. h: number;
  31865. };
  31866. }): VertexData;
  31867. /**
  31868. * Creates the VertexData of the Ground designed from a heightmap
  31869. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31870. * * width the width (x direction) of the ground
  31871. * * height the height (z direction) of the ground
  31872. * * subdivisions the number of subdivisions per side
  31873. * * minHeight the minimum altitude on the ground, optional, default 0
  31874. * * maxHeight the maximum altitude on the ground, optional default 1
  31875. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31876. * * buffer the array holding the image color data
  31877. * * bufferWidth the width of image
  31878. * * bufferHeight the height of image
  31879. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31880. * @returns the VertexData of the Ground designed from a heightmap
  31881. */
  31882. static CreateGroundFromHeightMap(options: {
  31883. width: number;
  31884. height: number;
  31885. subdivisions: number;
  31886. minHeight: number;
  31887. maxHeight: number;
  31888. colorFilter: Color3;
  31889. buffer: Uint8Array;
  31890. bufferWidth: number;
  31891. bufferHeight: number;
  31892. alphaFilter: number;
  31893. }): VertexData;
  31894. /**
  31895. * Creates the VertexData for a Plane
  31896. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31897. * * size sets the width and height of the plane to the value of size, optional default 1
  31898. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31899. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31901. * * 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)
  31902. * * 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)
  31903. * @returns the VertexData of the box
  31904. */
  31905. static CreatePlane(options: {
  31906. size?: number;
  31907. width?: number;
  31908. height?: number;
  31909. sideOrientation?: number;
  31910. frontUVs?: Vector4;
  31911. backUVs?: Vector4;
  31912. }): VertexData;
  31913. /**
  31914. * Creates the VertexData of the Disc or regular Polygon
  31915. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31916. * * radius the radius of the disc, optional default 0.5
  31917. * * tessellation the number of polygon sides, optional, default 64
  31918. * * 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
  31919. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31920. * * 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)
  31921. * * 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)
  31922. * @returns the VertexData of the box
  31923. */
  31924. static CreateDisc(options: {
  31925. radius?: number;
  31926. tessellation?: number;
  31927. arc?: number;
  31928. sideOrientation?: number;
  31929. frontUVs?: Vector4;
  31930. backUVs?: Vector4;
  31931. }): VertexData;
  31932. /**
  31933. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31934. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31935. * @param polygon a mesh built from polygonTriangulation.build()
  31936. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31937. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31938. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31939. * @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)
  31940. * @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)
  31941. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31942. * @returns the VertexData of the Polygon
  31943. */
  31944. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31945. /**
  31946. * Creates the VertexData of the IcoSphere
  31947. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31948. * * radius the radius of the IcoSphere, optional default 1
  31949. * * radiusX allows stretching in the x direction, optional, default radius
  31950. * * radiusY allows stretching in the y direction, optional, default radius
  31951. * * radiusZ allows stretching in the z direction, optional, default radius
  31952. * * flat when true creates a flat shaded mesh, optional, default true
  31953. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31955. * * 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)
  31956. * * 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)
  31957. * @returns the VertexData of the IcoSphere
  31958. */
  31959. static CreateIcoSphere(options: {
  31960. radius?: number;
  31961. radiusX?: number;
  31962. radiusY?: number;
  31963. radiusZ?: number;
  31964. flat?: boolean;
  31965. subdivisions?: number;
  31966. sideOrientation?: number;
  31967. frontUVs?: Vector4;
  31968. backUVs?: Vector4;
  31969. }): VertexData;
  31970. /**
  31971. * Creates the VertexData for a Polyhedron
  31972. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31973. * * type provided types are:
  31974. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31975. * * 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)
  31976. * * size the size of the IcoSphere, optional default 1
  31977. * * sizeX allows stretching in the x direction, optional, default size
  31978. * * sizeY allows stretching in the y direction, optional, default size
  31979. * * sizeZ allows stretching in the z direction, optional, default size
  31980. * * 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
  31981. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31982. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31983. * * flat when true creates a flat shaded mesh, optional, default true
  31984. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31986. * * 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)
  31987. * * 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)
  31988. * @returns the VertexData of the Polyhedron
  31989. */
  31990. static CreatePolyhedron(options: {
  31991. type?: number;
  31992. size?: number;
  31993. sizeX?: number;
  31994. sizeY?: number;
  31995. sizeZ?: number;
  31996. custom?: any;
  31997. faceUV?: Vector4[];
  31998. faceColors?: Color4[];
  31999. flat?: boolean;
  32000. sideOrientation?: number;
  32001. frontUVs?: Vector4;
  32002. backUVs?: Vector4;
  32003. }): VertexData;
  32004. /**
  32005. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32006. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32007. * @returns the VertexData of the Capsule
  32008. */
  32009. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32010. /**
  32011. * Creates the VertexData for a TorusKnot
  32012. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32013. * * radius the radius of the torus knot, optional, default 2
  32014. * * tube the thickness of the tube, optional, default 0.5
  32015. * * radialSegments the number of sides on each tube segments, optional, default 32
  32016. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32017. * * p the number of windings around the z axis, optional, default 2
  32018. * * q the number of windings around the x axis, optional, default 3
  32019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32020. * * 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)
  32021. * * 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)
  32022. * @returns the VertexData of the Torus Knot
  32023. */
  32024. static CreateTorusKnot(options: {
  32025. radius?: number;
  32026. tube?: number;
  32027. radialSegments?: number;
  32028. tubularSegments?: number;
  32029. p?: number;
  32030. q?: number;
  32031. sideOrientation?: number;
  32032. frontUVs?: Vector4;
  32033. backUVs?: Vector4;
  32034. }): VertexData;
  32035. /**
  32036. * Compute normals for given positions and indices
  32037. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32038. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32039. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32040. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32041. * * facetNormals : optional array of facet normals (vector3)
  32042. * * facetPositions : optional array of facet positions (vector3)
  32043. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32044. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32045. * * bInfo : optional bounding info, required for facetPartitioning computation
  32046. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32047. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32048. * * useRightHandedSystem: optional boolean to for right handed system computation
  32049. * * depthSort : optional boolean to enable the facet depth sort computation
  32050. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32051. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32052. */
  32053. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32054. facetNormals?: any;
  32055. facetPositions?: any;
  32056. facetPartitioning?: any;
  32057. ratio?: number;
  32058. bInfo?: any;
  32059. bbSize?: Vector3;
  32060. subDiv?: any;
  32061. useRightHandedSystem?: boolean;
  32062. depthSort?: boolean;
  32063. distanceTo?: Vector3;
  32064. depthSortedFacets?: any;
  32065. }): void;
  32066. /** @hidden */
  32067. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32068. /**
  32069. * Applies VertexData created from the imported parameters to the geometry
  32070. * @param parsedVertexData the parsed data from an imported file
  32071. * @param geometry the geometry to apply the VertexData to
  32072. */
  32073. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32074. }
  32075. }
  32076. declare module "babylonjs/Morph/morphTarget" {
  32077. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32078. import { Observable } from "babylonjs/Misc/observable";
  32079. import { Nullable, FloatArray } from "babylonjs/types";
  32080. import { Scene } from "babylonjs/scene";
  32081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32082. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32083. /**
  32084. * Defines a target to use with MorphTargetManager
  32085. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32086. */
  32087. export class MorphTarget implements IAnimatable {
  32088. /** defines the name of the target */
  32089. name: string;
  32090. /**
  32091. * Gets or sets the list of animations
  32092. */
  32093. animations: import("babylonjs/Animations/animation").Animation[];
  32094. private _scene;
  32095. private _positions;
  32096. private _normals;
  32097. private _tangents;
  32098. private _uvs;
  32099. private _influence;
  32100. private _uniqueId;
  32101. /**
  32102. * Observable raised when the influence changes
  32103. */
  32104. onInfluenceChanged: Observable<boolean>;
  32105. /** @hidden */
  32106. _onDataLayoutChanged: Observable<void>;
  32107. /**
  32108. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32109. */
  32110. get influence(): number;
  32111. set influence(influence: number);
  32112. /**
  32113. * Gets or sets the id of the morph Target
  32114. */
  32115. id: string;
  32116. private _animationPropertiesOverride;
  32117. /**
  32118. * Gets or sets the animation properties override
  32119. */
  32120. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32121. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32122. /**
  32123. * Creates a new MorphTarget
  32124. * @param name defines the name of the target
  32125. * @param influence defines the influence to use
  32126. * @param scene defines the scene the morphtarget belongs to
  32127. */
  32128. constructor(
  32129. /** defines the name of the target */
  32130. name: string, influence?: number, scene?: Nullable<Scene>);
  32131. /**
  32132. * Gets the unique ID of this manager
  32133. */
  32134. get uniqueId(): number;
  32135. /**
  32136. * Gets a boolean defining if the target contains position data
  32137. */
  32138. get hasPositions(): boolean;
  32139. /**
  32140. * Gets a boolean defining if the target contains normal data
  32141. */
  32142. get hasNormals(): boolean;
  32143. /**
  32144. * Gets a boolean defining if the target contains tangent data
  32145. */
  32146. get hasTangents(): boolean;
  32147. /**
  32148. * Gets a boolean defining if the target contains texture coordinates data
  32149. */
  32150. get hasUVs(): boolean;
  32151. /**
  32152. * Affects position data to this target
  32153. * @param data defines the position data to use
  32154. */
  32155. setPositions(data: Nullable<FloatArray>): void;
  32156. /**
  32157. * Gets the position data stored in this target
  32158. * @returns a FloatArray containing the position data (or null if not present)
  32159. */
  32160. getPositions(): Nullable<FloatArray>;
  32161. /**
  32162. * Affects normal data to this target
  32163. * @param data defines the normal data to use
  32164. */
  32165. setNormals(data: Nullable<FloatArray>): void;
  32166. /**
  32167. * Gets the normal data stored in this target
  32168. * @returns a FloatArray containing the normal data (or null if not present)
  32169. */
  32170. getNormals(): Nullable<FloatArray>;
  32171. /**
  32172. * Affects tangent data to this target
  32173. * @param data defines the tangent data to use
  32174. */
  32175. setTangents(data: Nullable<FloatArray>): void;
  32176. /**
  32177. * Gets the tangent data stored in this target
  32178. * @returns a FloatArray containing the tangent data (or null if not present)
  32179. */
  32180. getTangents(): Nullable<FloatArray>;
  32181. /**
  32182. * Affects texture coordinates data to this target
  32183. * @param data defines the texture coordinates data to use
  32184. */
  32185. setUVs(data: Nullable<FloatArray>): void;
  32186. /**
  32187. * Gets the texture coordinates data stored in this target
  32188. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32189. */
  32190. getUVs(): Nullable<FloatArray>;
  32191. /**
  32192. * Clone the current target
  32193. * @returns a new MorphTarget
  32194. */
  32195. clone(): MorphTarget;
  32196. /**
  32197. * Serializes the current target into a Serialization object
  32198. * @returns the serialized object
  32199. */
  32200. serialize(): any;
  32201. /**
  32202. * Returns the string "MorphTarget"
  32203. * @returns "MorphTarget"
  32204. */
  32205. getClassName(): string;
  32206. /**
  32207. * Creates a new target from serialized data
  32208. * @param serializationObject defines the serialized data to use
  32209. * @returns a new MorphTarget
  32210. */
  32211. static Parse(serializationObject: any): MorphTarget;
  32212. /**
  32213. * Creates a MorphTarget from mesh data
  32214. * @param mesh defines the source mesh
  32215. * @param name defines the name to use for the new target
  32216. * @param influence defines the influence to attach to the target
  32217. * @returns a new MorphTarget
  32218. */
  32219. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32220. }
  32221. }
  32222. declare module "babylonjs/Morph/morphTargetManager" {
  32223. import { Nullable } from "babylonjs/types";
  32224. import { Scene } from "babylonjs/scene";
  32225. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32226. /**
  32227. * This class is used to deform meshes using morphing between different targets
  32228. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32229. */
  32230. export class MorphTargetManager {
  32231. private _targets;
  32232. private _targetInfluenceChangedObservers;
  32233. private _targetDataLayoutChangedObservers;
  32234. private _activeTargets;
  32235. private _scene;
  32236. private _influences;
  32237. private _supportsNormals;
  32238. private _supportsTangents;
  32239. private _supportsUVs;
  32240. private _vertexCount;
  32241. private _uniqueId;
  32242. private _tempInfluences;
  32243. /**
  32244. * Gets or sets a boolean indicating if normals must be morphed
  32245. */
  32246. enableNormalMorphing: boolean;
  32247. /**
  32248. * Gets or sets a boolean indicating if tangents must be morphed
  32249. */
  32250. enableTangentMorphing: boolean;
  32251. /**
  32252. * Gets or sets a boolean indicating if UV must be morphed
  32253. */
  32254. enableUVMorphing: boolean;
  32255. /**
  32256. * Creates a new MorphTargetManager
  32257. * @param scene defines the current scene
  32258. */
  32259. constructor(scene?: Nullable<Scene>);
  32260. /**
  32261. * Gets the unique ID of this manager
  32262. */
  32263. get uniqueId(): number;
  32264. /**
  32265. * Gets the number of vertices handled by this manager
  32266. */
  32267. get vertexCount(): number;
  32268. /**
  32269. * Gets a boolean indicating if this manager supports morphing of normals
  32270. */
  32271. get supportsNormals(): boolean;
  32272. /**
  32273. * Gets a boolean indicating if this manager supports morphing of tangents
  32274. */
  32275. get supportsTangents(): boolean;
  32276. /**
  32277. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32278. */
  32279. get supportsUVs(): boolean;
  32280. /**
  32281. * Gets the number of targets stored in this manager
  32282. */
  32283. get numTargets(): number;
  32284. /**
  32285. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32286. */
  32287. get numInfluencers(): number;
  32288. /**
  32289. * Gets the list of influences (one per target)
  32290. */
  32291. get influences(): Float32Array;
  32292. /**
  32293. * Gets the active target at specified index. An active target is a target with an influence > 0
  32294. * @param index defines the index to check
  32295. * @returns the requested target
  32296. */
  32297. getActiveTarget(index: number): MorphTarget;
  32298. /**
  32299. * Gets the target at specified index
  32300. * @param index defines the index to check
  32301. * @returns the requested target
  32302. */
  32303. getTarget(index: number): MorphTarget;
  32304. /**
  32305. * Add a new target to this manager
  32306. * @param target defines the target to add
  32307. */
  32308. addTarget(target: MorphTarget): void;
  32309. /**
  32310. * Removes a target from the manager
  32311. * @param target defines the target to remove
  32312. */
  32313. removeTarget(target: MorphTarget): void;
  32314. /**
  32315. * Clone the current manager
  32316. * @returns a new MorphTargetManager
  32317. */
  32318. clone(): MorphTargetManager;
  32319. /**
  32320. * Serializes the current manager into a Serialization object
  32321. * @returns the serialized object
  32322. */
  32323. serialize(): any;
  32324. private _syncActiveTargets;
  32325. /**
  32326. * Syncrhonize the targets with all the meshes using this morph target manager
  32327. */
  32328. synchronize(): void;
  32329. /**
  32330. * Creates a new MorphTargetManager from serialized data
  32331. * @param serializationObject defines the serialized data
  32332. * @param scene defines the hosting scene
  32333. * @returns the new MorphTargetManager
  32334. */
  32335. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32336. }
  32337. }
  32338. declare module "babylonjs/Meshes/meshLODLevel" {
  32339. import { Mesh } from "babylonjs/Meshes/mesh";
  32340. import { Nullable } from "babylonjs/types";
  32341. /**
  32342. * Class used to represent a specific level of detail of a mesh
  32343. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32344. */
  32345. export class MeshLODLevel {
  32346. /** Defines the distance where this level should start being displayed */
  32347. distance: number;
  32348. /** Defines the mesh to use to render this level */
  32349. mesh: Nullable<Mesh>;
  32350. /**
  32351. * Creates a new LOD level
  32352. * @param distance defines the distance where this level should star being displayed
  32353. * @param mesh defines the mesh to use to render this level
  32354. */
  32355. constructor(
  32356. /** Defines the distance where this level should start being displayed */
  32357. distance: number,
  32358. /** Defines the mesh to use to render this level */
  32359. mesh: Nullable<Mesh>);
  32360. }
  32361. }
  32362. declare module "babylonjs/Misc/canvasGenerator" {
  32363. /**
  32364. * Helper class used to generate a canvas to manipulate images
  32365. */
  32366. export class CanvasGenerator {
  32367. /**
  32368. * Create a new canvas (or offscreen canvas depending on the context)
  32369. * @param width defines the expected width
  32370. * @param height defines the expected height
  32371. * @return a new canvas or offscreen canvas
  32372. */
  32373. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32374. }
  32375. }
  32376. declare module "babylonjs/Meshes/groundMesh" {
  32377. import { Scene } from "babylonjs/scene";
  32378. import { Vector3 } from "babylonjs/Maths/math.vector";
  32379. import { Mesh } from "babylonjs/Meshes/mesh";
  32380. /**
  32381. * Mesh representing the gorund
  32382. */
  32383. export class GroundMesh extends Mesh {
  32384. /** If octree should be generated */
  32385. generateOctree: boolean;
  32386. private _heightQuads;
  32387. /** @hidden */
  32388. _subdivisionsX: number;
  32389. /** @hidden */
  32390. _subdivisionsY: number;
  32391. /** @hidden */
  32392. _width: number;
  32393. /** @hidden */
  32394. _height: number;
  32395. /** @hidden */
  32396. _minX: number;
  32397. /** @hidden */
  32398. _maxX: number;
  32399. /** @hidden */
  32400. _minZ: number;
  32401. /** @hidden */
  32402. _maxZ: number;
  32403. constructor(name: string, scene: Scene);
  32404. /**
  32405. * "GroundMesh"
  32406. * @returns "GroundMesh"
  32407. */
  32408. getClassName(): string;
  32409. /**
  32410. * The minimum of x and y subdivisions
  32411. */
  32412. get subdivisions(): number;
  32413. /**
  32414. * X subdivisions
  32415. */
  32416. get subdivisionsX(): number;
  32417. /**
  32418. * Y subdivisions
  32419. */
  32420. get subdivisionsY(): number;
  32421. /**
  32422. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32423. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32424. * @param chunksCount the number of subdivisions for x and y
  32425. * @param octreeBlocksSize (Default: 32)
  32426. */
  32427. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32428. /**
  32429. * Returns a height (y) value in the Worl system :
  32430. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32431. * @param x x coordinate
  32432. * @param z z coordinate
  32433. * @returns the ground y position if (x, z) are outside the ground surface.
  32434. */
  32435. getHeightAtCoordinates(x: number, z: number): number;
  32436. /**
  32437. * Returns a normalized vector (Vector3) orthogonal to the ground
  32438. * at the ground coordinates (x, z) expressed in the World system.
  32439. * @param x x coordinate
  32440. * @param z z coordinate
  32441. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32442. */
  32443. getNormalAtCoordinates(x: number, z: number): Vector3;
  32444. /**
  32445. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32446. * at the ground coordinates (x, z) expressed in the World system.
  32447. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32448. * @param x x coordinate
  32449. * @param z z coordinate
  32450. * @param ref vector to store the result
  32451. * @returns the GroundMesh.
  32452. */
  32453. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32454. /**
  32455. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32456. * if the ground has been updated.
  32457. * This can be used in the render loop.
  32458. * @returns the GroundMesh.
  32459. */
  32460. updateCoordinateHeights(): GroundMesh;
  32461. private _getFacetAt;
  32462. private _initHeightQuads;
  32463. private _computeHeightQuads;
  32464. /**
  32465. * Serializes this ground mesh
  32466. * @param serializationObject object to write serialization to
  32467. */
  32468. serialize(serializationObject: any): void;
  32469. /**
  32470. * Parses a serialized ground mesh
  32471. * @param parsedMesh the serialized mesh
  32472. * @param scene the scene to create the ground mesh in
  32473. * @returns the created ground mesh
  32474. */
  32475. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32476. }
  32477. }
  32478. declare module "babylonjs/Physics/physicsJoint" {
  32479. import { Vector3 } from "babylonjs/Maths/math.vector";
  32480. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32481. /**
  32482. * Interface for Physics-Joint data
  32483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32484. */
  32485. export interface PhysicsJointData {
  32486. /**
  32487. * The main pivot of the joint
  32488. */
  32489. mainPivot?: Vector3;
  32490. /**
  32491. * The connected pivot of the joint
  32492. */
  32493. connectedPivot?: Vector3;
  32494. /**
  32495. * The main axis of the joint
  32496. */
  32497. mainAxis?: Vector3;
  32498. /**
  32499. * The connected axis of the joint
  32500. */
  32501. connectedAxis?: Vector3;
  32502. /**
  32503. * The collision of the joint
  32504. */
  32505. collision?: boolean;
  32506. /**
  32507. * Native Oimo/Cannon/Energy data
  32508. */
  32509. nativeParams?: any;
  32510. }
  32511. /**
  32512. * This is a holder class for the physics joint created by the physics plugin
  32513. * It holds a set of functions to control the underlying joint
  32514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32515. */
  32516. export class PhysicsJoint {
  32517. /**
  32518. * The type of the physics joint
  32519. */
  32520. type: number;
  32521. /**
  32522. * The data for the physics joint
  32523. */
  32524. jointData: PhysicsJointData;
  32525. private _physicsJoint;
  32526. protected _physicsPlugin: IPhysicsEnginePlugin;
  32527. /**
  32528. * Initializes the physics joint
  32529. * @param type The type of the physics joint
  32530. * @param jointData The data for the physics joint
  32531. */
  32532. constructor(
  32533. /**
  32534. * The type of the physics joint
  32535. */
  32536. type: number,
  32537. /**
  32538. * The data for the physics joint
  32539. */
  32540. jointData: PhysicsJointData);
  32541. /**
  32542. * Gets the physics joint
  32543. */
  32544. get physicsJoint(): any;
  32545. /**
  32546. * Sets the physics joint
  32547. */
  32548. set physicsJoint(newJoint: any);
  32549. /**
  32550. * Sets the physics plugin
  32551. */
  32552. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32553. /**
  32554. * Execute a function that is physics-plugin specific.
  32555. * @param {Function} func the function that will be executed.
  32556. * It accepts two parameters: the physics world and the physics joint
  32557. */
  32558. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32559. /**
  32560. * Distance-Joint type
  32561. */
  32562. static DistanceJoint: number;
  32563. /**
  32564. * Hinge-Joint type
  32565. */
  32566. static HingeJoint: number;
  32567. /**
  32568. * Ball-and-Socket joint type
  32569. */
  32570. static BallAndSocketJoint: number;
  32571. /**
  32572. * Wheel-Joint type
  32573. */
  32574. static WheelJoint: number;
  32575. /**
  32576. * Slider-Joint type
  32577. */
  32578. static SliderJoint: number;
  32579. /**
  32580. * Prismatic-Joint type
  32581. */
  32582. static PrismaticJoint: number;
  32583. /**
  32584. * Universal-Joint type
  32585. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32586. */
  32587. static UniversalJoint: number;
  32588. /**
  32589. * Hinge-Joint 2 type
  32590. */
  32591. static Hinge2Joint: number;
  32592. /**
  32593. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32594. */
  32595. static PointToPointJoint: number;
  32596. /**
  32597. * Spring-Joint type
  32598. */
  32599. static SpringJoint: number;
  32600. /**
  32601. * Lock-Joint type
  32602. */
  32603. static LockJoint: number;
  32604. }
  32605. /**
  32606. * A class representing a physics distance joint
  32607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32608. */
  32609. export class DistanceJoint extends PhysicsJoint {
  32610. /**
  32611. *
  32612. * @param jointData The data for the Distance-Joint
  32613. */
  32614. constructor(jointData: DistanceJointData);
  32615. /**
  32616. * Update the predefined distance.
  32617. * @param maxDistance The maximum preferred distance
  32618. * @param minDistance The minimum preferred distance
  32619. */
  32620. updateDistance(maxDistance: number, minDistance?: number): void;
  32621. }
  32622. /**
  32623. * Represents a Motor-Enabled Joint
  32624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32625. */
  32626. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32627. /**
  32628. * Initializes the Motor-Enabled Joint
  32629. * @param type The type of the joint
  32630. * @param jointData The physica joint data for the joint
  32631. */
  32632. constructor(type: number, jointData: PhysicsJointData);
  32633. /**
  32634. * Set the motor values.
  32635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32636. * @param force the force to apply
  32637. * @param maxForce max force for this motor.
  32638. */
  32639. setMotor(force?: number, maxForce?: number): void;
  32640. /**
  32641. * Set the motor's limits.
  32642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32643. * @param upperLimit The upper limit of the motor
  32644. * @param lowerLimit The lower limit of the motor
  32645. */
  32646. setLimit(upperLimit: number, lowerLimit?: number): void;
  32647. }
  32648. /**
  32649. * This class represents a single physics Hinge-Joint
  32650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32651. */
  32652. export class HingeJoint extends MotorEnabledJoint {
  32653. /**
  32654. * Initializes the Hinge-Joint
  32655. * @param jointData The joint data for the Hinge-Joint
  32656. */
  32657. constructor(jointData: PhysicsJointData);
  32658. /**
  32659. * Set the motor values.
  32660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32661. * @param {number} force the force to apply
  32662. * @param {number} maxForce max force for this motor.
  32663. */
  32664. setMotor(force?: number, maxForce?: number): void;
  32665. /**
  32666. * Set the motor's limits.
  32667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32668. * @param upperLimit The upper limit of the motor
  32669. * @param lowerLimit The lower limit of the motor
  32670. */
  32671. setLimit(upperLimit: number, lowerLimit?: number): void;
  32672. }
  32673. /**
  32674. * This class represents a dual hinge physics joint (same as wheel joint)
  32675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32676. */
  32677. export class Hinge2Joint extends MotorEnabledJoint {
  32678. /**
  32679. * Initializes the Hinge2-Joint
  32680. * @param jointData The joint data for the Hinge2-Joint
  32681. */
  32682. constructor(jointData: PhysicsJointData);
  32683. /**
  32684. * Set the motor values.
  32685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32686. * @param {number} targetSpeed the speed the motor is to reach
  32687. * @param {number} maxForce max force for this motor.
  32688. * @param {motorIndex} the motor's index, 0 or 1.
  32689. */
  32690. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32691. /**
  32692. * Set the motor limits.
  32693. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32694. * @param {number} upperLimit the upper limit
  32695. * @param {number} lowerLimit lower limit
  32696. * @param {motorIndex} the motor's index, 0 or 1.
  32697. */
  32698. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32699. }
  32700. /**
  32701. * Interface for a motor enabled joint
  32702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32703. */
  32704. export interface IMotorEnabledJoint {
  32705. /**
  32706. * Physics joint
  32707. */
  32708. physicsJoint: any;
  32709. /**
  32710. * Sets the motor of the motor-enabled joint
  32711. * @param force The force of the motor
  32712. * @param maxForce The maximum force of the motor
  32713. * @param motorIndex The index of the motor
  32714. */
  32715. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32716. /**
  32717. * Sets the limit of the motor
  32718. * @param upperLimit The upper limit of the motor
  32719. * @param lowerLimit The lower limit of the motor
  32720. * @param motorIndex The index of the motor
  32721. */
  32722. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32723. }
  32724. /**
  32725. * Joint data for a Distance-Joint
  32726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32727. */
  32728. export interface DistanceJointData extends PhysicsJointData {
  32729. /**
  32730. * Max distance the 2 joint objects can be apart
  32731. */
  32732. maxDistance: number;
  32733. }
  32734. /**
  32735. * Joint data from a spring joint
  32736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32737. */
  32738. export interface SpringJointData extends PhysicsJointData {
  32739. /**
  32740. * Length of the spring
  32741. */
  32742. length: number;
  32743. /**
  32744. * Stiffness of the spring
  32745. */
  32746. stiffness: number;
  32747. /**
  32748. * Damping of the spring
  32749. */
  32750. damping: number;
  32751. /** this callback will be called when applying the force to the impostors. */
  32752. forceApplicationCallback: () => void;
  32753. }
  32754. }
  32755. declare module "babylonjs/Physics/physicsRaycastResult" {
  32756. import { Vector3 } from "babylonjs/Maths/math.vector";
  32757. /**
  32758. * Holds the data for the raycast result
  32759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32760. */
  32761. export class PhysicsRaycastResult {
  32762. private _hasHit;
  32763. private _hitDistance;
  32764. private _hitNormalWorld;
  32765. private _hitPointWorld;
  32766. private _rayFromWorld;
  32767. private _rayToWorld;
  32768. /**
  32769. * Gets if there was a hit
  32770. */
  32771. get hasHit(): boolean;
  32772. /**
  32773. * Gets the distance from the hit
  32774. */
  32775. get hitDistance(): number;
  32776. /**
  32777. * Gets the hit normal/direction in the world
  32778. */
  32779. get hitNormalWorld(): Vector3;
  32780. /**
  32781. * Gets the hit point in the world
  32782. */
  32783. get hitPointWorld(): Vector3;
  32784. /**
  32785. * Gets the ray "start point" of the ray in the world
  32786. */
  32787. get rayFromWorld(): Vector3;
  32788. /**
  32789. * Gets the ray "end point" of the ray in the world
  32790. */
  32791. get rayToWorld(): Vector3;
  32792. /**
  32793. * Sets the hit data (normal & point in world space)
  32794. * @param hitNormalWorld defines the normal in world space
  32795. * @param hitPointWorld defines the point in world space
  32796. */
  32797. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32798. /**
  32799. * Sets the distance from the start point to the hit point
  32800. * @param distance
  32801. */
  32802. setHitDistance(distance: number): void;
  32803. /**
  32804. * Calculates the distance manually
  32805. */
  32806. calculateHitDistance(): void;
  32807. /**
  32808. * Resets all the values to default
  32809. * @param from The from point on world space
  32810. * @param to The to point on world space
  32811. */
  32812. reset(from?: Vector3, to?: Vector3): void;
  32813. }
  32814. /**
  32815. * Interface for the size containing width and height
  32816. */
  32817. interface IXYZ {
  32818. /**
  32819. * X
  32820. */
  32821. x: number;
  32822. /**
  32823. * Y
  32824. */
  32825. y: number;
  32826. /**
  32827. * Z
  32828. */
  32829. z: number;
  32830. }
  32831. }
  32832. declare module "babylonjs/Physics/IPhysicsEngine" {
  32833. import { Nullable } from "babylonjs/types";
  32834. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32836. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32837. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32838. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32839. /**
  32840. * Interface used to describe a physics joint
  32841. */
  32842. export interface PhysicsImpostorJoint {
  32843. /** Defines the main impostor to which the joint is linked */
  32844. mainImpostor: PhysicsImpostor;
  32845. /** Defines the impostor that is connected to the main impostor using this joint */
  32846. connectedImpostor: PhysicsImpostor;
  32847. /** Defines the joint itself */
  32848. joint: PhysicsJoint;
  32849. }
  32850. /** @hidden */
  32851. export interface IPhysicsEnginePlugin {
  32852. world: any;
  32853. name: string;
  32854. setGravity(gravity: Vector3): void;
  32855. setTimeStep(timeStep: number): void;
  32856. getTimeStep(): number;
  32857. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32858. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32859. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32860. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32861. removePhysicsBody(impostor: PhysicsImpostor): void;
  32862. generateJoint(joint: PhysicsImpostorJoint): void;
  32863. removeJoint(joint: PhysicsImpostorJoint): void;
  32864. isSupported(): boolean;
  32865. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32866. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32867. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32868. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32869. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32870. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32871. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32872. getBodyMass(impostor: PhysicsImpostor): number;
  32873. getBodyFriction(impostor: PhysicsImpostor): number;
  32874. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32875. getBodyRestitution(impostor: PhysicsImpostor): number;
  32876. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32877. getBodyPressure?(impostor: PhysicsImpostor): number;
  32878. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32879. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32880. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32881. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32882. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32883. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32884. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32885. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32886. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32887. sleepBody(impostor: PhysicsImpostor): void;
  32888. wakeUpBody(impostor: PhysicsImpostor): void;
  32889. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32890. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32891. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32892. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32893. getRadius(impostor: PhysicsImpostor): number;
  32894. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32895. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32896. dispose(): void;
  32897. }
  32898. /**
  32899. * Interface used to define a physics engine
  32900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32901. */
  32902. export interface IPhysicsEngine {
  32903. /**
  32904. * Gets the gravity vector used by the simulation
  32905. */
  32906. gravity: Vector3;
  32907. /**
  32908. * Sets the gravity vector used by the simulation
  32909. * @param gravity defines the gravity vector to use
  32910. */
  32911. setGravity(gravity: Vector3): void;
  32912. /**
  32913. * Set the time step of the physics engine.
  32914. * Default is 1/60.
  32915. * To slow it down, enter 1/600 for example.
  32916. * To speed it up, 1/30
  32917. * @param newTimeStep the new timestep to apply to this world.
  32918. */
  32919. setTimeStep(newTimeStep: number): void;
  32920. /**
  32921. * Get the time step of the physics engine.
  32922. * @returns the current time step
  32923. */
  32924. getTimeStep(): number;
  32925. /**
  32926. * Set the sub time step of the physics engine.
  32927. * Default is 0 meaning there is no sub steps
  32928. * To increase physics resolution precision, set a small value (like 1 ms)
  32929. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32930. */
  32931. setSubTimeStep(subTimeStep: number): void;
  32932. /**
  32933. * Get the sub time step of the physics engine.
  32934. * @returns the current sub time step
  32935. */
  32936. getSubTimeStep(): number;
  32937. /**
  32938. * Release all resources
  32939. */
  32940. dispose(): void;
  32941. /**
  32942. * Gets the name of the current physics plugin
  32943. * @returns the name of the plugin
  32944. */
  32945. getPhysicsPluginName(): string;
  32946. /**
  32947. * Adding a new impostor for the impostor tracking.
  32948. * This will be done by the impostor itself.
  32949. * @param impostor the impostor to add
  32950. */
  32951. addImpostor(impostor: PhysicsImpostor): void;
  32952. /**
  32953. * Remove an impostor from the engine.
  32954. * This impostor and its mesh will not longer be updated by the physics engine.
  32955. * @param impostor the impostor to remove
  32956. */
  32957. removeImpostor(impostor: PhysicsImpostor): void;
  32958. /**
  32959. * Add a joint to the physics engine
  32960. * @param mainImpostor defines the main impostor to which the joint is added.
  32961. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32962. * @param joint defines the joint that will connect both impostors.
  32963. */
  32964. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32965. /**
  32966. * Removes a joint from the simulation
  32967. * @param mainImpostor defines the impostor used with the joint
  32968. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32969. * @param joint defines the joint to remove
  32970. */
  32971. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32972. /**
  32973. * Gets the current plugin used to run the simulation
  32974. * @returns current plugin
  32975. */
  32976. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32977. /**
  32978. * Gets the list of physic impostors
  32979. * @returns an array of PhysicsImpostor
  32980. */
  32981. getImpostors(): Array<PhysicsImpostor>;
  32982. /**
  32983. * Gets the impostor for a physics enabled object
  32984. * @param object defines the object impersonated by the impostor
  32985. * @returns the PhysicsImpostor or null if not found
  32986. */
  32987. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32988. /**
  32989. * Gets the impostor for a physics body object
  32990. * @param body defines physics body used by the impostor
  32991. * @returns the PhysicsImpostor or null if not found
  32992. */
  32993. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32994. /**
  32995. * Does a raycast in the physics world
  32996. * @param from when should the ray start?
  32997. * @param to when should the ray end?
  32998. * @returns PhysicsRaycastResult
  32999. */
  33000. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33001. /**
  33002. * Called by the scene. No need to call it.
  33003. * @param delta defines the timespam between frames
  33004. */
  33005. _step(delta: number): void;
  33006. }
  33007. }
  33008. declare module "babylonjs/Physics/physicsImpostor" {
  33009. import { Nullable, IndicesArray } from "babylonjs/types";
  33010. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33011. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33013. import { Scene } from "babylonjs/scene";
  33014. import { Bone } from "babylonjs/Bones/bone";
  33015. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33016. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33017. import { Space } from "babylonjs/Maths/math.axis";
  33018. /**
  33019. * The interface for the physics imposter parameters
  33020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33021. */
  33022. export interface PhysicsImpostorParameters {
  33023. /**
  33024. * The mass of the physics imposter
  33025. */
  33026. mass: number;
  33027. /**
  33028. * The friction of the physics imposter
  33029. */
  33030. friction?: number;
  33031. /**
  33032. * The coefficient of restitution of the physics imposter
  33033. */
  33034. restitution?: number;
  33035. /**
  33036. * The native options of the physics imposter
  33037. */
  33038. nativeOptions?: any;
  33039. /**
  33040. * Specifies if the parent should be ignored
  33041. */
  33042. ignoreParent?: boolean;
  33043. /**
  33044. * Specifies if bi-directional transformations should be disabled
  33045. */
  33046. disableBidirectionalTransformation?: boolean;
  33047. /**
  33048. * The pressure inside the physics imposter, soft object only
  33049. */
  33050. pressure?: number;
  33051. /**
  33052. * The stiffness the physics imposter, soft object only
  33053. */
  33054. stiffness?: number;
  33055. /**
  33056. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33057. */
  33058. velocityIterations?: number;
  33059. /**
  33060. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33061. */
  33062. positionIterations?: number;
  33063. /**
  33064. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33065. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33066. * Add to fix multiple points
  33067. */
  33068. fixedPoints?: number;
  33069. /**
  33070. * The collision margin around a soft object
  33071. */
  33072. margin?: number;
  33073. /**
  33074. * The collision margin around a soft object
  33075. */
  33076. damping?: number;
  33077. /**
  33078. * The path for a rope based on an extrusion
  33079. */
  33080. path?: any;
  33081. /**
  33082. * The shape of an extrusion used for a rope based on an extrusion
  33083. */
  33084. shape?: any;
  33085. }
  33086. /**
  33087. * Interface for a physics-enabled object
  33088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33089. */
  33090. export interface IPhysicsEnabledObject {
  33091. /**
  33092. * The position of the physics-enabled object
  33093. */
  33094. position: Vector3;
  33095. /**
  33096. * The rotation of the physics-enabled object
  33097. */
  33098. rotationQuaternion: Nullable<Quaternion>;
  33099. /**
  33100. * The scale of the physics-enabled object
  33101. */
  33102. scaling: Vector3;
  33103. /**
  33104. * The rotation of the physics-enabled object
  33105. */
  33106. rotation?: Vector3;
  33107. /**
  33108. * The parent of the physics-enabled object
  33109. */
  33110. parent?: any;
  33111. /**
  33112. * The bounding info of the physics-enabled object
  33113. * @returns The bounding info of the physics-enabled object
  33114. */
  33115. getBoundingInfo(): BoundingInfo;
  33116. /**
  33117. * Computes the world matrix
  33118. * @param force Specifies if the world matrix should be computed by force
  33119. * @returns A world matrix
  33120. */
  33121. computeWorldMatrix(force: boolean): Matrix;
  33122. /**
  33123. * Gets the world matrix
  33124. * @returns A world matrix
  33125. */
  33126. getWorldMatrix?(): Matrix;
  33127. /**
  33128. * Gets the child meshes
  33129. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33130. * @returns An array of abstract meshes
  33131. */
  33132. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33133. /**
  33134. * Gets the vertex data
  33135. * @param kind The type of vertex data
  33136. * @returns A nullable array of numbers, or a float32 array
  33137. */
  33138. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33139. /**
  33140. * Gets the indices from the mesh
  33141. * @returns A nullable array of index arrays
  33142. */
  33143. getIndices?(): Nullable<IndicesArray>;
  33144. /**
  33145. * Gets the scene from the mesh
  33146. * @returns the indices array or null
  33147. */
  33148. getScene?(): Scene;
  33149. /**
  33150. * Gets the absolute position from the mesh
  33151. * @returns the absolute position
  33152. */
  33153. getAbsolutePosition(): Vector3;
  33154. /**
  33155. * Gets the absolute pivot point from the mesh
  33156. * @returns the absolute pivot point
  33157. */
  33158. getAbsolutePivotPoint(): Vector3;
  33159. /**
  33160. * Rotates the mesh
  33161. * @param axis The axis of rotation
  33162. * @param amount The amount of rotation
  33163. * @param space The space of the rotation
  33164. * @returns The rotation transform node
  33165. */
  33166. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33167. /**
  33168. * Translates the mesh
  33169. * @param axis The axis of translation
  33170. * @param distance The distance of translation
  33171. * @param space The space of the translation
  33172. * @returns The transform node
  33173. */
  33174. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33175. /**
  33176. * Sets the absolute position of the mesh
  33177. * @param absolutePosition The absolute position of the mesh
  33178. * @returns The transform node
  33179. */
  33180. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33181. /**
  33182. * Gets the class name of the mesh
  33183. * @returns The class name
  33184. */
  33185. getClassName(): string;
  33186. }
  33187. /**
  33188. * Represents a physics imposter
  33189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33190. */
  33191. export class PhysicsImpostor {
  33192. /**
  33193. * The physics-enabled object used as the physics imposter
  33194. */
  33195. object: IPhysicsEnabledObject;
  33196. /**
  33197. * The type of the physics imposter
  33198. */
  33199. type: number;
  33200. private _options;
  33201. private _scene?;
  33202. /**
  33203. * The default object size of the imposter
  33204. */
  33205. static DEFAULT_OBJECT_SIZE: Vector3;
  33206. /**
  33207. * The identity quaternion of the imposter
  33208. */
  33209. static IDENTITY_QUATERNION: Quaternion;
  33210. /** @hidden */
  33211. _pluginData: any;
  33212. private _physicsEngine;
  33213. private _physicsBody;
  33214. private _bodyUpdateRequired;
  33215. private _onBeforePhysicsStepCallbacks;
  33216. private _onAfterPhysicsStepCallbacks;
  33217. /** @hidden */
  33218. _onPhysicsCollideCallbacks: Array<{
  33219. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33220. otherImpostors: Array<PhysicsImpostor>;
  33221. }>;
  33222. private _deltaPosition;
  33223. private _deltaRotation;
  33224. private _deltaRotationConjugated;
  33225. /** @hidden */
  33226. _isFromLine: boolean;
  33227. private _parent;
  33228. private _isDisposed;
  33229. private static _tmpVecs;
  33230. private static _tmpQuat;
  33231. /**
  33232. * Specifies if the physics imposter is disposed
  33233. */
  33234. get isDisposed(): boolean;
  33235. /**
  33236. * Gets the mass of the physics imposter
  33237. */
  33238. get mass(): number;
  33239. set mass(value: number);
  33240. /**
  33241. * Gets the coefficient of friction
  33242. */
  33243. get friction(): number;
  33244. /**
  33245. * Sets the coefficient of friction
  33246. */
  33247. set friction(value: number);
  33248. /**
  33249. * Gets the coefficient of restitution
  33250. */
  33251. get restitution(): number;
  33252. /**
  33253. * Sets the coefficient of restitution
  33254. */
  33255. set restitution(value: number);
  33256. /**
  33257. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33258. */
  33259. get pressure(): number;
  33260. /**
  33261. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33262. */
  33263. set pressure(value: number);
  33264. /**
  33265. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33266. */
  33267. get stiffness(): number;
  33268. /**
  33269. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33270. */
  33271. set stiffness(value: number);
  33272. /**
  33273. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33274. */
  33275. get velocityIterations(): number;
  33276. /**
  33277. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33278. */
  33279. set velocityIterations(value: number);
  33280. /**
  33281. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33282. */
  33283. get positionIterations(): number;
  33284. /**
  33285. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33286. */
  33287. set positionIterations(value: number);
  33288. /**
  33289. * The unique id of the physics imposter
  33290. * set by the physics engine when adding this impostor to the array
  33291. */
  33292. uniqueId: number;
  33293. /**
  33294. * @hidden
  33295. */
  33296. soft: boolean;
  33297. /**
  33298. * @hidden
  33299. */
  33300. segments: number;
  33301. private _joints;
  33302. /**
  33303. * Initializes the physics imposter
  33304. * @param object The physics-enabled object used as the physics imposter
  33305. * @param type The type of the physics imposter
  33306. * @param _options The options for the physics imposter
  33307. * @param _scene The Babylon scene
  33308. */
  33309. constructor(
  33310. /**
  33311. * The physics-enabled object used as the physics imposter
  33312. */
  33313. object: IPhysicsEnabledObject,
  33314. /**
  33315. * The type of the physics imposter
  33316. */
  33317. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33318. /**
  33319. * This function will completly initialize this impostor.
  33320. * It will create a new body - but only if this mesh has no parent.
  33321. * If it has, this impostor will not be used other than to define the impostor
  33322. * of the child mesh.
  33323. * @hidden
  33324. */
  33325. _init(): void;
  33326. private _getPhysicsParent;
  33327. /**
  33328. * Should a new body be generated.
  33329. * @returns boolean specifying if body initialization is required
  33330. */
  33331. isBodyInitRequired(): boolean;
  33332. /**
  33333. * Sets the updated scaling
  33334. * @param updated Specifies if the scaling is updated
  33335. */
  33336. setScalingUpdated(): void;
  33337. /**
  33338. * Force a regeneration of this or the parent's impostor's body.
  33339. * Use under cautious - This will remove all joints already implemented.
  33340. */
  33341. forceUpdate(): void;
  33342. /**
  33343. * Gets the body that holds this impostor. Either its own, or its parent.
  33344. */
  33345. get physicsBody(): any;
  33346. /**
  33347. * Get the parent of the physics imposter
  33348. * @returns Physics imposter or null
  33349. */
  33350. get parent(): Nullable<PhysicsImpostor>;
  33351. /**
  33352. * Sets the parent of the physics imposter
  33353. */
  33354. set parent(value: Nullable<PhysicsImpostor>);
  33355. /**
  33356. * Set the physics body. Used mainly by the physics engine/plugin
  33357. */
  33358. set physicsBody(physicsBody: any);
  33359. /**
  33360. * Resets the update flags
  33361. */
  33362. resetUpdateFlags(): void;
  33363. /**
  33364. * Gets the object extend size
  33365. * @returns the object extend size
  33366. */
  33367. getObjectExtendSize(): Vector3;
  33368. /**
  33369. * Gets the object center
  33370. * @returns The object center
  33371. */
  33372. getObjectCenter(): Vector3;
  33373. /**
  33374. * Get a specific parameter from the options parameters
  33375. * @param paramName The object parameter name
  33376. * @returns The object parameter
  33377. */
  33378. getParam(paramName: string): any;
  33379. /**
  33380. * Sets a specific parameter in the options given to the physics plugin
  33381. * @param paramName The parameter name
  33382. * @param value The value of the parameter
  33383. */
  33384. setParam(paramName: string, value: number): void;
  33385. /**
  33386. * Specifically change the body's mass option. Won't recreate the physics body object
  33387. * @param mass The mass of the physics imposter
  33388. */
  33389. setMass(mass: number): void;
  33390. /**
  33391. * Gets the linear velocity
  33392. * @returns linear velocity or null
  33393. */
  33394. getLinearVelocity(): Nullable<Vector3>;
  33395. /**
  33396. * Sets the linear velocity
  33397. * @param velocity linear velocity or null
  33398. */
  33399. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33400. /**
  33401. * Gets the angular velocity
  33402. * @returns angular velocity or null
  33403. */
  33404. getAngularVelocity(): Nullable<Vector3>;
  33405. /**
  33406. * Sets the angular velocity
  33407. * @param velocity The velocity or null
  33408. */
  33409. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33410. /**
  33411. * Execute a function with the physics plugin native code
  33412. * Provide a function the will have two variables - the world object and the physics body object
  33413. * @param func The function to execute with the physics plugin native code
  33414. */
  33415. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33416. /**
  33417. * Register a function that will be executed before the physics world is stepping forward
  33418. * @param func The function to execute before the physics world is stepped forward
  33419. */
  33420. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33421. /**
  33422. * Unregister a function that will be executed before the physics world is stepping forward
  33423. * @param func The function to execute before the physics world is stepped forward
  33424. */
  33425. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33426. /**
  33427. * Register a function that will be executed after the physics step
  33428. * @param func The function to execute after physics step
  33429. */
  33430. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33431. /**
  33432. * Unregisters a function that will be executed after the physics step
  33433. * @param func The function to execute after physics step
  33434. */
  33435. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33436. /**
  33437. * register a function that will be executed when this impostor collides against a different body
  33438. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33439. * @param func Callback that is executed on collision
  33440. */
  33441. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33442. /**
  33443. * Unregisters the physics imposter on contact
  33444. * @param collideAgainst The physics object to collide against
  33445. * @param func Callback to execute on collision
  33446. */
  33447. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33448. private _tmpQuat;
  33449. private _tmpQuat2;
  33450. /**
  33451. * Get the parent rotation
  33452. * @returns The parent rotation
  33453. */
  33454. getParentsRotation(): Quaternion;
  33455. /**
  33456. * this function is executed by the physics engine.
  33457. */
  33458. beforeStep: () => void;
  33459. /**
  33460. * this function is executed by the physics engine
  33461. */
  33462. afterStep: () => void;
  33463. /**
  33464. * Legacy collision detection event support
  33465. */
  33466. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33467. /**
  33468. * event and body object due to cannon's event-based architecture.
  33469. */
  33470. onCollide: (e: {
  33471. body: any;
  33472. point: Nullable<Vector3>;
  33473. }) => void;
  33474. /**
  33475. * Apply a force
  33476. * @param force The force to apply
  33477. * @param contactPoint The contact point for the force
  33478. * @returns The physics imposter
  33479. */
  33480. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33481. /**
  33482. * Apply an impulse
  33483. * @param force The impulse force
  33484. * @param contactPoint The contact point for the impulse force
  33485. * @returns The physics imposter
  33486. */
  33487. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33488. /**
  33489. * A help function to create a joint
  33490. * @param otherImpostor A physics imposter used to create a joint
  33491. * @param jointType The type of joint
  33492. * @param jointData The data for the joint
  33493. * @returns The physics imposter
  33494. */
  33495. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33496. /**
  33497. * Add a joint to this impostor with a different impostor
  33498. * @param otherImpostor A physics imposter used to add a joint
  33499. * @param joint The joint to add
  33500. * @returns The physics imposter
  33501. */
  33502. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33503. /**
  33504. * Add an anchor to a cloth impostor
  33505. * @param otherImpostor rigid impostor to anchor to
  33506. * @param width ratio across width from 0 to 1
  33507. * @param height ratio up height from 0 to 1
  33508. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33509. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33510. * @returns impostor the soft imposter
  33511. */
  33512. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33513. /**
  33514. * Add a hook to a rope impostor
  33515. * @param otherImpostor rigid impostor to anchor to
  33516. * @param length ratio across rope from 0 to 1
  33517. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33518. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33519. * @returns impostor the rope imposter
  33520. */
  33521. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33522. /**
  33523. * Will keep this body still, in a sleep mode.
  33524. * @returns the physics imposter
  33525. */
  33526. sleep(): PhysicsImpostor;
  33527. /**
  33528. * Wake the body up.
  33529. * @returns The physics imposter
  33530. */
  33531. wakeUp(): PhysicsImpostor;
  33532. /**
  33533. * Clones the physics imposter
  33534. * @param newObject The physics imposter clones to this physics-enabled object
  33535. * @returns A nullable physics imposter
  33536. */
  33537. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33538. /**
  33539. * Disposes the physics imposter
  33540. */
  33541. dispose(): void;
  33542. /**
  33543. * Sets the delta position
  33544. * @param position The delta position amount
  33545. */
  33546. setDeltaPosition(position: Vector3): void;
  33547. /**
  33548. * Sets the delta rotation
  33549. * @param rotation The delta rotation amount
  33550. */
  33551. setDeltaRotation(rotation: Quaternion): void;
  33552. /**
  33553. * Gets the box size of the physics imposter and stores the result in the input parameter
  33554. * @param result Stores the box size
  33555. * @returns The physics imposter
  33556. */
  33557. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33558. /**
  33559. * Gets the radius of the physics imposter
  33560. * @returns Radius of the physics imposter
  33561. */
  33562. getRadius(): number;
  33563. /**
  33564. * Sync a bone with this impostor
  33565. * @param bone The bone to sync to the impostor.
  33566. * @param boneMesh The mesh that the bone is influencing.
  33567. * @param jointPivot The pivot of the joint / bone in local space.
  33568. * @param distToJoint Optional distance from the impostor to the joint.
  33569. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33570. */
  33571. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33572. /**
  33573. * Sync impostor to a bone
  33574. * @param bone The bone that the impostor will be synced to.
  33575. * @param boneMesh The mesh that the bone is influencing.
  33576. * @param jointPivot The pivot of the joint / bone in local space.
  33577. * @param distToJoint Optional distance from the impostor to the joint.
  33578. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33579. * @param boneAxis Optional vector3 axis the bone is aligned with
  33580. */
  33581. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33582. /**
  33583. * No-Imposter type
  33584. */
  33585. static NoImpostor: number;
  33586. /**
  33587. * Sphere-Imposter type
  33588. */
  33589. static SphereImpostor: number;
  33590. /**
  33591. * Box-Imposter type
  33592. */
  33593. static BoxImpostor: number;
  33594. /**
  33595. * Plane-Imposter type
  33596. */
  33597. static PlaneImpostor: number;
  33598. /**
  33599. * Mesh-imposter type
  33600. */
  33601. static MeshImpostor: number;
  33602. /**
  33603. * Capsule-Impostor type (Ammo.js plugin only)
  33604. */
  33605. static CapsuleImpostor: number;
  33606. /**
  33607. * Cylinder-Imposter type
  33608. */
  33609. static CylinderImpostor: number;
  33610. /**
  33611. * Particle-Imposter type
  33612. */
  33613. static ParticleImpostor: number;
  33614. /**
  33615. * Heightmap-Imposter type
  33616. */
  33617. static HeightmapImpostor: number;
  33618. /**
  33619. * ConvexHull-Impostor type (Ammo.js plugin only)
  33620. */
  33621. static ConvexHullImpostor: number;
  33622. /**
  33623. * Custom-Imposter type (Ammo.js plugin only)
  33624. */
  33625. static CustomImpostor: number;
  33626. /**
  33627. * Rope-Imposter type
  33628. */
  33629. static RopeImpostor: number;
  33630. /**
  33631. * Cloth-Imposter type
  33632. */
  33633. static ClothImpostor: number;
  33634. /**
  33635. * Softbody-Imposter type
  33636. */
  33637. static SoftbodyImpostor: number;
  33638. }
  33639. }
  33640. declare module "babylonjs/Meshes/mesh" {
  33641. import { Observable } from "babylonjs/Misc/observable";
  33642. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33643. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33644. import { Camera } from "babylonjs/Cameras/camera";
  33645. import { Scene } from "babylonjs/scene";
  33646. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33647. import { Color4 } from "babylonjs/Maths/math.color";
  33648. import { Engine } from "babylonjs/Engines/engine";
  33649. import { Node } from "babylonjs/node";
  33650. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33651. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33652. import { Buffer } from "babylonjs/Meshes/buffer";
  33653. import { Geometry } from "babylonjs/Meshes/geometry";
  33654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33655. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33656. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33657. import { Effect } from "babylonjs/Materials/effect";
  33658. import { Material } from "babylonjs/Materials/material";
  33659. import { Skeleton } from "babylonjs/Bones/skeleton";
  33660. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33661. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33662. import { Path3D } from "babylonjs/Maths/math.path";
  33663. import { Plane } from "babylonjs/Maths/math.plane";
  33664. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33665. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33666. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33667. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33668. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33669. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33670. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33671. /**
  33672. * @hidden
  33673. **/
  33674. export class _CreationDataStorage {
  33675. closePath?: boolean;
  33676. closeArray?: boolean;
  33677. idx: number[];
  33678. dashSize: number;
  33679. gapSize: number;
  33680. path3D: Path3D;
  33681. pathArray: Vector3[][];
  33682. arc: number;
  33683. radius: number;
  33684. cap: number;
  33685. tessellation: number;
  33686. }
  33687. /**
  33688. * @hidden
  33689. **/
  33690. class _InstanceDataStorage {
  33691. visibleInstances: any;
  33692. batchCache: _InstancesBatch;
  33693. instancesBufferSize: number;
  33694. instancesBuffer: Nullable<Buffer>;
  33695. instancesData: Float32Array;
  33696. overridenInstanceCount: number;
  33697. isFrozen: boolean;
  33698. previousBatch: Nullable<_InstancesBatch>;
  33699. hardwareInstancedRendering: boolean;
  33700. sideOrientation: number;
  33701. manualUpdate: boolean;
  33702. previousRenderId: number;
  33703. }
  33704. /**
  33705. * @hidden
  33706. **/
  33707. export class _InstancesBatch {
  33708. mustReturn: boolean;
  33709. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33710. renderSelf: boolean[];
  33711. hardwareInstancedRendering: boolean[];
  33712. }
  33713. /**
  33714. * @hidden
  33715. **/
  33716. class _ThinInstanceDataStorage {
  33717. instancesCount: number;
  33718. matrixBuffer: Nullable<Buffer>;
  33719. matrixBufferSize: number;
  33720. matrixData: Nullable<Float32Array>;
  33721. boundingVectors: Array<Vector3>;
  33722. worldMatrices: Nullable<Matrix[]>;
  33723. }
  33724. /**
  33725. * Class used to represent renderable models
  33726. */
  33727. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33728. /**
  33729. * Mesh side orientation : usually the external or front surface
  33730. */
  33731. static readonly FRONTSIDE: number;
  33732. /**
  33733. * Mesh side orientation : usually the internal or back surface
  33734. */
  33735. static readonly BACKSIDE: number;
  33736. /**
  33737. * Mesh side orientation : both internal and external or front and back surfaces
  33738. */
  33739. static readonly DOUBLESIDE: number;
  33740. /**
  33741. * Mesh side orientation : by default, `FRONTSIDE`
  33742. */
  33743. static readonly DEFAULTSIDE: number;
  33744. /**
  33745. * Mesh cap setting : no cap
  33746. */
  33747. static readonly NO_CAP: number;
  33748. /**
  33749. * Mesh cap setting : one cap at the beginning of the mesh
  33750. */
  33751. static readonly CAP_START: number;
  33752. /**
  33753. * Mesh cap setting : one cap at the end of the mesh
  33754. */
  33755. static readonly CAP_END: number;
  33756. /**
  33757. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33758. */
  33759. static readonly CAP_ALL: number;
  33760. /**
  33761. * Mesh pattern setting : no flip or rotate
  33762. */
  33763. static readonly NO_FLIP: number;
  33764. /**
  33765. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33766. */
  33767. static readonly FLIP_TILE: number;
  33768. /**
  33769. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33770. */
  33771. static readonly ROTATE_TILE: number;
  33772. /**
  33773. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33774. */
  33775. static readonly FLIP_ROW: number;
  33776. /**
  33777. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33778. */
  33779. static readonly ROTATE_ROW: number;
  33780. /**
  33781. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33782. */
  33783. static readonly FLIP_N_ROTATE_TILE: number;
  33784. /**
  33785. * Mesh pattern setting : rotate pattern and rotate
  33786. */
  33787. static readonly FLIP_N_ROTATE_ROW: number;
  33788. /**
  33789. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33790. */
  33791. static readonly CENTER: number;
  33792. /**
  33793. * Mesh tile positioning : part tiles on left
  33794. */
  33795. static readonly LEFT: number;
  33796. /**
  33797. * Mesh tile positioning : part tiles on right
  33798. */
  33799. static readonly RIGHT: number;
  33800. /**
  33801. * Mesh tile positioning : part tiles on top
  33802. */
  33803. static readonly TOP: number;
  33804. /**
  33805. * Mesh tile positioning : part tiles on bottom
  33806. */
  33807. static readonly BOTTOM: number;
  33808. /**
  33809. * Gets the default side orientation.
  33810. * @param orientation the orientation to value to attempt to get
  33811. * @returns the default orientation
  33812. * @hidden
  33813. */
  33814. static _GetDefaultSideOrientation(orientation?: number): number;
  33815. private _internalMeshDataInfo;
  33816. get computeBonesUsingShaders(): boolean;
  33817. set computeBonesUsingShaders(value: boolean);
  33818. /**
  33819. * An event triggered before rendering the mesh
  33820. */
  33821. get onBeforeRenderObservable(): Observable<Mesh>;
  33822. /**
  33823. * An event triggered before binding the mesh
  33824. */
  33825. get onBeforeBindObservable(): Observable<Mesh>;
  33826. /**
  33827. * An event triggered after rendering the mesh
  33828. */
  33829. get onAfterRenderObservable(): Observable<Mesh>;
  33830. /**
  33831. * An event triggered before drawing the mesh
  33832. */
  33833. get onBeforeDrawObservable(): Observable<Mesh>;
  33834. private _onBeforeDrawObserver;
  33835. /**
  33836. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33837. */
  33838. set onBeforeDraw(callback: () => void);
  33839. get hasInstances(): boolean;
  33840. get hasThinInstances(): boolean;
  33841. /**
  33842. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33843. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33844. */
  33845. delayLoadState: number;
  33846. /**
  33847. * Gets the list of instances created from this mesh
  33848. * it is not supposed to be modified manually.
  33849. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33851. */
  33852. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33853. /**
  33854. * Gets the file containing delay loading data for this mesh
  33855. */
  33856. delayLoadingFile: string;
  33857. /** @hidden */
  33858. _binaryInfo: any;
  33859. /**
  33860. * User defined function used to change how LOD level selection is done
  33861. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33862. */
  33863. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33864. /**
  33865. * Gets or sets the morph target manager
  33866. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33867. */
  33868. get morphTargetManager(): Nullable<MorphTargetManager>;
  33869. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33870. /** @hidden */
  33871. _creationDataStorage: Nullable<_CreationDataStorage>;
  33872. /** @hidden */
  33873. _geometry: Nullable<Geometry>;
  33874. /** @hidden */
  33875. _delayInfo: Array<string>;
  33876. /** @hidden */
  33877. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33878. /** @hidden */
  33879. _instanceDataStorage: _InstanceDataStorage;
  33880. /** @hidden */
  33881. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33882. private _effectiveMaterial;
  33883. /** @hidden */
  33884. _shouldGenerateFlatShading: boolean;
  33885. /** @hidden */
  33886. _originalBuilderSideOrientation: number;
  33887. /**
  33888. * Use this property to change the original side orientation defined at construction time
  33889. */
  33890. overrideMaterialSideOrientation: Nullable<number>;
  33891. /**
  33892. * Gets the source mesh (the one used to clone this one from)
  33893. */
  33894. get source(): Nullable<Mesh>;
  33895. /**
  33896. * Gets the list of clones of this mesh
  33897. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33898. * Note that useClonedMeshMap=true is the default setting
  33899. */
  33900. get cloneMeshMap(): Nullable<{
  33901. [id: string]: Mesh | undefined;
  33902. }>;
  33903. /**
  33904. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33905. */
  33906. get isUnIndexed(): boolean;
  33907. set isUnIndexed(value: boolean);
  33908. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33909. get worldMatrixInstancedBuffer(): Float32Array;
  33910. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33911. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33912. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33913. /**
  33914. * @constructor
  33915. * @param name The value used by scene.getMeshByName() to do a lookup.
  33916. * @param scene The scene to add this mesh to.
  33917. * @param parent The parent of this mesh, if it has one
  33918. * @param source An optional Mesh from which geometry is shared, cloned.
  33919. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33920. * When false, achieved by calling a clone(), also passing False.
  33921. * This will make creation of children, recursive.
  33922. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33923. */
  33924. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33925. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33926. doNotInstantiate: boolean;
  33927. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33928. /**
  33929. * Gets the class name
  33930. * @returns the string "Mesh".
  33931. */
  33932. getClassName(): string;
  33933. /** @hidden */
  33934. get _isMesh(): boolean;
  33935. /**
  33936. * Returns a description of this mesh
  33937. * @param fullDetails define if full details about this mesh must be used
  33938. * @returns a descriptive string representing this mesh
  33939. */
  33940. toString(fullDetails?: boolean): string;
  33941. /** @hidden */
  33942. _unBindEffect(): void;
  33943. /**
  33944. * Gets a boolean indicating if this mesh has LOD
  33945. */
  33946. get hasLODLevels(): boolean;
  33947. /**
  33948. * Gets the list of MeshLODLevel associated with the current mesh
  33949. * @returns an array of MeshLODLevel
  33950. */
  33951. getLODLevels(): MeshLODLevel[];
  33952. private _sortLODLevels;
  33953. /**
  33954. * Add a mesh as LOD level triggered at the given distance.
  33955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33956. * @param distance The distance from the center of the object to show this level
  33957. * @param mesh The mesh to be added as LOD level (can be null)
  33958. * @return This mesh (for chaining)
  33959. */
  33960. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33961. /**
  33962. * Returns the LOD level mesh at the passed distance or null if not found.
  33963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33964. * @param distance The distance from the center of the object to show this level
  33965. * @returns a Mesh or `null`
  33966. */
  33967. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33968. /**
  33969. * Remove a mesh from the LOD array
  33970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33971. * @param mesh defines the mesh to be removed
  33972. * @return This mesh (for chaining)
  33973. */
  33974. removeLODLevel(mesh: Mesh): Mesh;
  33975. /**
  33976. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33977. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33978. * @param camera defines the camera to use to compute distance
  33979. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33980. * @return This mesh (for chaining)
  33981. */
  33982. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33983. /**
  33984. * Gets the mesh internal Geometry object
  33985. */
  33986. get geometry(): Nullable<Geometry>;
  33987. /**
  33988. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33989. * @returns the total number of vertices
  33990. */
  33991. getTotalVertices(): number;
  33992. /**
  33993. * Returns the content of an associated vertex buffer
  33994. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33995. * - VertexBuffer.PositionKind
  33996. * - VertexBuffer.UVKind
  33997. * - VertexBuffer.UV2Kind
  33998. * - VertexBuffer.UV3Kind
  33999. * - VertexBuffer.UV4Kind
  34000. * - VertexBuffer.UV5Kind
  34001. * - VertexBuffer.UV6Kind
  34002. * - VertexBuffer.ColorKind
  34003. * - VertexBuffer.MatricesIndicesKind
  34004. * - VertexBuffer.MatricesIndicesExtraKind
  34005. * - VertexBuffer.MatricesWeightsKind
  34006. * - VertexBuffer.MatricesWeightsExtraKind
  34007. * @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
  34008. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34009. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34010. */
  34011. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34012. /**
  34013. * Returns the mesh VertexBuffer object from the requested `kind`
  34014. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34015. * - VertexBuffer.PositionKind
  34016. * - VertexBuffer.NormalKind
  34017. * - VertexBuffer.UVKind
  34018. * - VertexBuffer.UV2Kind
  34019. * - VertexBuffer.UV3Kind
  34020. * - VertexBuffer.UV4Kind
  34021. * - VertexBuffer.UV5Kind
  34022. * - VertexBuffer.UV6Kind
  34023. * - VertexBuffer.ColorKind
  34024. * - VertexBuffer.MatricesIndicesKind
  34025. * - VertexBuffer.MatricesIndicesExtraKind
  34026. * - VertexBuffer.MatricesWeightsKind
  34027. * - VertexBuffer.MatricesWeightsExtraKind
  34028. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34029. */
  34030. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34031. /**
  34032. * Tests if a specific vertex buffer is associated with this mesh
  34033. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34034. * - VertexBuffer.PositionKind
  34035. * - VertexBuffer.NormalKind
  34036. * - VertexBuffer.UVKind
  34037. * - VertexBuffer.UV2Kind
  34038. * - VertexBuffer.UV3Kind
  34039. * - VertexBuffer.UV4Kind
  34040. * - VertexBuffer.UV5Kind
  34041. * - VertexBuffer.UV6Kind
  34042. * - VertexBuffer.ColorKind
  34043. * - VertexBuffer.MatricesIndicesKind
  34044. * - VertexBuffer.MatricesIndicesExtraKind
  34045. * - VertexBuffer.MatricesWeightsKind
  34046. * - VertexBuffer.MatricesWeightsExtraKind
  34047. * @returns a boolean
  34048. */
  34049. isVerticesDataPresent(kind: string): boolean;
  34050. /**
  34051. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34052. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34053. * - VertexBuffer.PositionKind
  34054. * - VertexBuffer.UVKind
  34055. * - VertexBuffer.UV2Kind
  34056. * - VertexBuffer.UV3Kind
  34057. * - VertexBuffer.UV4Kind
  34058. * - VertexBuffer.UV5Kind
  34059. * - VertexBuffer.UV6Kind
  34060. * - VertexBuffer.ColorKind
  34061. * - VertexBuffer.MatricesIndicesKind
  34062. * - VertexBuffer.MatricesIndicesExtraKind
  34063. * - VertexBuffer.MatricesWeightsKind
  34064. * - VertexBuffer.MatricesWeightsExtraKind
  34065. * @returns a boolean
  34066. */
  34067. isVertexBufferUpdatable(kind: string): boolean;
  34068. /**
  34069. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34070. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34071. * - VertexBuffer.PositionKind
  34072. * - VertexBuffer.NormalKind
  34073. * - VertexBuffer.UVKind
  34074. * - VertexBuffer.UV2Kind
  34075. * - VertexBuffer.UV3Kind
  34076. * - VertexBuffer.UV4Kind
  34077. * - VertexBuffer.UV5Kind
  34078. * - VertexBuffer.UV6Kind
  34079. * - VertexBuffer.ColorKind
  34080. * - VertexBuffer.MatricesIndicesKind
  34081. * - VertexBuffer.MatricesIndicesExtraKind
  34082. * - VertexBuffer.MatricesWeightsKind
  34083. * - VertexBuffer.MatricesWeightsExtraKind
  34084. * @returns an array of strings
  34085. */
  34086. getVerticesDataKinds(): string[];
  34087. /**
  34088. * Returns a positive integer : the total number of indices in this mesh geometry.
  34089. * @returns the numner of indices or zero if the mesh has no geometry.
  34090. */
  34091. getTotalIndices(): number;
  34092. /**
  34093. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34094. * @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.
  34095. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34096. * @returns the indices array or an empty array if the mesh has no geometry
  34097. */
  34098. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34099. get isBlocked(): boolean;
  34100. /**
  34101. * Determine if the current mesh is ready to be rendered
  34102. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34103. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34104. * @returns true if all associated assets are ready (material, textures, shaders)
  34105. */
  34106. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34107. /**
  34108. * 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.
  34109. */
  34110. get areNormalsFrozen(): boolean;
  34111. /**
  34112. * 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.
  34113. * @returns the current mesh
  34114. */
  34115. freezeNormals(): Mesh;
  34116. /**
  34117. * 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
  34118. * @returns the current mesh
  34119. */
  34120. unfreezeNormals(): Mesh;
  34121. /**
  34122. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34123. */
  34124. set overridenInstanceCount(count: number);
  34125. /** @hidden */
  34126. _preActivate(): Mesh;
  34127. /** @hidden */
  34128. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34129. /** @hidden */
  34130. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34131. protected _afterComputeWorldMatrix(): void;
  34132. /** @hidden */
  34133. _postActivate(): void;
  34134. /**
  34135. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34136. * This means the mesh underlying bounding box and sphere are recomputed.
  34137. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34138. * @returns the current mesh
  34139. */
  34140. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34141. /** @hidden */
  34142. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34143. /**
  34144. * This function will subdivide the mesh into multiple submeshes
  34145. * @param count defines the expected number of submeshes
  34146. */
  34147. subdivide(count: number): void;
  34148. /**
  34149. * Copy a FloatArray into a specific associated vertex buffer
  34150. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34151. * - VertexBuffer.PositionKind
  34152. * - VertexBuffer.UVKind
  34153. * - VertexBuffer.UV2Kind
  34154. * - VertexBuffer.UV3Kind
  34155. * - VertexBuffer.UV4Kind
  34156. * - VertexBuffer.UV5Kind
  34157. * - VertexBuffer.UV6Kind
  34158. * - VertexBuffer.ColorKind
  34159. * - VertexBuffer.MatricesIndicesKind
  34160. * - VertexBuffer.MatricesIndicesExtraKind
  34161. * - VertexBuffer.MatricesWeightsKind
  34162. * - VertexBuffer.MatricesWeightsExtraKind
  34163. * @param data defines the data source
  34164. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34165. * @param stride defines the data stride size (can be null)
  34166. * @returns the current mesh
  34167. */
  34168. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34169. /**
  34170. * Delete a vertex buffer associated with this mesh
  34171. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34172. * - VertexBuffer.PositionKind
  34173. * - VertexBuffer.UVKind
  34174. * - VertexBuffer.UV2Kind
  34175. * - VertexBuffer.UV3Kind
  34176. * - VertexBuffer.UV4Kind
  34177. * - VertexBuffer.UV5Kind
  34178. * - VertexBuffer.UV6Kind
  34179. * - VertexBuffer.ColorKind
  34180. * - VertexBuffer.MatricesIndicesKind
  34181. * - VertexBuffer.MatricesIndicesExtraKind
  34182. * - VertexBuffer.MatricesWeightsKind
  34183. * - VertexBuffer.MatricesWeightsExtraKind
  34184. */
  34185. removeVerticesData(kind: string): void;
  34186. /**
  34187. * Flags an associated vertex buffer as updatable
  34188. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34189. * - VertexBuffer.PositionKind
  34190. * - VertexBuffer.UVKind
  34191. * - VertexBuffer.UV2Kind
  34192. * - VertexBuffer.UV3Kind
  34193. * - VertexBuffer.UV4Kind
  34194. * - VertexBuffer.UV5Kind
  34195. * - VertexBuffer.UV6Kind
  34196. * - VertexBuffer.ColorKind
  34197. * - VertexBuffer.MatricesIndicesKind
  34198. * - VertexBuffer.MatricesIndicesExtraKind
  34199. * - VertexBuffer.MatricesWeightsKind
  34200. * - VertexBuffer.MatricesWeightsExtraKind
  34201. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34202. */
  34203. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34204. /**
  34205. * Sets the mesh global Vertex Buffer
  34206. * @param buffer defines the buffer to use
  34207. * @returns the current mesh
  34208. */
  34209. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34210. /**
  34211. * Update a specific associated vertex buffer
  34212. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34213. * - VertexBuffer.PositionKind
  34214. * - VertexBuffer.UVKind
  34215. * - VertexBuffer.UV2Kind
  34216. * - VertexBuffer.UV3Kind
  34217. * - VertexBuffer.UV4Kind
  34218. * - VertexBuffer.UV5Kind
  34219. * - VertexBuffer.UV6Kind
  34220. * - VertexBuffer.ColorKind
  34221. * - VertexBuffer.MatricesIndicesKind
  34222. * - VertexBuffer.MatricesIndicesExtraKind
  34223. * - VertexBuffer.MatricesWeightsKind
  34224. * - VertexBuffer.MatricesWeightsExtraKind
  34225. * @param data defines the data source
  34226. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34227. * @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)
  34228. * @returns the current mesh
  34229. */
  34230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34231. /**
  34232. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34233. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34234. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34235. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34236. * @returns the current mesh
  34237. */
  34238. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34239. /**
  34240. * Creates a un-shared specific occurence of the geometry for the mesh.
  34241. * @returns the current mesh
  34242. */
  34243. makeGeometryUnique(): Mesh;
  34244. /**
  34245. * Set the index buffer of this mesh
  34246. * @param indices defines the source data
  34247. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34248. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34249. * @returns the current mesh
  34250. */
  34251. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34252. /**
  34253. * Update the current index buffer
  34254. * @param indices defines the source data
  34255. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34256. * @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)
  34257. * @returns the current mesh
  34258. */
  34259. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34260. /**
  34261. * Invert the geometry to move from a right handed system to a left handed one.
  34262. * @returns the current mesh
  34263. */
  34264. toLeftHanded(): Mesh;
  34265. /** @hidden */
  34266. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34267. /** @hidden */
  34268. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34269. /**
  34270. * Registers for this mesh a javascript function called just before the rendering process
  34271. * @param func defines the function to call before rendering this mesh
  34272. * @returns the current mesh
  34273. */
  34274. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34275. /**
  34276. * Disposes a previously registered javascript function called before the rendering
  34277. * @param func defines the function to remove
  34278. * @returns the current mesh
  34279. */
  34280. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34281. /**
  34282. * Registers for this mesh a javascript function called just after the rendering is complete
  34283. * @param func defines the function to call after rendering this mesh
  34284. * @returns the current mesh
  34285. */
  34286. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34287. /**
  34288. * Disposes a previously registered javascript function called after the rendering.
  34289. * @param func defines the function to remove
  34290. * @returns the current mesh
  34291. */
  34292. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34293. /** @hidden */
  34294. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34295. /** @hidden */
  34296. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34297. /** @hidden */
  34298. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34299. /** @hidden */
  34300. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34301. /** @hidden */
  34302. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34303. /** @hidden */
  34304. _rebuild(): void;
  34305. /** @hidden */
  34306. _freeze(): void;
  34307. /** @hidden */
  34308. _unFreeze(): void;
  34309. /**
  34310. * 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
  34311. * @param subMesh defines the subMesh to render
  34312. * @param enableAlphaMode defines if alpha mode can be changed
  34313. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34314. * @returns the current mesh
  34315. */
  34316. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34317. private _onBeforeDraw;
  34318. /**
  34319. * Renormalize the mesh and patch it up if there are no weights
  34320. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34321. * However in the case of zero weights then we set just a single influence to 1.
  34322. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34323. */
  34324. cleanMatrixWeights(): void;
  34325. private normalizeSkinFourWeights;
  34326. private normalizeSkinWeightsAndExtra;
  34327. /**
  34328. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34329. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34330. * the user know there was an issue with importing the mesh
  34331. * @returns a validation object with skinned, valid and report string
  34332. */
  34333. validateSkinning(): {
  34334. skinned: boolean;
  34335. valid: boolean;
  34336. report: string;
  34337. };
  34338. /** @hidden */
  34339. _checkDelayState(): Mesh;
  34340. private _queueLoad;
  34341. /**
  34342. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34343. * A mesh is in the frustum if its bounding box intersects the frustum
  34344. * @param frustumPlanes defines the frustum to test
  34345. * @returns true if the mesh is in the frustum planes
  34346. */
  34347. isInFrustum(frustumPlanes: Plane[]): boolean;
  34348. /**
  34349. * Sets the mesh material by the material or multiMaterial `id` property
  34350. * @param id is a string identifying the material or the multiMaterial
  34351. * @returns the current mesh
  34352. */
  34353. setMaterialByID(id: string): Mesh;
  34354. /**
  34355. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34356. * @returns an array of IAnimatable
  34357. */
  34358. getAnimatables(): IAnimatable[];
  34359. /**
  34360. * Modifies the mesh geometry according to the passed transformation matrix.
  34361. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34362. * The mesh normals are modified using the same transformation.
  34363. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34364. * @param transform defines the transform matrix to use
  34365. * @see https://doc.babylonjs.com/resources/baking_transformations
  34366. * @returns the current mesh
  34367. */
  34368. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34369. /**
  34370. * Modifies the mesh geometry according to its own current World Matrix.
  34371. * The mesh World Matrix is then reset.
  34372. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34373. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34374. * @see https://doc.babylonjs.com/resources/baking_transformations
  34375. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34376. * @returns the current mesh
  34377. */
  34378. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34379. /** @hidden */
  34380. get _positions(): Nullable<Vector3[]>;
  34381. /** @hidden */
  34382. _resetPointsArrayCache(): Mesh;
  34383. /** @hidden */
  34384. _generatePointsArray(): boolean;
  34385. /**
  34386. * Returns a new Mesh object generated from the current mesh properties.
  34387. * This method must not get confused with createInstance()
  34388. * @param name is a string, the name given to the new mesh
  34389. * @param newParent can be any Node object (default `null`)
  34390. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34391. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34392. * @returns a new mesh
  34393. */
  34394. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34395. /**
  34396. * Releases resources associated with this mesh.
  34397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34399. */
  34400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34401. /** @hidden */
  34402. _disposeInstanceSpecificData(): void;
  34403. /** @hidden */
  34404. _disposeThinInstanceSpecificData(): void;
  34405. /**
  34406. * Modifies the mesh geometry according to a displacement map.
  34407. * 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.
  34408. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34409. * @param url is a string, the URL from the image file is to be downloaded.
  34410. * @param minHeight is the lower limit of the displacement.
  34411. * @param maxHeight is the upper limit of the displacement.
  34412. * @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.
  34413. * @param uvOffset is an optional vector2 used to offset UV.
  34414. * @param uvScale is an optional vector2 used to scale UV.
  34415. * @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.
  34416. * @returns the Mesh.
  34417. */
  34418. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34419. /**
  34420. * Modifies the mesh geometry according to a displacementMap buffer.
  34421. * 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.
  34422. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34423. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34424. * @param heightMapWidth is the width of the buffer image.
  34425. * @param heightMapHeight is the height of the buffer image.
  34426. * @param minHeight is the lower limit of the displacement.
  34427. * @param maxHeight is the upper limit of the displacement.
  34428. * @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.
  34429. * @param uvOffset is an optional vector2 used to offset UV.
  34430. * @param uvScale is an optional vector2 used to scale UV.
  34431. * @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.
  34432. * @returns the Mesh.
  34433. */
  34434. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34435. /**
  34436. * Modify the mesh to get a flat shading rendering.
  34437. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34438. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34439. * @returns current mesh
  34440. */
  34441. convertToFlatShadedMesh(): Mesh;
  34442. /**
  34443. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34444. * In other words, more vertices, no more indices and a single bigger VBO.
  34445. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34446. * @returns current mesh
  34447. */
  34448. convertToUnIndexedMesh(): Mesh;
  34449. /**
  34450. * Inverses facet orientations.
  34451. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34452. * @param flipNormals will also inverts the normals
  34453. * @returns current mesh
  34454. */
  34455. flipFaces(flipNormals?: boolean): Mesh;
  34456. /**
  34457. * Increase the number of facets and hence vertices in a mesh
  34458. * Vertex normals are interpolated from existing vertex normals
  34459. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34460. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34461. */
  34462. increaseVertices(numberPerEdge: number): void;
  34463. /**
  34464. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34465. * This will undo any application of covertToFlatShadedMesh
  34466. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34467. */
  34468. forceSharedVertices(): void;
  34469. /** @hidden */
  34470. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34471. /** @hidden */
  34472. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34473. /**
  34474. * Creates a new InstancedMesh object from the mesh model.
  34475. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34476. * @param name defines the name of the new instance
  34477. * @returns a new InstancedMesh
  34478. */
  34479. createInstance(name: string): InstancedMesh;
  34480. /**
  34481. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34482. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34483. * @returns the current mesh
  34484. */
  34485. synchronizeInstances(): Mesh;
  34486. /**
  34487. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34488. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34489. * This should be used together with the simplification to avoid disappearing triangles.
  34490. * @param successCallback an optional success callback to be called after the optimization finished.
  34491. * @returns the current mesh
  34492. */
  34493. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34494. /**
  34495. * Serialize current mesh
  34496. * @param serializationObject defines the object which will receive the serialization data
  34497. */
  34498. serialize(serializationObject: any): void;
  34499. /** @hidden */
  34500. _syncGeometryWithMorphTargetManager(): void;
  34501. /** @hidden */
  34502. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34503. /**
  34504. * Returns a new Mesh object parsed from the source provided.
  34505. * @param parsedMesh is the source
  34506. * @param scene defines the hosting scene
  34507. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34508. * @returns a new Mesh
  34509. */
  34510. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34511. /**
  34512. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34514. * @param name defines the name of the mesh to create
  34515. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34516. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34517. * @param closePath creates a seam between the first and the last points of each path of the path array
  34518. * @param offset is taken in account only if the `pathArray` is containing a single path
  34519. * @param scene defines the hosting scene
  34520. * @param updatable defines if the mesh must be flagged as updatable
  34521. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34522. * @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)
  34523. * @returns a new Mesh
  34524. */
  34525. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34526. /**
  34527. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34528. * @param name defines the name of the mesh to create
  34529. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34530. * @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
  34531. * @param scene defines the hosting scene
  34532. * @param updatable defines if the mesh must be flagged as updatable
  34533. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34534. * @returns a new Mesh
  34535. */
  34536. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34537. /**
  34538. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34539. * @param name defines the name of the mesh to create
  34540. * @param size sets the size (float) of each box side (default 1)
  34541. * @param scene defines the hosting scene
  34542. * @param updatable defines if the mesh must be flagged as updatable
  34543. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34544. * @returns a new Mesh
  34545. */
  34546. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34547. /**
  34548. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34549. * @param name defines the name of the mesh to create
  34550. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34551. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34552. * @param scene defines the hosting scene
  34553. * @param updatable defines if the mesh must be flagged as updatable
  34554. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34555. * @returns a new Mesh
  34556. */
  34557. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34558. /**
  34559. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34560. * @param name defines the name of the mesh to create
  34561. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34562. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34563. * @param scene defines the hosting scene
  34564. * @returns a new Mesh
  34565. */
  34566. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34567. /**
  34568. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34569. * @param name defines the name of the mesh to create
  34570. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34571. * @param diameterTop set the top cap diameter (floats, default 1)
  34572. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34573. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34574. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34575. * @param scene defines the hosting scene
  34576. * @param updatable defines if the mesh must be flagged as updatable
  34577. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34578. * @returns a new Mesh
  34579. */
  34580. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34581. /**
  34582. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34583. * @param name defines the name of the mesh to create
  34584. * @param diameter sets the diameter size (float) of the torus (default 1)
  34585. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34586. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34587. * @param scene defines the hosting scene
  34588. * @param updatable defines if the mesh must be flagged as updatable
  34589. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34590. * @returns a new Mesh
  34591. */
  34592. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34593. /**
  34594. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34595. * @param name defines the name of the mesh to create
  34596. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34597. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34598. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34599. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34600. * @param p the number of windings on X axis (positive integers, default 2)
  34601. * @param q the number of windings on Y axis (positive integers, default 3)
  34602. * @param scene defines the hosting scene
  34603. * @param updatable defines if the mesh must be flagged as updatable
  34604. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34605. * @returns a new Mesh
  34606. */
  34607. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34608. /**
  34609. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34610. * @param name defines the name of the mesh to create
  34611. * @param points is an array successive Vector3
  34612. * @param scene defines the hosting scene
  34613. * @param updatable defines if the mesh must be flagged as updatable
  34614. * @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).
  34615. * @returns a new Mesh
  34616. */
  34617. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34618. /**
  34619. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34620. * @param name defines the name of the mesh to create
  34621. * @param points is an array successive Vector3
  34622. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34623. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34624. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34625. * @param scene defines the hosting scene
  34626. * @param updatable defines if the mesh must be flagged as updatable
  34627. * @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)
  34628. * @returns a new Mesh
  34629. */
  34630. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34631. /**
  34632. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34633. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34634. * 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.
  34635. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34636. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34637. * Remember you can only change the shape positions, not their number when updating a polygon.
  34638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34639. * @param name defines the name of the mesh to create
  34640. * @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
  34641. * @param scene defines the hosting scene
  34642. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34643. * @param updatable defines if the mesh must be flagged as updatable
  34644. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34645. * @param earcutInjection can be used to inject your own earcut reference
  34646. * @returns a new Mesh
  34647. */
  34648. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34649. /**
  34650. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34652. * @param name defines the name of the mesh to create
  34653. * @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
  34654. * @param depth defines the height of extrusion
  34655. * @param scene defines the hosting scene
  34656. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34657. * @param updatable defines if the mesh must be flagged as updatable
  34658. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34659. * @param earcutInjection can be used to inject your own earcut reference
  34660. * @returns a new Mesh
  34661. */
  34662. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34663. /**
  34664. * Creates an extruded shape mesh.
  34665. * 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
  34666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34668. * @param name defines the name of the mesh to create
  34669. * @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
  34670. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34671. * @param scale is the value to scale the shape
  34672. * @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
  34673. * @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
  34674. * @param scene defines the hosting scene
  34675. * @param updatable defines if the mesh must be flagged as updatable
  34676. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34677. * @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)
  34678. * @returns a new Mesh
  34679. */
  34680. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34681. /**
  34682. * Creates an custom extruded shape mesh.
  34683. * The custom extrusion is a parametric shape.
  34684. * It has no predefined shape. Its final shape will depend on the input parameters.
  34685. * Please consider using the same method from the MeshBuilder class instead
  34686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34687. * @param name defines the name of the mesh to create
  34688. * @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
  34689. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34690. * @param scaleFunction is a custom Javascript function called on each path point
  34691. * @param rotationFunction is a custom Javascript function called on each path point
  34692. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34693. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34694. * @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
  34695. * @param scene defines the hosting scene
  34696. * @param updatable defines if the mesh must be flagged as updatable
  34697. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34698. * @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)
  34699. * @returns a new Mesh
  34700. */
  34701. 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;
  34702. /**
  34703. * Creates lathe mesh.
  34704. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34705. * Please consider using the same method from the MeshBuilder class instead
  34706. * @param name defines the name of the mesh to create
  34707. * @param 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
  34708. * @param radius is the radius value of the lathe
  34709. * @param tessellation is the side number of the lathe.
  34710. * @param scene defines the hosting scene
  34711. * @param updatable defines if the mesh must be flagged as updatable
  34712. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34713. * @returns a new Mesh
  34714. */
  34715. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34716. /**
  34717. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34718. * @param name defines the name of the mesh to create
  34719. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34720. * @param scene defines the hosting scene
  34721. * @param updatable defines if the mesh must be flagged as updatable
  34722. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34723. * @returns a new Mesh
  34724. */
  34725. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34726. /**
  34727. * Creates a ground mesh.
  34728. * Please consider using the same method from the MeshBuilder class instead
  34729. * @param name defines the name of the mesh to create
  34730. * @param width set the width of the ground
  34731. * @param height set the height of the ground
  34732. * @param subdivisions sets the number of subdivisions per side
  34733. * @param scene defines the hosting scene
  34734. * @param updatable defines if the mesh must be flagged as updatable
  34735. * @returns a new Mesh
  34736. */
  34737. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34738. /**
  34739. * Creates a tiled ground mesh.
  34740. * Please consider using the same method from the MeshBuilder class instead
  34741. * @param name defines the name of the mesh to create
  34742. * @param xmin set the ground minimum X coordinate
  34743. * @param zmin set the ground minimum Y coordinate
  34744. * @param xmax set the ground maximum X coordinate
  34745. * @param zmax set the ground maximum Z coordinate
  34746. * @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
  34747. * @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
  34748. * @param scene defines the hosting scene
  34749. * @param updatable defines if the mesh must be flagged as updatable
  34750. * @returns a new Mesh
  34751. */
  34752. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34753. w: number;
  34754. h: number;
  34755. }, precision: {
  34756. w: number;
  34757. h: number;
  34758. }, scene: Scene, updatable?: boolean): Mesh;
  34759. /**
  34760. * Creates a ground mesh from a height map.
  34761. * Please consider using the same method from the MeshBuilder class instead
  34762. * @see https://doc.babylonjs.com/babylon101/height_map
  34763. * @param name defines the name of the mesh to create
  34764. * @param url sets the URL of the height map image resource
  34765. * @param width set the ground width size
  34766. * @param height set the ground height size
  34767. * @param subdivisions sets the number of subdivision per side
  34768. * @param minHeight is the minimum altitude on the ground
  34769. * @param maxHeight is the maximum altitude on the ground
  34770. * @param scene defines the hosting scene
  34771. * @param updatable defines if the mesh must be flagged as updatable
  34772. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34773. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34774. * @returns a new Mesh
  34775. */
  34776. 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;
  34777. /**
  34778. * Creates a tube mesh.
  34779. * The tube is a parametric shape.
  34780. * It has no predefined shape. Its final shape will depend on the input parameters.
  34781. * Please consider using the same method from the MeshBuilder class instead
  34782. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34783. * @param name defines the name of the mesh to create
  34784. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34785. * @param radius sets the tube radius size
  34786. * @param tessellation is the number of sides on the tubular surface
  34787. * @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
  34788. * @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
  34789. * @param scene defines the hosting scene
  34790. * @param updatable defines if the mesh must be flagged as updatable
  34791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34792. * @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)
  34793. * @returns a new Mesh
  34794. */
  34795. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34796. (i: number, distance: number): number;
  34797. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34798. /**
  34799. * Creates a polyhedron mesh.
  34800. * Please consider using the same method from the MeshBuilder class instead.
  34801. * * 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
  34802. * * The parameter `size` (positive float, default 1) sets the polygon size
  34803. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34804. * * 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`
  34805. * * 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
  34806. * * 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)`)
  34807. * * 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
  34808. * * 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
  34809. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34812. * @param name defines the name of the mesh to create
  34813. * @param options defines the options used to create the mesh
  34814. * @param scene defines the hosting scene
  34815. * @returns a new Mesh
  34816. */
  34817. static CreatePolyhedron(name: string, options: {
  34818. type?: number;
  34819. size?: number;
  34820. sizeX?: number;
  34821. sizeY?: number;
  34822. sizeZ?: number;
  34823. custom?: any;
  34824. faceUV?: Vector4[];
  34825. faceColors?: Color4[];
  34826. updatable?: boolean;
  34827. sideOrientation?: number;
  34828. }, scene: Scene): Mesh;
  34829. /**
  34830. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34831. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34832. * * 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`)
  34833. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34834. * * 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
  34835. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34838. * @param name defines the name of the mesh
  34839. * @param options defines the options used to create the mesh
  34840. * @param scene defines the hosting scene
  34841. * @returns a new Mesh
  34842. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34843. */
  34844. static CreateIcoSphere(name: string, options: {
  34845. radius?: number;
  34846. flat?: boolean;
  34847. subdivisions?: number;
  34848. sideOrientation?: number;
  34849. updatable?: boolean;
  34850. }, scene: Scene): Mesh;
  34851. /**
  34852. * Creates a decal mesh.
  34853. * Please consider using the same method from the MeshBuilder class instead.
  34854. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34855. * @param name defines the name of the mesh
  34856. * @param sourceMesh defines the mesh receiving the decal
  34857. * @param position sets the position of the decal in world coordinates
  34858. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34859. * @param size sets the decal scaling
  34860. * @param angle sets the angle to rotate the decal
  34861. * @returns a new Mesh
  34862. */
  34863. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34864. /** Creates a Capsule Mesh
  34865. * @param name defines the name of the mesh.
  34866. * @param options the constructors options used to shape the mesh.
  34867. * @param scene defines the scene the mesh is scoped to.
  34868. * @returns the capsule mesh
  34869. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34870. */
  34871. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34872. /**
  34873. * Prepare internal position array for software CPU skinning
  34874. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34875. */
  34876. setPositionsForCPUSkinning(): Float32Array;
  34877. /**
  34878. * Prepare internal normal array for software CPU skinning
  34879. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34880. */
  34881. setNormalsForCPUSkinning(): Float32Array;
  34882. /**
  34883. * Updates the vertex buffer by applying transformation from the bones
  34884. * @param skeleton defines the skeleton to apply to current mesh
  34885. * @returns the current mesh
  34886. */
  34887. applySkeleton(skeleton: Skeleton): Mesh;
  34888. /**
  34889. * 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
  34890. * @param meshes defines the list of meshes to scan
  34891. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34892. */
  34893. static MinMax(meshes: AbstractMesh[]): {
  34894. min: Vector3;
  34895. max: Vector3;
  34896. };
  34897. /**
  34898. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34899. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34900. * @returns a vector3
  34901. */
  34902. static Center(meshesOrMinMaxVector: {
  34903. min: Vector3;
  34904. max: Vector3;
  34905. } | AbstractMesh[]): Vector3;
  34906. /**
  34907. * Merge the array of meshes into a single mesh for performance reasons.
  34908. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34909. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34910. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34911. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34912. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34913. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34914. * @returns a new mesh
  34915. */
  34916. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34917. /** @hidden */
  34918. addInstance(instance: InstancedMesh): void;
  34919. /** @hidden */
  34920. removeInstance(instance: InstancedMesh): void;
  34921. }
  34922. }
  34923. declare module "babylonjs/Cameras/camera" {
  34924. import { SmartArray } from "babylonjs/Misc/smartArray";
  34925. import { Observable } from "babylonjs/Misc/observable";
  34926. import { Nullable } from "babylonjs/types";
  34927. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34928. import { Scene } from "babylonjs/scene";
  34929. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34930. import { Node } from "babylonjs/node";
  34931. import { Mesh } from "babylonjs/Meshes/mesh";
  34932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34933. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34934. import { Viewport } from "babylonjs/Maths/math.viewport";
  34935. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34936. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34938. import { Ray } from "babylonjs/Culling/ray";
  34939. /**
  34940. * This is the base class of all the camera used in the application.
  34941. * @see https://doc.babylonjs.com/features/cameras
  34942. */
  34943. export class Camera extends Node {
  34944. /** @hidden */
  34945. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34946. /**
  34947. * This is the default projection mode used by the cameras.
  34948. * It helps recreating a feeling of perspective and better appreciate depth.
  34949. * This is the best way to simulate real life cameras.
  34950. */
  34951. static readonly PERSPECTIVE_CAMERA: number;
  34952. /**
  34953. * This helps creating camera with an orthographic mode.
  34954. * 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.
  34955. */
  34956. static readonly ORTHOGRAPHIC_CAMERA: number;
  34957. /**
  34958. * This is the default FOV mode for perspective cameras.
  34959. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34960. */
  34961. static readonly FOVMODE_VERTICAL_FIXED: number;
  34962. /**
  34963. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34964. */
  34965. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34966. /**
  34967. * This specifies ther is no need for a camera rig.
  34968. * Basically only one eye is rendered corresponding to the camera.
  34969. */
  34970. static readonly RIG_MODE_NONE: number;
  34971. /**
  34972. * Simulates a camera Rig with one blue eye and one red eye.
  34973. * This can be use with 3d blue and red glasses.
  34974. */
  34975. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34976. /**
  34977. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34978. */
  34979. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34980. /**
  34981. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34982. */
  34983. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34984. /**
  34985. * Defines that both eyes of the camera will be rendered over under each other.
  34986. */
  34987. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34988. /**
  34989. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34990. */
  34991. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34992. /**
  34993. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  34994. */
  34995. static readonly RIG_MODE_VR: number;
  34996. /**
  34997. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  34998. */
  34999. static readonly RIG_MODE_WEBVR: number;
  35000. /**
  35001. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35002. */
  35003. static readonly RIG_MODE_CUSTOM: number;
  35004. /**
  35005. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35006. */
  35007. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35008. /**
  35009. * Define the input manager associated with the camera.
  35010. */
  35011. inputs: CameraInputsManager<Camera>;
  35012. /** @hidden */
  35013. _position: Vector3;
  35014. /**
  35015. * Define the current local position of the camera in the scene
  35016. */
  35017. get position(): Vector3;
  35018. set position(newPosition: Vector3);
  35019. protected _upVector: Vector3;
  35020. /**
  35021. * The vector the camera should consider as up.
  35022. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35023. */
  35024. set upVector(vec: Vector3);
  35025. get upVector(): Vector3;
  35026. /**
  35027. * Define the current limit on the left side for an orthographic camera
  35028. * In scene unit
  35029. */
  35030. orthoLeft: Nullable<number>;
  35031. /**
  35032. * Define the current limit on the right side for an orthographic camera
  35033. * In scene unit
  35034. */
  35035. orthoRight: Nullable<number>;
  35036. /**
  35037. * Define the current limit on the bottom side for an orthographic camera
  35038. * In scene unit
  35039. */
  35040. orthoBottom: Nullable<number>;
  35041. /**
  35042. * Define the current limit on the top side for an orthographic camera
  35043. * In scene unit
  35044. */
  35045. orthoTop: Nullable<number>;
  35046. /**
  35047. * Field Of View is set in Radians. (default is 0.8)
  35048. */
  35049. fov: number;
  35050. /**
  35051. * Define the minimum distance the camera can see from.
  35052. * This is important to note that the depth buffer are not infinite and the closer it starts
  35053. * the more your scene might encounter depth fighting issue.
  35054. */
  35055. minZ: number;
  35056. /**
  35057. * Define the maximum distance the camera can see to.
  35058. * This is important to note that the depth buffer are not infinite and the further it end
  35059. * the more your scene might encounter depth fighting issue.
  35060. */
  35061. maxZ: number;
  35062. /**
  35063. * Define the default inertia of the camera.
  35064. * This helps giving a smooth feeling to the camera movement.
  35065. */
  35066. inertia: number;
  35067. /**
  35068. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35069. */
  35070. mode: number;
  35071. /**
  35072. * Define whether the camera is intermediate.
  35073. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35074. */
  35075. isIntermediate: boolean;
  35076. /**
  35077. * Define the viewport of the camera.
  35078. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35079. */
  35080. viewport: Viewport;
  35081. /**
  35082. * Restricts the camera to viewing objects with the same layerMask.
  35083. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35084. */
  35085. layerMask: number;
  35086. /**
  35087. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35088. */
  35089. fovMode: number;
  35090. /**
  35091. * Rig mode of the camera.
  35092. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35093. * This is normally controlled byt the camera themselves as internal use.
  35094. */
  35095. cameraRigMode: number;
  35096. /**
  35097. * Defines the distance between both "eyes" in case of a RIG
  35098. */
  35099. interaxialDistance: number;
  35100. /**
  35101. * Defines if stereoscopic rendering is done side by side or over under.
  35102. */
  35103. isStereoscopicSideBySide: boolean;
  35104. /**
  35105. * 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
  35106. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35107. * else in the scene. (Eg. security camera)
  35108. *
  35109. * 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)
  35110. */
  35111. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35112. /**
  35113. * When set, the camera will render to this render target instead of the default canvas
  35114. *
  35115. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35116. */
  35117. outputRenderTarget: Nullable<RenderTargetTexture>;
  35118. /**
  35119. * Observable triggered when the camera view matrix has changed.
  35120. */
  35121. onViewMatrixChangedObservable: Observable<Camera>;
  35122. /**
  35123. * Observable triggered when the camera Projection matrix has changed.
  35124. */
  35125. onProjectionMatrixChangedObservable: Observable<Camera>;
  35126. /**
  35127. * Observable triggered when the inputs have been processed.
  35128. */
  35129. onAfterCheckInputsObservable: Observable<Camera>;
  35130. /**
  35131. * Observable triggered when reset has been called and applied to the camera.
  35132. */
  35133. onRestoreStateObservable: Observable<Camera>;
  35134. /**
  35135. * Is this camera a part of a rig system?
  35136. */
  35137. isRigCamera: boolean;
  35138. /**
  35139. * If isRigCamera set to true this will be set with the parent camera.
  35140. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35141. */
  35142. rigParent?: Camera;
  35143. /** @hidden */
  35144. _cameraRigParams: any;
  35145. /** @hidden */
  35146. _rigCameras: Camera[];
  35147. /** @hidden */
  35148. _rigPostProcess: Nullable<PostProcess>;
  35149. protected _webvrViewMatrix: Matrix;
  35150. /** @hidden */
  35151. _skipRendering: boolean;
  35152. /** @hidden */
  35153. _projectionMatrix: Matrix;
  35154. /** @hidden */
  35155. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35156. /** @hidden */
  35157. _activeMeshes: SmartArray<AbstractMesh>;
  35158. protected _globalPosition: Vector3;
  35159. /** @hidden */
  35160. _computedViewMatrix: Matrix;
  35161. private _doNotComputeProjectionMatrix;
  35162. private _transformMatrix;
  35163. private _frustumPlanes;
  35164. private _refreshFrustumPlanes;
  35165. private _storedFov;
  35166. private _stateStored;
  35167. /**
  35168. * Instantiates a new camera object.
  35169. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35170. * @see https://doc.babylonjs.com/features/cameras
  35171. * @param name Defines the name of the camera in the scene
  35172. * @param position Defines the position of the camera
  35173. * @param scene Defines the scene the camera belongs too
  35174. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35175. */
  35176. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35177. /**
  35178. * Store current camera state (fov, position, etc..)
  35179. * @returns the camera
  35180. */
  35181. storeState(): Camera;
  35182. /**
  35183. * Restores the camera state values if it has been stored. You must call storeState() first
  35184. */
  35185. protected _restoreStateValues(): boolean;
  35186. /**
  35187. * Restored camera state. You must call storeState() first.
  35188. * @returns true if restored and false otherwise
  35189. */
  35190. restoreState(): boolean;
  35191. /**
  35192. * Gets the class name of the camera.
  35193. * @returns the class name
  35194. */
  35195. getClassName(): string;
  35196. /** @hidden */
  35197. readonly _isCamera: boolean;
  35198. /**
  35199. * Gets a string representation of the camera useful for debug purpose.
  35200. * @param fullDetails Defines that a more verboe level of logging is required
  35201. * @returns the string representation
  35202. */
  35203. toString(fullDetails?: boolean): string;
  35204. /**
  35205. * Gets the current world space position of the camera.
  35206. */
  35207. get globalPosition(): Vector3;
  35208. /**
  35209. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35210. * @returns the active meshe list
  35211. */
  35212. getActiveMeshes(): SmartArray<AbstractMesh>;
  35213. /**
  35214. * Check whether a mesh is part of the current active mesh list of the camera
  35215. * @param mesh Defines the mesh to check
  35216. * @returns true if active, false otherwise
  35217. */
  35218. isActiveMesh(mesh: Mesh): boolean;
  35219. /**
  35220. * Is this camera ready to be used/rendered
  35221. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35222. * @return true if the camera is ready
  35223. */
  35224. isReady(completeCheck?: boolean): boolean;
  35225. /** @hidden */
  35226. _initCache(): void;
  35227. /** @hidden */
  35228. _updateCache(ignoreParentClass?: boolean): void;
  35229. /** @hidden */
  35230. _isSynchronized(): boolean;
  35231. /** @hidden */
  35232. _isSynchronizedViewMatrix(): boolean;
  35233. /** @hidden */
  35234. _isSynchronizedProjectionMatrix(): boolean;
  35235. /**
  35236. * Attach the input controls to a specific dom element to get the input from.
  35237. * @param element Defines the element the controls should be listened from
  35238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35239. */
  35240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35241. /**
  35242. * Detach the current controls from the specified dom element.
  35243. * @param element Defines the element to stop listening the inputs from
  35244. */
  35245. detachControl(element: HTMLElement): void;
  35246. /**
  35247. * Update the camera state according to the different inputs gathered during the frame.
  35248. */
  35249. update(): void;
  35250. /** @hidden */
  35251. _checkInputs(): void;
  35252. /** @hidden */
  35253. get rigCameras(): Camera[];
  35254. /**
  35255. * Gets the post process used by the rig cameras
  35256. */
  35257. get rigPostProcess(): Nullable<PostProcess>;
  35258. /**
  35259. * Internal, gets the first post proces.
  35260. * @returns the first post process to be run on this camera.
  35261. */
  35262. _getFirstPostProcess(): Nullable<PostProcess>;
  35263. private _cascadePostProcessesToRigCams;
  35264. /**
  35265. * Attach a post process to the camera.
  35266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35267. * @param postProcess The post process to attach to the camera
  35268. * @param insertAt The position of the post process in case several of them are in use in the scene
  35269. * @returns the position the post process has been inserted at
  35270. */
  35271. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35272. /**
  35273. * Detach a post process to the camera.
  35274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35275. * @param postProcess The post process to detach from the camera
  35276. */
  35277. detachPostProcess(postProcess: PostProcess): void;
  35278. /**
  35279. * Gets the current world matrix of the camera
  35280. */
  35281. getWorldMatrix(): Matrix;
  35282. /** @hidden */
  35283. _getViewMatrix(): Matrix;
  35284. /**
  35285. * Gets the current view matrix of the camera.
  35286. * @param force forces the camera to recompute the matrix without looking at the cached state
  35287. * @returns the view matrix
  35288. */
  35289. getViewMatrix(force?: boolean): Matrix;
  35290. /**
  35291. * Freeze the projection matrix.
  35292. * It will prevent the cache check of the camera projection compute and can speed up perf
  35293. * if no parameter of the camera are meant to change
  35294. * @param projection Defines manually a projection if necessary
  35295. */
  35296. freezeProjectionMatrix(projection?: Matrix): void;
  35297. /**
  35298. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35299. */
  35300. unfreezeProjectionMatrix(): void;
  35301. /**
  35302. * Gets the current projection matrix of the camera.
  35303. * @param force forces the camera to recompute the matrix without looking at the cached state
  35304. * @returns the projection matrix
  35305. */
  35306. getProjectionMatrix(force?: boolean): Matrix;
  35307. /**
  35308. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35309. * @returns a Matrix
  35310. */
  35311. getTransformationMatrix(): Matrix;
  35312. private _updateFrustumPlanes;
  35313. /**
  35314. * Checks if a cullable object (mesh...) is in the camera frustum
  35315. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35316. * @param target The object to check
  35317. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35318. * @returns true if the object is in frustum otherwise false
  35319. */
  35320. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35321. /**
  35322. * Checks if a cullable object (mesh...) is in the camera frustum
  35323. * Unlike isInFrustum this cheks the full bounding box
  35324. * @param target The object to check
  35325. * @returns true if the object is in frustum otherwise false
  35326. */
  35327. isCompletelyInFrustum(target: ICullable): boolean;
  35328. /**
  35329. * Gets a ray in the forward direction from the camera.
  35330. * @param length Defines the length of the ray to create
  35331. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35332. * @param origin Defines the start point of the ray which defaults to the camera position
  35333. * @returns the forward ray
  35334. */
  35335. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35336. /**
  35337. * Gets a ray in the forward direction from the camera.
  35338. * @param refRay the ray to (re)use when setting the values
  35339. * @param length Defines the length of the ray to create
  35340. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35341. * @param origin Defines the start point of the ray which defaults to the camera position
  35342. * @returns the forward ray
  35343. */
  35344. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35345. /**
  35346. * Releases resources associated with this node.
  35347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35349. */
  35350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35351. /** @hidden */
  35352. _isLeftCamera: boolean;
  35353. /**
  35354. * Gets the left camera of a rig setup in case of Rigged Camera
  35355. */
  35356. get isLeftCamera(): boolean;
  35357. /** @hidden */
  35358. _isRightCamera: boolean;
  35359. /**
  35360. * Gets the right camera of a rig setup in case of Rigged Camera
  35361. */
  35362. get isRightCamera(): boolean;
  35363. /**
  35364. * Gets the left camera of a rig setup in case of Rigged Camera
  35365. */
  35366. get leftCamera(): Nullable<FreeCamera>;
  35367. /**
  35368. * Gets the right camera of a rig setup in case of Rigged Camera
  35369. */
  35370. get rightCamera(): Nullable<FreeCamera>;
  35371. /**
  35372. * Gets the left camera target of a rig setup in case of Rigged Camera
  35373. * @returns the target position
  35374. */
  35375. getLeftTarget(): Nullable<Vector3>;
  35376. /**
  35377. * Gets the right camera target of a rig setup in case of Rigged Camera
  35378. * @returns the target position
  35379. */
  35380. getRightTarget(): Nullable<Vector3>;
  35381. /**
  35382. * @hidden
  35383. */
  35384. setCameraRigMode(mode: number, rigParams: any): void;
  35385. /** @hidden */
  35386. static _setStereoscopicRigMode(camera: Camera): void;
  35387. /** @hidden */
  35388. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35389. /** @hidden */
  35390. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35391. /** @hidden */
  35392. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35393. /** @hidden */
  35394. _getVRProjectionMatrix(): Matrix;
  35395. protected _updateCameraRotationMatrix(): void;
  35396. protected _updateWebVRCameraRotationMatrix(): void;
  35397. /**
  35398. * This function MUST be overwritten by the different WebVR cameras available.
  35399. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35400. * @hidden
  35401. */
  35402. _getWebVRProjectionMatrix(): Matrix;
  35403. /**
  35404. * This function MUST be overwritten by the different WebVR cameras available.
  35405. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35406. * @hidden
  35407. */
  35408. _getWebVRViewMatrix(): Matrix;
  35409. /** @hidden */
  35410. setCameraRigParameter(name: string, value: any): void;
  35411. /**
  35412. * needs to be overridden by children so sub has required properties to be copied
  35413. * @hidden
  35414. */
  35415. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35416. /**
  35417. * May need to be overridden by children
  35418. * @hidden
  35419. */
  35420. _updateRigCameras(): void;
  35421. /** @hidden */
  35422. _setupInputs(): void;
  35423. /**
  35424. * Serialiaze the camera setup to a json represention
  35425. * @returns the JSON representation
  35426. */
  35427. serialize(): any;
  35428. /**
  35429. * Clones the current camera.
  35430. * @param name The cloned camera name
  35431. * @returns the cloned camera
  35432. */
  35433. clone(name: string): Camera;
  35434. /**
  35435. * Gets the direction of the camera relative to a given local axis.
  35436. * @param localAxis Defines the reference axis to provide a relative direction.
  35437. * @return the direction
  35438. */
  35439. getDirection(localAxis: Vector3): Vector3;
  35440. /**
  35441. * Returns the current camera absolute rotation
  35442. */
  35443. get absoluteRotation(): Quaternion;
  35444. /**
  35445. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35446. * @param localAxis Defines the reference axis to provide a relative direction.
  35447. * @param result Defines the vector to store the result in
  35448. */
  35449. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35450. /**
  35451. * Gets a camera constructor for a given camera type
  35452. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35453. * @param name The name of the camera the result will be able to instantiate
  35454. * @param scene The scene the result will construct the camera in
  35455. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35456. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35457. * @returns a factory method to construc the camera
  35458. */
  35459. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35460. /**
  35461. * Compute the world matrix of the camera.
  35462. * @returns the camera world matrix
  35463. */
  35464. computeWorldMatrix(): Matrix;
  35465. /**
  35466. * Parse a JSON and creates the camera from the parsed information
  35467. * @param parsedCamera The JSON to parse
  35468. * @param scene The scene to instantiate the camera in
  35469. * @returns the newly constructed camera
  35470. */
  35471. static Parse(parsedCamera: any, scene: Scene): Camera;
  35472. }
  35473. }
  35474. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35475. import { Nullable } from "babylonjs/types";
  35476. import { Scene } from "babylonjs/scene";
  35477. import { Vector4 } from "babylonjs/Maths/math.vector";
  35478. import { Mesh } from "babylonjs/Meshes/mesh";
  35479. /**
  35480. * Class containing static functions to help procedurally build meshes
  35481. */
  35482. export class DiscBuilder {
  35483. /**
  35484. * Creates a plane polygonal mesh. By default, this is a disc
  35485. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35486. * * 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
  35487. * * 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
  35488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35491. * @param name defines the name of the mesh
  35492. * @param options defines the options used to create the mesh
  35493. * @param scene defines the hosting scene
  35494. * @returns the plane polygonal mesh
  35495. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35496. */
  35497. static CreateDisc(name: string, options: {
  35498. radius?: number;
  35499. tessellation?: number;
  35500. arc?: number;
  35501. updatable?: boolean;
  35502. sideOrientation?: number;
  35503. frontUVs?: Vector4;
  35504. backUVs?: Vector4;
  35505. }, scene?: Nullable<Scene>): Mesh;
  35506. }
  35507. }
  35508. declare module "babylonjs/Particles/solidParticleSystem" {
  35509. import { Nullable } from "babylonjs/types";
  35510. import { Mesh } from "babylonjs/Meshes/mesh";
  35511. import { Scene, IDisposable } from "babylonjs/scene";
  35512. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35513. import { Material } from "babylonjs/Materials/material";
  35514. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35515. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35516. /**
  35517. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35518. *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.
  35519. * The SPS is also a particle system. It provides some methods to manage the particles.
  35520. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35521. *
  35522. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35523. */
  35524. export class SolidParticleSystem implements IDisposable {
  35525. /**
  35526. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35527. * Example : var p = SPS.particles[i];
  35528. */
  35529. particles: SolidParticle[];
  35530. /**
  35531. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35532. */
  35533. nbParticles: number;
  35534. /**
  35535. * If the particles must ever face the camera (default false). Useful for planar particles.
  35536. */
  35537. billboard: boolean;
  35538. /**
  35539. * Recompute normals when adding a shape
  35540. */
  35541. recomputeNormals: boolean;
  35542. /**
  35543. * This a counter ofr your own usage. It's not set by any SPS functions.
  35544. */
  35545. counter: number;
  35546. /**
  35547. * The SPS name. This name is also given to the underlying mesh.
  35548. */
  35549. name: string;
  35550. /**
  35551. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35552. */
  35553. mesh: Mesh;
  35554. /**
  35555. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35556. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35557. */
  35558. vars: any;
  35559. /**
  35560. * This array is populated when the SPS is set as 'pickable'.
  35561. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35562. * Each element of this array is an object `{idx: int, faceId: int}`.
  35563. * `idx` is the picked particle index in the `SPS.particles` array
  35564. * `faceId` is the picked face index counted within this particle.
  35565. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35566. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35567. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35568. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35569. */
  35570. pickedParticles: {
  35571. idx: number;
  35572. faceId: number;
  35573. }[];
  35574. /**
  35575. * This array is populated when the SPS is set as 'pickable'
  35576. * Each key of this array is a submesh index.
  35577. * Each element of this array is a second array defined like this :
  35578. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35579. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35580. * `idx` is the picked particle index in the `SPS.particles` array
  35581. * `faceId` is the picked face index counted within this particle.
  35582. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35583. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35584. */
  35585. pickedBySubMesh: {
  35586. idx: number;
  35587. faceId: number;
  35588. }[][];
  35589. /**
  35590. * This array is populated when `enableDepthSort` is set to true.
  35591. * Each element of this array is an instance of the class DepthSortedParticle.
  35592. */
  35593. depthSortedParticles: DepthSortedParticle[];
  35594. /**
  35595. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35596. * @hidden
  35597. */
  35598. _bSphereOnly: boolean;
  35599. /**
  35600. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35601. * @hidden
  35602. */
  35603. _bSphereRadiusFactor: number;
  35604. private _scene;
  35605. private _positions;
  35606. private _indices;
  35607. private _normals;
  35608. private _colors;
  35609. private _uvs;
  35610. private _indices32;
  35611. private _positions32;
  35612. private _normals32;
  35613. private _fixedNormal32;
  35614. private _colors32;
  35615. private _uvs32;
  35616. private _index;
  35617. private _updatable;
  35618. private _pickable;
  35619. private _isVisibilityBoxLocked;
  35620. private _alwaysVisible;
  35621. private _depthSort;
  35622. private _expandable;
  35623. private _shapeCounter;
  35624. private _copy;
  35625. private _color;
  35626. private _computeParticleColor;
  35627. private _computeParticleTexture;
  35628. private _computeParticleRotation;
  35629. private _computeParticleVertex;
  35630. private _computeBoundingBox;
  35631. private _depthSortParticles;
  35632. private _camera;
  35633. private _mustUnrotateFixedNormals;
  35634. private _particlesIntersect;
  35635. private _needs32Bits;
  35636. private _isNotBuilt;
  35637. private _lastParticleId;
  35638. private _idxOfId;
  35639. private _multimaterialEnabled;
  35640. private _useModelMaterial;
  35641. private _indicesByMaterial;
  35642. private _materialIndexes;
  35643. private _depthSortFunction;
  35644. private _materialSortFunction;
  35645. private _materials;
  35646. private _multimaterial;
  35647. private _materialIndexesById;
  35648. private _defaultMaterial;
  35649. private _autoUpdateSubMeshes;
  35650. private _tmpVertex;
  35651. /**
  35652. * Creates a SPS (Solid Particle System) object.
  35653. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35654. * @param scene (Scene) is the scene in which the SPS is added.
  35655. * @param options defines the options of the sps e.g.
  35656. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35657. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35658. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35659. * * 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.
  35660. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35661. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35662. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35663. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35664. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35665. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35666. */
  35667. constructor(name: string, scene: Scene, options?: {
  35668. updatable?: boolean;
  35669. isPickable?: boolean;
  35670. enableDepthSort?: boolean;
  35671. particleIntersection?: boolean;
  35672. boundingSphereOnly?: boolean;
  35673. bSphereRadiusFactor?: number;
  35674. expandable?: boolean;
  35675. useModelMaterial?: boolean;
  35676. enableMultiMaterial?: boolean;
  35677. });
  35678. /**
  35679. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35680. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35681. * @returns the created mesh
  35682. */
  35683. buildMesh(): Mesh;
  35684. /**
  35685. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35686. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35687. * Thus the particles generated from `digest()` have their property `position` set yet.
  35688. * @param mesh ( Mesh ) is the mesh to be digested
  35689. * @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
  35690. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35691. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35692. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35693. * @returns the current SPS
  35694. */
  35695. digest(mesh: Mesh, options?: {
  35696. facetNb?: number;
  35697. number?: number;
  35698. delta?: number;
  35699. storage?: [];
  35700. }): SolidParticleSystem;
  35701. /**
  35702. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35703. * @hidden
  35704. */
  35705. private _unrotateFixedNormals;
  35706. /**
  35707. * Resets the temporary working copy particle
  35708. * @hidden
  35709. */
  35710. private _resetCopy;
  35711. /**
  35712. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35713. * @param p the current index in the positions array to be updated
  35714. * @param ind the current index in the indices array
  35715. * @param shape a Vector3 array, the shape geometry
  35716. * @param positions the positions array to be updated
  35717. * @param meshInd the shape indices array
  35718. * @param indices the indices array to be updated
  35719. * @param meshUV the shape uv array
  35720. * @param uvs the uv array to be updated
  35721. * @param meshCol the shape color array
  35722. * @param colors the color array to be updated
  35723. * @param meshNor the shape normals array
  35724. * @param normals the normals array to be updated
  35725. * @param idx the particle index
  35726. * @param idxInShape the particle index in its shape
  35727. * @param options the addShape() method passed options
  35728. * @model the particle model
  35729. * @hidden
  35730. */
  35731. private _meshBuilder;
  35732. /**
  35733. * Returns a shape Vector3 array from positions float array
  35734. * @param positions float array
  35735. * @returns a vector3 array
  35736. * @hidden
  35737. */
  35738. private _posToShape;
  35739. /**
  35740. * Returns a shapeUV array from a float uvs (array deep copy)
  35741. * @param uvs as a float array
  35742. * @returns a shapeUV array
  35743. * @hidden
  35744. */
  35745. private _uvsToShapeUV;
  35746. /**
  35747. * Adds a new particle object in the particles array
  35748. * @param idx particle index in particles array
  35749. * @param id particle id
  35750. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35751. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35752. * @param model particle ModelShape object
  35753. * @param shapeId model shape identifier
  35754. * @param idxInShape index of the particle in the current model
  35755. * @param bInfo model bounding info object
  35756. * @param storage target storage array, if any
  35757. * @hidden
  35758. */
  35759. private _addParticle;
  35760. /**
  35761. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35762. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35763. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35764. * @param nb (positive integer) the number of particles to be created from this model
  35765. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35766. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35767. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35768. * @returns the number of shapes in the system
  35769. */
  35770. addShape(mesh: Mesh, nb: number, options?: {
  35771. positionFunction?: any;
  35772. vertexFunction?: any;
  35773. storage?: [];
  35774. }): number;
  35775. /**
  35776. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35777. * @hidden
  35778. */
  35779. private _rebuildParticle;
  35780. /**
  35781. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35782. * @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.
  35783. * @returns the SPS.
  35784. */
  35785. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35786. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35787. * Returns an array with the removed particles.
  35788. * 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.
  35789. * The SPS can't be empty so at least one particle needs to remain in place.
  35790. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35791. * @param start index of the first particle to remove
  35792. * @param end index of the last particle to remove (included)
  35793. * @returns an array populated with the removed particles
  35794. */
  35795. removeParticles(start: number, end: number): SolidParticle[];
  35796. /**
  35797. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35798. * @param solidParticleArray an array populated with Solid Particles objects
  35799. * @returns the SPS
  35800. */
  35801. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35802. /**
  35803. * Creates a new particle and modifies the SPS mesh geometry :
  35804. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35805. * - calls _addParticle() to populate the particle array
  35806. * factorized code from addShape() and insertParticlesFromArray()
  35807. * @param idx particle index in the particles array
  35808. * @param i particle index in its shape
  35809. * @param modelShape particle ModelShape object
  35810. * @param shape shape vertex array
  35811. * @param meshInd shape indices array
  35812. * @param meshUV shape uv array
  35813. * @param meshCol shape color array
  35814. * @param meshNor shape normals array
  35815. * @param bbInfo shape bounding info
  35816. * @param storage target particle storage
  35817. * @options addShape() passed options
  35818. * @hidden
  35819. */
  35820. private _insertNewParticle;
  35821. /**
  35822. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35823. * This method calls `updateParticle()` for each particle of the SPS.
  35824. * For an animated SPS, it is usually called within the render loop.
  35825. * 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.
  35826. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35827. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35828. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35829. * @returns the SPS.
  35830. */
  35831. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35832. /**
  35833. * Disposes the SPS.
  35834. */
  35835. dispose(): void;
  35836. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35837. * idx is the particle index in the SPS
  35838. * faceId is the picked face index counted within this particle.
  35839. * Returns null if the pickInfo can't identify a picked particle.
  35840. * @param pickingInfo (PickingInfo object)
  35841. * @returns {idx: number, faceId: number} or null
  35842. */
  35843. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35844. idx: number;
  35845. faceId: number;
  35846. }>;
  35847. /**
  35848. * Returns a SolidParticle object from its identifier : particle.id
  35849. * @param id (integer) the particle Id
  35850. * @returns the searched particle or null if not found in the SPS.
  35851. */
  35852. getParticleById(id: number): Nullable<SolidParticle>;
  35853. /**
  35854. * Returns a new array populated with the particles having the passed shapeId.
  35855. * @param shapeId (integer) the shape identifier
  35856. * @returns a new solid particle array
  35857. */
  35858. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35859. /**
  35860. * Populates the passed array "ref" with the particles having the passed shapeId.
  35861. * @param shapeId the shape identifier
  35862. * @returns the SPS
  35863. * @param ref
  35864. */
  35865. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35866. /**
  35867. * Computes the required SubMeshes according the materials assigned to the particles.
  35868. * @returns the solid particle system.
  35869. * Does nothing if called before the SPS mesh is built.
  35870. */
  35871. computeSubMeshes(): SolidParticleSystem;
  35872. /**
  35873. * Sorts the solid particles by material when MultiMaterial is enabled.
  35874. * Updates the indices32 array.
  35875. * Updates the indicesByMaterial array.
  35876. * Updates the mesh indices array.
  35877. * @returns the SPS
  35878. * @hidden
  35879. */
  35880. private _sortParticlesByMaterial;
  35881. /**
  35882. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35883. * @hidden
  35884. */
  35885. private _setMaterialIndexesById;
  35886. /**
  35887. * Returns an array with unique values of Materials from the passed array
  35888. * @param array the material array to be checked and filtered
  35889. * @hidden
  35890. */
  35891. private _filterUniqueMaterialId;
  35892. /**
  35893. * Sets a new Standard Material as _defaultMaterial if not already set.
  35894. * @hidden
  35895. */
  35896. private _setDefaultMaterial;
  35897. /**
  35898. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35899. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35900. * @returns the SPS.
  35901. */
  35902. refreshVisibleSize(): SolidParticleSystem;
  35903. /**
  35904. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35905. * @param size the size (float) of the visibility box
  35906. * note : this doesn't lock the SPS mesh bounding box.
  35907. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35908. */
  35909. setVisibilityBox(size: number): void;
  35910. /**
  35911. * Gets whether the SPS as always visible or not
  35912. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35913. */
  35914. get isAlwaysVisible(): boolean;
  35915. /**
  35916. * Sets the SPS as always visible or not
  35917. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35918. */
  35919. set isAlwaysVisible(val: boolean);
  35920. /**
  35921. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35922. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35923. */
  35924. set isVisibilityBoxLocked(val: boolean);
  35925. /**
  35926. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35927. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35928. */
  35929. get isVisibilityBoxLocked(): boolean;
  35930. /**
  35931. * Tells to `setParticles()` to compute the particle rotations or not.
  35932. * Default value : true. The SPS is faster when it's set to false.
  35933. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35934. */
  35935. set computeParticleRotation(val: boolean);
  35936. /**
  35937. * Tells to `setParticles()` to compute the particle colors or not.
  35938. * Default value : true. The SPS is faster when it's set to false.
  35939. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35940. */
  35941. set computeParticleColor(val: boolean);
  35942. set computeParticleTexture(val: boolean);
  35943. /**
  35944. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35945. * Default value : false. The SPS is faster when it's set to false.
  35946. * Note : the particle custom vertex positions aren't stored values.
  35947. */
  35948. set computeParticleVertex(val: boolean);
  35949. /**
  35950. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35951. */
  35952. set computeBoundingBox(val: boolean);
  35953. /**
  35954. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35956. * Default : `true`
  35957. */
  35958. set depthSortParticles(val: boolean);
  35959. /**
  35960. * Gets if `setParticles()` computes the particle rotations or not.
  35961. * Default value : true. The SPS is faster when it's set to false.
  35962. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35963. */
  35964. get computeParticleRotation(): boolean;
  35965. /**
  35966. * Gets if `setParticles()` computes the particle colors or not.
  35967. * Default value : true. The SPS is faster when it's set to false.
  35968. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35969. */
  35970. get computeParticleColor(): boolean;
  35971. /**
  35972. * Gets if `setParticles()` computes the particle textures or not.
  35973. * Default value : true. The SPS is faster when it's set to false.
  35974. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35975. */
  35976. get computeParticleTexture(): boolean;
  35977. /**
  35978. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35979. * Default value : false. The SPS is faster when it's set to false.
  35980. * Note : the particle custom vertex positions aren't stored values.
  35981. */
  35982. get computeParticleVertex(): boolean;
  35983. /**
  35984. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35985. */
  35986. get computeBoundingBox(): boolean;
  35987. /**
  35988. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35989. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35990. * Default : `true`
  35991. */
  35992. get depthSortParticles(): boolean;
  35993. /**
  35994. * Gets if the SPS is created as expandable at construction time.
  35995. * Default : `false`
  35996. */
  35997. get expandable(): boolean;
  35998. /**
  35999. * Gets if the SPS supports the Multi Materials
  36000. */
  36001. get multimaterialEnabled(): boolean;
  36002. /**
  36003. * Gets if the SPS uses the model materials for its own multimaterial.
  36004. */
  36005. get useModelMaterial(): boolean;
  36006. /**
  36007. * The SPS used material array.
  36008. */
  36009. get materials(): Material[];
  36010. /**
  36011. * Sets the SPS MultiMaterial from the passed materials.
  36012. * Note : the passed array is internally copied and not used then by reference.
  36013. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36014. */
  36015. setMultiMaterial(materials: Material[]): void;
  36016. /**
  36017. * The SPS computed multimaterial object
  36018. */
  36019. get multimaterial(): MultiMaterial;
  36020. set multimaterial(mm: MultiMaterial);
  36021. /**
  36022. * If the subMeshes must be updated on the next call to setParticles()
  36023. */
  36024. get autoUpdateSubMeshes(): boolean;
  36025. set autoUpdateSubMeshes(val: boolean);
  36026. /**
  36027. * This function does nothing. It may be overwritten to set all the particle first values.
  36028. * The SPS doesn't call this function, you may have to call it by your own.
  36029. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36030. */
  36031. initParticles(): void;
  36032. /**
  36033. * This function does nothing. It may be overwritten to recycle a particle.
  36034. * The SPS doesn't call this function, you may have to call it by your own.
  36035. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36036. * @param particle The particle to recycle
  36037. * @returns the recycled particle
  36038. */
  36039. recycleParticle(particle: SolidParticle): SolidParticle;
  36040. /**
  36041. * Updates a particle : this function should be overwritten by the user.
  36042. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36043. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36044. * @example : just set a particle position or velocity and recycle conditions
  36045. * @param particle The particle to update
  36046. * @returns the updated particle
  36047. */
  36048. updateParticle(particle: SolidParticle): SolidParticle;
  36049. /**
  36050. * Updates a vertex of a particle : it can be overwritten by the user.
  36051. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36052. * @param particle the current particle
  36053. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36054. * @param pt the index of the current vertex in the particle shape
  36055. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36056. * @example : just set a vertex particle position or color
  36057. * @returns the sps
  36058. */
  36059. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36060. /**
  36061. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36062. * This does nothing and may be overwritten by the user.
  36063. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36064. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36065. * @param update the boolean update value actually passed to setParticles()
  36066. */
  36067. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36068. /**
  36069. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36070. * This will be passed three parameters.
  36071. * This does nothing and may be overwritten by the user.
  36072. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36073. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36074. * @param update the boolean update value actually passed to setParticles()
  36075. */
  36076. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36077. }
  36078. }
  36079. declare module "babylonjs/Particles/solidParticle" {
  36080. import { Nullable } from "babylonjs/types";
  36081. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36082. import { Color4 } from "babylonjs/Maths/math.color";
  36083. import { Mesh } from "babylonjs/Meshes/mesh";
  36084. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36085. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36086. import { Plane } from "babylonjs/Maths/math.plane";
  36087. import { Material } from "babylonjs/Materials/material";
  36088. /**
  36089. * Represents one particle of a solid particle system.
  36090. */
  36091. export class SolidParticle {
  36092. /**
  36093. * particle global index
  36094. */
  36095. idx: number;
  36096. /**
  36097. * particle identifier
  36098. */
  36099. id: number;
  36100. /**
  36101. * The color of the particle
  36102. */
  36103. color: Nullable<Color4>;
  36104. /**
  36105. * The world space position of the particle.
  36106. */
  36107. position: Vector3;
  36108. /**
  36109. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36110. */
  36111. rotation: Vector3;
  36112. /**
  36113. * The world space rotation quaternion of the particle.
  36114. */
  36115. rotationQuaternion: Nullable<Quaternion>;
  36116. /**
  36117. * The scaling of the particle.
  36118. */
  36119. scaling: Vector3;
  36120. /**
  36121. * The uvs of the particle.
  36122. */
  36123. uvs: Vector4;
  36124. /**
  36125. * The current speed of the particle.
  36126. */
  36127. velocity: Vector3;
  36128. /**
  36129. * The pivot point in the particle local space.
  36130. */
  36131. pivot: Vector3;
  36132. /**
  36133. * Must the particle be translated from its pivot point in its local space ?
  36134. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36135. * Default : false
  36136. */
  36137. translateFromPivot: boolean;
  36138. /**
  36139. * Is the particle active or not ?
  36140. */
  36141. alive: boolean;
  36142. /**
  36143. * Is the particle visible or not ?
  36144. */
  36145. isVisible: boolean;
  36146. /**
  36147. * Index of this particle in the global "positions" array (Internal use)
  36148. * @hidden
  36149. */
  36150. _pos: number;
  36151. /**
  36152. * @hidden Index of this particle in the global "indices" array (Internal use)
  36153. */
  36154. _ind: number;
  36155. /**
  36156. * @hidden ModelShape of this particle (Internal use)
  36157. */
  36158. _model: ModelShape;
  36159. /**
  36160. * ModelShape id of this particle
  36161. */
  36162. shapeId: number;
  36163. /**
  36164. * Index of the particle in its shape id
  36165. */
  36166. idxInShape: number;
  36167. /**
  36168. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36169. */
  36170. _modelBoundingInfo: BoundingInfo;
  36171. /**
  36172. * @hidden Particle BoundingInfo object (Internal use)
  36173. */
  36174. _boundingInfo: BoundingInfo;
  36175. /**
  36176. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36177. */
  36178. _sps: SolidParticleSystem;
  36179. /**
  36180. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36181. */
  36182. _stillInvisible: boolean;
  36183. /**
  36184. * @hidden Last computed particle rotation matrix
  36185. */
  36186. _rotationMatrix: number[];
  36187. /**
  36188. * Parent particle Id, if any.
  36189. * Default null.
  36190. */
  36191. parentId: Nullable<number>;
  36192. /**
  36193. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36194. */
  36195. materialIndex: Nullable<number>;
  36196. /**
  36197. * Custom object or properties.
  36198. */
  36199. props: Nullable<any>;
  36200. /**
  36201. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36202. * The possible values are :
  36203. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36204. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36205. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36206. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36207. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36208. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36209. * */
  36210. cullingStrategy: number;
  36211. /**
  36212. * @hidden Internal global position in the SPS.
  36213. */
  36214. _globalPosition: Vector3;
  36215. /**
  36216. * Creates a Solid Particle object.
  36217. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36218. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36219. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36220. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36221. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36222. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36223. * @param shapeId (integer) is the model shape identifier in the SPS.
  36224. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36225. * @param sps defines the sps it is associated to
  36226. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36227. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36228. */
  36229. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36230. /**
  36231. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36232. * @param target the particle target
  36233. * @returns the current particle
  36234. */
  36235. copyToRef(target: SolidParticle): SolidParticle;
  36236. /**
  36237. * Legacy support, changed scale to scaling
  36238. */
  36239. get scale(): Vector3;
  36240. /**
  36241. * Legacy support, changed scale to scaling
  36242. */
  36243. set scale(scale: Vector3);
  36244. /**
  36245. * Legacy support, changed quaternion to rotationQuaternion
  36246. */
  36247. get quaternion(): Nullable<Quaternion>;
  36248. /**
  36249. * Legacy support, changed quaternion to rotationQuaternion
  36250. */
  36251. set quaternion(q: Nullable<Quaternion>);
  36252. /**
  36253. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36254. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36255. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36256. * @returns true if it intersects
  36257. */
  36258. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36259. /**
  36260. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36261. * A particle is in the frustum if its bounding box intersects the frustum
  36262. * @param frustumPlanes defines the frustum to test
  36263. * @returns true if the particle is in the frustum planes
  36264. */
  36265. isInFrustum(frustumPlanes: Plane[]): boolean;
  36266. /**
  36267. * get the rotation matrix of the particle
  36268. * @hidden
  36269. */
  36270. getRotationMatrix(m: Matrix): void;
  36271. }
  36272. /**
  36273. * Represents the shape of the model used by one particle of a solid particle system.
  36274. * SPS internal tool, don't use it manually.
  36275. */
  36276. export class ModelShape {
  36277. /**
  36278. * The shape id
  36279. * @hidden
  36280. */
  36281. shapeID: number;
  36282. /**
  36283. * flat array of model positions (internal use)
  36284. * @hidden
  36285. */
  36286. _shape: Vector3[];
  36287. /**
  36288. * flat array of model UVs (internal use)
  36289. * @hidden
  36290. */
  36291. _shapeUV: number[];
  36292. /**
  36293. * color array of the model
  36294. * @hidden
  36295. */
  36296. _shapeColors: number[];
  36297. /**
  36298. * indices array of the model
  36299. * @hidden
  36300. */
  36301. _indices: number[];
  36302. /**
  36303. * normals array of the model
  36304. * @hidden
  36305. */
  36306. _normals: number[];
  36307. /**
  36308. * length of the shape in the model indices array (internal use)
  36309. * @hidden
  36310. */
  36311. _indicesLength: number;
  36312. /**
  36313. * Custom position function (internal use)
  36314. * @hidden
  36315. */
  36316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36317. /**
  36318. * Custom vertex function (internal use)
  36319. * @hidden
  36320. */
  36321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36322. /**
  36323. * Model material (internal use)
  36324. * @hidden
  36325. */
  36326. _material: Nullable<Material>;
  36327. /**
  36328. * 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.
  36329. * SPS internal tool, don't use it manually.
  36330. * @hidden
  36331. */
  36332. 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>);
  36333. }
  36334. /**
  36335. * Represents a Depth Sorted Particle in the solid particle system.
  36336. * @hidden
  36337. */
  36338. export class DepthSortedParticle {
  36339. /**
  36340. * Particle index
  36341. */
  36342. idx: number;
  36343. /**
  36344. * Index of the particle in the "indices" array
  36345. */
  36346. ind: number;
  36347. /**
  36348. * Length of the particle shape in the "indices" array
  36349. */
  36350. indicesLength: number;
  36351. /**
  36352. * Squared distance from the particle to the camera
  36353. */
  36354. sqDistance: number;
  36355. /**
  36356. * Material index when used with MultiMaterials
  36357. */
  36358. materialIndex: number;
  36359. /**
  36360. * Creates a new sorted particle
  36361. * @param materialIndex
  36362. */
  36363. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36364. }
  36365. /**
  36366. * Represents a solid particle vertex
  36367. */
  36368. export class SolidParticleVertex {
  36369. /**
  36370. * Vertex position
  36371. */
  36372. position: Vector3;
  36373. /**
  36374. * Vertex color
  36375. */
  36376. color: Color4;
  36377. /**
  36378. * Vertex UV
  36379. */
  36380. uv: Vector2;
  36381. /**
  36382. * Creates a new solid particle vertex
  36383. */
  36384. constructor();
  36385. /** Vertex x coordinate */
  36386. get x(): number;
  36387. set x(val: number);
  36388. /** Vertex y coordinate */
  36389. get y(): number;
  36390. set y(val: number);
  36391. /** Vertex z coordinate */
  36392. get z(): number;
  36393. set z(val: number);
  36394. }
  36395. }
  36396. declare module "babylonjs/Collisions/meshCollisionData" {
  36397. import { Collider } from "babylonjs/Collisions/collider";
  36398. import { Vector3 } from "babylonjs/Maths/math.vector";
  36399. import { Nullable } from "babylonjs/types";
  36400. import { Observer } from "babylonjs/Misc/observable";
  36401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36402. /**
  36403. * @hidden
  36404. */
  36405. export class _MeshCollisionData {
  36406. _checkCollisions: boolean;
  36407. _collisionMask: number;
  36408. _collisionGroup: number;
  36409. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36410. _collider: Nullable<Collider>;
  36411. _oldPositionForCollisions: Vector3;
  36412. _diffPositionForCollisions: Vector3;
  36413. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36414. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36415. _collisionResponse: boolean;
  36416. }
  36417. }
  36418. declare module "babylonjs/Meshes/abstractMesh" {
  36419. import { Observable } from "babylonjs/Misc/observable";
  36420. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36421. import { Camera } from "babylonjs/Cameras/camera";
  36422. import { Scene, IDisposable } from "babylonjs/scene";
  36423. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36424. import { Node } from "babylonjs/node";
  36425. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36426. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36427. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36428. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36429. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36430. import { Material } from "babylonjs/Materials/material";
  36431. import { Light } from "babylonjs/Lights/light";
  36432. import { Skeleton } from "babylonjs/Bones/skeleton";
  36433. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36434. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36435. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36436. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36437. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36438. import { Plane } from "babylonjs/Maths/math.plane";
  36439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36440. import { Ray } from "babylonjs/Culling/ray";
  36441. import { Collider } from "babylonjs/Collisions/collider";
  36442. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36443. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36444. /** @hidden */
  36445. class _FacetDataStorage {
  36446. facetPositions: Vector3[];
  36447. facetNormals: Vector3[];
  36448. facetPartitioning: number[][];
  36449. facetNb: number;
  36450. partitioningSubdivisions: number;
  36451. partitioningBBoxRatio: number;
  36452. facetDataEnabled: boolean;
  36453. facetParameters: any;
  36454. bbSize: Vector3;
  36455. subDiv: {
  36456. max: number;
  36457. X: number;
  36458. Y: number;
  36459. Z: number;
  36460. };
  36461. facetDepthSort: boolean;
  36462. facetDepthSortEnabled: boolean;
  36463. depthSortedIndices: IndicesArray;
  36464. depthSortedFacets: {
  36465. ind: number;
  36466. sqDistance: number;
  36467. }[];
  36468. facetDepthSortFunction: (f1: {
  36469. ind: number;
  36470. sqDistance: number;
  36471. }, f2: {
  36472. ind: number;
  36473. sqDistance: number;
  36474. }) => number;
  36475. facetDepthSortFrom: Vector3;
  36476. facetDepthSortOrigin: Vector3;
  36477. invertedMatrix: Matrix;
  36478. }
  36479. /**
  36480. * @hidden
  36481. **/
  36482. class _InternalAbstractMeshDataInfo {
  36483. _hasVertexAlpha: boolean;
  36484. _useVertexColors: boolean;
  36485. _numBoneInfluencers: number;
  36486. _applyFog: boolean;
  36487. _receiveShadows: boolean;
  36488. _facetData: _FacetDataStorage;
  36489. _visibility: number;
  36490. _skeleton: Nullable<Skeleton>;
  36491. _layerMask: number;
  36492. _computeBonesUsingShaders: boolean;
  36493. _isActive: boolean;
  36494. _onlyForInstances: boolean;
  36495. _isActiveIntermediate: boolean;
  36496. _onlyForInstancesIntermediate: boolean;
  36497. _actAsRegularMesh: boolean;
  36498. }
  36499. /**
  36500. * Class used to store all common mesh properties
  36501. */
  36502. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36503. /** No occlusion */
  36504. static OCCLUSION_TYPE_NONE: number;
  36505. /** Occlusion set to optimisitic */
  36506. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36507. /** Occlusion set to strict */
  36508. static OCCLUSION_TYPE_STRICT: number;
  36509. /** Use an accurante occlusion algorithm */
  36510. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36511. /** Use a conservative occlusion algorithm */
  36512. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36513. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36514. * Test order :
  36515. * Is the bounding sphere outside the frustum ?
  36516. * If not, are the bounding box vertices outside the frustum ?
  36517. * It not, then the cullable object is in the frustum.
  36518. */
  36519. static readonly CULLINGSTRATEGY_STANDARD: number;
  36520. /** Culling strategy : Bounding Sphere Only.
  36521. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36522. * It's also less accurate than the standard because some not visible objects can still be selected.
  36523. * Test : is the bounding sphere outside the frustum ?
  36524. * If not, then the cullable object is in the frustum.
  36525. */
  36526. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36527. /** Culling strategy : Optimistic Inclusion.
  36528. * This in an inclusion test first, then the standard exclusion test.
  36529. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36530. * 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.
  36531. * Anyway, it's as accurate as the standard strategy.
  36532. * Test :
  36533. * Is the cullable object bounding sphere center in the frustum ?
  36534. * If not, apply the default culling strategy.
  36535. */
  36536. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36537. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36538. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36539. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36540. * 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.
  36541. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36542. * Test :
  36543. * Is the cullable object bounding sphere center in the frustum ?
  36544. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36545. */
  36546. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36547. /**
  36548. * No billboard
  36549. */
  36550. static get BILLBOARDMODE_NONE(): number;
  36551. /** Billboard on X axis */
  36552. static get BILLBOARDMODE_X(): number;
  36553. /** Billboard on Y axis */
  36554. static get BILLBOARDMODE_Y(): number;
  36555. /** Billboard on Z axis */
  36556. static get BILLBOARDMODE_Z(): number;
  36557. /** Billboard on all axes */
  36558. static get BILLBOARDMODE_ALL(): number;
  36559. /** Billboard on using position instead of orientation */
  36560. static get BILLBOARDMODE_USE_POSITION(): number;
  36561. /** @hidden */
  36562. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36563. /**
  36564. * The culling strategy to use to check whether the mesh must be rendered or not.
  36565. * This value can be changed at any time and will be used on the next render mesh selection.
  36566. * The possible values are :
  36567. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36568. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36569. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36570. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36571. * Please read each static variable documentation to get details about the culling process.
  36572. * */
  36573. cullingStrategy: number;
  36574. /**
  36575. * Gets the number of facets in the mesh
  36576. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36577. */
  36578. get facetNb(): number;
  36579. /**
  36580. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36581. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36582. */
  36583. get partitioningSubdivisions(): number;
  36584. set partitioningSubdivisions(nb: number);
  36585. /**
  36586. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36587. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36588. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36589. */
  36590. get partitioningBBoxRatio(): number;
  36591. set partitioningBBoxRatio(ratio: number);
  36592. /**
  36593. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36594. * Works only for updatable meshes.
  36595. * Doesn't work with multi-materials
  36596. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36597. */
  36598. get mustDepthSortFacets(): boolean;
  36599. set mustDepthSortFacets(sort: boolean);
  36600. /**
  36601. * The location (Vector3) where the facet depth sort must be computed from.
  36602. * By default, the active camera position.
  36603. * Used only when facet depth sort is enabled
  36604. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36605. */
  36606. get facetDepthSortFrom(): Vector3;
  36607. set facetDepthSortFrom(location: Vector3);
  36608. /**
  36609. * gets a boolean indicating if facetData is enabled
  36610. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36611. */
  36612. get isFacetDataEnabled(): boolean;
  36613. /** @hidden */
  36614. _updateNonUniformScalingState(value: boolean): boolean;
  36615. /**
  36616. * An event triggered when this mesh collides with another one
  36617. */
  36618. onCollideObservable: Observable<AbstractMesh>;
  36619. /** Set a function to call when this mesh collides with another one */
  36620. set onCollide(callback: () => void);
  36621. /**
  36622. * An event triggered when the collision's position changes
  36623. */
  36624. onCollisionPositionChangeObservable: Observable<Vector3>;
  36625. /** Set a function to call when the collision's position changes */
  36626. set onCollisionPositionChange(callback: () => void);
  36627. /**
  36628. * An event triggered when material is changed
  36629. */
  36630. onMaterialChangedObservable: Observable<AbstractMesh>;
  36631. /**
  36632. * Gets or sets the orientation for POV movement & rotation
  36633. */
  36634. definedFacingForward: boolean;
  36635. /** @hidden */
  36636. _occlusionQuery: Nullable<WebGLQuery>;
  36637. /** @hidden */
  36638. _renderingGroup: Nullable<RenderingGroup>;
  36639. /**
  36640. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36641. */
  36642. get visibility(): number;
  36643. /**
  36644. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36645. */
  36646. set visibility(value: number);
  36647. /** Gets or sets the alpha index used to sort transparent meshes
  36648. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36649. */
  36650. alphaIndex: number;
  36651. /**
  36652. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36653. */
  36654. isVisible: boolean;
  36655. /**
  36656. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36657. */
  36658. isPickable: boolean;
  36659. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36660. showSubMeshesBoundingBox: boolean;
  36661. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36662. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36663. */
  36664. isBlocker: boolean;
  36665. /**
  36666. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36667. */
  36668. enablePointerMoveEvents: boolean;
  36669. private _renderingGroupId;
  36670. /**
  36671. * Specifies the rendering group id for this mesh (0 by default)
  36672. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36673. */
  36674. get renderingGroupId(): number;
  36675. set renderingGroupId(value: number);
  36676. private _material;
  36677. /** Gets or sets current material */
  36678. get material(): Nullable<Material>;
  36679. set material(value: Nullable<Material>);
  36680. /**
  36681. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36682. * @see https://doc.babylonjs.com/babylon101/shadows
  36683. */
  36684. get receiveShadows(): boolean;
  36685. set receiveShadows(value: boolean);
  36686. /** Defines color to use when rendering outline */
  36687. outlineColor: Color3;
  36688. /** Define width to use when rendering outline */
  36689. outlineWidth: number;
  36690. /** Defines color to use when rendering overlay */
  36691. overlayColor: Color3;
  36692. /** Defines alpha to use when rendering overlay */
  36693. overlayAlpha: number;
  36694. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36695. get hasVertexAlpha(): boolean;
  36696. set hasVertexAlpha(value: boolean);
  36697. /** 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) */
  36698. get useVertexColors(): boolean;
  36699. set useVertexColors(value: boolean);
  36700. /**
  36701. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36702. */
  36703. get computeBonesUsingShaders(): boolean;
  36704. set computeBonesUsingShaders(value: boolean);
  36705. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36706. get numBoneInfluencers(): number;
  36707. set numBoneInfluencers(value: number);
  36708. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36709. get applyFog(): boolean;
  36710. set applyFog(value: boolean);
  36711. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36712. useOctreeForRenderingSelection: boolean;
  36713. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36714. useOctreeForPicking: boolean;
  36715. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36716. useOctreeForCollisions: boolean;
  36717. /**
  36718. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36719. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36720. */
  36721. get layerMask(): number;
  36722. set layerMask(value: number);
  36723. /**
  36724. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36725. */
  36726. alwaysSelectAsActiveMesh: boolean;
  36727. /**
  36728. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36729. */
  36730. doNotSyncBoundingInfo: boolean;
  36731. /**
  36732. * Gets or sets the current action manager
  36733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36734. */
  36735. actionManager: Nullable<AbstractActionManager>;
  36736. private _meshCollisionData;
  36737. /**
  36738. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36739. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36740. */
  36741. ellipsoid: Vector3;
  36742. /**
  36743. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36744. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36745. */
  36746. ellipsoidOffset: Vector3;
  36747. /**
  36748. * Gets or sets a collision mask used to mask collisions (default is -1).
  36749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36750. */
  36751. get collisionMask(): number;
  36752. set collisionMask(mask: number);
  36753. /**
  36754. * Gets or sets a collision response flag (default is true).
  36755. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36756. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36757. * to respond to the collision.
  36758. */
  36759. get collisionResponse(): boolean;
  36760. set collisionResponse(response: boolean);
  36761. /**
  36762. * Gets or sets the current collision group mask (-1 by default).
  36763. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36764. */
  36765. get collisionGroup(): number;
  36766. set collisionGroup(mask: number);
  36767. /**
  36768. * Gets or sets current surrounding meshes (null by default).
  36769. *
  36770. * By default collision detection is tested against every mesh in the scene.
  36771. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36772. * meshes will be tested for the collision.
  36773. *
  36774. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36775. */
  36776. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36777. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36778. /**
  36779. * Defines edge width used when edgesRenderer is enabled
  36780. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36781. */
  36782. edgesWidth: number;
  36783. /**
  36784. * Defines edge color used when edgesRenderer is enabled
  36785. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36786. */
  36787. edgesColor: Color4;
  36788. /** @hidden */
  36789. _edgesRenderer: Nullable<IEdgesRenderer>;
  36790. /** @hidden */
  36791. _masterMesh: Nullable<AbstractMesh>;
  36792. /** @hidden */
  36793. _boundingInfo: Nullable<BoundingInfo>;
  36794. /** @hidden */
  36795. _renderId: number;
  36796. /**
  36797. * Gets or sets the list of subMeshes
  36798. * @see https://doc.babylonjs.com/how_to/multi_materials
  36799. */
  36800. subMeshes: SubMesh[];
  36801. /** @hidden */
  36802. _intersectionsInProgress: AbstractMesh[];
  36803. /** @hidden */
  36804. _unIndexed: boolean;
  36805. /** @hidden */
  36806. _lightSources: Light[];
  36807. /** Gets the list of lights affecting that mesh */
  36808. get lightSources(): Light[];
  36809. /** @hidden */
  36810. get _positions(): Nullable<Vector3[]>;
  36811. /** @hidden */
  36812. _waitingData: {
  36813. lods: Nullable<any>;
  36814. actions: Nullable<any>;
  36815. freezeWorldMatrix: Nullable<boolean>;
  36816. };
  36817. /** @hidden */
  36818. _bonesTransformMatrices: Nullable<Float32Array>;
  36819. /** @hidden */
  36820. _transformMatrixTexture: Nullable<RawTexture>;
  36821. /**
  36822. * Gets or sets a skeleton to apply skining transformations
  36823. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36824. */
  36825. set skeleton(value: Nullable<Skeleton>);
  36826. get skeleton(): Nullable<Skeleton>;
  36827. /**
  36828. * An event triggered when the mesh is rebuilt.
  36829. */
  36830. onRebuildObservable: Observable<AbstractMesh>;
  36831. /**
  36832. * Creates a new AbstractMesh
  36833. * @param name defines the name of the mesh
  36834. * @param scene defines the hosting scene
  36835. */
  36836. constructor(name: string, scene?: Nullable<Scene>);
  36837. /**
  36838. * Returns the string "AbstractMesh"
  36839. * @returns "AbstractMesh"
  36840. */
  36841. getClassName(): string;
  36842. /**
  36843. * Gets a string representation of the current mesh
  36844. * @param fullDetails defines a boolean indicating if full details must be included
  36845. * @returns a string representation of the current mesh
  36846. */
  36847. toString(fullDetails?: boolean): string;
  36848. /**
  36849. * @hidden
  36850. */
  36851. protected _getEffectiveParent(): Nullable<Node>;
  36852. /** @hidden */
  36853. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36854. /** @hidden */
  36855. _rebuild(): void;
  36856. /** @hidden */
  36857. _resyncLightSources(): void;
  36858. /** @hidden */
  36859. _resyncLightSource(light: Light): void;
  36860. /** @hidden */
  36861. _unBindEffect(): void;
  36862. /** @hidden */
  36863. _removeLightSource(light: Light, dispose: boolean): void;
  36864. private _markSubMeshesAsDirty;
  36865. /** @hidden */
  36866. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36867. /** @hidden */
  36868. _markSubMeshesAsAttributesDirty(): void;
  36869. /** @hidden */
  36870. _markSubMeshesAsMiscDirty(): void;
  36871. /**
  36872. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36873. */
  36874. get scaling(): Vector3;
  36875. set scaling(newScaling: Vector3);
  36876. /**
  36877. * Returns true if the mesh is blocked. Implemented by child classes
  36878. */
  36879. get isBlocked(): boolean;
  36880. /**
  36881. * Returns the mesh itself by default. Implemented by child classes
  36882. * @param camera defines the camera to use to pick the right LOD level
  36883. * @returns the currentAbstractMesh
  36884. */
  36885. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36886. /**
  36887. * Returns 0 by default. Implemented by child classes
  36888. * @returns an integer
  36889. */
  36890. getTotalVertices(): number;
  36891. /**
  36892. * Returns a positive integer : the total number of indices in this mesh geometry.
  36893. * @returns the numner of indices or zero if the mesh has no geometry.
  36894. */
  36895. getTotalIndices(): number;
  36896. /**
  36897. * Returns null by default. Implemented by child classes
  36898. * @returns null
  36899. */
  36900. getIndices(): Nullable<IndicesArray>;
  36901. /**
  36902. * Returns the array of the requested vertex data kind. Implemented by child classes
  36903. * @param kind defines the vertex data kind to use
  36904. * @returns null
  36905. */
  36906. getVerticesData(kind: string): Nullable<FloatArray>;
  36907. /**
  36908. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36909. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36910. * Note that a new underlying VertexBuffer object is created each call.
  36911. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36912. * @param kind defines vertex data kind:
  36913. * * VertexBuffer.PositionKind
  36914. * * VertexBuffer.UVKind
  36915. * * VertexBuffer.UV2Kind
  36916. * * VertexBuffer.UV3Kind
  36917. * * VertexBuffer.UV4Kind
  36918. * * VertexBuffer.UV5Kind
  36919. * * VertexBuffer.UV6Kind
  36920. * * VertexBuffer.ColorKind
  36921. * * VertexBuffer.MatricesIndicesKind
  36922. * * VertexBuffer.MatricesIndicesExtraKind
  36923. * * VertexBuffer.MatricesWeightsKind
  36924. * * VertexBuffer.MatricesWeightsExtraKind
  36925. * @param data defines the data source
  36926. * @param updatable defines if the data must be flagged as updatable (or static)
  36927. * @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
  36928. * @returns the current mesh
  36929. */
  36930. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36931. /**
  36932. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36933. * If the mesh has no geometry, it is simply returned as it is.
  36934. * @param kind defines vertex data kind:
  36935. * * VertexBuffer.PositionKind
  36936. * * VertexBuffer.UVKind
  36937. * * VertexBuffer.UV2Kind
  36938. * * VertexBuffer.UV3Kind
  36939. * * VertexBuffer.UV4Kind
  36940. * * VertexBuffer.UV5Kind
  36941. * * VertexBuffer.UV6Kind
  36942. * * VertexBuffer.ColorKind
  36943. * * VertexBuffer.MatricesIndicesKind
  36944. * * VertexBuffer.MatricesIndicesExtraKind
  36945. * * VertexBuffer.MatricesWeightsKind
  36946. * * VertexBuffer.MatricesWeightsExtraKind
  36947. * @param data defines the data source
  36948. * @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
  36949. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36950. * @returns the current mesh
  36951. */
  36952. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36953. /**
  36954. * Sets the mesh indices,
  36955. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36956. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36957. * @param totalVertices Defines the total number of vertices
  36958. * @returns the current mesh
  36959. */
  36960. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36961. /**
  36962. * Gets a boolean indicating if specific vertex data is present
  36963. * @param kind defines the vertex data kind to use
  36964. * @returns true is data kind is present
  36965. */
  36966. isVerticesDataPresent(kind: string): boolean;
  36967. /**
  36968. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36969. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36970. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36971. * @returns a BoundingInfo
  36972. */
  36973. getBoundingInfo(): BoundingInfo;
  36974. /**
  36975. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36976. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36977. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36978. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36979. * @returns the current mesh
  36980. */
  36981. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36982. /**
  36983. * Overwrite the current bounding info
  36984. * @param boundingInfo defines the new bounding info
  36985. * @returns the current mesh
  36986. */
  36987. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36988. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36989. get useBones(): boolean;
  36990. /** @hidden */
  36991. _preActivate(): void;
  36992. /** @hidden */
  36993. _preActivateForIntermediateRendering(renderId: number): void;
  36994. /** @hidden */
  36995. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36996. /** @hidden */
  36997. _postActivate(): void;
  36998. /** @hidden */
  36999. _freeze(): void;
  37000. /** @hidden */
  37001. _unFreeze(): void;
  37002. /**
  37003. * Gets the current world matrix
  37004. * @returns a Matrix
  37005. */
  37006. getWorldMatrix(): Matrix;
  37007. /** @hidden */
  37008. _getWorldMatrixDeterminant(): number;
  37009. /**
  37010. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37011. */
  37012. get isAnInstance(): boolean;
  37013. /**
  37014. * Gets a boolean indicating if this mesh has instances
  37015. */
  37016. get hasInstances(): boolean;
  37017. /**
  37018. * Gets a boolean indicating if this mesh has thin instances
  37019. */
  37020. get hasThinInstances(): boolean;
  37021. /**
  37022. * Perform relative position change from the point of view of behind the front of the mesh.
  37023. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37024. * Supports definition of mesh facing forward or backward
  37025. * @param amountRight defines the distance on the right axis
  37026. * @param amountUp defines the distance on the up axis
  37027. * @param amountForward defines the distance on the forward axis
  37028. * @returns the current mesh
  37029. */
  37030. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37031. /**
  37032. * Calculate relative position change from the point of view of behind the front of the mesh.
  37033. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37034. * Supports definition of mesh facing forward or backward
  37035. * @param amountRight defines the distance on the right axis
  37036. * @param amountUp defines the distance on the up axis
  37037. * @param amountForward defines the distance on the forward axis
  37038. * @returns the new displacement vector
  37039. */
  37040. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37041. /**
  37042. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37043. * Supports definition of mesh facing forward or backward
  37044. * @param flipBack defines the flip
  37045. * @param twirlClockwise defines the twirl
  37046. * @param tiltRight defines the tilt
  37047. * @returns the current mesh
  37048. */
  37049. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37050. /**
  37051. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37052. * Supports definition of mesh facing forward or backward.
  37053. * @param flipBack defines the flip
  37054. * @param twirlClockwise defines the twirl
  37055. * @param tiltRight defines the tilt
  37056. * @returns the new rotation vector
  37057. */
  37058. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37059. /**
  37060. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37061. * This means the mesh underlying bounding box and sphere are recomputed.
  37062. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37063. * @returns the current mesh
  37064. */
  37065. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37066. /** @hidden */
  37067. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37068. /** @hidden */
  37069. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37070. /** @hidden */
  37071. _updateBoundingInfo(): AbstractMesh;
  37072. /** @hidden */
  37073. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37074. /** @hidden */
  37075. protected _afterComputeWorldMatrix(): void;
  37076. /** @hidden */
  37077. get _effectiveMesh(): AbstractMesh;
  37078. /**
  37079. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37080. * A mesh is in the frustum if its bounding box intersects the frustum
  37081. * @param frustumPlanes defines the frustum to test
  37082. * @returns true if the mesh is in the frustum planes
  37083. */
  37084. isInFrustum(frustumPlanes: Plane[]): boolean;
  37085. /**
  37086. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37087. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37088. * @param frustumPlanes defines the frustum to test
  37089. * @returns true if the mesh is completely in the frustum planes
  37090. */
  37091. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37092. /**
  37093. * True if the mesh intersects another mesh or a SolidParticle object
  37094. * @param mesh defines a target mesh or SolidParticle to test
  37095. * @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)
  37096. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37097. * @returns true if there is an intersection
  37098. */
  37099. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37100. /**
  37101. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37102. * @param point defines the point to test
  37103. * @returns true if there is an intersection
  37104. */
  37105. intersectsPoint(point: Vector3): boolean;
  37106. /**
  37107. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37108. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37109. */
  37110. get checkCollisions(): boolean;
  37111. set checkCollisions(collisionEnabled: boolean);
  37112. /**
  37113. * Gets Collider object used to compute collisions (not physics)
  37114. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37115. */
  37116. get collider(): Nullable<Collider>;
  37117. /**
  37118. * Move the mesh using collision engine
  37119. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37120. * @param displacement defines the requested displacement vector
  37121. * @returns the current mesh
  37122. */
  37123. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37124. private _onCollisionPositionChange;
  37125. /** @hidden */
  37126. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37127. /** @hidden */
  37128. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37129. /** @hidden */
  37130. _checkCollision(collider: Collider): AbstractMesh;
  37131. /** @hidden */
  37132. _generatePointsArray(): boolean;
  37133. /**
  37134. * Checks if the passed Ray intersects with the mesh
  37135. * @param ray defines the ray to use
  37136. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37137. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37138. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37139. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37140. * @returns the picking info
  37141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37142. */
  37143. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37144. /**
  37145. * Clones the current mesh
  37146. * @param name defines the mesh name
  37147. * @param newParent defines the new mesh parent
  37148. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37149. * @returns the new mesh
  37150. */
  37151. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37152. /**
  37153. * Disposes all the submeshes of the current meshnp
  37154. * @returns the current mesh
  37155. */
  37156. releaseSubMeshes(): AbstractMesh;
  37157. /**
  37158. * Releases resources associated with this abstract mesh.
  37159. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37160. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37161. */
  37162. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37163. /**
  37164. * Adds the passed mesh as a child to the current mesh
  37165. * @param mesh defines the child mesh
  37166. * @returns the current mesh
  37167. */
  37168. addChild(mesh: AbstractMesh): AbstractMesh;
  37169. /**
  37170. * Removes the passed mesh from the current mesh children list
  37171. * @param mesh defines the child mesh
  37172. * @returns the current mesh
  37173. */
  37174. removeChild(mesh: AbstractMesh): AbstractMesh;
  37175. /** @hidden */
  37176. private _initFacetData;
  37177. /**
  37178. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37179. * This method can be called within the render loop.
  37180. * 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
  37181. * @returns the current mesh
  37182. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37183. */
  37184. updateFacetData(): AbstractMesh;
  37185. /**
  37186. * Returns the facetLocalNormals array.
  37187. * The normals are expressed in the mesh local spac
  37188. * @returns an array of Vector3
  37189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37190. */
  37191. getFacetLocalNormals(): Vector3[];
  37192. /**
  37193. * Returns the facetLocalPositions array.
  37194. * The facet positions are expressed in the mesh local space
  37195. * @returns an array of Vector3
  37196. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37197. */
  37198. getFacetLocalPositions(): Vector3[];
  37199. /**
  37200. * Returns the facetLocalPartioning array
  37201. * @returns an array of array of numbers
  37202. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37203. */
  37204. getFacetLocalPartitioning(): number[][];
  37205. /**
  37206. * Returns the i-th facet position in the world system.
  37207. * This method allocates a new Vector3 per call
  37208. * @param i defines the facet index
  37209. * @returns a new Vector3
  37210. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37211. */
  37212. getFacetPosition(i: number): Vector3;
  37213. /**
  37214. * Sets the reference Vector3 with the i-th facet position in the world system
  37215. * @param i defines the facet index
  37216. * @param ref defines the target vector
  37217. * @returns the current mesh
  37218. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37219. */
  37220. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37221. /**
  37222. * Returns the i-th facet normal in the world system.
  37223. * This method allocates a new Vector3 per call
  37224. * @param i defines the facet index
  37225. * @returns a new Vector3
  37226. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37227. */
  37228. getFacetNormal(i: number): Vector3;
  37229. /**
  37230. * Sets the reference Vector3 with the i-th facet normal in the world system
  37231. * @param i defines the facet index
  37232. * @param ref defines the target vector
  37233. * @returns the current mesh
  37234. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37235. */
  37236. getFacetNormalToRef(i: number, ref: Vector3): this;
  37237. /**
  37238. * 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)
  37239. * @param x defines x coordinate
  37240. * @param y defines y coordinate
  37241. * @param z defines z coordinate
  37242. * @returns the array of facet indexes
  37243. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37244. */
  37245. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37246. /**
  37247. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37248. * @param projected sets as the (x,y,z) world projection on the facet
  37249. * @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
  37250. * @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
  37251. * @param x defines x coordinate
  37252. * @param y defines y coordinate
  37253. * @param z defines z coordinate
  37254. * @returns the face index if found (or null instead)
  37255. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37256. */
  37257. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37258. /**
  37259. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37260. * @param projected sets as the (x,y,z) local projection on the facet
  37261. * @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
  37262. * @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
  37263. * @param x defines x coordinate
  37264. * @param y defines y coordinate
  37265. * @param z defines z coordinate
  37266. * @returns the face index if found (or null instead)
  37267. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37268. */
  37269. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37270. /**
  37271. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37272. * @returns the parameters
  37273. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37274. */
  37275. getFacetDataParameters(): any;
  37276. /**
  37277. * Disables the feature FacetData and frees the related memory
  37278. * @returns the current mesh
  37279. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37280. */
  37281. disableFacetData(): AbstractMesh;
  37282. /**
  37283. * Updates the AbstractMesh indices array
  37284. * @param indices defines the data source
  37285. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37286. * @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)
  37287. * @returns the current mesh
  37288. */
  37289. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37290. /**
  37291. * Creates new normals data for the mesh
  37292. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37293. * @returns the current mesh
  37294. */
  37295. createNormals(updatable: boolean): AbstractMesh;
  37296. /**
  37297. * Align the mesh with a normal
  37298. * @param normal defines the normal to use
  37299. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37300. * @returns the current mesh
  37301. */
  37302. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37303. /** @hidden */
  37304. _checkOcclusionQuery(): boolean;
  37305. /**
  37306. * Disables the mesh edge rendering mode
  37307. * @returns the currentAbstractMesh
  37308. */
  37309. disableEdgesRendering(): AbstractMesh;
  37310. /**
  37311. * Enables the edge rendering mode on the mesh.
  37312. * This mode makes the mesh edges visible
  37313. * @param epsilon defines the maximal distance between two angles to detect a face
  37314. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37315. * @returns the currentAbstractMesh
  37316. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37317. */
  37318. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37319. /**
  37320. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37321. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37322. */
  37323. getConnectedParticleSystems(): IParticleSystem[];
  37324. }
  37325. }
  37326. declare module "babylonjs/Actions/actionEvent" {
  37327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37328. import { Nullable } from "babylonjs/types";
  37329. import { Sprite } from "babylonjs/Sprites/sprite";
  37330. import { Scene } from "babylonjs/scene";
  37331. import { Vector2 } from "babylonjs/Maths/math.vector";
  37332. /**
  37333. * Interface used to define ActionEvent
  37334. */
  37335. export interface IActionEvent {
  37336. /** The mesh or sprite that triggered the action */
  37337. source: any;
  37338. /** The X mouse cursor position at the time of the event */
  37339. pointerX: number;
  37340. /** The Y mouse cursor position at the time of the event */
  37341. pointerY: number;
  37342. /** The mesh that is currently pointed at (can be null) */
  37343. meshUnderPointer: Nullable<AbstractMesh>;
  37344. /** the original (browser) event that triggered the ActionEvent */
  37345. sourceEvent?: any;
  37346. /** additional data for the event */
  37347. additionalData?: any;
  37348. }
  37349. /**
  37350. * ActionEvent is the event being sent when an action is triggered.
  37351. */
  37352. export class ActionEvent implements IActionEvent {
  37353. /** The mesh or sprite that triggered the action */
  37354. source: any;
  37355. /** The X mouse cursor position at the time of the event */
  37356. pointerX: number;
  37357. /** The Y mouse cursor position at the time of the event */
  37358. pointerY: number;
  37359. /** The mesh that is currently pointed at (can be null) */
  37360. meshUnderPointer: Nullable<AbstractMesh>;
  37361. /** the original (browser) event that triggered the ActionEvent */
  37362. sourceEvent?: any;
  37363. /** additional data for the event */
  37364. additionalData?: any;
  37365. /**
  37366. * Creates a new ActionEvent
  37367. * @param source The mesh or sprite that triggered the action
  37368. * @param pointerX The X mouse cursor position at the time of the event
  37369. * @param pointerY The Y mouse cursor position at the time of the event
  37370. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37371. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37372. * @param additionalData additional data for the event
  37373. */
  37374. constructor(
  37375. /** The mesh or sprite that triggered the action */
  37376. source: any,
  37377. /** The X mouse cursor position at the time of the event */
  37378. pointerX: number,
  37379. /** The Y mouse cursor position at the time of the event */
  37380. pointerY: number,
  37381. /** The mesh that is currently pointed at (can be null) */
  37382. meshUnderPointer: Nullable<AbstractMesh>,
  37383. /** the original (browser) event that triggered the ActionEvent */
  37384. sourceEvent?: any,
  37385. /** additional data for the event */
  37386. additionalData?: any);
  37387. /**
  37388. * Helper function to auto-create an ActionEvent from a source mesh.
  37389. * @param source The source mesh that triggered the event
  37390. * @param evt The original (browser) event
  37391. * @param additionalData additional data for the event
  37392. * @returns the new ActionEvent
  37393. */
  37394. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37395. /**
  37396. * Helper function to auto-create an ActionEvent from a source sprite
  37397. * @param source The source sprite that triggered the event
  37398. * @param scene Scene associated with the sprite
  37399. * @param evt The original (browser) event
  37400. * @param additionalData additional data for the event
  37401. * @returns the new ActionEvent
  37402. */
  37403. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37404. /**
  37405. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37406. * @param scene the scene where the event occurred
  37407. * @param evt The original (browser) event
  37408. * @returns the new ActionEvent
  37409. */
  37410. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37411. /**
  37412. * Helper function to auto-create an ActionEvent from a primitive
  37413. * @param prim defines the target primitive
  37414. * @param pointerPos defines the pointer position
  37415. * @param evt The original (browser) event
  37416. * @param additionalData additional data for the event
  37417. * @returns the new ActionEvent
  37418. */
  37419. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37420. }
  37421. }
  37422. declare module "babylonjs/Actions/abstractActionManager" {
  37423. import { IDisposable } from "babylonjs/scene";
  37424. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37425. import { IAction } from "babylonjs/Actions/action";
  37426. import { Nullable } from "babylonjs/types";
  37427. /**
  37428. * Abstract class used to decouple action Manager from scene and meshes.
  37429. * Do not instantiate.
  37430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37431. */
  37432. export abstract class AbstractActionManager implements IDisposable {
  37433. /** Gets the list of active triggers */
  37434. static Triggers: {
  37435. [key: string]: number;
  37436. };
  37437. /** Gets the cursor to use when hovering items */
  37438. hoverCursor: string;
  37439. /** Gets the list of actions */
  37440. actions: IAction[];
  37441. /**
  37442. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37443. */
  37444. isRecursive: boolean;
  37445. /**
  37446. * Releases all associated resources
  37447. */
  37448. abstract dispose(): void;
  37449. /**
  37450. * Does this action manager has pointer triggers
  37451. */
  37452. abstract get hasPointerTriggers(): boolean;
  37453. /**
  37454. * Does this action manager has pick triggers
  37455. */
  37456. abstract get hasPickTriggers(): boolean;
  37457. /**
  37458. * Process a specific trigger
  37459. * @param trigger defines the trigger to process
  37460. * @param evt defines the event details to be processed
  37461. */
  37462. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37463. /**
  37464. * Does this action manager handles actions of any of the given triggers
  37465. * @param triggers defines the triggers to be tested
  37466. * @return a boolean indicating whether one (or more) of the triggers is handled
  37467. */
  37468. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37469. /**
  37470. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37471. * speed.
  37472. * @param triggerA defines the trigger to be tested
  37473. * @param triggerB defines the trigger to be tested
  37474. * @return a boolean indicating whether one (or more) of the triggers is handled
  37475. */
  37476. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37477. /**
  37478. * Does this action manager handles actions of a given trigger
  37479. * @param trigger defines the trigger to be tested
  37480. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37481. * @return whether the trigger is handled
  37482. */
  37483. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37484. /**
  37485. * Serialize this manager to a JSON object
  37486. * @param name defines the property name to store this manager
  37487. * @returns a JSON representation of this manager
  37488. */
  37489. abstract serialize(name: string): any;
  37490. /**
  37491. * Registers an action to this action manager
  37492. * @param action defines the action to be registered
  37493. * @return the action amended (prepared) after registration
  37494. */
  37495. abstract registerAction(action: IAction): Nullable<IAction>;
  37496. /**
  37497. * Unregisters an action to this action manager
  37498. * @param action defines the action to be unregistered
  37499. * @return a boolean indicating whether the action has been unregistered
  37500. */
  37501. abstract unregisterAction(action: IAction): Boolean;
  37502. /**
  37503. * Does exist one action manager with at least one trigger
  37504. **/
  37505. static get HasTriggers(): boolean;
  37506. /**
  37507. * Does exist one action manager with at least one pick trigger
  37508. **/
  37509. static get HasPickTriggers(): boolean;
  37510. /**
  37511. * Does exist one action manager that handles actions of a given trigger
  37512. * @param trigger defines the trigger to be tested
  37513. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37514. **/
  37515. static HasSpecificTrigger(trigger: number): boolean;
  37516. }
  37517. }
  37518. declare module "babylonjs/node" {
  37519. import { Scene } from "babylonjs/scene";
  37520. import { Nullable } from "babylonjs/types";
  37521. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37522. import { Engine } from "babylonjs/Engines/engine";
  37523. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37524. import { Observable } from "babylonjs/Misc/observable";
  37525. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37526. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37527. import { Animatable } from "babylonjs/Animations/animatable";
  37528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37529. import { Animation } from "babylonjs/Animations/animation";
  37530. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37532. /**
  37533. * Defines how a node can be built from a string name.
  37534. */
  37535. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37536. /**
  37537. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37538. */
  37539. export class Node implements IBehaviorAware<Node> {
  37540. /** @hidden */
  37541. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37542. private static _NodeConstructors;
  37543. /**
  37544. * Add a new node constructor
  37545. * @param type defines the type name of the node to construct
  37546. * @param constructorFunc defines the constructor function
  37547. */
  37548. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37549. /**
  37550. * Returns a node constructor based on type name
  37551. * @param type defines the type name
  37552. * @param name defines the new node name
  37553. * @param scene defines the hosting scene
  37554. * @param options defines optional options to transmit to constructors
  37555. * @returns the new constructor or null
  37556. */
  37557. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37558. /**
  37559. * Gets or sets the name of the node
  37560. */
  37561. name: string;
  37562. /**
  37563. * Gets or sets the id of the node
  37564. */
  37565. id: string;
  37566. /**
  37567. * Gets or sets the unique id of the node
  37568. */
  37569. uniqueId: number;
  37570. /**
  37571. * Gets or sets a string used to store user defined state for the node
  37572. */
  37573. state: string;
  37574. /**
  37575. * Gets or sets an object used to store user defined information for the node
  37576. */
  37577. metadata: any;
  37578. /**
  37579. * For internal use only. Please do not use.
  37580. */
  37581. reservedDataStore: any;
  37582. /**
  37583. * List of inspectable custom properties (used by the Inspector)
  37584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37585. */
  37586. inspectableCustomProperties: IInspectable[];
  37587. private _doNotSerialize;
  37588. /**
  37589. * Gets or sets a boolean used to define if the node must be serialized
  37590. */
  37591. get doNotSerialize(): boolean;
  37592. set doNotSerialize(value: boolean);
  37593. /** @hidden */
  37594. _isDisposed: boolean;
  37595. /**
  37596. * Gets a list of Animations associated with the node
  37597. */
  37598. animations: import("babylonjs/Animations/animation").Animation[];
  37599. protected _ranges: {
  37600. [name: string]: Nullable<AnimationRange>;
  37601. };
  37602. /**
  37603. * Callback raised when the node is ready to be used
  37604. */
  37605. onReady: Nullable<(node: Node) => void>;
  37606. private _isEnabled;
  37607. private _isParentEnabled;
  37608. private _isReady;
  37609. /** @hidden */
  37610. _currentRenderId: number;
  37611. private _parentUpdateId;
  37612. /** @hidden */
  37613. _childUpdateId: number;
  37614. /** @hidden */
  37615. _waitingParentId: Nullable<string>;
  37616. /** @hidden */
  37617. _scene: Scene;
  37618. /** @hidden */
  37619. _cache: any;
  37620. private _parentNode;
  37621. private _children;
  37622. /** @hidden */
  37623. _worldMatrix: Matrix;
  37624. /** @hidden */
  37625. _worldMatrixDeterminant: number;
  37626. /** @hidden */
  37627. _worldMatrixDeterminantIsDirty: boolean;
  37628. /** @hidden */
  37629. private _sceneRootNodesIndex;
  37630. /**
  37631. * Gets a boolean indicating if the node has been disposed
  37632. * @returns true if the node was disposed
  37633. */
  37634. isDisposed(): boolean;
  37635. /**
  37636. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37637. * @see https://doc.babylonjs.com/how_to/parenting
  37638. */
  37639. set parent(parent: Nullable<Node>);
  37640. get parent(): Nullable<Node>;
  37641. /** @hidden */
  37642. _addToSceneRootNodes(): void;
  37643. /** @hidden */
  37644. _removeFromSceneRootNodes(): void;
  37645. private _animationPropertiesOverride;
  37646. /**
  37647. * Gets or sets the animation properties override
  37648. */
  37649. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37650. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37651. /**
  37652. * Gets a string identifying the name of the class
  37653. * @returns "Node" string
  37654. */
  37655. getClassName(): string;
  37656. /** @hidden */
  37657. readonly _isNode: boolean;
  37658. /**
  37659. * An event triggered when the mesh is disposed
  37660. */
  37661. onDisposeObservable: Observable<Node>;
  37662. private _onDisposeObserver;
  37663. /**
  37664. * Sets a callback that will be raised when the node will be disposed
  37665. */
  37666. set onDispose(callback: () => void);
  37667. /**
  37668. * Creates a new Node
  37669. * @param name the name and id to be given to this node
  37670. * @param scene the scene this node will be added to
  37671. */
  37672. constructor(name: string, scene?: Nullable<Scene>);
  37673. /**
  37674. * Gets the scene of the node
  37675. * @returns a scene
  37676. */
  37677. getScene(): Scene;
  37678. /**
  37679. * Gets the engine of the node
  37680. * @returns a Engine
  37681. */
  37682. getEngine(): Engine;
  37683. private _behaviors;
  37684. /**
  37685. * Attach a behavior to the node
  37686. * @see https://doc.babylonjs.com/features/behaviour
  37687. * @param behavior defines the behavior to attach
  37688. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37689. * @returns the current Node
  37690. */
  37691. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37692. /**
  37693. * Remove an attached behavior
  37694. * @see https://doc.babylonjs.com/features/behaviour
  37695. * @param behavior defines the behavior to attach
  37696. * @returns the current Node
  37697. */
  37698. removeBehavior(behavior: Behavior<Node>): Node;
  37699. /**
  37700. * Gets the list of attached behaviors
  37701. * @see https://doc.babylonjs.com/features/behaviour
  37702. */
  37703. get behaviors(): Behavior<Node>[];
  37704. /**
  37705. * Gets an attached behavior by name
  37706. * @param name defines the name of the behavior to look for
  37707. * @see https://doc.babylonjs.com/features/behaviour
  37708. * @returns null if behavior was not found else the requested behavior
  37709. */
  37710. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37711. /**
  37712. * Returns the latest update of the World matrix
  37713. * @returns a Matrix
  37714. */
  37715. getWorldMatrix(): Matrix;
  37716. /** @hidden */
  37717. _getWorldMatrixDeterminant(): number;
  37718. /**
  37719. * Returns directly the latest state of the mesh World matrix.
  37720. * A Matrix is returned.
  37721. */
  37722. get worldMatrixFromCache(): Matrix;
  37723. /** @hidden */
  37724. _initCache(): void;
  37725. /** @hidden */
  37726. updateCache(force?: boolean): void;
  37727. /** @hidden */
  37728. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37729. /** @hidden */
  37730. _updateCache(ignoreParentClass?: boolean): void;
  37731. /** @hidden */
  37732. _isSynchronized(): boolean;
  37733. /** @hidden */
  37734. _markSyncedWithParent(): void;
  37735. /** @hidden */
  37736. isSynchronizedWithParent(): boolean;
  37737. /** @hidden */
  37738. isSynchronized(): boolean;
  37739. /**
  37740. * Is this node ready to be used/rendered
  37741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37742. * @return true if the node is ready
  37743. */
  37744. isReady(completeCheck?: boolean): boolean;
  37745. /**
  37746. * Is this node enabled?
  37747. * 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
  37748. * @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
  37749. * @return whether this node (and its parent) is enabled
  37750. */
  37751. isEnabled(checkAncestors?: boolean): boolean;
  37752. /** @hidden */
  37753. protected _syncParentEnabledState(): void;
  37754. /**
  37755. * Set the enabled state of this node
  37756. * @param value defines the new enabled state
  37757. */
  37758. setEnabled(value: boolean): void;
  37759. /**
  37760. * Is this node a descendant of the given node?
  37761. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37762. * @param ancestor defines the parent node to inspect
  37763. * @returns a boolean indicating if this node is a descendant of the given node
  37764. */
  37765. isDescendantOf(ancestor: Node): boolean;
  37766. /** @hidden */
  37767. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37768. /**
  37769. * Will return all nodes that have this node as ascendant
  37770. * @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
  37771. * @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
  37772. * @return all children nodes of all types
  37773. */
  37774. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37775. /**
  37776. * Get all child-meshes of this node
  37777. * @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)
  37778. * @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
  37779. * @returns an array of AbstractMesh
  37780. */
  37781. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37782. /**
  37783. * Get all direct children of this node
  37784. * @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
  37785. * @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)
  37786. * @returns an array of Node
  37787. */
  37788. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37789. /** @hidden */
  37790. _setReady(state: boolean): void;
  37791. /**
  37792. * Get an animation by name
  37793. * @param name defines the name of the animation to look for
  37794. * @returns null if not found else the requested animation
  37795. */
  37796. getAnimationByName(name: string): Nullable<Animation>;
  37797. /**
  37798. * Creates an animation range for this node
  37799. * @param name defines the name of the range
  37800. * @param from defines the starting key
  37801. * @param to defines the end key
  37802. */
  37803. createAnimationRange(name: string, from: number, to: number): void;
  37804. /**
  37805. * Delete a specific animation range
  37806. * @param name defines the name of the range to delete
  37807. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37808. */
  37809. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37810. /**
  37811. * Get an animation range by name
  37812. * @param name defines the name of the animation range to look for
  37813. * @returns null if not found else the requested animation range
  37814. */
  37815. getAnimationRange(name: string): Nullable<AnimationRange>;
  37816. /**
  37817. * Gets the list of all animation ranges defined on this node
  37818. * @returns an array
  37819. */
  37820. getAnimationRanges(): Nullable<AnimationRange>[];
  37821. /**
  37822. * Will start the animation sequence
  37823. * @param name defines the range frames for animation sequence
  37824. * @param loop defines if the animation should loop (false by default)
  37825. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37826. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37827. * @returns the object created for this animation. If range does not exist, it will return null
  37828. */
  37829. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37830. /**
  37831. * Serialize animation ranges into a JSON compatible object
  37832. * @returns serialization object
  37833. */
  37834. serializeAnimationRanges(): any;
  37835. /**
  37836. * Computes the world matrix of the node
  37837. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37838. * @returns the world matrix
  37839. */
  37840. computeWorldMatrix(force?: boolean): Matrix;
  37841. /**
  37842. * Releases resources associated with this node.
  37843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37845. */
  37846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37847. /**
  37848. * Parse animation range data from a serialization object and store them into a given node
  37849. * @param node defines where to store the animation ranges
  37850. * @param parsedNode defines the serialization object to read data from
  37851. * @param scene defines the hosting scene
  37852. */
  37853. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37854. /**
  37855. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37856. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37857. * @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
  37858. * @returns the new bounding vectors
  37859. */
  37860. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37861. min: Vector3;
  37862. max: Vector3;
  37863. };
  37864. }
  37865. }
  37866. declare module "babylonjs/Animations/animation" {
  37867. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37868. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37869. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37870. import { Nullable } from "babylonjs/types";
  37871. import { Scene } from "babylonjs/scene";
  37872. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37873. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37874. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37875. import { Node } from "babylonjs/node";
  37876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37877. import { Size } from "babylonjs/Maths/math.size";
  37878. import { Animatable } from "babylonjs/Animations/animatable";
  37879. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37880. /**
  37881. * @hidden
  37882. */
  37883. export class _IAnimationState {
  37884. key: number;
  37885. repeatCount: number;
  37886. workValue?: any;
  37887. loopMode?: number;
  37888. offsetValue?: any;
  37889. highLimitValue?: any;
  37890. }
  37891. /**
  37892. * Class used to store any kind of animation
  37893. */
  37894. export class Animation {
  37895. /**Name of the animation */
  37896. name: string;
  37897. /**Property to animate */
  37898. targetProperty: string;
  37899. /**The frames per second of the animation */
  37900. framePerSecond: number;
  37901. /**The data type of the animation */
  37902. dataType: number;
  37903. /**The loop mode of the animation */
  37904. loopMode?: number | undefined;
  37905. /**Specifies if blending should be enabled */
  37906. enableBlending?: boolean | undefined;
  37907. /**
  37908. * Use matrix interpolation instead of using direct key value when animating matrices
  37909. */
  37910. static AllowMatricesInterpolation: boolean;
  37911. /**
  37912. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37913. */
  37914. static AllowMatrixDecomposeForInterpolation: boolean;
  37915. /** Define the Url to load snippets */
  37916. static SnippetUrl: string;
  37917. /** Snippet ID if the animation was created from the snippet server */
  37918. snippetId: string;
  37919. /**
  37920. * Stores the key frames of the animation
  37921. */
  37922. private _keys;
  37923. /**
  37924. * Stores the easing function of the animation
  37925. */
  37926. private _easingFunction;
  37927. /**
  37928. * @hidden Internal use only
  37929. */
  37930. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37931. /**
  37932. * The set of event that will be linked to this animation
  37933. */
  37934. private _events;
  37935. /**
  37936. * Stores an array of target property paths
  37937. */
  37938. targetPropertyPath: string[];
  37939. /**
  37940. * Stores the blending speed of the animation
  37941. */
  37942. blendingSpeed: number;
  37943. /**
  37944. * Stores the animation ranges for the animation
  37945. */
  37946. private _ranges;
  37947. /**
  37948. * @hidden Internal use
  37949. */
  37950. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37951. /**
  37952. * Sets up an animation
  37953. * @param property The property to animate
  37954. * @param animationType The animation type to apply
  37955. * @param framePerSecond The frames per second of the animation
  37956. * @param easingFunction The easing function used in the animation
  37957. * @returns The created animation
  37958. */
  37959. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37960. /**
  37961. * Create and start an animation on a node
  37962. * @param name defines the name of the global animation that will be run on all nodes
  37963. * @param node defines the root node where the animation will take place
  37964. * @param targetProperty defines property to animate
  37965. * @param framePerSecond defines the number of frame per second yo use
  37966. * @param totalFrame defines the number of frames in total
  37967. * @param from defines the initial value
  37968. * @param to defines the final value
  37969. * @param loopMode defines which loop mode you want to use (off by default)
  37970. * @param easingFunction defines the easing function to use (linear by default)
  37971. * @param onAnimationEnd defines the callback to call when animation end
  37972. * @returns the animatable created for this animation
  37973. */
  37974. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37975. /**
  37976. * Create and start an animation on a node and its descendants
  37977. * @param name defines the name of the global animation that will be run on all nodes
  37978. * @param node defines the root node where the animation will take place
  37979. * @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
  37980. * @param targetProperty defines property to animate
  37981. * @param framePerSecond defines the number of frame per second to use
  37982. * @param totalFrame defines the number of frames in total
  37983. * @param from defines the initial value
  37984. * @param to defines the final value
  37985. * @param loopMode defines which loop mode you want to use (off by default)
  37986. * @param easingFunction defines the easing function to use (linear by default)
  37987. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37988. * @returns the list of animatables created for all nodes
  37989. * @example https://www.babylonjs-playground.com/#MH0VLI
  37990. */
  37991. 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[]>;
  37992. /**
  37993. * Creates a new animation, merges it with the existing animations and starts it
  37994. * @param name Name of the animation
  37995. * @param node Node which contains the scene that begins the animations
  37996. * @param targetProperty Specifies which property to animate
  37997. * @param framePerSecond The frames per second of the animation
  37998. * @param totalFrame The total number of frames
  37999. * @param from The frame at the beginning of the animation
  38000. * @param to The frame at the end of the animation
  38001. * @param loopMode Specifies the loop mode of the animation
  38002. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38003. * @param onAnimationEnd Callback to run once the animation is complete
  38004. * @returns Nullable animation
  38005. */
  38006. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38007. /**
  38008. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38009. * @param sourceAnimation defines the Animation containing keyframes to convert
  38010. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38011. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38012. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38013. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38014. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38015. */
  38016. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38017. /**
  38018. * Transition property of an host to the target Value
  38019. * @param property The property to transition
  38020. * @param targetValue The target Value of the property
  38021. * @param host The object where the property to animate belongs
  38022. * @param scene Scene used to run the animation
  38023. * @param frameRate Framerate (in frame/s) to use
  38024. * @param transition The transition type we want to use
  38025. * @param duration The duration of the animation, in milliseconds
  38026. * @param onAnimationEnd Callback trigger at the end of the animation
  38027. * @returns Nullable animation
  38028. */
  38029. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38030. /**
  38031. * Return the array of runtime animations currently using this animation
  38032. */
  38033. get runtimeAnimations(): RuntimeAnimation[];
  38034. /**
  38035. * Specifies if any of the runtime animations are currently running
  38036. */
  38037. get hasRunningRuntimeAnimations(): boolean;
  38038. /**
  38039. * Initializes the animation
  38040. * @param name Name of the animation
  38041. * @param targetProperty Property to animate
  38042. * @param framePerSecond The frames per second of the animation
  38043. * @param dataType The data type of the animation
  38044. * @param loopMode The loop mode of the animation
  38045. * @param enableBlending Specifies if blending should be enabled
  38046. */
  38047. constructor(
  38048. /**Name of the animation */
  38049. name: string,
  38050. /**Property to animate */
  38051. targetProperty: string,
  38052. /**The frames per second of the animation */
  38053. framePerSecond: number,
  38054. /**The data type of the animation */
  38055. dataType: number,
  38056. /**The loop mode of the animation */
  38057. loopMode?: number | undefined,
  38058. /**Specifies if blending should be enabled */
  38059. enableBlending?: boolean | undefined);
  38060. /**
  38061. * Converts the animation to a string
  38062. * @param fullDetails support for multiple levels of logging within scene loading
  38063. * @returns String form of the animation
  38064. */
  38065. toString(fullDetails?: boolean): string;
  38066. /**
  38067. * Add an event to this animation
  38068. * @param event Event to add
  38069. */
  38070. addEvent(event: AnimationEvent): void;
  38071. /**
  38072. * Remove all events found at the given frame
  38073. * @param frame The frame to remove events from
  38074. */
  38075. removeEvents(frame: number): void;
  38076. /**
  38077. * Retrieves all the events from the animation
  38078. * @returns Events from the animation
  38079. */
  38080. getEvents(): AnimationEvent[];
  38081. /**
  38082. * Creates an animation range
  38083. * @param name Name of the animation range
  38084. * @param from Starting frame of the animation range
  38085. * @param to Ending frame of the animation
  38086. */
  38087. createRange(name: string, from: number, to: number): void;
  38088. /**
  38089. * Deletes an animation range by name
  38090. * @param name Name of the animation range to delete
  38091. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38092. */
  38093. deleteRange(name: string, deleteFrames?: boolean): void;
  38094. /**
  38095. * Gets the animation range by name, or null if not defined
  38096. * @param name Name of the animation range
  38097. * @returns Nullable animation range
  38098. */
  38099. getRange(name: string): Nullable<AnimationRange>;
  38100. /**
  38101. * Gets the key frames from the animation
  38102. * @returns The key frames of the animation
  38103. */
  38104. getKeys(): Array<IAnimationKey>;
  38105. /**
  38106. * Gets the highest frame rate of the animation
  38107. * @returns Highest frame rate of the animation
  38108. */
  38109. getHighestFrame(): number;
  38110. /**
  38111. * Gets the easing function of the animation
  38112. * @returns Easing function of the animation
  38113. */
  38114. getEasingFunction(): IEasingFunction;
  38115. /**
  38116. * Sets the easing function of the animation
  38117. * @param easingFunction A custom mathematical formula for animation
  38118. */
  38119. setEasingFunction(easingFunction: EasingFunction): void;
  38120. /**
  38121. * Interpolates a scalar linearly
  38122. * @param startValue Start value of the animation curve
  38123. * @param endValue End value of the animation curve
  38124. * @param gradient Scalar amount to interpolate
  38125. * @returns Interpolated scalar value
  38126. */
  38127. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38128. /**
  38129. * Interpolates a scalar cubically
  38130. * @param startValue Start value of the animation curve
  38131. * @param outTangent End tangent of the animation
  38132. * @param endValue End value of the animation curve
  38133. * @param inTangent Start tangent of the animation curve
  38134. * @param gradient Scalar amount to interpolate
  38135. * @returns Interpolated scalar value
  38136. */
  38137. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38138. /**
  38139. * Interpolates a quaternion using a spherical linear interpolation
  38140. * @param startValue Start value of the animation curve
  38141. * @param endValue End value of the animation curve
  38142. * @param gradient Scalar amount to interpolate
  38143. * @returns Interpolated quaternion value
  38144. */
  38145. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38146. /**
  38147. * Interpolates a quaternion cubically
  38148. * @param startValue Start value of the animation curve
  38149. * @param outTangent End tangent of the animation curve
  38150. * @param endValue End value of the animation curve
  38151. * @param inTangent Start tangent of the animation curve
  38152. * @param gradient Scalar amount to interpolate
  38153. * @returns Interpolated quaternion value
  38154. */
  38155. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38156. /**
  38157. * Interpolates a Vector3 linearl
  38158. * @param startValue Start value of the animation curve
  38159. * @param endValue End value of the animation curve
  38160. * @param gradient Scalar amount to interpolate
  38161. * @returns Interpolated scalar value
  38162. */
  38163. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38164. /**
  38165. * Interpolates a Vector3 cubically
  38166. * @param startValue Start value of the animation curve
  38167. * @param outTangent End tangent of the animation
  38168. * @param endValue End value of the animation curve
  38169. * @param inTangent Start tangent of the animation curve
  38170. * @param gradient Scalar amount to interpolate
  38171. * @returns InterpolatedVector3 value
  38172. */
  38173. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38174. /**
  38175. * Interpolates a Vector2 linearly
  38176. * @param startValue Start value of the animation curve
  38177. * @param endValue End value of the animation curve
  38178. * @param gradient Scalar amount to interpolate
  38179. * @returns Interpolated Vector2 value
  38180. */
  38181. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38182. /**
  38183. * Interpolates a Vector2 cubically
  38184. * @param startValue Start value of the animation curve
  38185. * @param outTangent End tangent of the animation
  38186. * @param endValue End value of the animation curve
  38187. * @param inTangent Start tangent of the animation curve
  38188. * @param gradient Scalar amount to interpolate
  38189. * @returns Interpolated Vector2 value
  38190. */
  38191. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38192. /**
  38193. * Interpolates a size linearly
  38194. * @param startValue Start value of the animation curve
  38195. * @param endValue End value of the animation curve
  38196. * @param gradient Scalar amount to interpolate
  38197. * @returns Interpolated Size value
  38198. */
  38199. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38200. /**
  38201. * Interpolates a Color3 linearly
  38202. * @param startValue Start value of the animation curve
  38203. * @param endValue End value of the animation curve
  38204. * @param gradient Scalar amount to interpolate
  38205. * @returns Interpolated Color3 value
  38206. */
  38207. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38208. /**
  38209. * Interpolates a Color4 linearly
  38210. * @param startValue Start value of the animation curve
  38211. * @param endValue End value of the animation curve
  38212. * @param gradient Scalar amount to interpolate
  38213. * @returns Interpolated Color3 value
  38214. */
  38215. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38216. /**
  38217. * @hidden Internal use only
  38218. */
  38219. _getKeyValue(value: any): any;
  38220. /**
  38221. * @hidden Internal use only
  38222. */
  38223. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38224. /**
  38225. * Defines the function to use to interpolate matrices
  38226. * @param startValue defines the start matrix
  38227. * @param endValue defines the end matrix
  38228. * @param gradient defines the gradient between both matrices
  38229. * @param result defines an optional target matrix where to store the interpolation
  38230. * @returns the interpolated matrix
  38231. */
  38232. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38233. /**
  38234. * Makes a copy of the animation
  38235. * @returns Cloned animation
  38236. */
  38237. clone(): Animation;
  38238. /**
  38239. * Sets the key frames of the animation
  38240. * @param values The animation key frames to set
  38241. */
  38242. setKeys(values: Array<IAnimationKey>): void;
  38243. /**
  38244. * Serializes the animation to an object
  38245. * @returns Serialized object
  38246. */
  38247. serialize(): any;
  38248. /**
  38249. * Float animation type
  38250. */
  38251. static readonly ANIMATIONTYPE_FLOAT: number;
  38252. /**
  38253. * Vector3 animation type
  38254. */
  38255. static readonly ANIMATIONTYPE_VECTOR3: number;
  38256. /**
  38257. * Quaternion animation type
  38258. */
  38259. static readonly ANIMATIONTYPE_QUATERNION: number;
  38260. /**
  38261. * Matrix animation type
  38262. */
  38263. static readonly ANIMATIONTYPE_MATRIX: number;
  38264. /**
  38265. * Color3 animation type
  38266. */
  38267. static readonly ANIMATIONTYPE_COLOR3: number;
  38268. /**
  38269. * Color3 animation type
  38270. */
  38271. static readonly ANIMATIONTYPE_COLOR4: number;
  38272. /**
  38273. * Vector2 animation type
  38274. */
  38275. static readonly ANIMATIONTYPE_VECTOR2: number;
  38276. /**
  38277. * Size animation type
  38278. */
  38279. static readonly ANIMATIONTYPE_SIZE: number;
  38280. /**
  38281. * Relative Loop Mode
  38282. */
  38283. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38284. /**
  38285. * Cycle Loop Mode
  38286. */
  38287. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38288. /**
  38289. * Constant Loop Mode
  38290. */
  38291. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38292. /** @hidden */
  38293. static _UniversalLerp(left: any, right: any, amount: number): any;
  38294. /**
  38295. * Parses an animation object and creates an animation
  38296. * @param parsedAnimation Parsed animation object
  38297. * @returns Animation object
  38298. */
  38299. static Parse(parsedAnimation: any): Animation;
  38300. /**
  38301. * Appends the serialized animations from the source animations
  38302. * @param source Source containing the animations
  38303. * @param destination Target to store the animations
  38304. */
  38305. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38306. /**
  38307. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38308. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38309. * @param url defines the url to load from
  38310. * @returns a promise that will resolve to the new animation or an array of animations
  38311. */
  38312. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38313. /**
  38314. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38315. * @param snippetId defines the snippet to load
  38316. * @returns a promise that will resolve to the new animation or a new array of animations
  38317. */
  38318. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38319. }
  38320. }
  38321. declare module "babylonjs/Animations/animatable.interface" {
  38322. import { Nullable } from "babylonjs/types";
  38323. import { Animation } from "babylonjs/Animations/animation";
  38324. /**
  38325. * Interface containing an array of animations
  38326. */
  38327. export interface IAnimatable {
  38328. /**
  38329. * Array of animations
  38330. */
  38331. animations: Nullable<Array<Animation>>;
  38332. }
  38333. }
  38334. declare module "babylonjs/Misc/decorators" {
  38335. import { Nullable } from "babylonjs/types";
  38336. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38337. import { Scene } from "babylonjs/scene";
  38338. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38339. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38340. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38342. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38343. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38344. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38345. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38346. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38347. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38348. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38349. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38350. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38351. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38352. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38353. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38354. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38355. /**
  38356. * Decorator used to define property that can be serialized as reference to a camera
  38357. * @param sourceName defines the name of the property to decorate
  38358. */
  38359. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38360. /**
  38361. * Class used to help serialization objects
  38362. */
  38363. export class SerializationHelper {
  38364. /** @hidden */
  38365. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38366. /** @hidden */
  38367. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38368. /** @hidden */
  38369. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38370. /** @hidden */
  38371. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38372. /**
  38373. * Appends the serialized animations from the source animations
  38374. * @param source Source containing the animations
  38375. * @param destination Target to store the animations
  38376. */
  38377. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38378. /**
  38379. * Static function used to serialized a specific entity
  38380. * @param entity defines the entity to serialize
  38381. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38382. * @returns a JSON compatible object representing the serialization of the entity
  38383. */
  38384. static Serialize<T>(entity: T, serializationObject?: any): any;
  38385. /**
  38386. * Creates a new entity from a serialization data object
  38387. * @param creationFunction defines a function used to instanciated the new entity
  38388. * @param source defines the source serialization data
  38389. * @param scene defines the hosting scene
  38390. * @param rootUrl defines the root url for resources
  38391. * @returns a new entity
  38392. */
  38393. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38394. /**
  38395. * Clones an object
  38396. * @param creationFunction defines the function used to instanciate the new object
  38397. * @param source defines the source object
  38398. * @returns the cloned object
  38399. */
  38400. static Clone<T>(creationFunction: () => T, source: T): T;
  38401. /**
  38402. * Instanciates a new object based on a source one (some data will be shared between both object)
  38403. * @param creationFunction defines the function used to instanciate the new object
  38404. * @param source defines the source object
  38405. * @returns the new object
  38406. */
  38407. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38408. }
  38409. }
  38410. declare module "babylonjs/Materials/Textures/baseTexture" {
  38411. import { Observable } from "babylonjs/Misc/observable";
  38412. import { Nullable } from "babylonjs/types";
  38413. import { Scene } from "babylonjs/scene";
  38414. import { Matrix } from "babylonjs/Maths/math.vector";
  38415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38416. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38417. import { ISize } from "babylonjs/Maths/math.size";
  38418. import "babylonjs/Misc/fileTools";
  38419. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38420. /**
  38421. * Base class of all the textures in babylon.
  38422. * It groups all the common properties the materials, post process, lights... might need
  38423. * in order to make a correct use of the texture.
  38424. */
  38425. export class BaseTexture implements IAnimatable {
  38426. /**
  38427. * Default anisotropic filtering level for the application.
  38428. * It is set to 4 as a good tradeoff between perf and quality.
  38429. */
  38430. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38431. /**
  38432. * Gets or sets the unique id of the texture
  38433. */
  38434. uniqueId: number;
  38435. /**
  38436. * Define the name of the texture.
  38437. */
  38438. name: string;
  38439. /**
  38440. * Gets or sets an object used to store user defined information.
  38441. */
  38442. metadata: any;
  38443. /**
  38444. * For internal use only. Please do not use.
  38445. */
  38446. reservedDataStore: any;
  38447. private _hasAlpha;
  38448. /**
  38449. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38450. */
  38451. set hasAlpha(value: boolean);
  38452. get hasAlpha(): boolean;
  38453. /**
  38454. * Defines if the alpha value should be determined via the rgb values.
  38455. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38456. */
  38457. getAlphaFromRGB: boolean;
  38458. /**
  38459. * Intensity or strength of the texture.
  38460. * It is commonly used by materials to fine tune the intensity of the texture
  38461. */
  38462. level: number;
  38463. /**
  38464. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38465. * This is part of the texture as textures usually maps to one uv set.
  38466. */
  38467. coordinatesIndex: number;
  38468. protected _coordinatesMode: number;
  38469. /**
  38470. * How a texture is mapped.
  38471. *
  38472. * | Value | Type | Description |
  38473. * | ----- | ----------------------------------- | ----------- |
  38474. * | 0 | EXPLICIT_MODE | |
  38475. * | 1 | SPHERICAL_MODE | |
  38476. * | 2 | PLANAR_MODE | |
  38477. * | 3 | CUBIC_MODE | |
  38478. * | 4 | PROJECTION_MODE | |
  38479. * | 5 | SKYBOX_MODE | |
  38480. * | 6 | INVCUBIC_MODE | |
  38481. * | 7 | EQUIRECTANGULAR_MODE | |
  38482. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38483. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38484. */
  38485. set coordinatesMode(value: number);
  38486. get coordinatesMode(): number;
  38487. private _wrapU;
  38488. /**
  38489. * | Value | Type | Description |
  38490. * | ----- | ------------------ | ----------- |
  38491. * | 0 | CLAMP_ADDRESSMODE | |
  38492. * | 1 | WRAP_ADDRESSMODE | |
  38493. * | 2 | MIRROR_ADDRESSMODE | |
  38494. */
  38495. get wrapU(): number;
  38496. set wrapU(value: number);
  38497. private _wrapV;
  38498. /**
  38499. * | Value | Type | Description |
  38500. * | ----- | ------------------ | ----------- |
  38501. * | 0 | CLAMP_ADDRESSMODE | |
  38502. * | 1 | WRAP_ADDRESSMODE | |
  38503. * | 2 | MIRROR_ADDRESSMODE | |
  38504. */
  38505. get wrapV(): number;
  38506. set wrapV(value: number);
  38507. /**
  38508. * | Value | Type | Description |
  38509. * | ----- | ------------------ | ----------- |
  38510. * | 0 | CLAMP_ADDRESSMODE | |
  38511. * | 1 | WRAP_ADDRESSMODE | |
  38512. * | 2 | MIRROR_ADDRESSMODE | |
  38513. */
  38514. wrapR: number;
  38515. /**
  38516. * With compliant hardware and browser (supporting anisotropic filtering)
  38517. * this defines the level of anisotropic filtering in the texture.
  38518. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38519. */
  38520. anisotropicFilteringLevel: number;
  38521. /**
  38522. * Define if the texture is a cube texture or if false a 2d texture.
  38523. */
  38524. get isCube(): boolean;
  38525. set isCube(value: boolean);
  38526. /**
  38527. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38528. */
  38529. get is3D(): boolean;
  38530. set is3D(value: boolean);
  38531. /**
  38532. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38533. */
  38534. get is2DArray(): boolean;
  38535. set is2DArray(value: boolean);
  38536. private _gammaSpace;
  38537. /**
  38538. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38539. * HDR texture are usually stored in linear space.
  38540. * This only impacts the PBR and Background materials
  38541. */
  38542. get gammaSpace(): boolean;
  38543. set gammaSpace(gamma: boolean);
  38544. /**
  38545. * Gets or sets whether or not the texture contains RGBD data.
  38546. */
  38547. get isRGBD(): boolean;
  38548. set isRGBD(value: boolean);
  38549. /**
  38550. * Is Z inverted in the texture (useful in a cube texture).
  38551. */
  38552. invertZ: boolean;
  38553. /**
  38554. * Are mip maps generated for this texture or not.
  38555. */
  38556. get noMipmap(): boolean;
  38557. /**
  38558. * @hidden
  38559. */
  38560. lodLevelInAlpha: boolean;
  38561. /**
  38562. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38563. */
  38564. get lodGenerationOffset(): number;
  38565. set lodGenerationOffset(value: number);
  38566. /**
  38567. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38568. */
  38569. get lodGenerationScale(): number;
  38570. set lodGenerationScale(value: number);
  38571. /**
  38572. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38573. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38574. * average roughness values.
  38575. */
  38576. get linearSpecularLOD(): boolean;
  38577. set linearSpecularLOD(value: boolean);
  38578. /**
  38579. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38580. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38581. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38582. */
  38583. get irradianceTexture(): Nullable<BaseTexture>;
  38584. set irradianceTexture(value: Nullable<BaseTexture>);
  38585. /**
  38586. * Define if the texture is a render target.
  38587. */
  38588. isRenderTarget: boolean;
  38589. /**
  38590. * Define the unique id of the texture in the scene.
  38591. */
  38592. get uid(): string;
  38593. /** @hidden */
  38594. _prefiltered: boolean;
  38595. /**
  38596. * Return a string representation of the texture.
  38597. * @returns the texture as a string
  38598. */
  38599. toString(): string;
  38600. /**
  38601. * Get the class name of the texture.
  38602. * @returns "BaseTexture"
  38603. */
  38604. getClassName(): string;
  38605. /**
  38606. * Define the list of animation attached to the texture.
  38607. */
  38608. animations: import("babylonjs/Animations/animation").Animation[];
  38609. /**
  38610. * An event triggered when the texture is disposed.
  38611. */
  38612. onDisposeObservable: Observable<BaseTexture>;
  38613. private _onDisposeObserver;
  38614. /**
  38615. * Callback triggered when the texture has been disposed.
  38616. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38617. */
  38618. set onDispose(callback: () => void);
  38619. /**
  38620. * Define the current state of the loading sequence when in delayed load mode.
  38621. */
  38622. delayLoadState: number;
  38623. protected _scene: Nullable<Scene>;
  38624. protected _engine: Nullable<ThinEngine>;
  38625. /** @hidden */
  38626. _texture: Nullable<InternalTexture>;
  38627. private _uid;
  38628. /**
  38629. * Define if the texture is preventinga material to render or not.
  38630. * If not and the texture is not ready, the engine will use a default black texture instead.
  38631. */
  38632. get isBlocking(): boolean;
  38633. /**
  38634. * Instantiates a new BaseTexture.
  38635. * Base class of all the textures in babylon.
  38636. * It groups all the common properties the materials, post process, lights... might need
  38637. * in order to make a correct use of the texture.
  38638. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38639. */
  38640. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38641. /**
  38642. * Get the scene the texture belongs to.
  38643. * @returns the scene or null if undefined
  38644. */
  38645. getScene(): Nullable<Scene>;
  38646. /** @hidden */
  38647. protected _getEngine(): Nullable<ThinEngine>;
  38648. /**
  38649. * Checks if the texture has the same transform matrix than another texture
  38650. * @param texture texture to check against
  38651. * @returns true if the transforms are the same, else false
  38652. */
  38653. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38654. /**
  38655. * Get the texture transform matrix used to offset tile the texture for istance.
  38656. * @returns the transformation matrix
  38657. */
  38658. getTextureMatrix(): Matrix;
  38659. /**
  38660. * Get the texture reflection matrix used to rotate/transform the reflection.
  38661. * @returns the reflection matrix
  38662. */
  38663. getReflectionTextureMatrix(): Matrix;
  38664. /**
  38665. * Get the underlying lower level texture from Babylon.
  38666. * @returns the insternal texture
  38667. */
  38668. getInternalTexture(): Nullable<InternalTexture>;
  38669. /**
  38670. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38671. * @returns true if ready or not blocking
  38672. */
  38673. isReadyOrNotBlocking(): boolean;
  38674. /**
  38675. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38676. * @returns true if fully ready
  38677. */
  38678. isReady(): boolean;
  38679. private _cachedSize;
  38680. /**
  38681. * Get the size of the texture.
  38682. * @returns the texture size.
  38683. */
  38684. getSize(): ISize;
  38685. /**
  38686. * Get the base size of the texture.
  38687. * It can be different from the size if the texture has been resized for POT for instance
  38688. * @returns the base size
  38689. */
  38690. getBaseSize(): ISize;
  38691. /**
  38692. * Update the sampling mode of the texture.
  38693. * Default is Trilinear mode.
  38694. *
  38695. * | Value | Type | Description |
  38696. * | ----- | ------------------ | ----------- |
  38697. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38698. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38699. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38700. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38701. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38702. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38703. * | 7 | NEAREST_LINEAR | |
  38704. * | 8 | NEAREST_NEAREST | |
  38705. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38706. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38707. * | 11 | LINEAR_LINEAR | |
  38708. * | 12 | LINEAR_NEAREST | |
  38709. *
  38710. * > _mag_: magnification filter (close to the viewer)
  38711. * > _min_: minification filter (far from the viewer)
  38712. * > _mip_: filter used between mip map levels
  38713. *@param samplingMode Define the new sampling mode of the texture
  38714. */
  38715. updateSamplingMode(samplingMode: number): void;
  38716. /**
  38717. * Scales the texture if is `canRescale()`
  38718. * @param ratio the resize factor we want to use to rescale
  38719. */
  38720. scale(ratio: number): void;
  38721. /**
  38722. * Get if the texture can rescale.
  38723. */
  38724. get canRescale(): boolean;
  38725. /** @hidden */
  38726. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38727. /** @hidden */
  38728. _rebuild(): void;
  38729. /**
  38730. * Triggers the load sequence in delayed load mode.
  38731. */
  38732. delayLoad(): void;
  38733. /**
  38734. * Clones the texture.
  38735. * @returns the cloned texture
  38736. */
  38737. clone(): Nullable<BaseTexture>;
  38738. /**
  38739. * Get the texture underlying type (INT, FLOAT...)
  38740. */
  38741. get textureType(): number;
  38742. /**
  38743. * Get the texture underlying format (RGB, RGBA...)
  38744. */
  38745. get textureFormat(): number;
  38746. /**
  38747. * Indicates that textures need to be re-calculated for all materials
  38748. */
  38749. protected _markAllSubMeshesAsTexturesDirty(): void;
  38750. /**
  38751. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38752. * This will returns an RGBA array buffer containing either in values (0-255) or
  38753. * float values (0-1) depending of the underlying buffer type.
  38754. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38755. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38756. * @param buffer defines a user defined buffer to fill with data (can be null)
  38757. * @returns The Array buffer containing the pixels data.
  38758. */
  38759. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38760. /**
  38761. * Release and destroy the underlying lower level texture aka internalTexture.
  38762. */
  38763. releaseInternalTexture(): void;
  38764. /** @hidden */
  38765. get _lodTextureHigh(): Nullable<BaseTexture>;
  38766. /** @hidden */
  38767. get _lodTextureMid(): Nullable<BaseTexture>;
  38768. /** @hidden */
  38769. get _lodTextureLow(): Nullable<BaseTexture>;
  38770. /**
  38771. * Dispose the texture and release its associated resources.
  38772. */
  38773. dispose(): void;
  38774. /**
  38775. * Serialize the texture into a JSON representation that can be parsed later on.
  38776. * @returns the JSON representation of the texture
  38777. */
  38778. serialize(): any;
  38779. /**
  38780. * Helper function to be called back once a list of texture contains only ready textures.
  38781. * @param textures Define the list of textures to wait for
  38782. * @param callback Define the callback triggered once the entire list will be ready
  38783. */
  38784. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38785. private static _isScene;
  38786. }
  38787. }
  38788. declare module "babylonjs/Materials/effect" {
  38789. import { Observable } from "babylonjs/Misc/observable";
  38790. import { Nullable } from "babylonjs/types";
  38791. import { IDisposable } from "babylonjs/scene";
  38792. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38793. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38794. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38795. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38796. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38797. import { Engine } from "babylonjs/Engines/engine";
  38798. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38801. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38802. /**
  38803. * Options to be used when creating an effect.
  38804. */
  38805. export interface IEffectCreationOptions {
  38806. /**
  38807. * Atrributes that will be used in the shader.
  38808. */
  38809. attributes: string[];
  38810. /**
  38811. * Uniform varible names that will be set in the shader.
  38812. */
  38813. uniformsNames: string[];
  38814. /**
  38815. * Uniform buffer variable names that will be set in the shader.
  38816. */
  38817. uniformBuffersNames: string[];
  38818. /**
  38819. * Sampler texture variable names that will be set in the shader.
  38820. */
  38821. samplers: string[];
  38822. /**
  38823. * Define statements that will be set in the shader.
  38824. */
  38825. defines: any;
  38826. /**
  38827. * Possible fallbacks for this effect to improve performance when needed.
  38828. */
  38829. fallbacks: Nullable<IEffectFallbacks>;
  38830. /**
  38831. * Callback that will be called when the shader is compiled.
  38832. */
  38833. onCompiled: Nullable<(effect: Effect) => void>;
  38834. /**
  38835. * Callback that will be called if an error occurs during shader compilation.
  38836. */
  38837. onError: Nullable<(effect: Effect, errors: string) => void>;
  38838. /**
  38839. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38840. */
  38841. indexParameters?: any;
  38842. /**
  38843. * Max number of lights that can be used in the shader.
  38844. */
  38845. maxSimultaneousLights?: number;
  38846. /**
  38847. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38848. */
  38849. transformFeedbackVaryings?: Nullable<string[]>;
  38850. /**
  38851. * 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
  38852. */
  38853. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38854. /**
  38855. * Is this effect rendering to several color attachments ?
  38856. */
  38857. multiTarget?: boolean;
  38858. }
  38859. /**
  38860. * Effect containing vertex and fragment shader that can be executed on an object.
  38861. */
  38862. export class Effect implements IDisposable {
  38863. /**
  38864. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38865. */
  38866. static ShadersRepository: string;
  38867. /**
  38868. * Enable logging of the shader code when a compilation error occurs
  38869. */
  38870. static LogShaderCodeOnCompilationError: boolean;
  38871. /**
  38872. * Name of the effect.
  38873. */
  38874. name: any;
  38875. /**
  38876. * String container all the define statements that should be set on the shader.
  38877. */
  38878. defines: string;
  38879. /**
  38880. * Callback that will be called when the shader is compiled.
  38881. */
  38882. onCompiled: Nullable<(effect: Effect) => void>;
  38883. /**
  38884. * Callback that will be called if an error occurs during shader compilation.
  38885. */
  38886. onError: Nullable<(effect: Effect, errors: string) => void>;
  38887. /**
  38888. * Callback that will be called when effect is bound.
  38889. */
  38890. onBind: Nullable<(effect: Effect) => void>;
  38891. /**
  38892. * Unique ID of the effect.
  38893. */
  38894. uniqueId: number;
  38895. /**
  38896. * Observable that will be called when the shader is compiled.
  38897. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38898. */
  38899. onCompileObservable: Observable<Effect>;
  38900. /**
  38901. * Observable that will be called if an error occurs during shader compilation.
  38902. */
  38903. onErrorObservable: Observable<Effect>;
  38904. /** @hidden */
  38905. _onBindObservable: Nullable<Observable<Effect>>;
  38906. /**
  38907. * @hidden
  38908. * Specifies if the effect was previously ready
  38909. */
  38910. _wasPreviouslyReady: boolean;
  38911. /**
  38912. * Observable that will be called when effect is bound.
  38913. */
  38914. get onBindObservable(): Observable<Effect>;
  38915. /** @hidden */
  38916. _bonesComputationForcedToCPU: boolean;
  38917. /** @hidden */
  38918. _multiTarget: boolean;
  38919. private static _uniqueIdSeed;
  38920. private _engine;
  38921. private _uniformBuffersNames;
  38922. private _uniformBuffersNamesList;
  38923. private _uniformsNames;
  38924. private _samplerList;
  38925. private _samplers;
  38926. private _isReady;
  38927. private _compilationError;
  38928. private _allFallbacksProcessed;
  38929. private _attributesNames;
  38930. private _attributes;
  38931. private _attributeLocationByName;
  38932. private _uniforms;
  38933. /**
  38934. * Key for the effect.
  38935. * @hidden
  38936. */
  38937. _key: string;
  38938. private _indexParameters;
  38939. private _fallbacks;
  38940. private _vertexSourceCode;
  38941. private _fragmentSourceCode;
  38942. private _vertexSourceCodeOverride;
  38943. private _fragmentSourceCodeOverride;
  38944. private _transformFeedbackVaryings;
  38945. /**
  38946. * Compiled shader to webGL program.
  38947. * @hidden
  38948. */
  38949. _pipelineContext: Nullable<IPipelineContext>;
  38950. private _valueCache;
  38951. private static _baseCache;
  38952. /**
  38953. * Instantiates an effect.
  38954. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38955. * @param baseName Name of the effect.
  38956. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38957. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38958. * @param samplers List of sampler variables that will be passed to the shader.
  38959. * @param engine Engine to be used to render the effect
  38960. * @param defines Define statements to be added to the shader.
  38961. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38962. * @param onCompiled Callback that will be called when the shader is compiled.
  38963. * @param onError Callback that will be called if an error occurs during shader compilation.
  38964. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38965. */
  38966. 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);
  38967. private _useFinalCode;
  38968. /**
  38969. * Unique key for this effect
  38970. */
  38971. get key(): string;
  38972. /**
  38973. * If the effect has been compiled and prepared.
  38974. * @returns if the effect is compiled and prepared.
  38975. */
  38976. isReady(): boolean;
  38977. private _isReadyInternal;
  38978. /**
  38979. * The engine the effect was initialized with.
  38980. * @returns the engine.
  38981. */
  38982. getEngine(): Engine;
  38983. /**
  38984. * The pipeline context for this effect
  38985. * @returns the associated pipeline context
  38986. */
  38987. getPipelineContext(): Nullable<IPipelineContext>;
  38988. /**
  38989. * The set of names of attribute variables for the shader.
  38990. * @returns An array of attribute names.
  38991. */
  38992. getAttributesNames(): string[];
  38993. /**
  38994. * Returns the attribute at the given index.
  38995. * @param index The index of the attribute.
  38996. * @returns The location of the attribute.
  38997. */
  38998. getAttributeLocation(index: number): number;
  38999. /**
  39000. * Returns the attribute based on the name of the variable.
  39001. * @param name of the attribute to look up.
  39002. * @returns the attribute location.
  39003. */
  39004. getAttributeLocationByName(name: string): number;
  39005. /**
  39006. * The number of attributes.
  39007. * @returns the numnber of attributes.
  39008. */
  39009. getAttributesCount(): number;
  39010. /**
  39011. * Gets the index of a uniform variable.
  39012. * @param uniformName of the uniform to look up.
  39013. * @returns the index.
  39014. */
  39015. getUniformIndex(uniformName: string): number;
  39016. /**
  39017. * Returns the attribute based on the name of the variable.
  39018. * @param uniformName of the uniform to look up.
  39019. * @returns the location of the uniform.
  39020. */
  39021. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39022. /**
  39023. * Returns an array of sampler variable names
  39024. * @returns The array of sampler variable names.
  39025. */
  39026. getSamplers(): string[];
  39027. /**
  39028. * Returns an array of uniform variable names
  39029. * @returns The array of uniform variable names.
  39030. */
  39031. getUniformNames(): string[];
  39032. /**
  39033. * Returns an array of uniform buffer variable names
  39034. * @returns The array of uniform buffer variable names.
  39035. */
  39036. getUniformBuffersNames(): string[];
  39037. /**
  39038. * Returns the index parameters used to create the effect
  39039. * @returns The index parameters object
  39040. */
  39041. getIndexParameters(): any;
  39042. /**
  39043. * The error from the last compilation.
  39044. * @returns the error string.
  39045. */
  39046. getCompilationError(): string;
  39047. /**
  39048. * Gets a boolean indicating that all fallbacks were used during compilation
  39049. * @returns true if all fallbacks were used
  39050. */
  39051. allFallbacksProcessed(): boolean;
  39052. /**
  39053. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39054. * @param func The callback to be used.
  39055. */
  39056. executeWhenCompiled(func: (effect: Effect) => void): void;
  39057. private _checkIsReady;
  39058. private _loadShader;
  39059. /**
  39060. * Gets the vertex shader source code of this effect
  39061. */
  39062. get vertexSourceCode(): string;
  39063. /**
  39064. * Gets the fragment shader source code of this effect
  39065. */
  39066. get fragmentSourceCode(): string;
  39067. /**
  39068. * Recompiles the webGL program
  39069. * @param vertexSourceCode The source code for the vertex shader.
  39070. * @param fragmentSourceCode The source code for the fragment shader.
  39071. * @param onCompiled Callback called when completed.
  39072. * @param onError Callback called on error.
  39073. * @hidden
  39074. */
  39075. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39076. /**
  39077. * Prepares the effect
  39078. * @hidden
  39079. */
  39080. _prepareEffect(): void;
  39081. private _getShaderCodeAndErrorLine;
  39082. private _processCompilationErrors;
  39083. /**
  39084. * Checks if the effect is supported. (Must be called after compilation)
  39085. */
  39086. get isSupported(): boolean;
  39087. /**
  39088. * Binds a texture to the engine to be used as output of the shader.
  39089. * @param channel Name of the output variable.
  39090. * @param texture Texture to bind.
  39091. * @hidden
  39092. */
  39093. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39094. /**
  39095. * Sets a texture on the engine to be used in the shader.
  39096. * @param channel Name of the sampler variable.
  39097. * @param texture Texture to set.
  39098. */
  39099. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39100. /**
  39101. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39102. * @param channel Name of the sampler variable.
  39103. * @param texture Texture to set.
  39104. */
  39105. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39106. /**
  39107. * Sets an array of textures on the engine to be used in the shader.
  39108. * @param channel Name of the variable.
  39109. * @param textures Textures to set.
  39110. */
  39111. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39112. /**
  39113. * 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)
  39114. * @param channel Name of the sampler variable.
  39115. * @param postProcess Post process to get the input texture from.
  39116. */
  39117. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39118. /**
  39119. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39120. * 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)
  39121. * @param channel Name of the sampler variable.
  39122. * @param postProcess Post process to get the output texture from.
  39123. */
  39124. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39125. /** @hidden */
  39126. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39127. /** @hidden */
  39128. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39129. /** @hidden */
  39130. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39131. /** @hidden */
  39132. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39133. /**
  39134. * Binds a buffer to a uniform.
  39135. * @param buffer Buffer to bind.
  39136. * @param name Name of the uniform variable to bind to.
  39137. */
  39138. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39139. /**
  39140. * Binds block to a uniform.
  39141. * @param blockName Name of the block to bind.
  39142. * @param index Index to bind.
  39143. */
  39144. bindUniformBlock(blockName: string, index: number): void;
  39145. /**
  39146. * Sets an interger value on a uniform variable.
  39147. * @param uniformName Name of the variable.
  39148. * @param value Value to be set.
  39149. * @returns this effect.
  39150. */
  39151. setInt(uniformName: string, value: number): Effect;
  39152. /**
  39153. * Sets an int array on a uniform variable.
  39154. * @param uniformName Name of the variable.
  39155. * @param array array to be set.
  39156. * @returns this effect.
  39157. */
  39158. setIntArray(uniformName: string, array: Int32Array): Effect;
  39159. /**
  39160. * 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)
  39161. * @param uniformName Name of the variable.
  39162. * @param array array to be set.
  39163. * @returns this effect.
  39164. */
  39165. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39166. /**
  39167. * 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)
  39168. * @param uniformName Name of the variable.
  39169. * @param array array to be set.
  39170. * @returns this effect.
  39171. */
  39172. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39173. /**
  39174. * 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)
  39175. * @param uniformName Name of the variable.
  39176. * @param array array to be set.
  39177. * @returns this effect.
  39178. */
  39179. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39180. /**
  39181. * Sets an float array on a uniform variable.
  39182. * @param uniformName Name of the variable.
  39183. * @param array array to be set.
  39184. * @returns this effect.
  39185. */
  39186. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39187. /**
  39188. * 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)
  39189. * @param uniformName Name of the variable.
  39190. * @param array array to be set.
  39191. * @returns this effect.
  39192. */
  39193. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39194. /**
  39195. * 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)
  39196. * @param uniformName Name of the variable.
  39197. * @param array array to be set.
  39198. * @returns this effect.
  39199. */
  39200. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39201. /**
  39202. * 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)
  39203. * @param uniformName Name of the variable.
  39204. * @param array array to be set.
  39205. * @returns this effect.
  39206. */
  39207. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39208. /**
  39209. * Sets an array on a uniform variable.
  39210. * @param uniformName Name of the variable.
  39211. * @param array array to be set.
  39212. * @returns this effect.
  39213. */
  39214. setArray(uniformName: string, array: number[]): Effect;
  39215. /**
  39216. * 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)
  39217. * @param uniformName Name of the variable.
  39218. * @param array array to be set.
  39219. * @returns this effect.
  39220. */
  39221. setArray2(uniformName: string, array: number[]): Effect;
  39222. /**
  39223. * 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)
  39224. * @param uniformName Name of the variable.
  39225. * @param array array to be set.
  39226. * @returns this effect.
  39227. */
  39228. setArray3(uniformName: string, array: number[]): Effect;
  39229. /**
  39230. * 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)
  39231. * @param uniformName Name of the variable.
  39232. * @param array array to be set.
  39233. * @returns this effect.
  39234. */
  39235. setArray4(uniformName: string, array: number[]): Effect;
  39236. /**
  39237. * Sets matrices on a uniform variable.
  39238. * @param uniformName Name of the variable.
  39239. * @param matrices matrices to be set.
  39240. * @returns this effect.
  39241. */
  39242. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39243. /**
  39244. * Sets matrix on a uniform variable.
  39245. * @param uniformName Name of the variable.
  39246. * @param matrix matrix to be set.
  39247. * @returns this effect.
  39248. */
  39249. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39250. /**
  39251. * 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)
  39252. * @param uniformName Name of the variable.
  39253. * @param matrix matrix to be set.
  39254. * @returns this effect.
  39255. */
  39256. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39257. /**
  39258. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39259. * @param uniformName Name of the variable.
  39260. * @param matrix matrix to be set.
  39261. * @returns this effect.
  39262. */
  39263. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39264. /**
  39265. * Sets a float on a uniform variable.
  39266. * @param uniformName Name of the variable.
  39267. * @param value value to be set.
  39268. * @returns this effect.
  39269. */
  39270. setFloat(uniformName: string, value: number): Effect;
  39271. /**
  39272. * Sets a boolean on a uniform variable.
  39273. * @param uniformName Name of the variable.
  39274. * @param bool value to be set.
  39275. * @returns this effect.
  39276. */
  39277. setBool(uniformName: string, bool: boolean): Effect;
  39278. /**
  39279. * Sets a Vector2 on a uniform variable.
  39280. * @param uniformName Name of the variable.
  39281. * @param vector2 vector2 to be set.
  39282. * @returns this effect.
  39283. */
  39284. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39285. /**
  39286. * Sets a float2 on a uniform variable.
  39287. * @param uniformName Name of the variable.
  39288. * @param x First float in float2.
  39289. * @param y Second float in float2.
  39290. * @returns this effect.
  39291. */
  39292. setFloat2(uniformName: string, x: number, y: number): Effect;
  39293. /**
  39294. * Sets a Vector3 on a uniform variable.
  39295. * @param uniformName Name of the variable.
  39296. * @param vector3 Value to be set.
  39297. * @returns this effect.
  39298. */
  39299. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39300. /**
  39301. * Sets a float3 on a uniform variable.
  39302. * @param uniformName Name of the variable.
  39303. * @param x First float in float3.
  39304. * @param y Second float in float3.
  39305. * @param z Third float in float3.
  39306. * @returns this effect.
  39307. */
  39308. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39309. /**
  39310. * Sets a Vector4 on a uniform variable.
  39311. * @param uniformName Name of the variable.
  39312. * @param vector4 Value to be set.
  39313. * @returns this effect.
  39314. */
  39315. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39316. /**
  39317. * Sets a float4 on a uniform variable.
  39318. * @param uniformName Name of the variable.
  39319. * @param x First float in float4.
  39320. * @param y Second float in float4.
  39321. * @param z Third float in float4.
  39322. * @param w Fourth float in float4.
  39323. * @returns this effect.
  39324. */
  39325. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39326. /**
  39327. * Sets a Color3 on a uniform variable.
  39328. * @param uniformName Name of the variable.
  39329. * @param color3 Value to be set.
  39330. * @returns this effect.
  39331. */
  39332. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39333. /**
  39334. * Sets a Color4 on a uniform variable.
  39335. * @param uniformName Name of the variable.
  39336. * @param color3 Value to be set.
  39337. * @param alpha Alpha value to be set.
  39338. * @returns this effect.
  39339. */
  39340. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39341. /**
  39342. * Sets a Color4 on a uniform variable
  39343. * @param uniformName defines the name of the variable
  39344. * @param color4 defines the value to be set
  39345. * @returns this effect.
  39346. */
  39347. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39348. /** Release all associated resources */
  39349. dispose(): void;
  39350. /**
  39351. * This function will add a new shader to the shader store
  39352. * @param name the name of the shader
  39353. * @param pixelShader optional pixel shader content
  39354. * @param vertexShader optional vertex shader content
  39355. */
  39356. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39357. /**
  39358. * Store of each shader (The can be looked up using effect.key)
  39359. */
  39360. static ShadersStore: {
  39361. [key: string]: string;
  39362. };
  39363. /**
  39364. * Store of each included file for a shader (The can be looked up using effect.key)
  39365. */
  39366. static IncludesShadersStore: {
  39367. [key: string]: string;
  39368. };
  39369. /**
  39370. * Resets the cache of effects.
  39371. */
  39372. static ResetCache(): void;
  39373. }
  39374. }
  39375. declare module "babylonjs/Engines/engineCapabilities" {
  39376. /**
  39377. * Interface used to describe the capabilities of the engine relatively to the current browser
  39378. */
  39379. export interface EngineCapabilities {
  39380. /** Maximum textures units per fragment shader */
  39381. maxTexturesImageUnits: number;
  39382. /** Maximum texture units per vertex shader */
  39383. maxVertexTextureImageUnits: number;
  39384. /** Maximum textures units in the entire pipeline */
  39385. maxCombinedTexturesImageUnits: number;
  39386. /** Maximum texture size */
  39387. maxTextureSize: number;
  39388. /** Maximum texture samples */
  39389. maxSamples?: number;
  39390. /** Maximum cube texture size */
  39391. maxCubemapTextureSize: number;
  39392. /** Maximum render texture size */
  39393. maxRenderTextureSize: number;
  39394. /** Maximum number of vertex attributes */
  39395. maxVertexAttribs: number;
  39396. /** Maximum number of varyings */
  39397. maxVaryingVectors: number;
  39398. /** Maximum number of uniforms per vertex shader */
  39399. maxVertexUniformVectors: number;
  39400. /** Maximum number of uniforms per fragment shader */
  39401. maxFragmentUniformVectors: number;
  39402. /** Defines if standard derivates (dx/dy) are supported */
  39403. standardDerivatives: boolean;
  39404. /** Defines if s3tc texture compression is supported */
  39405. s3tc?: WEBGL_compressed_texture_s3tc;
  39406. /** Defines if pvrtc texture compression is supported */
  39407. pvrtc: any;
  39408. /** Defines if etc1 texture compression is supported */
  39409. etc1: any;
  39410. /** Defines if etc2 texture compression is supported */
  39411. etc2: any;
  39412. /** Defines if astc texture compression is supported */
  39413. astc: any;
  39414. /** Defines if bptc texture compression is supported */
  39415. bptc: any;
  39416. /** Defines if float textures are supported */
  39417. textureFloat: boolean;
  39418. /** Defines if vertex array objects are supported */
  39419. vertexArrayObject: boolean;
  39420. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39421. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39422. /** Gets the maximum level of anisotropy supported */
  39423. maxAnisotropy: number;
  39424. /** Defines if instancing is supported */
  39425. instancedArrays: boolean;
  39426. /** Defines if 32 bits indices are supported */
  39427. uintIndices: boolean;
  39428. /** Defines if high precision shaders are supported */
  39429. highPrecisionShaderSupported: boolean;
  39430. /** Defines if depth reading in the fragment shader is supported */
  39431. fragmentDepthSupported: boolean;
  39432. /** Defines if float texture linear filtering is supported*/
  39433. textureFloatLinearFiltering: boolean;
  39434. /** Defines if rendering to float textures is supported */
  39435. textureFloatRender: boolean;
  39436. /** Defines if half float textures are supported*/
  39437. textureHalfFloat: boolean;
  39438. /** Defines if half float texture linear filtering is supported*/
  39439. textureHalfFloatLinearFiltering: boolean;
  39440. /** Defines if rendering to half float textures is supported */
  39441. textureHalfFloatRender: boolean;
  39442. /** Defines if textureLOD shader command is supported */
  39443. textureLOD: boolean;
  39444. /** Defines if draw buffers extension is supported */
  39445. drawBuffersExtension: boolean;
  39446. /** Defines if depth textures are supported */
  39447. depthTextureExtension: boolean;
  39448. /** Defines if float color buffer are supported */
  39449. colorBufferFloat: boolean;
  39450. /** Gets disjoint timer query extension (null if not supported) */
  39451. timerQuery?: EXT_disjoint_timer_query;
  39452. /** Defines if timestamp can be used with timer query */
  39453. canUseTimestampForTimerQuery: boolean;
  39454. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39455. multiview?: any;
  39456. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39457. oculusMultiview?: any;
  39458. /** Function used to let the system compiles shaders in background */
  39459. parallelShaderCompile?: {
  39460. COMPLETION_STATUS_KHR: number;
  39461. };
  39462. /** Max number of texture samples for MSAA */
  39463. maxMSAASamples: number;
  39464. /** Defines if the blend min max extension is supported */
  39465. blendMinMax: boolean;
  39466. }
  39467. }
  39468. declare module "babylonjs/States/depthCullingState" {
  39469. import { Nullable } from "babylonjs/types";
  39470. /**
  39471. * @hidden
  39472. **/
  39473. export class DepthCullingState {
  39474. private _isDepthTestDirty;
  39475. private _isDepthMaskDirty;
  39476. private _isDepthFuncDirty;
  39477. private _isCullFaceDirty;
  39478. private _isCullDirty;
  39479. private _isZOffsetDirty;
  39480. private _isFrontFaceDirty;
  39481. private _depthTest;
  39482. private _depthMask;
  39483. private _depthFunc;
  39484. private _cull;
  39485. private _cullFace;
  39486. private _zOffset;
  39487. private _frontFace;
  39488. /**
  39489. * Initializes the state.
  39490. */
  39491. constructor();
  39492. get isDirty(): boolean;
  39493. get zOffset(): number;
  39494. set zOffset(value: number);
  39495. get cullFace(): Nullable<number>;
  39496. set cullFace(value: Nullable<number>);
  39497. get cull(): Nullable<boolean>;
  39498. set cull(value: Nullable<boolean>);
  39499. get depthFunc(): Nullable<number>;
  39500. set depthFunc(value: Nullable<number>);
  39501. get depthMask(): boolean;
  39502. set depthMask(value: boolean);
  39503. get depthTest(): boolean;
  39504. set depthTest(value: boolean);
  39505. get frontFace(): Nullable<number>;
  39506. set frontFace(value: Nullable<number>);
  39507. reset(): void;
  39508. apply(gl: WebGLRenderingContext): void;
  39509. }
  39510. }
  39511. declare module "babylonjs/States/stencilState" {
  39512. /**
  39513. * @hidden
  39514. **/
  39515. export class StencilState {
  39516. /** 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 */
  39517. static readonly ALWAYS: number;
  39518. /** Passed to stencilOperation to specify that stencil value must be kept */
  39519. static readonly KEEP: number;
  39520. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39521. static readonly REPLACE: number;
  39522. private _isStencilTestDirty;
  39523. private _isStencilMaskDirty;
  39524. private _isStencilFuncDirty;
  39525. private _isStencilOpDirty;
  39526. private _stencilTest;
  39527. private _stencilMask;
  39528. private _stencilFunc;
  39529. private _stencilFuncRef;
  39530. private _stencilFuncMask;
  39531. private _stencilOpStencilFail;
  39532. private _stencilOpDepthFail;
  39533. private _stencilOpStencilDepthPass;
  39534. get isDirty(): boolean;
  39535. get stencilFunc(): number;
  39536. set stencilFunc(value: number);
  39537. get stencilFuncRef(): number;
  39538. set stencilFuncRef(value: number);
  39539. get stencilFuncMask(): number;
  39540. set stencilFuncMask(value: number);
  39541. get stencilOpStencilFail(): number;
  39542. set stencilOpStencilFail(value: number);
  39543. get stencilOpDepthFail(): number;
  39544. set stencilOpDepthFail(value: number);
  39545. get stencilOpStencilDepthPass(): number;
  39546. set stencilOpStencilDepthPass(value: number);
  39547. get stencilMask(): number;
  39548. set stencilMask(value: number);
  39549. get stencilTest(): boolean;
  39550. set stencilTest(value: boolean);
  39551. constructor();
  39552. reset(): void;
  39553. apply(gl: WebGLRenderingContext): void;
  39554. }
  39555. }
  39556. declare module "babylonjs/States/alphaCullingState" {
  39557. /**
  39558. * @hidden
  39559. **/
  39560. export class AlphaState {
  39561. private _isAlphaBlendDirty;
  39562. private _isBlendFunctionParametersDirty;
  39563. private _isBlendEquationParametersDirty;
  39564. private _isBlendConstantsDirty;
  39565. private _alphaBlend;
  39566. private _blendFunctionParameters;
  39567. private _blendEquationParameters;
  39568. private _blendConstants;
  39569. /**
  39570. * Initializes the state.
  39571. */
  39572. constructor();
  39573. get isDirty(): boolean;
  39574. get alphaBlend(): boolean;
  39575. set alphaBlend(value: boolean);
  39576. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39577. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39578. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39579. reset(): void;
  39580. apply(gl: WebGLRenderingContext): void;
  39581. }
  39582. }
  39583. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39584. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39585. /** @hidden */
  39586. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39587. attributeProcessor(attribute: string): string;
  39588. varyingProcessor(varying: string, isFragment: boolean): string;
  39589. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39590. }
  39591. }
  39592. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39593. /**
  39594. * Interface for attribute information associated with buffer instanciation
  39595. */
  39596. export interface InstancingAttributeInfo {
  39597. /**
  39598. * Name of the GLSL attribute
  39599. * if attribute index is not specified, this is used to retrieve the index from the effect
  39600. */
  39601. attributeName: string;
  39602. /**
  39603. * Index/offset of the attribute in the vertex shader
  39604. * if not specified, this will be computes from the name.
  39605. */
  39606. index?: number;
  39607. /**
  39608. * size of the attribute, 1, 2, 3 or 4
  39609. */
  39610. attributeSize: number;
  39611. /**
  39612. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39613. */
  39614. offset: number;
  39615. /**
  39616. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39617. * default to 1
  39618. */
  39619. divisor?: number;
  39620. /**
  39621. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39622. * default is FLOAT
  39623. */
  39624. attributeType?: number;
  39625. /**
  39626. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39627. */
  39628. normalized?: boolean;
  39629. }
  39630. }
  39631. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39633. import { Nullable } from "babylonjs/types";
  39634. module "babylonjs/Engines/thinEngine" {
  39635. interface ThinEngine {
  39636. /**
  39637. * Update a video texture
  39638. * @param texture defines the texture to update
  39639. * @param video defines the video element to use
  39640. * @param invertY defines if data must be stored with Y axis inverted
  39641. */
  39642. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39643. }
  39644. }
  39645. }
  39646. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39648. import { Nullable } from "babylonjs/types";
  39649. module "babylonjs/Engines/thinEngine" {
  39650. interface ThinEngine {
  39651. /**
  39652. * Creates a dynamic texture
  39653. * @param width defines the width of the texture
  39654. * @param height defines the height of the texture
  39655. * @param generateMipMaps defines if the engine should generate the mip levels
  39656. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39657. * @returns the dynamic texture inside an InternalTexture
  39658. */
  39659. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39660. /**
  39661. * Update the content of a dynamic texture
  39662. * @param texture defines the texture to update
  39663. * @param canvas defines the canvas containing the source
  39664. * @param invertY defines if data must be stored with Y axis inverted
  39665. * @param premulAlpha defines if alpha is stored as premultiplied
  39666. * @param format defines the format of the data
  39667. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39668. */
  39669. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39670. }
  39671. }
  39672. }
  39673. declare module "babylonjs/Materials/Textures/videoTexture" {
  39674. import { Observable } from "babylonjs/Misc/observable";
  39675. import { Nullable } from "babylonjs/types";
  39676. import { Scene } from "babylonjs/scene";
  39677. import { Texture } from "babylonjs/Materials/Textures/texture";
  39678. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39679. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39680. /**
  39681. * Settings for finer control over video usage
  39682. */
  39683. export interface VideoTextureSettings {
  39684. /**
  39685. * Applies `autoplay` to video, if specified
  39686. */
  39687. autoPlay?: boolean;
  39688. /**
  39689. * Applies `muted` to video, if specified
  39690. */
  39691. muted?: boolean;
  39692. /**
  39693. * Applies `loop` to video, if specified
  39694. */
  39695. loop?: boolean;
  39696. /**
  39697. * Automatically updates internal texture from video at every frame in the render loop
  39698. */
  39699. autoUpdateTexture: boolean;
  39700. /**
  39701. * Image src displayed during the video loading or until the user interacts with the video.
  39702. */
  39703. poster?: string;
  39704. }
  39705. /**
  39706. * If you want to display a video in your scene, this is the special texture for that.
  39707. * This special texture works similar to other textures, with the exception of a few parameters.
  39708. * @see https://doc.babylonjs.com/how_to/video_texture
  39709. */
  39710. export class VideoTexture extends Texture {
  39711. /**
  39712. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39713. */
  39714. readonly autoUpdateTexture: boolean;
  39715. /**
  39716. * The video instance used by the texture internally
  39717. */
  39718. readonly video: HTMLVideoElement;
  39719. private _onUserActionRequestedObservable;
  39720. /**
  39721. * Event triggerd when a dom action is required by the user to play the video.
  39722. * This happens due to recent changes in browser policies preventing video to auto start.
  39723. */
  39724. get onUserActionRequestedObservable(): Observable<Texture>;
  39725. private _generateMipMaps;
  39726. private _stillImageCaptured;
  39727. private _displayingPosterTexture;
  39728. private _settings;
  39729. private _createInternalTextureOnEvent;
  39730. private _frameId;
  39731. private _currentSrc;
  39732. /**
  39733. * Creates a video texture.
  39734. * If you want to display a video in your scene, this is the special texture for that.
  39735. * This special texture works similar to other textures, with the exception of a few parameters.
  39736. * @see https://doc.babylonjs.com/how_to/video_texture
  39737. * @param name optional name, will detect from video source, if not defined
  39738. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39739. * @param scene is obviously the current scene.
  39740. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39741. * @param invertY is false by default but can be used to invert video on Y axis
  39742. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39743. * @param settings allows finer control over video usage
  39744. */
  39745. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39746. private _getName;
  39747. private _getVideo;
  39748. private _createInternalTexture;
  39749. private reset;
  39750. /**
  39751. * @hidden Internal method to initiate `update`.
  39752. */
  39753. _rebuild(): void;
  39754. /**
  39755. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39756. */
  39757. update(): void;
  39758. /**
  39759. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39760. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39761. */
  39762. updateTexture(isVisible: boolean): void;
  39763. protected _updateInternalTexture: () => void;
  39764. /**
  39765. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39766. * @param url New url.
  39767. */
  39768. updateURL(url: string): void;
  39769. /**
  39770. * Clones the texture.
  39771. * @returns the cloned texture
  39772. */
  39773. clone(): VideoTexture;
  39774. /**
  39775. * Dispose the texture and release its associated resources.
  39776. */
  39777. dispose(): void;
  39778. /**
  39779. * Creates a video texture straight from a stream.
  39780. * @param scene Define the scene the texture should be created in
  39781. * @param stream Define the stream the texture should be created from
  39782. * @returns The created video texture as a promise
  39783. */
  39784. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39785. /**
  39786. * Creates a video texture straight from your WebCam video feed.
  39787. * @param scene Define the scene the texture should be created in
  39788. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39789. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39790. * @returns The created video texture as a promise
  39791. */
  39792. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39793. minWidth: number;
  39794. maxWidth: number;
  39795. minHeight: number;
  39796. maxHeight: number;
  39797. deviceId: string;
  39798. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39799. /**
  39800. * Creates a video texture straight from your WebCam video feed.
  39801. * @param scene Define the scene the texture should be created in
  39802. * @param onReady Define a callback to triggered once the texture will be ready
  39803. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39804. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39805. */
  39806. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39807. minWidth: number;
  39808. maxWidth: number;
  39809. minHeight: number;
  39810. maxHeight: number;
  39811. deviceId: string;
  39812. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39813. }
  39814. }
  39815. declare module "babylonjs/Engines/thinEngine" {
  39816. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39817. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39818. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39819. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39820. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39821. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39822. import { Observable } from "babylonjs/Misc/observable";
  39823. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39824. import { StencilState } from "babylonjs/States/stencilState";
  39825. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39826. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39827. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39828. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39829. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39830. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39831. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39832. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39833. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39835. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39836. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39837. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39838. import { WebRequest } from "babylonjs/Misc/webRequest";
  39839. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39840. /**
  39841. * Defines the interface used by objects working like Scene
  39842. * @hidden
  39843. */
  39844. export interface ISceneLike {
  39845. _addPendingData(data: any): void;
  39846. _removePendingData(data: any): void;
  39847. offlineProvider: IOfflineProvider;
  39848. }
  39849. /**
  39850. * Information about the current host
  39851. */
  39852. export interface HostInformation {
  39853. /**
  39854. * Defines if the current host is a mobile
  39855. */
  39856. isMobile: boolean;
  39857. }
  39858. /** Interface defining initialization parameters for Engine class */
  39859. export interface EngineOptions extends WebGLContextAttributes {
  39860. /**
  39861. * Defines if the engine should no exceed a specified device ratio
  39862. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39863. */
  39864. limitDeviceRatio?: number;
  39865. /**
  39866. * Defines if webvr should be enabled automatically
  39867. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39868. */
  39869. autoEnableWebVR?: boolean;
  39870. /**
  39871. * Defines if webgl2 should be turned off even if supported
  39872. * @see https://doc.babylonjs.com/features/webgl2
  39873. */
  39874. disableWebGL2Support?: boolean;
  39875. /**
  39876. * Defines if webaudio should be initialized as well
  39877. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39878. */
  39879. audioEngine?: boolean;
  39880. /**
  39881. * Defines if animations should run using a deterministic lock step
  39882. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39883. */
  39884. deterministicLockstep?: boolean;
  39885. /** Defines the maximum steps to use with deterministic lock step mode */
  39886. lockstepMaxSteps?: number;
  39887. /** Defines the seconds between each deterministic lock step */
  39888. timeStep?: number;
  39889. /**
  39890. * Defines that engine should ignore context lost events
  39891. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39892. */
  39893. doNotHandleContextLost?: boolean;
  39894. /**
  39895. * Defines that engine should ignore modifying touch action attribute and style
  39896. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39897. */
  39898. doNotHandleTouchAction?: boolean;
  39899. /**
  39900. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39901. */
  39902. useHighPrecisionFloats?: boolean;
  39903. /**
  39904. * Make the canvas XR Compatible for XR sessions
  39905. */
  39906. xrCompatible?: boolean;
  39907. /**
  39908. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39909. */
  39910. useHighPrecisionMatrix?: boolean;
  39911. /**
  39912. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39913. */
  39914. failIfMajorPerformanceCaveat?: boolean;
  39915. }
  39916. /**
  39917. * The base engine class (root of all engines)
  39918. */
  39919. export class ThinEngine {
  39920. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39921. static ExceptionList: ({
  39922. key: string;
  39923. capture: string;
  39924. captureConstraint: number;
  39925. targets: string[];
  39926. } | {
  39927. key: string;
  39928. capture: null;
  39929. captureConstraint: null;
  39930. targets: string[];
  39931. })[];
  39932. /** @hidden */
  39933. static _TextureLoaders: IInternalTextureLoader[];
  39934. /**
  39935. * Returns the current npm package of the sdk
  39936. */
  39937. static get NpmPackage(): string;
  39938. /**
  39939. * Returns the current version of the framework
  39940. */
  39941. static get Version(): string;
  39942. /**
  39943. * Returns a string describing the current engine
  39944. */
  39945. get description(): string;
  39946. /**
  39947. * Gets or sets the epsilon value used by collision engine
  39948. */
  39949. static CollisionsEpsilon: number;
  39950. /**
  39951. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39952. */
  39953. static get ShadersRepository(): string;
  39954. static set ShadersRepository(value: string);
  39955. /** @hidden */
  39956. _shaderProcessor: IShaderProcessor;
  39957. /**
  39958. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39959. */
  39960. forcePOTTextures: boolean;
  39961. /**
  39962. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39963. */
  39964. isFullscreen: boolean;
  39965. /**
  39966. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39967. */
  39968. cullBackFaces: boolean;
  39969. /**
  39970. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39971. */
  39972. renderEvenInBackground: boolean;
  39973. /**
  39974. * Gets or sets a boolean indicating that cache can be kept between frames
  39975. */
  39976. preventCacheWipeBetweenFrames: boolean;
  39977. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39978. validateShaderPrograms: boolean;
  39979. /**
  39980. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39981. * This can provide greater z depth for distant objects.
  39982. */
  39983. useReverseDepthBuffer: boolean;
  39984. /**
  39985. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39986. */
  39987. disableUniformBuffers: boolean;
  39988. /** @hidden */
  39989. _uniformBuffers: UniformBuffer[];
  39990. /**
  39991. * Gets a boolean indicating that the engine supports uniform buffers
  39992. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39993. */
  39994. get supportsUniformBuffers(): boolean;
  39995. /** @hidden */
  39996. _gl: WebGLRenderingContext;
  39997. /** @hidden */
  39998. _webGLVersion: number;
  39999. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40000. protected _windowIsBackground: boolean;
  40001. protected _creationOptions: EngineOptions;
  40002. protected _highPrecisionShadersAllowed: boolean;
  40003. /** @hidden */
  40004. get _shouldUseHighPrecisionShader(): boolean;
  40005. /**
  40006. * Gets a boolean indicating that only power of 2 textures are supported
  40007. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40008. */
  40009. get needPOTTextures(): boolean;
  40010. /** @hidden */
  40011. _badOS: boolean;
  40012. /** @hidden */
  40013. _badDesktopOS: boolean;
  40014. private _hardwareScalingLevel;
  40015. /** @hidden */
  40016. _caps: EngineCapabilities;
  40017. private _isStencilEnable;
  40018. private _glVersion;
  40019. private _glRenderer;
  40020. private _glVendor;
  40021. /** @hidden */
  40022. _videoTextureSupported: boolean;
  40023. protected _renderingQueueLaunched: boolean;
  40024. protected _activeRenderLoops: (() => void)[];
  40025. /**
  40026. * Observable signaled when a context lost event is raised
  40027. */
  40028. onContextLostObservable: Observable<ThinEngine>;
  40029. /**
  40030. * Observable signaled when a context restored event is raised
  40031. */
  40032. onContextRestoredObservable: Observable<ThinEngine>;
  40033. private _onContextLost;
  40034. private _onContextRestored;
  40035. protected _contextWasLost: boolean;
  40036. /** @hidden */
  40037. _doNotHandleContextLost: boolean;
  40038. /**
  40039. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40040. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40041. */
  40042. get doNotHandleContextLost(): boolean;
  40043. set doNotHandleContextLost(value: boolean);
  40044. /**
  40045. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40046. */
  40047. disableVertexArrayObjects: boolean;
  40048. /** @hidden */
  40049. protected _colorWrite: boolean;
  40050. /** @hidden */
  40051. protected _colorWriteChanged: boolean;
  40052. /** @hidden */
  40053. protected _depthCullingState: DepthCullingState;
  40054. /** @hidden */
  40055. protected _stencilState: StencilState;
  40056. /** @hidden */
  40057. _alphaState: AlphaState;
  40058. /** @hidden */
  40059. _alphaMode: number;
  40060. /** @hidden */
  40061. _alphaEquation: number;
  40062. /** @hidden */
  40063. _internalTexturesCache: InternalTexture[];
  40064. /** @hidden */
  40065. protected _activeChannel: number;
  40066. private _currentTextureChannel;
  40067. /** @hidden */
  40068. protected _boundTexturesCache: {
  40069. [key: string]: Nullable<InternalTexture>;
  40070. };
  40071. /** @hidden */
  40072. protected _currentEffect: Nullable<Effect>;
  40073. /** @hidden */
  40074. protected _currentProgram: Nullable<WebGLProgram>;
  40075. private _compiledEffects;
  40076. private _vertexAttribArraysEnabled;
  40077. /** @hidden */
  40078. protected _cachedViewport: Nullable<IViewportLike>;
  40079. private _cachedVertexArrayObject;
  40080. /** @hidden */
  40081. protected _cachedVertexBuffers: any;
  40082. /** @hidden */
  40083. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40084. /** @hidden */
  40085. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40086. /** @hidden */
  40087. _currentRenderTarget: Nullable<InternalTexture>;
  40088. private _uintIndicesCurrentlySet;
  40089. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40090. /** @hidden */
  40091. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40092. /** @hidden */
  40093. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40094. private _currentBufferPointers;
  40095. private _currentInstanceLocations;
  40096. private _currentInstanceBuffers;
  40097. private _textureUnits;
  40098. /** @hidden */
  40099. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40100. /** @hidden */
  40101. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40102. /** @hidden */
  40103. _boundRenderFunction: any;
  40104. private _vaoRecordInProgress;
  40105. private _mustWipeVertexAttributes;
  40106. private _emptyTexture;
  40107. private _emptyCubeTexture;
  40108. private _emptyTexture3D;
  40109. private _emptyTexture2DArray;
  40110. /** @hidden */
  40111. _frameHandler: number;
  40112. private _nextFreeTextureSlots;
  40113. private _maxSimultaneousTextures;
  40114. private _activeRequests;
  40115. /** @hidden */
  40116. _transformTextureUrl: Nullable<(url: string) => string>;
  40117. /**
  40118. * Gets information about the current host
  40119. */
  40120. hostInformation: HostInformation;
  40121. protected get _supportsHardwareTextureRescaling(): boolean;
  40122. private _framebufferDimensionsObject;
  40123. /**
  40124. * sets the object from which width and height will be taken from when getting render width and height
  40125. * Will fallback to the gl object
  40126. * @param dimensions the framebuffer width and height that will be used.
  40127. */
  40128. set framebufferDimensionsObject(dimensions: Nullable<{
  40129. framebufferWidth: number;
  40130. framebufferHeight: number;
  40131. }>);
  40132. /**
  40133. * Gets the current viewport
  40134. */
  40135. get currentViewport(): Nullable<IViewportLike>;
  40136. /**
  40137. * Gets the default empty texture
  40138. */
  40139. get emptyTexture(): InternalTexture;
  40140. /**
  40141. * Gets the default empty 3D texture
  40142. */
  40143. get emptyTexture3D(): InternalTexture;
  40144. /**
  40145. * Gets the default empty 2D array texture
  40146. */
  40147. get emptyTexture2DArray(): InternalTexture;
  40148. /**
  40149. * Gets the default empty cube texture
  40150. */
  40151. get emptyCubeTexture(): InternalTexture;
  40152. /**
  40153. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40154. */
  40155. readonly premultipliedAlpha: boolean;
  40156. /**
  40157. * Observable event triggered before each texture is initialized
  40158. */
  40159. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40160. /**
  40161. * Creates a new engine
  40162. * @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
  40163. * @param antialias defines enable antialiasing (default: false)
  40164. * @param options defines further options to be sent to the getContext() function
  40165. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40166. */
  40167. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40168. private _rebuildInternalTextures;
  40169. private _rebuildEffects;
  40170. /**
  40171. * Gets a boolean indicating if all created effects are ready
  40172. * @returns true if all effects are ready
  40173. */
  40174. areAllEffectsReady(): boolean;
  40175. protected _rebuildBuffers(): void;
  40176. protected _initGLContext(): void;
  40177. /**
  40178. * Gets version of the current webGL context
  40179. */
  40180. get webGLVersion(): number;
  40181. /**
  40182. * Gets a string identifying the name of the class
  40183. * @returns "Engine" string
  40184. */
  40185. getClassName(): string;
  40186. /**
  40187. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40188. */
  40189. get isStencilEnable(): boolean;
  40190. /** @hidden */
  40191. _prepareWorkingCanvas(): void;
  40192. /**
  40193. * Reset the texture cache to empty state
  40194. */
  40195. resetTextureCache(): void;
  40196. /**
  40197. * Gets an object containing information about the current webGL context
  40198. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40199. */
  40200. getGlInfo(): {
  40201. vendor: string;
  40202. renderer: string;
  40203. version: string;
  40204. };
  40205. /**
  40206. * Defines the hardware scaling level.
  40207. * By default the hardware scaling level is computed from the window device ratio.
  40208. * 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.
  40209. * @param level defines the level to use
  40210. */
  40211. setHardwareScalingLevel(level: number): void;
  40212. /**
  40213. * Gets the current hardware scaling level.
  40214. * By default the hardware scaling level is computed from the window device ratio.
  40215. * 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.
  40216. * @returns a number indicating the current hardware scaling level
  40217. */
  40218. getHardwareScalingLevel(): number;
  40219. /**
  40220. * Gets the list of loaded textures
  40221. * @returns an array containing all loaded textures
  40222. */
  40223. getLoadedTexturesCache(): InternalTexture[];
  40224. /**
  40225. * Gets the object containing all engine capabilities
  40226. * @returns the EngineCapabilities object
  40227. */
  40228. getCaps(): EngineCapabilities;
  40229. /**
  40230. * stop executing a render loop function and remove it from the execution array
  40231. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40232. */
  40233. stopRenderLoop(renderFunction?: () => void): void;
  40234. /** @hidden */
  40235. _renderLoop(): void;
  40236. /**
  40237. * Gets the HTML canvas attached with the current webGL context
  40238. * @returns a HTML canvas
  40239. */
  40240. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40241. /**
  40242. * Gets host window
  40243. * @returns the host window object
  40244. */
  40245. getHostWindow(): Nullable<Window>;
  40246. /**
  40247. * Gets the current render width
  40248. * @param useScreen defines if screen size must be used (or the current render target if any)
  40249. * @returns a number defining the current render width
  40250. */
  40251. getRenderWidth(useScreen?: boolean): number;
  40252. /**
  40253. * Gets the current render height
  40254. * @param useScreen defines if screen size must be used (or the current render target if any)
  40255. * @returns a number defining the current render height
  40256. */
  40257. getRenderHeight(useScreen?: boolean): number;
  40258. /**
  40259. * Can be used to override the current requestAnimationFrame requester.
  40260. * @hidden
  40261. */
  40262. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40263. /**
  40264. * Register and execute a render loop. The engine can have more than one render function
  40265. * @param renderFunction defines the function to continuously execute
  40266. */
  40267. runRenderLoop(renderFunction: () => void): void;
  40268. /**
  40269. * Clear the current render buffer or the current render target (if any is set up)
  40270. * @param color defines the color to use
  40271. * @param backBuffer defines if the back buffer must be cleared
  40272. * @param depth defines if the depth buffer must be cleared
  40273. * @param stencil defines if the stencil buffer must be cleared
  40274. */
  40275. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40276. private _viewportCached;
  40277. /** @hidden */
  40278. _viewport(x: number, y: number, width: number, height: number): void;
  40279. /**
  40280. * Set the WebGL's viewport
  40281. * @param viewport defines the viewport element to be used
  40282. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40283. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40284. */
  40285. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40286. /**
  40287. * Begin a new frame
  40288. */
  40289. beginFrame(): void;
  40290. /**
  40291. * Enf the current frame
  40292. */
  40293. endFrame(): void;
  40294. /**
  40295. * Resize the view according to the canvas' size
  40296. */
  40297. resize(): void;
  40298. /**
  40299. * Force a specific size of the canvas
  40300. * @param width defines the new canvas' width
  40301. * @param height defines the new canvas' height
  40302. * @returns true if the size was changed
  40303. */
  40304. setSize(width: number, height: number): boolean;
  40305. /**
  40306. * Binds the frame buffer to the specified texture.
  40307. * @param texture The texture to render to or null for the default canvas
  40308. * @param faceIndex The face of the texture to render to in case of cube texture
  40309. * @param requiredWidth The width of the target to render to
  40310. * @param requiredHeight The height of the target to render to
  40311. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40312. * @param lodLevel defines the lod level to bind to the frame buffer
  40313. * @param layer defines the 2d array index to bind to frame buffer to
  40314. */
  40315. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40316. /** @hidden */
  40317. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40318. /**
  40319. * Unbind the current render target texture from the webGL context
  40320. * @param texture defines the render target texture to unbind
  40321. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40322. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40323. */
  40324. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40325. /**
  40326. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40327. */
  40328. flushFramebuffer(): void;
  40329. /**
  40330. * Unbind the current render target and bind the default framebuffer
  40331. */
  40332. restoreDefaultFramebuffer(): void;
  40333. /** @hidden */
  40334. protected _resetVertexBufferBinding(): void;
  40335. /**
  40336. * Creates a vertex buffer
  40337. * @param data the data for the vertex buffer
  40338. * @returns the new WebGL static buffer
  40339. */
  40340. createVertexBuffer(data: DataArray): DataBuffer;
  40341. private _createVertexBuffer;
  40342. /**
  40343. * Creates a dynamic vertex buffer
  40344. * @param data the data for the dynamic vertex buffer
  40345. * @returns the new WebGL dynamic buffer
  40346. */
  40347. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40348. protected _resetIndexBufferBinding(): void;
  40349. /**
  40350. * Creates a new index buffer
  40351. * @param indices defines the content of the index buffer
  40352. * @param updatable defines if the index buffer must be updatable
  40353. * @returns a new webGL buffer
  40354. */
  40355. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40356. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40357. /**
  40358. * Bind a webGL buffer to the webGL context
  40359. * @param buffer defines the buffer to bind
  40360. */
  40361. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40362. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40363. private bindBuffer;
  40364. /**
  40365. * update the bound buffer with the given data
  40366. * @param data defines the data to update
  40367. */
  40368. updateArrayBuffer(data: Float32Array): void;
  40369. private _vertexAttribPointer;
  40370. /** @hidden */
  40371. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40372. private _bindVertexBuffersAttributes;
  40373. /**
  40374. * Records a vertex array object
  40375. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40376. * @param vertexBuffers defines the list of vertex buffers to store
  40377. * @param indexBuffer defines the index buffer to store
  40378. * @param effect defines the effect to store
  40379. * @returns the new vertex array object
  40380. */
  40381. recordVertexArrayObject(vertexBuffers: {
  40382. [key: string]: VertexBuffer;
  40383. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40384. /**
  40385. * Bind a specific vertex array object
  40386. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40387. * @param vertexArrayObject defines the vertex array object to bind
  40388. * @param indexBuffer defines the index buffer to bind
  40389. */
  40390. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40391. /**
  40392. * Bind webGl buffers directly to the webGL context
  40393. * @param vertexBuffer defines the vertex buffer to bind
  40394. * @param indexBuffer defines the index buffer to bind
  40395. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40396. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40397. * @param effect defines the effect associated with the vertex buffer
  40398. */
  40399. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40400. private _unbindVertexArrayObject;
  40401. /**
  40402. * Bind a list of vertex buffers to the webGL context
  40403. * @param vertexBuffers defines the list of vertex buffers to bind
  40404. * @param indexBuffer defines the index buffer to bind
  40405. * @param effect defines the effect associated with the vertex buffers
  40406. */
  40407. bindBuffers(vertexBuffers: {
  40408. [key: string]: Nullable<VertexBuffer>;
  40409. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40410. /**
  40411. * Unbind all instance attributes
  40412. */
  40413. unbindInstanceAttributes(): void;
  40414. /**
  40415. * Release and free the memory of a vertex array object
  40416. * @param vao defines the vertex array object to delete
  40417. */
  40418. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40419. /** @hidden */
  40420. _releaseBuffer(buffer: DataBuffer): boolean;
  40421. protected _deleteBuffer(buffer: DataBuffer): void;
  40422. /**
  40423. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40424. * @param instancesBuffer defines the webGL buffer to update and bind
  40425. * @param data defines the data to store in the buffer
  40426. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40427. */
  40428. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40429. /**
  40430. * Bind the content of a webGL buffer used with instantiation
  40431. * @param instancesBuffer defines the webGL buffer to bind
  40432. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40433. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40434. */
  40435. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40436. /**
  40437. * Disable the instance attribute corresponding to the name in parameter
  40438. * @param name defines the name of the attribute to disable
  40439. */
  40440. disableInstanceAttributeByName(name: string): void;
  40441. /**
  40442. * Disable the instance attribute corresponding to the location in parameter
  40443. * @param attributeLocation defines the attribute location of the attribute to disable
  40444. */
  40445. disableInstanceAttribute(attributeLocation: number): void;
  40446. /**
  40447. * Disable the attribute corresponding to the location in parameter
  40448. * @param attributeLocation defines the attribute location of the attribute to disable
  40449. */
  40450. disableAttributeByIndex(attributeLocation: number): void;
  40451. /**
  40452. * Send a draw order
  40453. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40454. * @param indexStart defines the starting index
  40455. * @param indexCount defines the number of index to draw
  40456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40457. */
  40458. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40459. /**
  40460. * Draw a list of points
  40461. * @param verticesStart defines the index of first vertex to draw
  40462. * @param verticesCount defines the count of vertices to draw
  40463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40464. */
  40465. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40466. /**
  40467. * Draw a list of unindexed primitives
  40468. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40469. * @param verticesStart defines the index of first vertex to draw
  40470. * @param verticesCount defines the count of vertices to draw
  40471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40472. */
  40473. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40474. /**
  40475. * Draw a list of indexed primitives
  40476. * @param fillMode defines the primitive to use
  40477. * @param indexStart defines the starting index
  40478. * @param indexCount defines the number of index to draw
  40479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40480. */
  40481. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40482. /**
  40483. * Draw a list of unindexed primitives
  40484. * @param fillMode defines the primitive to use
  40485. * @param verticesStart defines the index of first vertex to draw
  40486. * @param verticesCount defines the count of vertices to draw
  40487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40488. */
  40489. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40490. private _drawMode;
  40491. /** @hidden */
  40492. protected _reportDrawCall(): void;
  40493. /** @hidden */
  40494. _releaseEffect(effect: Effect): void;
  40495. /** @hidden */
  40496. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40497. /**
  40498. * Create a new effect (used to store vertex/fragment shaders)
  40499. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40500. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40501. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40502. * @param samplers defines an array of string used to represent textures
  40503. * @param defines defines the string containing the defines to use to compile the shaders
  40504. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40505. * @param onCompiled defines a function to call when the effect creation is successful
  40506. * @param onError defines a function to call when the effect creation has failed
  40507. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40508. * @returns the new Effect
  40509. */
  40510. 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;
  40511. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40512. private _compileShader;
  40513. private _compileRawShader;
  40514. /** @hidden */
  40515. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40516. /**
  40517. * Directly creates a webGL program
  40518. * @param pipelineContext defines the pipeline context to attach to
  40519. * @param vertexCode defines the vertex shader code to use
  40520. * @param fragmentCode defines the fragment shader code to use
  40521. * @param context defines the webGL context to use (if not set, the current one will be used)
  40522. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40523. * @returns the new webGL program
  40524. */
  40525. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40526. /**
  40527. * Creates a webGL program
  40528. * @param pipelineContext defines the pipeline context to attach to
  40529. * @param vertexCode defines the vertex shader code to use
  40530. * @param fragmentCode defines the fragment shader code to use
  40531. * @param defines defines the string containing the defines to use to compile the shaders
  40532. * @param context defines the webGL context to use (if not set, the current one will be used)
  40533. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40534. * @returns the new webGL program
  40535. */
  40536. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40537. /**
  40538. * Creates a new pipeline context
  40539. * @returns the new pipeline
  40540. */
  40541. createPipelineContext(): IPipelineContext;
  40542. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40543. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40544. /** @hidden */
  40545. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40546. /** @hidden */
  40547. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40548. /** @hidden */
  40549. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40550. /**
  40551. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40552. * @param pipelineContext defines the pipeline context to use
  40553. * @param uniformsNames defines the list of uniform names
  40554. * @returns an array of webGL uniform locations
  40555. */
  40556. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40557. /**
  40558. * Gets the lsit of active attributes for a given webGL program
  40559. * @param pipelineContext defines the pipeline context to use
  40560. * @param attributesNames defines the list of attribute names to get
  40561. * @returns an array of indices indicating the offset of each attribute
  40562. */
  40563. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40564. /**
  40565. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40566. * @param effect defines the effect to activate
  40567. */
  40568. enableEffect(effect: Nullable<Effect>): void;
  40569. /**
  40570. * Set the value of an uniform to a number (int)
  40571. * @param uniform defines the webGL uniform location where to store the value
  40572. * @param value defines the int number to store
  40573. * @returns true if the value was set
  40574. */
  40575. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40576. /**
  40577. * Set the value of an uniform to an array of int32
  40578. * @param uniform defines the webGL uniform location where to store the value
  40579. * @param array defines the array of int32 to store
  40580. * @returns true if the value was set
  40581. */
  40582. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40583. /**
  40584. * Set the value of an uniform to an array of int32 (stored as vec2)
  40585. * @param uniform defines the webGL uniform location where to store the value
  40586. * @param array defines the array of int32 to store
  40587. * @returns true if the value was set
  40588. */
  40589. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40590. /**
  40591. * Set the value of an uniform to an array of int32 (stored as vec3)
  40592. * @param uniform defines the webGL uniform location where to store the value
  40593. * @param array defines the array of int32 to store
  40594. * @returns true if the value was set
  40595. */
  40596. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40597. /**
  40598. * Set the value of an uniform to an array of int32 (stored as vec4)
  40599. * @param uniform defines the webGL uniform location where to store the value
  40600. * @param array defines the array of int32 to store
  40601. * @returns true if the value was set
  40602. */
  40603. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40604. /**
  40605. * Set the value of an uniform to an array of number
  40606. * @param uniform defines the webGL uniform location where to store the value
  40607. * @param array defines the array of number to store
  40608. * @returns true if the value was set
  40609. */
  40610. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40611. /**
  40612. * Set the value of an uniform to an array of number (stored as vec2)
  40613. * @param uniform defines the webGL uniform location where to store the value
  40614. * @param array defines the array of number to store
  40615. * @returns true if the value was set
  40616. */
  40617. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40618. /**
  40619. * Set the value of an uniform to an array of number (stored as vec3)
  40620. * @param uniform defines the webGL uniform location where to store the value
  40621. * @param array defines the array of number to store
  40622. * @returns true if the value was set
  40623. */
  40624. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40625. /**
  40626. * Set the value of an uniform to an array of number (stored as vec4)
  40627. * @param uniform defines the webGL uniform location where to store the value
  40628. * @param array defines the array of number to store
  40629. * @returns true if the value was set
  40630. */
  40631. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40632. /**
  40633. * Set the value of an uniform to an array of float32 (stored as matrices)
  40634. * @param uniform defines the webGL uniform location where to store the value
  40635. * @param matrices defines the array of float32 to store
  40636. * @returns true if the value was set
  40637. */
  40638. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40639. /**
  40640. * Set the value of an uniform to a matrix (3x3)
  40641. * @param uniform defines the webGL uniform location where to store the value
  40642. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40643. * @returns true if the value was set
  40644. */
  40645. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40646. /**
  40647. * Set the value of an uniform to a matrix (2x2)
  40648. * @param uniform defines the webGL uniform location where to store the value
  40649. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40650. * @returns true if the value was set
  40651. */
  40652. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40653. /**
  40654. * Set the value of an uniform to a number (float)
  40655. * @param uniform defines the webGL uniform location where to store the value
  40656. * @param value defines the float number to store
  40657. * @returns true if the value was transfered
  40658. */
  40659. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40660. /**
  40661. * Set the value of an uniform to a vec2
  40662. * @param uniform defines the webGL uniform location where to store the value
  40663. * @param x defines the 1st component of the value
  40664. * @param y defines the 2nd component of the value
  40665. * @returns true if the value was set
  40666. */
  40667. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40668. /**
  40669. * Set the value of an uniform to a vec3
  40670. * @param uniform defines the webGL uniform location where to store the value
  40671. * @param x defines the 1st component of the value
  40672. * @param y defines the 2nd component of the value
  40673. * @param z defines the 3rd component of the value
  40674. * @returns true if the value was set
  40675. */
  40676. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40677. /**
  40678. * Set the value of an uniform to a vec4
  40679. * @param uniform defines the webGL uniform location where to store the value
  40680. * @param x defines the 1st component of the value
  40681. * @param y defines the 2nd component of the value
  40682. * @param z defines the 3rd component of the value
  40683. * @param w defines the 4th component of the value
  40684. * @returns true if the value was set
  40685. */
  40686. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40687. /**
  40688. * Apply all cached states (depth, culling, stencil and alpha)
  40689. */
  40690. applyStates(): void;
  40691. /**
  40692. * Enable or disable color writing
  40693. * @param enable defines the state to set
  40694. */
  40695. setColorWrite(enable: boolean): void;
  40696. /**
  40697. * Gets a boolean indicating if color writing is enabled
  40698. * @returns the current color writing state
  40699. */
  40700. getColorWrite(): boolean;
  40701. /**
  40702. * Gets the depth culling state manager
  40703. */
  40704. get depthCullingState(): DepthCullingState;
  40705. /**
  40706. * Gets the alpha state manager
  40707. */
  40708. get alphaState(): AlphaState;
  40709. /**
  40710. * Gets the stencil state manager
  40711. */
  40712. get stencilState(): StencilState;
  40713. /**
  40714. * Clears the list of texture accessible through engine.
  40715. * This can help preventing texture load conflict due to name collision.
  40716. */
  40717. clearInternalTexturesCache(): void;
  40718. /**
  40719. * Force the entire cache to be cleared
  40720. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40721. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40722. */
  40723. wipeCaches(bruteForce?: boolean): void;
  40724. /** @hidden */
  40725. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40726. min: number;
  40727. mag: number;
  40728. };
  40729. /** @hidden */
  40730. _createTexture(): WebGLTexture;
  40731. /**
  40732. * Usually called from Texture.ts.
  40733. * Passed information to create a WebGLTexture
  40734. * @param url defines a value which contains one of the following:
  40735. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40736. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40737. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40738. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40739. * @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)
  40740. * @param scene needed for loading to the correct scene
  40741. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40742. * @param onLoad optional callback to be called upon successful completion
  40743. * @param onError optional callback to be called upon failure
  40744. * @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
  40745. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40746. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40747. * @param forcedExtension defines the extension to use to pick the right loader
  40748. * @param mimeType defines an optional mime type
  40749. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40750. */
  40751. 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;
  40752. /**
  40753. * Loads an image as an HTMLImageElement.
  40754. * @param input url string, ArrayBuffer, or Blob to load
  40755. * @param onLoad callback called when the image successfully loads
  40756. * @param onError callback called when the image fails to load
  40757. * @param offlineProvider offline provider for caching
  40758. * @param mimeType optional mime type
  40759. * @returns the HTMLImageElement of the loaded image
  40760. * @hidden
  40761. */
  40762. 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>;
  40763. /**
  40764. * @hidden
  40765. */
  40766. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40767. private _unpackFlipYCached;
  40768. /**
  40769. * In case you are sharing the context with other applications, it might
  40770. * be interested to not cache the unpack flip y state to ensure a consistent
  40771. * value would be set.
  40772. */
  40773. enableUnpackFlipYCached: boolean;
  40774. /** @hidden */
  40775. _unpackFlipY(value: boolean): void;
  40776. /** @hidden */
  40777. _getUnpackAlignement(): number;
  40778. private _getTextureTarget;
  40779. /**
  40780. * Update the sampling mode of a given texture
  40781. * @param samplingMode defines the required sampling mode
  40782. * @param texture defines the texture to update
  40783. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40784. */
  40785. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40786. /**
  40787. * Update the sampling mode of a given texture
  40788. * @param texture defines the texture to update
  40789. * @param wrapU defines the texture wrap mode of the u coordinates
  40790. * @param wrapV defines the texture wrap mode of the v coordinates
  40791. * @param wrapR defines the texture wrap mode of the r coordinates
  40792. */
  40793. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40794. /** @hidden */
  40795. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40796. width: number;
  40797. height: number;
  40798. layers?: number;
  40799. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40800. /** @hidden */
  40801. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40802. /** @hidden */
  40803. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40804. /**
  40805. * Update a portion of an internal texture
  40806. * @param texture defines the texture to update
  40807. * @param imageData defines the data to store into the texture
  40808. * @param xOffset defines the x coordinates of the update rectangle
  40809. * @param yOffset defines the y coordinates of the update rectangle
  40810. * @param width defines the width of the update rectangle
  40811. * @param height defines the height of the update rectangle
  40812. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40813. * @param lod defines the lod level to update (0 by default)
  40814. */
  40815. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40816. /** @hidden */
  40817. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40818. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40819. private _prepareWebGLTexture;
  40820. /** @hidden */
  40821. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40822. private _getDepthStencilBuffer;
  40823. /** @hidden */
  40824. _releaseFramebufferObjects(texture: InternalTexture): void;
  40825. /** @hidden */
  40826. _releaseTexture(texture: InternalTexture): void;
  40827. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40828. protected _setProgram(program: WebGLProgram): void;
  40829. protected _boundUniforms: {
  40830. [key: number]: WebGLUniformLocation;
  40831. };
  40832. /**
  40833. * Binds an effect to the webGL context
  40834. * @param effect defines the effect to bind
  40835. */
  40836. bindSamplers(effect: Effect): void;
  40837. private _activateCurrentTexture;
  40838. /** @hidden */
  40839. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40840. /** @hidden */
  40841. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40842. /**
  40843. * Unbind all textures from the webGL context
  40844. */
  40845. unbindAllTextures(): void;
  40846. /**
  40847. * Sets a texture to the according uniform.
  40848. * @param channel The texture channel
  40849. * @param uniform The uniform to set
  40850. * @param texture The texture to apply
  40851. */
  40852. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40853. private _bindSamplerUniformToChannel;
  40854. private _getTextureWrapMode;
  40855. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40856. /**
  40857. * Sets an array of texture to the webGL context
  40858. * @param channel defines the channel where the texture array must be set
  40859. * @param uniform defines the associated uniform location
  40860. * @param textures defines the array of textures to bind
  40861. */
  40862. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40863. /** @hidden */
  40864. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40865. private _setTextureParameterFloat;
  40866. private _setTextureParameterInteger;
  40867. /**
  40868. * Unbind all vertex attributes from the webGL context
  40869. */
  40870. unbindAllAttributes(): void;
  40871. /**
  40872. * 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
  40873. */
  40874. releaseEffects(): void;
  40875. /**
  40876. * Dispose and release all associated resources
  40877. */
  40878. dispose(): void;
  40879. /**
  40880. * Attach a new callback raised when context lost event is fired
  40881. * @param callback defines the callback to call
  40882. */
  40883. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40884. /**
  40885. * Attach a new callback raised when context restored event is fired
  40886. * @param callback defines the callback to call
  40887. */
  40888. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40889. /**
  40890. * Get the current error code of the webGL context
  40891. * @returns the error code
  40892. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40893. */
  40894. getError(): number;
  40895. private _canRenderToFloatFramebuffer;
  40896. private _canRenderToHalfFloatFramebuffer;
  40897. private _canRenderToFramebuffer;
  40898. /** @hidden */
  40899. _getWebGLTextureType(type: number): number;
  40900. /** @hidden */
  40901. _getInternalFormat(format: number): number;
  40902. /** @hidden */
  40903. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40904. /** @hidden */
  40905. _getRGBAMultiSampleBufferFormat(type: number): number;
  40906. /** @hidden */
  40907. _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;
  40908. /**
  40909. * Loads a file from a url
  40910. * @param url url to load
  40911. * @param onSuccess callback called when the file successfully loads
  40912. * @param onProgress callback called while file is loading (if the server supports this mode)
  40913. * @param offlineProvider defines the offline provider for caching
  40914. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40915. * @param onError callback called when the file fails to load
  40916. * @returns a file request object
  40917. * @hidden
  40918. */
  40919. 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;
  40920. /**
  40921. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40922. * @param x defines the x coordinate of the rectangle where pixels must be read
  40923. * @param y defines the y coordinate of the rectangle where pixels must be read
  40924. * @param width defines the width of the rectangle where pixels must be read
  40925. * @param height defines the height of the rectangle where pixels must be read
  40926. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40927. * @returns a Uint8Array containing RGBA colors
  40928. */
  40929. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40930. private static _IsSupported;
  40931. private static _HasMajorPerformanceCaveat;
  40932. /**
  40933. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40934. */
  40935. static get IsSupported(): boolean;
  40936. /**
  40937. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40938. * @returns true if the engine can be created
  40939. * @ignorenaming
  40940. */
  40941. static isSupported(): boolean;
  40942. /**
  40943. * 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)
  40944. */
  40945. static get HasMajorPerformanceCaveat(): boolean;
  40946. /**
  40947. * Find the next highest power of two.
  40948. * @param x Number to start search from.
  40949. * @return Next highest power of two.
  40950. */
  40951. static CeilingPOT(x: number): number;
  40952. /**
  40953. * Find the next lowest power of two.
  40954. * @param x Number to start search from.
  40955. * @return Next lowest power of two.
  40956. */
  40957. static FloorPOT(x: number): number;
  40958. /**
  40959. * Find the nearest power of two.
  40960. * @param x Number to start search from.
  40961. * @return Next nearest power of two.
  40962. */
  40963. static NearestPOT(x: number): number;
  40964. /**
  40965. * Get the closest exponent of two
  40966. * @param value defines the value to approximate
  40967. * @param max defines the maximum value to return
  40968. * @param mode defines how to define the closest value
  40969. * @returns closest exponent of two of the given value
  40970. */
  40971. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40972. /**
  40973. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40974. * @param func - the function to be called
  40975. * @param requester - the object that will request the next frame. Falls back to window.
  40976. * @returns frame number
  40977. */
  40978. static QueueNewFrame(func: () => void, requester?: any): number;
  40979. /**
  40980. * Gets host document
  40981. * @returns the host document object
  40982. */
  40983. getHostDocument(): Nullable<Document>;
  40984. }
  40985. }
  40986. declare module "babylonjs/Materials/Textures/internalTexture" {
  40987. import { Observable } from "babylonjs/Misc/observable";
  40988. import { Nullable, int } from "babylonjs/types";
  40989. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40991. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  40992. /**
  40993. * Defines the source of the internal texture
  40994. */
  40995. export enum InternalTextureSource {
  40996. /**
  40997. * The source of the texture data is unknown
  40998. */
  40999. Unknown = 0,
  41000. /**
  41001. * Texture data comes from an URL
  41002. */
  41003. Url = 1,
  41004. /**
  41005. * Texture data is only used for temporary storage
  41006. */
  41007. Temp = 2,
  41008. /**
  41009. * Texture data comes from raw data (ArrayBuffer)
  41010. */
  41011. Raw = 3,
  41012. /**
  41013. * Texture content is dynamic (video or dynamic texture)
  41014. */
  41015. Dynamic = 4,
  41016. /**
  41017. * Texture content is generated by rendering to it
  41018. */
  41019. RenderTarget = 5,
  41020. /**
  41021. * Texture content is part of a multi render target process
  41022. */
  41023. MultiRenderTarget = 6,
  41024. /**
  41025. * Texture data comes from a cube data file
  41026. */
  41027. Cube = 7,
  41028. /**
  41029. * Texture data comes from a raw cube data
  41030. */
  41031. CubeRaw = 8,
  41032. /**
  41033. * Texture data come from a prefiltered cube data file
  41034. */
  41035. CubePrefiltered = 9,
  41036. /**
  41037. * Texture content is raw 3D data
  41038. */
  41039. Raw3D = 10,
  41040. /**
  41041. * Texture content is raw 2D array data
  41042. */
  41043. Raw2DArray = 11,
  41044. /**
  41045. * Texture content is a depth texture
  41046. */
  41047. Depth = 12,
  41048. /**
  41049. * Texture data comes from a raw cube data encoded with RGBD
  41050. */
  41051. CubeRawRGBD = 13
  41052. }
  41053. /**
  41054. * Class used to store data associated with WebGL texture data for the engine
  41055. * This class should not be used directly
  41056. */
  41057. export class InternalTexture {
  41058. /** @hidden */
  41059. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41060. /**
  41061. * Defines if the texture is ready
  41062. */
  41063. isReady: boolean;
  41064. /**
  41065. * Defines if the texture is a cube texture
  41066. */
  41067. isCube: boolean;
  41068. /**
  41069. * Defines if the texture contains 3D data
  41070. */
  41071. is3D: boolean;
  41072. /**
  41073. * Defines if the texture contains 2D array data
  41074. */
  41075. is2DArray: boolean;
  41076. /**
  41077. * Defines if the texture contains multiview data
  41078. */
  41079. isMultiview: boolean;
  41080. /**
  41081. * Gets the URL used to load this texture
  41082. */
  41083. url: string;
  41084. /**
  41085. * Gets the sampling mode of the texture
  41086. */
  41087. samplingMode: number;
  41088. /**
  41089. * Gets a boolean indicating if the texture needs mipmaps generation
  41090. */
  41091. generateMipMaps: boolean;
  41092. /**
  41093. * Gets the number of samples used by the texture (WebGL2+ only)
  41094. */
  41095. samples: number;
  41096. /**
  41097. * Gets the type of the texture (int, float...)
  41098. */
  41099. type: number;
  41100. /**
  41101. * Gets the format of the texture (RGB, RGBA...)
  41102. */
  41103. format: number;
  41104. /**
  41105. * Observable called when the texture is loaded
  41106. */
  41107. onLoadedObservable: Observable<InternalTexture>;
  41108. /**
  41109. * Gets the width of the texture
  41110. */
  41111. width: number;
  41112. /**
  41113. * Gets the height of the texture
  41114. */
  41115. height: number;
  41116. /**
  41117. * Gets the depth of the texture
  41118. */
  41119. depth: number;
  41120. /**
  41121. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41122. */
  41123. baseWidth: number;
  41124. /**
  41125. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41126. */
  41127. baseHeight: number;
  41128. /**
  41129. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41130. */
  41131. baseDepth: number;
  41132. /**
  41133. * Gets a boolean indicating if the texture is inverted on Y axis
  41134. */
  41135. invertY: boolean;
  41136. /** @hidden */
  41137. _invertVScale: boolean;
  41138. /** @hidden */
  41139. _associatedChannel: number;
  41140. /** @hidden */
  41141. _source: InternalTextureSource;
  41142. /** @hidden */
  41143. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41144. /** @hidden */
  41145. _bufferView: Nullable<ArrayBufferView>;
  41146. /** @hidden */
  41147. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41148. /** @hidden */
  41149. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41150. /** @hidden */
  41151. _size: number;
  41152. /** @hidden */
  41153. _extension: string;
  41154. /** @hidden */
  41155. _files: Nullable<string[]>;
  41156. /** @hidden */
  41157. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41158. /** @hidden */
  41159. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41160. /** @hidden */
  41161. _framebuffer: Nullable<WebGLFramebuffer>;
  41162. /** @hidden */
  41163. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41164. /** @hidden */
  41165. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41166. /** @hidden */
  41167. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41168. /** @hidden */
  41169. _attachments: Nullable<number[]>;
  41170. /** @hidden */
  41171. _textureArray: Nullable<InternalTexture[]>;
  41172. /** @hidden */
  41173. _cachedCoordinatesMode: Nullable<number>;
  41174. /** @hidden */
  41175. _cachedWrapU: Nullable<number>;
  41176. /** @hidden */
  41177. _cachedWrapV: Nullable<number>;
  41178. /** @hidden */
  41179. _cachedWrapR: Nullable<number>;
  41180. /** @hidden */
  41181. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41182. /** @hidden */
  41183. _isDisabled: boolean;
  41184. /** @hidden */
  41185. _compression: Nullable<string>;
  41186. /** @hidden */
  41187. _generateStencilBuffer: boolean;
  41188. /** @hidden */
  41189. _generateDepthBuffer: boolean;
  41190. /** @hidden */
  41191. _comparisonFunction: number;
  41192. /** @hidden */
  41193. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41194. /** @hidden */
  41195. _lodGenerationScale: number;
  41196. /** @hidden */
  41197. _lodGenerationOffset: number;
  41198. /** @hidden */
  41199. _depthStencilTexture: Nullable<InternalTexture>;
  41200. /** @hidden */
  41201. _colorTextureArray: Nullable<WebGLTexture>;
  41202. /** @hidden */
  41203. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41204. /** @hidden */
  41205. _lodTextureHigh: Nullable<BaseTexture>;
  41206. /** @hidden */
  41207. _lodTextureMid: Nullable<BaseTexture>;
  41208. /** @hidden */
  41209. _lodTextureLow: Nullable<BaseTexture>;
  41210. /** @hidden */
  41211. _isRGBD: boolean;
  41212. /** @hidden */
  41213. _linearSpecularLOD: boolean;
  41214. /** @hidden */
  41215. _irradianceTexture: Nullable<BaseTexture>;
  41216. /** @hidden */
  41217. _webGLTexture: Nullable<WebGLTexture>;
  41218. /** @hidden */
  41219. _references: number;
  41220. /** @hidden */
  41221. _gammaSpace: Nullable<boolean>;
  41222. private _engine;
  41223. /**
  41224. * Gets the Engine the texture belongs to.
  41225. * @returns The babylon engine
  41226. */
  41227. getEngine(): ThinEngine;
  41228. /**
  41229. * Gets the data source type of the texture
  41230. */
  41231. get source(): InternalTextureSource;
  41232. /**
  41233. * Creates a new InternalTexture
  41234. * @param engine defines the engine to use
  41235. * @param source defines the type of data that will be used
  41236. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41237. */
  41238. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41239. /**
  41240. * Increments the number of references (ie. the number of Texture that point to it)
  41241. */
  41242. incrementReferences(): void;
  41243. /**
  41244. * Change the size of the texture (not the size of the content)
  41245. * @param width defines the new width
  41246. * @param height defines the new height
  41247. * @param depth defines the new depth (1 by default)
  41248. */
  41249. updateSize(width: int, height: int, depth?: int): void;
  41250. /** @hidden */
  41251. _rebuild(): void;
  41252. /** @hidden */
  41253. _swapAndDie(target: InternalTexture): void;
  41254. /**
  41255. * Dispose the current allocated resources
  41256. */
  41257. dispose(): void;
  41258. }
  41259. }
  41260. declare module "babylonjs/Audio/analyser" {
  41261. import { Scene } from "babylonjs/scene";
  41262. /**
  41263. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41265. */
  41266. export class Analyser {
  41267. /**
  41268. * Gets or sets the smoothing
  41269. * @ignorenaming
  41270. */
  41271. SMOOTHING: number;
  41272. /**
  41273. * Gets or sets the FFT table size
  41274. * @ignorenaming
  41275. */
  41276. FFT_SIZE: number;
  41277. /**
  41278. * Gets or sets the bar graph amplitude
  41279. * @ignorenaming
  41280. */
  41281. BARGRAPHAMPLITUDE: number;
  41282. /**
  41283. * Gets or sets the position of the debug canvas
  41284. * @ignorenaming
  41285. */
  41286. DEBUGCANVASPOS: {
  41287. x: number;
  41288. y: number;
  41289. };
  41290. /**
  41291. * Gets or sets the debug canvas size
  41292. * @ignorenaming
  41293. */
  41294. DEBUGCANVASSIZE: {
  41295. width: number;
  41296. height: number;
  41297. };
  41298. private _byteFreqs;
  41299. private _byteTime;
  41300. private _floatFreqs;
  41301. private _webAudioAnalyser;
  41302. private _debugCanvas;
  41303. private _debugCanvasContext;
  41304. private _scene;
  41305. private _registerFunc;
  41306. private _audioEngine;
  41307. /**
  41308. * Creates a new analyser
  41309. * @param scene defines hosting scene
  41310. */
  41311. constructor(scene: Scene);
  41312. /**
  41313. * Get the number of data values you will have to play with for the visualization
  41314. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41315. * @returns a number
  41316. */
  41317. getFrequencyBinCount(): number;
  41318. /**
  41319. * Gets the current frequency data as a byte array
  41320. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41321. * @returns a Uint8Array
  41322. */
  41323. getByteFrequencyData(): Uint8Array;
  41324. /**
  41325. * Gets the current waveform as a byte array
  41326. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41327. * @returns a Uint8Array
  41328. */
  41329. getByteTimeDomainData(): Uint8Array;
  41330. /**
  41331. * Gets the current frequency data as a float array
  41332. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41333. * @returns a Float32Array
  41334. */
  41335. getFloatFrequencyData(): Float32Array;
  41336. /**
  41337. * Renders the debug canvas
  41338. */
  41339. drawDebugCanvas(): void;
  41340. /**
  41341. * Stops rendering the debug canvas and removes it
  41342. */
  41343. stopDebugCanvas(): void;
  41344. /**
  41345. * Connects two audio nodes
  41346. * @param inputAudioNode defines first node to connect
  41347. * @param outputAudioNode defines second node to connect
  41348. */
  41349. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41350. /**
  41351. * Releases all associated resources
  41352. */
  41353. dispose(): void;
  41354. }
  41355. }
  41356. declare module "babylonjs/Audio/audioEngine" {
  41357. import { IDisposable } from "babylonjs/scene";
  41358. import { Analyser } from "babylonjs/Audio/analyser";
  41359. import { Nullable } from "babylonjs/types";
  41360. import { Observable } from "babylonjs/Misc/observable";
  41361. /**
  41362. * This represents an audio engine and it is responsible
  41363. * to play, synchronize and analyse sounds throughout the application.
  41364. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41365. */
  41366. export interface IAudioEngine extends IDisposable {
  41367. /**
  41368. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41369. */
  41370. readonly canUseWebAudio: boolean;
  41371. /**
  41372. * Gets the current AudioContext if available.
  41373. */
  41374. readonly audioContext: Nullable<AudioContext>;
  41375. /**
  41376. * The master gain node defines the global audio volume of your audio engine.
  41377. */
  41378. readonly masterGain: GainNode;
  41379. /**
  41380. * Gets whether or not mp3 are supported by your browser.
  41381. */
  41382. readonly isMP3supported: boolean;
  41383. /**
  41384. * Gets whether or not ogg are supported by your browser.
  41385. */
  41386. readonly isOGGsupported: boolean;
  41387. /**
  41388. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41389. * @ignoreNaming
  41390. */
  41391. WarnedWebAudioUnsupported: boolean;
  41392. /**
  41393. * Defines if the audio engine relies on a custom unlocked button.
  41394. * In this case, the embedded button will not be displayed.
  41395. */
  41396. useCustomUnlockedButton: boolean;
  41397. /**
  41398. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41399. */
  41400. readonly unlocked: boolean;
  41401. /**
  41402. * Event raised when audio has been unlocked on the browser.
  41403. */
  41404. onAudioUnlockedObservable: Observable<AudioEngine>;
  41405. /**
  41406. * Event raised when audio has been locked on the browser.
  41407. */
  41408. onAudioLockedObservable: Observable<AudioEngine>;
  41409. /**
  41410. * Flags the audio engine in Locked state.
  41411. * This happens due to new browser policies preventing audio to autoplay.
  41412. */
  41413. lock(): void;
  41414. /**
  41415. * Unlocks the audio engine once a user action has been done on the dom.
  41416. * This is helpful to resume play once browser policies have been satisfied.
  41417. */
  41418. unlock(): void;
  41419. /**
  41420. * Gets the global volume sets on the master gain.
  41421. * @returns the global volume if set or -1 otherwise
  41422. */
  41423. getGlobalVolume(): number;
  41424. /**
  41425. * Sets the global volume of your experience (sets on the master gain).
  41426. * @param newVolume Defines the new global volume of the application
  41427. */
  41428. setGlobalVolume(newVolume: number): void;
  41429. /**
  41430. * Connect the audio engine to an audio analyser allowing some amazing
  41431. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41433. * @param analyser The analyser to connect to the engine
  41434. */
  41435. connectToAnalyser(analyser: Analyser): void;
  41436. }
  41437. /**
  41438. * This represents the default audio engine used in babylon.
  41439. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41441. */
  41442. export class AudioEngine implements IAudioEngine {
  41443. private _audioContext;
  41444. private _audioContextInitialized;
  41445. private _muteButton;
  41446. private _hostElement;
  41447. /**
  41448. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41449. */
  41450. canUseWebAudio: boolean;
  41451. /**
  41452. * The master gain node defines the global audio volume of your audio engine.
  41453. */
  41454. masterGain: GainNode;
  41455. /**
  41456. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41457. * @ignoreNaming
  41458. */
  41459. WarnedWebAudioUnsupported: boolean;
  41460. /**
  41461. * Gets whether or not mp3 are supported by your browser.
  41462. */
  41463. isMP3supported: boolean;
  41464. /**
  41465. * Gets whether or not ogg are supported by your browser.
  41466. */
  41467. isOGGsupported: boolean;
  41468. /**
  41469. * Gets whether audio has been unlocked on the device.
  41470. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41471. * a user interaction has happened.
  41472. */
  41473. unlocked: boolean;
  41474. /**
  41475. * Defines if the audio engine relies on a custom unlocked button.
  41476. * In this case, the embedded button will not be displayed.
  41477. */
  41478. useCustomUnlockedButton: boolean;
  41479. /**
  41480. * Event raised when audio has been unlocked on the browser.
  41481. */
  41482. onAudioUnlockedObservable: Observable<AudioEngine>;
  41483. /**
  41484. * Event raised when audio has been locked on the browser.
  41485. */
  41486. onAudioLockedObservable: Observable<AudioEngine>;
  41487. /**
  41488. * Gets the current AudioContext if available.
  41489. */
  41490. get audioContext(): Nullable<AudioContext>;
  41491. private _connectedAnalyser;
  41492. /**
  41493. * Instantiates a new audio engine.
  41494. *
  41495. * There should be only one per page as some browsers restrict the number
  41496. * of audio contexts you can create.
  41497. * @param hostElement defines the host element where to display the mute icon if necessary
  41498. */
  41499. constructor(hostElement?: Nullable<HTMLElement>);
  41500. /**
  41501. * Flags the audio engine in Locked state.
  41502. * This happens due to new browser policies preventing audio to autoplay.
  41503. */
  41504. lock(): void;
  41505. /**
  41506. * Unlocks the audio engine once a user action has been done on the dom.
  41507. * This is helpful to resume play once browser policies have been satisfied.
  41508. */
  41509. unlock(): void;
  41510. private _resumeAudioContext;
  41511. private _initializeAudioContext;
  41512. private _tryToRun;
  41513. private _triggerRunningState;
  41514. private _triggerSuspendedState;
  41515. private _displayMuteButton;
  41516. private _moveButtonToTopLeft;
  41517. private _onResize;
  41518. private _hideMuteButton;
  41519. /**
  41520. * Destroy and release the resources associated with the audio ccontext.
  41521. */
  41522. dispose(): void;
  41523. /**
  41524. * Gets the global volume sets on the master gain.
  41525. * @returns the global volume if set or -1 otherwise
  41526. */
  41527. getGlobalVolume(): number;
  41528. /**
  41529. * Sets the global volume of your experience (sets on the master gain).
  41530. * @param newVolume Defines the new global volume of the application
  41531. */
  41532. setGlobalVolume(newVolume: number): void;
  41533. /**
  41534. * Connect the audio engine to an audio analyser allowing some amazing
  41535. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41537. * @param analyser The analyser to connect to the engine
  41538. */
  41539. connectToAnalyser(analyser: Analyser): void;
  41540. }
  41541. }
  41542. declare module "babylonjs/Loading/loadingScreen" {
  41543. /**
  41544. * Interface used to present a loading screen while loading a scene
  41545. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41546. */
  41547. export interface ILoadingScreen {
  41548. /**
  41549. * Function called to display the loading screen
  41550. */
  41551. displayLoadingUI: () => void;
  41552. /**
  41553. * Function called to hide the loading screen
  41554. */
  41555. hideLoadingUI: () => void;
  41556. /**
  41557. * Gets or sets the color to use for the background
  41558. */
  41559. loadingUIBackgroundColor: string;
  41560. /**
  41561. * Gets or sets the text to display while loading
  41562. */
  41563. loadingUIText: string;
  41564. }
  41565. /**
  41566. * Class used for the default loading screen
  41567. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41568. */
  41569. export class DefaultLoadingScreen implements ILoadingScreen {
  41570. private _renderingCanvas;
  41571. private _loadingText;
  41572. private _loadingDivBackgroundColor;
  41573. private _loadingDiv;
  41574. private _loadingTextDiv;
  41575. /** Gets or sets the logo url to use for the default loading screen */
  41576. static DefaultLogoUrl: string;
  41577. /** Gets or sets the spinner url to use for the default loading screen */
  41578. static DefaultSpinnerUrl: string;
  41579. /**
  41580. * Creates a new default loading screen
  41581. * @param _renderingCanvas defines the canvas used to render the scene
  41582. * @param _loadingText defines the default text to display
  41583. * @param _loadingDivBackgroundColor defines the default background color
  41584. */
  41585. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41586. /**
  41587. * Function called to display the loading screen
  41588. */
  41589. displayLoadingUI(): void;
  41590. /**
  41591. * Function called to hide the loading screen
  41592. */
  41593. hideLoadingUI(): void;
  41594. /**
  41595. * Gets or sets the text to display while loading
  41596. */
  41597. set loadingUIText(text: string);
  41598. get loadingUIText(): string;
  41599. /**
  41600. * Gets or sets the color to use for the background
  41601. */
  41602. get loadingUIBackgroundColor(): string;
  41603. set loadingUIBackgroundColor(color: string);
  41604. private _resizeLoadingUI;
  41605. }
  41606. }
  41607. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41608. /**
  41609. * Interface for any object that can request an animation frame
  41610. */
  41611. export interface ICustomAnimationFrameRequester {
  41612. /**
  41613. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41614. */
  41615. renderFunction?: Function;
  41616. /**
  41617. * Called to request the next frame to render to
  41618. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41619. */
  41620. requestAnimationFrame: Function;
  41621. /**
  41622. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41623. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41624. */
  41625. requestID?: number;
  41626. }
  41627. }
  41628. declare module "babylonjs/Misc/performanceMonitor" {
  41629. /**
  41630. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41631. */
  41632. export class PerformanceMonitor {
  41633. private _enabled;
  41634. private _rollingFrameTime;
  41635. private _lastFrameTimeMs;
  41636. /**
  41637. * constructor
  41638. * @param frameSampleSize The number of samples required to saturate the sliding window
  41639. */
  41640. constructor(frameSampleSize?: number);
  41641. /**
  41642. * Samples current frame
  41643. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41644. */
  41645. sampleFrame(timeMs?: number): void;
  41646. /**
  41647. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41648. */
  41649. get averageFrameTime(): number;
  41650. /**
  41651. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41652. */
  41653. get averageFrameTimeVariance(): number;
  41654. /**
  41655. * Returns the frame time of the most recent frame
  41656. */
  41657. get instantaneousFrameTime(): number;
  41658. /**
  41659. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41660. */
  41661. get averageFPS(): number;
  41662. /**
  41663. * Returns the average framerate in frames per second using the most recent frame time
  41664. */
  41665. get instantaneousFPS(): number;
  41666. /**
  41667. * Returns true if enough samples have been taken to completely fill the sliding window
  41668. */
  41669. get isSaturated(): boolean;
  41670. /**
  41671. * Enables contributions to the sliding window sample set
  41672. */
  41673. enable(): void;
  41674. /**
  41675. * Disables contributions to the sliding window sample set
  41676. * Samples will not be interpolated over the disabled period
  41677. */
  41678. disable(): void;
  41679. /**
  41680. * Returns true if sampling is enabled
  41681. */
  41682. get isEnabled(): boolean;
  41683. /**
  41684. * Resets performance monitor
  41685. */
  41686. reset(): void;
  41687. }
  41688. /**
  41689. * RollingAverage
  41690. *
  41691. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41692. */
  41693. export class RollingAverage {
  41694. /**
  41695. * Current average
  41696. */
  41697. average: number;
  41698. /**
  41699. * Current variance
  41700. */
  41701. variance: number;
  41702. protected _samples: Array<number>;
  41703. protected _sampleCount: number;
  41704. protected _pos: number;
  41705. protected _m2: number;
  41706. /**
  41707. * constructor
  41708. * @param length The number of samples required to saturate the sliding window
  41709. */
  41710. constructor(length: number);
  41711. /**
  41712. * Adds a sample to the sample set
  41713. * @param v The sample value
  41714. */
  41715. add(v: number): void;
  41716. /**
  41717. * Returns previously added values or null if outside of history or outside the sliding window domain
  41718. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41719. * @return Value previously recorded with add() or null if outside of range
  41720. */
  41721. history(i: number): number;
  41722. /**
  41723. * Returns true if enough samples have been taken to completely fill the sliding window
  41724. * @return true if sample-set saturated
  41725. */
  41726. isSaturated(): boolean;
  41727. /**
  41728. * Resets the rolling average (equivalent to 0 samples taken so far)
  41729. */
  41730. reset(): void;
  41731. /**
  41732. * Wraps a value around the sample range boundaries
  41733. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41734. * @return Wrapped position in sample range
  41735. */
  41736. protected _wrapPosition(i: number): number;
  41737. }
  41738. }
  41739. declare module "babylonjs/Misc/perfCounter" {
  41740. /**
  41741. * This class is used to track a performance counter which is number based.
  41742. * The user has access to many properties which give statistics of different nature.
  41743. *
  41744. * The implementer can track two kinds of Performance Counter: time and count.
  41745. * 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.
  41746. * 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.
  41747. */
  41748. export class PerfCounter {
  41749. /**
  41750. * Gets or sets a global boolean to turn on and off all the counters
  41751. */
  41752. static Enabled: boolean;
  41753. /**
  41754. * Returns the smallest value ever
  41755. */
  41756. get min(): number;
  41757. /**
  41758. * Returns the biggest value ever
  41759. */
  41760. get max(): number;
  41761. /**
  41762. * Returns the average value since the performance counter is running
  41763. */
  41764. get average(): number;
  41765. /**
  41766. * Returns the average value of the last second the counter was monitored
  41767. */
  41768. get lastSecAverage(): number;
  41769. /**
  41770. * Returns the current value
  41771. */
  41772. get current(): number;
  41773. /**
  41774. * Gets the accumulated total
  41775. */
  41776. get total(): number;
  41777. /**
  41778. * Gets the total value count
  41779. */
  41780. get count(): number;
  41781. /**
  41782. * Creates a new counter
  41783. */
  41784. constructor();
  41785. /**
  41786. * Call this method to start monitoring a new frame.
  41787. * 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.
  41788. */
  41789. fetchNewFrame(): void;
  41790. /**
  41791. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41792. * @param newCount the count value to add to the monitored count
  41793. * @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.
  41794. */
  41795. addCount(newCount: number, fetchResult: boolean): void;
  41796. /**
  41797. * Start monitoring this performance counter
  41798. */
  41799. beginMonitoring(): void;
  41800. /**
  41801. * Compute the time lapsed since the previous beginMonitoring() call.
  41802. * @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
  41803. */
  41804. endMonitoring(newFrame?: boolean): void;
  41805. private _fetchResult;
  41806. private _startMonitoringTime;
  41807. private _min;
  41808. private _max;
  41809. private _average;
  41810. private _current;
  41811. private _totalValueCount;
  41812. private _totalAccumulated;
  41813. private _lastSecAverage;
  41814. private _lastSecAccumulated;
  41815. private _lastSecTime;
  41816. private _lastSecValueCount;
  41817. }
  41818. }
  41819. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41821. import { Nullable } from "babylonjs/types";
  41822. module "babylonjs/Engines/thinEngine" {
  41823. interface ThinEngine {
  41824. /** @hidden */
  41825. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41826. }
  41827. }
  41828. }
  41829. declare module "babylonjs/Engines/engine" {
  41830. import { Observable } from "babylonjs/Misc/observable";
  41831. import { Nullable } from "babylonjs/types";
  41832. import { Scene } from "babylonjs/scene";
  41833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41834. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41835. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41836. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41837. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41838. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41839. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41840. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41841. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41843. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41844. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41845. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41846. import "babylonjs/Engines/Extensions/engine.alpha";
  41847. import "babylonjs/Engines/Extensions/engine.readTexture";
  41848. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41849. import { Material } from "babylonjs/Materials/material";
  41850. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41851. /**
  41852. * Defines the interface used by display changed events
  41853. */
  41854. export interface IDisplayChangedEventArgs {
  41855. /** Gets the vrDisplay object (if any) */
  41856. vrDisplay: Nullable<any>;
  41857. /** Gets a boolean indicating if webVR is supported */
  41858. vrSupported: boolean;
  41859. }
  41860. /**
  41861. * Defines the interface used by objects containing a viewport (like a camera)
  41862. */
  41863. interface IViewportOwnerLike {
  41864. /**
  41865. * Gets or sets the viewport
  41866. */
  41867. viewport: IViewportLike;
  41868. }
  41869. /**
  41870. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41871. */
  41872. export class Engine extends ThinEngine {
  41873. /** Defines that alpha blending is disabled */
  41874. static readonly ALPHA_DISABLE: number;
  41875. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41876. static readonly ALPHA_ADD: number;
  41877. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41878. static readonly ALPHA_COMBINE: number;
  41879. /** Defines that alpha blending to DEST - SRC * DEST */
  41880. static readonly ALPHA_SUBTRACT: number;
  41881. /** Defines that alpha blending to SRC * DEST */
  41882. static readonly ALPHA_MULTIPLY: number;
  41883. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41884. static readonly ALPHA_MAXIMIZED: number;
  41885. /** Defines that alpha blending to SRC + DEST */
  41886. static readonly ALPHA_ONEONE: number;
  41887. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41888. static readonly ALPHA_PREMULTIPLIED: number;
  41889. /**
  41890. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41891. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41892. */
  41893. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41894. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41895. static readonly ALPHA_INTERPOLATE: number;
  41896. /**
  41897. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41898. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41899. */
  41900. static readonly ALPHA_SCREENMODE: number;
  41901. /** Defines that the ressource is not delayed*/
  41902. static readonly DELAYLOADSTATE_NONE: number;
  41903. /** Defines that the ressource was successfully delay loaded */
  41904. static readonly DELAYLOADSTATE_LOADED: number;
  41905. /** Defines that the ressource is currently delay loading */
  41906. static readonly DELAYLOADSTATE_LOADING: number;
  41907. /** Defines that the ressource is delayed and has not started loading */
  41908. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41909. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41910. static readonly NEVER: number;
  41911. /** 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 */
  41912. static readonly ALWAYS: number;
  41913. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41914. static readonly LESS: number;
  41915. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41916. static readonly EQUAL: number;
  41917. /** 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 */
  41918. static readonly LEQUAL: number;
  41919. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41920. static readonly GREATER: number;
  41921. /** 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 */
  41922. static readonly GEQUAL: number;
  41923. /** 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 */
  41924. static readonly NOTEQUAL: number;
  41925. /** Passed to stencilOperation to specify that stencil value must be kept */
  41926. static readonly KEEP: number;
  41927. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41928. static readonly REPLACE: number;
  41929. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41930. static readonly INCR: number;
  41931. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41932. static readonly DECR: number;
  41933. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41934. static readonly INVERT: number;
  41935. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41936. static readonly INCR_WRAP: number;
  41937. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41938. static readonly DECR_WRAP: number;
  41939. /** Texture is not repeating outside of 0..1 UVs */
  41940. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41941. /** Texture is repeating outside of 0..1 UVs */
  41942. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41943. /** Texture is repeating and mirrored */
  41944. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41945. /** ALPHA */
  41946. static readonly TEXTUREFORMAT_ALPHA: number;
  41947. /** LUMINANCE */
  41948. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41949. /** LUMINANCE_ALPHA */
  41950. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41951. /** RGB */
  41952. static readonly TEXTUREFORMAT_RGB: number;
  41953. /** RGBA */
  41954. static readonly TEXTUREFORMAT_RGBA: number;
  41955. /** RED */
  41956. static readonly TEXTUREFORMAT_RED: number;
  41957. /** RED (2nd reference) */
  41958. static readonly TEXTUREFORMAT_R: number;
  41959. /** RG */
  41960. static readonly TEXTUREFORMAT_RG: number;
  41961. /** RED_INTEGER */
  41962. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41963. /** RED_INTEGER (2nd reference) */
  41964. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41965. /** RG_INTEGER */
  41966. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41967. /** RGB_INTEGER */
  41968. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41969. /** RGBA_INTEGER */
  41970. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41971. /** UNSIGNED_BYTE */
  41972. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41973. /** UNSIGNED_BYTE (2nd reference) */
  41974. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41975. /** FLOAT */
  41976. static readonly TEXTURETYPE_FLOAT: number;
  41977. /** HALF_FLOAT */
  41978. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41979. /** BYTE */
  41980. static readonly TEXTURETYPE_BYTE: number;
  41981. /** SHORT */
  41982. static readonly TEXTURETYPE_SHORT: number;
  41983. /** UNSIGNED_SHORT */
  41984. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41985. /** INT */
  41986. static readonly TEXTURETYPE_INT: number;
  41987. /** UNSIGNED_INT */
  41988. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41989. /** UNSIGNED_SHORT_4_4_4_4 */
  41990. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41991. /** UNSIGNED_SHORT_5_5_5_1 */
  41992. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41993. /** UNSIGNED_SHORT_5_6_5 */
  41994. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41995. /** UNSIGNED_INT_2_10_10_10_REV */
  41996. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41997. /** UNSIGNED_INT_24_8 */
  41998. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41999. /** UNSIGNED_INT_10F_11F_11F_REV */
  42000. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42001. /** UNSIGNED_INT_5_9_9_9_REV */
  42002. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42003. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42004. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42005. /** nearest is mag = nearest and min = nearest and mip = linear */
  42006. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42007. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42008. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42009. /** Trilinear is mag = linear and min = linear and mip = linear */
  42010. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42011. /** nearest is mag = nearest and min = nearest and mip = linear */
  42012. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42013. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42014. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42015. /** Trilinear is mag = linear and min = linear and mip = linear */
  42016. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42017. /** mag = nearest and min = nearest and mip = nearest */
  42018. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42019. /** mag = nearest and min = linear and mip = nearest */
  42020. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42021. /** mag = nearest and min = linear and mip = linear */
  42022. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42023. /** mag = nearest and min = linear and mip = none */
  42024. static readonly TEXTURE_NEAREST_LINEAR: number;
  42025. /** mag = nearest and min = nearest and mip = none */
  42026. static readonly TEXTURE_NEAREST_NEAREST: number;
  42027. /** mag = linear and min = nearest and mip = nearest */
  42028. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42029. /** mag = linear and min = nearest and mip = linear */
  42030. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42031. /** mag = linear and min = linear and mip = none */
  42032. static readonly TEXTURE_LINEAR_LINEAR: number;
  42033. /** mag = linear and min = nearest and mip = none */
  42034. static readonly TEXTURE_LINEAR_NEAREST: number;
  42035. /** Explicit coordinates mode */
  42036. static readonly TEXTURE_EXPLICIT_MODE: number;
  42037. /** Spherical coordinates mode */
  42038. static readonly TEXTURE_SPHERICAL_MODE: number;
  42039. /** Planar coordinates mode */
  42040. static readonly TEXTURE_PLANAR_MODE: number;
  42041. /** Cubic coordinates mode */
  42042. static readonly TEXTURE_CUBIC_MODE: number;
  42043. /** Projection coordinates mode */
  42044. static readonly TEXTURE_PROJECTION_MODE: number;
  42045. /** Skybox coordinates mode */
  42046. static readonly TEXTURE_SKYBOX_MODE: number;
  42047. /** Inverse Cubic coordinates mode */
  42048. static readonly TEXTURE_INVCUBIC_MODE: number;
  42049. /** Equirectangular coordinates mode */
  42050. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42051. /** Equirectangular Fixed coordinates mode */
  42052. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42053. /** Equirectangular Fixed Mirrored coordinates mode */
  42054. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42055. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42056. static readonly SCALEMODE_FLOOR: number;
  42057. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42058. static readonly SCALEMODE_NEAREST: number;
  42059. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42060. static readonly SCALEMODE_CEILING: number;
  42061. /**
  42062. * Returns the current npm package of the sdk
  42063. */
  42064. static get NpmPackage(): string;
  42065. /**
  42066. * Returns the current version of the framework
  42067. */
  42068. static get Version(): string;
  42069. /** Gets the list of created engines */
  42070. static get Instances(): Engine[];
  42071. /**
  42072. * Gets the latest created engine
  42073. */
  42074. static get LastCreatedEngine(): Nullable<Engine>;
  42075. /**
  42076. * Gets the latest created scene
  42077. */
  42078. static get LastCreatedScene(): Nullable<Scene>;
  42079. /**
  42080. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42081. * @param flag defines which part of the materials must be marked as dirty
  42082. * @param predicate defines a predicate used to filter which materials should be affected
  42083. */
  42084. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42085. /**
  42086. * Method called to create the default loading screen.
  42087. * This can be overriden in your own app.
  42088. * @param canvas The rendering canvas element
  42089. * @returns The loading screen
  42090. */
  42091. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42092. /**
  42093. * Method called to create the default rescale post process on each engine.
  42094. */
  42095. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42096. /**
  42097. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42098. **/
  42099. enableOfflineSupport: boolean;
  42100. /**
  42101. * 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)
  42102. **/
  42103. disableManifestCheck: boolean;
  42104. /**
  42105. * Gets the list of created scenes
  42106. */
  42107. scenes: Scene[];
  42108. /**
  42109. * Event raised when a new scene is created
  42110. */
  42111. onNewSceneAddedObservable: Observable<Scene>;
  42112. /**
  42113. * Gets the list of created postprocesses
  42114. */
  42115. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42116. /**
  42117. * Gets a boolean indicating if the pointer is currently locked
  42118. */
  42119. isPointerLock: boolean;
  42120. /**
  42121. * Observable event triggered each time the rendering canvas is resized
  42122. */
  42123. onResizeObservable: Observable<Engine>;
  42124. /**
  42125. * Observable event triggered each time the canvas loses focus
  42126. */
  42127. onCanvasBlurObservable: Observable<Engine>;
  42128. /**
  42129. * Observable event triggered each time the canvas gains focus
  42130. */
  42131. onCanvasFocusObservable: Observable<Engine>;
  42132. /**
  42133. * Observable event triggered each time the canvas receives pointerout event
  42134. */
  42135. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42136. /**
  42137. * Observable raised when the engine begins a new frame
  42138. */
  42139. onBeginFrameObservable: Observable<Engine>;
  42140. /**
  42141. * If set, will be used to request the next animation frame for the render loop
  42142. */
  42143. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42144. /**
  42145. * Observable raised when the engine ends the current frame
  42146. */
  42147. onEndFrameObservable: Observable<Engine>;
  42148. /**
  42149. * Observable raised when the engine is about to compile a shader
  42150. */
  42151. onBeforeShaderCompilationObservable: Observable<Engine>;
  42152. /**
  42153. * Observable raised when the engine has jsut compiled a shader
  42154. */
  42155. onAfterShaderCompilationObservable: Observable<Engine>;
  42156. /**
  42157. * Gets the audio engine
  42158. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42159. * @ignorenaming
  42160. */
  42161. static audioEngine: IAudioEngine;
  42162. /**
  42163. * Default AudioEngine factory responsible of creating the Audio Engine.
  42164. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42165. */
  42166. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42167. /**
  42168. * Default offline support factory responsible of creating a tool used to store data locally.
  42169. * By default, this will create a Database object if the workload has been embedded.
  42170. */
  42171. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42172. private _loadingScreen;
  42173. private _pointerLockRequested;
  42174. private _rescalePostProcess;
  42175. private _deterministicLockstep;
  42176. private _lockstepMaxSteps;
  42177. private _timeStep;
  42178. protected get _supportsHardwareTextureRescaling(): boolean;
  42179. private _fps;
  42180. private _deltaTime;
  42181. /** @hidden */
  42182. _drawCalls: PerfCounter;
  42183. /** 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 */
  42184. canvasTabIndex: number;
  42185. /**
  42186. * Turn this value on if you want to pause FPS computation when in background
  42187. */
  42188. disablePerformanceMonitorInBackground: boolean;
  42189. private _performanceMonitor;
  42190. /**
  42191. * Gets the performance monitor attached to this engine
  42192. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42193. */
  42194. get performanceMonitor(): PerformanceMonitor;
  42195. private _onFocus;
  42196. private _onBlur;
  42197. private _onCanvasPointerOut;
  42198. private _onCanvasBlur;
  42199. private _onCanvasFocus;
  42200. private _onFullscreenChange;
  42201. private _onPointerLockChange;
  42202. /**
  42203. * Gets the HTML element used to attach event listeners
  42204. * @returns a HTML element
  42205. */
  42206. getInputElement(): Nullable<HTMLElement>;
  42207. /**
  42208. * Creates a new engine
  42209. * @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
  42210. * @param antialias defines enable antialiasing (default: false)
  42211. * @param options defines further options to be sent to the getContext() function
  42212. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42213. */
  42214. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42215. /**
  42216. * Gets current aspect ratio
  42217. * @param viewportOwner defines the camera to use to get the aspect ratio
  42218. * @param useScreen defines if screen size must be used (or the current render target if any)
  42219. * @returns a number defining the aspect ratio
  42220. */
  42221. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42222. /**
  42223. * Gets current screen aspect ratio
  42224. * @returns a number defining the aspect ratio
  42225. */
  42226. getScreenAspectRatio(): number;
  42227. /**
  42228. * Gets the client rect of the HTML canvas attached with the current webGL context
  42229. * @returns a client rectanglee
  42230. */
  42231. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42232. /**
  42233. * Gets the client rect of the HTML element used for events
  42234. * @returns a client rectanglee
  42235. */
  42236. getInputElementClientRect(): Nullable<ClientRect>;
  42237. /**
  42238. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42239. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42240. * @returns true if engine is in deterministic lock step mode
  42241. */
  42242. isDeterministicLockStep(): boolean;
  42243. /**
  42244. * Gets the max steps when engine is running in deterministic lock step
  42245. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42246. * @returns the max steps
  42247. */
  42248. getLockstepMaxSteps(): number;
  42249. /**
  42250. * Returns the time in ms between steps when using deterministic lock step.
  42251. * @returns time step in (ms)
  42252. */
  42253. getTimeStep(): number;
  42254. /**
  42255. * Force the mipmap generation for the given render target texture
  42256. * @param texture defines the render target texture to use
  42257. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42258. */
  42259. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42260. /** States */
  42261. /**
  42262. * Set various states to the webGL context
  42263. * @param culling defines backface culling state
  42264. * @param zOffset defines the value to apply to zOffset (0 by default)
  42265. * @param force defines if states must be applied even if cache is up to date
  42266. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42267. */
  42268. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42269. /**
  42270. * Set the z offset to apply to current rendering
  42271. * @param value defines the offset to apply
  42272. */
  42273. setZOffset(value: number): void;
  42274. /**
  42275. * Gets the current value of the zOffset
  42276. * @returns the current zOffset state
  42277. */
  42278. getZOffset(): number;
  42279. /**
  42280. * Enable or disable depth buffering
  42281. * @param enable defines the state to set
  42282. */
  42283. setDepthBuffer(enable: boolean): void;
  42284. /**
  42285. * Gets a boolean indicating if depth writing is enabled
  42286. * @returns the current depth writing state
  42287. */
  42288. getDepthWrite(): boolean;
  42289. /**
  42290. * Enable or disable depth writing
  42291. * @param enable defines the state to set
  42292. */
  42293. setDepthWrite(enable: boolean): void;
  42294. /**
  42295. * Gets a boolean indicating if stencil buffer is enabled
  42296. * @returns the current stencil buffer state
  42297. */
  42298. getStencilBuffer(): boolean;
  42299. /**
  42300. * Enable or disable the stencil buffer
  42301. * @param enable defines if the stencil buffer must be enabled or disabled
  42302. */
  42303. setStencilBuffer(enable: boolean): void;
  42304. /**
  42305. * Gets the current stencil mask
  42306. * @returns a number defining the new stencil mask to use
  42307. */
  42308. getStencilMask(): number;
  42309. /**
  42310. * Sets the current stencil mask
  42311. * @param mask defines the new stencil mask to use
  42312. */
  42313. setStencilMask(mask: number): void;
  42314. /**
  42315. * Gets the current stencil function
  42316. * @returns a number defining the stencil function to use
  42317. */
  42318. getStencilFunction(): number;
  42319. /**
  42320. * Gets the current stencil reference value
  42321. * @returns a number defining the stencil reference value to use
  42322. */
  42323. getStencilFunctionReference(): number;
  42324. /**
  42325. * Gets the current stencil mask
  42326. * @returns a number defining the stencil mask to use
  42327. */
  42328. getStencilFunctionMask(): number;
  42329. /**
  42330. * Sets the current stencil function
  42331. * @param stencilFunc defines the new stencil function to use
  42332. */
  42333. setStencilFunction(stencilFunc: number): void;
  42334. /**
  42335. * Sets the current stencil reference
  42336. * @param reference defines the new stencil reference to use
  42337. */
  42338. setStencilFunctionReference(reference: number): void;
  42339. /**
  42340. * Sets the current stencil mask
  42341. * @param mask defines the new stencil mask to use
  42342. */
  42343. setStencilFunctionMask(mask: number): void;
  42344. /**
  42345. * Gets the current stencil operation when stencil fails
  42346. * @returns a number defining stencil operation to use when stencil fails
  42347. */
  42348. getStencilOperationFail(): number;
  42349. /**
  42350. * Gets the current stencil operation when depth fails
  42351. * @returns a number defining stencil operation to use when depth fails
  42352. */
  42353. getStencilOperationDepthFail(): number;
  42354. /**
  42355. * Gets the current stencil operation when stencil passes
  42356. * @returns a number defining stencil operation to use when stencil passes
  42357. */
  42358. getStencilOperationPass(): number;
  42359. /**
  42360. * Sets the stencil operation to use when stencil fails
  42361. * @param operation defines the stencil operation to use when stencil fails
  42362. */
  42363. setStencilOperationFail(operation: number): void;
  42364. /**
  42365. * Sets the stencil operation to use when depth fails
  42366. * @param operation defines the stencil operation to use when depth fails
  42367. */
  42368. setStencilOperationDepthFail(operation: number): void;
  42369. /**
  42370. * Sets the stencil operation to use when stencil passes
  42371. * @param operation defines the stencil operation to use when stencil passes
  42372. */
  42373. setStencilOperationPass(operation: number): void;
  42374. /**
  42375. * Sets a boolean indicating if the dithering state is enabled or disabled
  42376. * @param value defines the dithering state
  42377. */
  42378. setDitheringState(value: boolean): void;
  42379. /**
  42380. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42381. * @param value defines the rasterizer state
  42382. */
  42383. setRasterizerState(value: boolean): void;
  42384. /**
  42385. * Gets the current depth function
  42386. * @returns a number defining the depth function
  42387. */
  42388. getDepthFunction(): Nullable<number>;
  42389. /**
  42390. * Sets the current depth function
  42391. * @param depthFunc defines the function to use
  42392. */
  42393. setDepthFunction(depthFunc: number): void;
  42394. /**
  42395. * Sets the current depth function to GREATER
  42396. */
  42397. setDepthFunctionToGreater(): void;
  42398. /**
  42399. * Sets the current depth function to GEQUAL
  42400. */
  42401. setDepthFunctionToGreaterOrEqual(): void;
  42402. /**
  42403. * Sets the current depth function to LESS
  42404. */
  42405. setDepthFunctionToLess(): void;
  42406. /**
  42407. * Sets the current depth function to LEQUAL
  42408. */
  42409. setDepthFunctionToLessOrEqual(): void;
  42410. private _cachedStencilBuffer;
  42411. private _cachedStencilFunction;
  42412. private _cachedStencilMask;
  42413. private _cachedStencilOperationPass;
  42414. private _cachedStencilOperationFail;
  42415. private _cachedStencilOperationDepthFail;
  42416. private _cachedStencilReference;
  42417. /**
  42418. * Caches the the state of the stencil buffer
  42419. */
  42420. cacheStencilState(): void;
  42421. /**
  42422. * Restores the state of the stencil buffer
  42423. */
  42424. restoreStencilState(): void;
  42425. /**
  42426. * Directly set the WebGL Viewport
  42427. * @param x defines the x coordinate of the viewport (in screen space)
  42428. * @param y defines the y coordinate of the viewport (in screen space)
  42429. * @param width defines the width of the viewport (in screen space)
  42430. * @param height defines the height of the viewport (in screen space)
  42431. * @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
  42432. */
  42433. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42434. /**
  42435. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42436. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42437. * @param y defines the y-coordinate of the corner of the clear rectangle
  42438. * @param width defines the width of the clear rectangle
  42439. * @param height defines the height of the clear rectangle
  42440. * @param clearColor defines the clear color
  42441. */
  42442. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42443. /**
  42444. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42445. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42446. * @param y defines the y-coordinate of the corner of the clear rectangle
  42447. * @param width defines the width of the clear rectangle
  42448. * @param height defines the height of the clear rectangle
  42449. */
  42450. enableScissor(x: number, y: number, width: number, height: number): void;
  42451. /**
  42452. * Disable previously set scissor test rectangle
  42453. */
  42454. disableScissor(): void;
  42455. protected _reportDrawCall(): void;
  42456. /**
  42457. * Initializes a webVR display and starts listening to display change events
  42458. * The onVRDisplayChangedObservable will be notified upon these changes
  42459. * @returns The onVRDisplayChangedObservable
  42460. */
  42461. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42462. /** @hidden */
  42463. _prepareVRComponent(): void;
  42464. /** @hidden */
  42465. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42466. /** @hidden */
  42467. _submitVRFrame(): void;
  42468. /**
  42469. * Call this function to leave webVR mode
  42470. * Will do nothing if webVR is not supported or if there is no webVR device
  42471. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42472. */
  42473. disableVR(): void;
  42474. /**
  42475. * Gets a boolean indicating that the system is in VR mode and is presenting
  42476. * @returns true if VR mode is engaged
  42477. */
  42478. isVRPresenting(): boolean;
  42479. /** @hidden */
  42480. _requestVRFrame(): void;
  42481. /** @hidden */
  42482. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42483. /**
  42484. * Gets the source code of the vertex shader associated with a specific webGL program
  42485. * @param program defines the program to use
  42486. * @returns a string containing the source code of the vertex shader associated with the program
  42487. */
  42488. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42489. /**
  42490. * Gets the source code of the fragment shader associated with a specific webGL program
  42491. * @param program defines the program to use
  42492. * @returns a string containing the source code of the fragment shader associated with the program
  42493. */
  42494. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42495. /**
  42496. * Sets a depth stencil texture from a render target to the according uniform.
  42497. * @param channel The texture channel
  42498. * @param uniform The uniform to set
  42499. * @param texture The render target texture containing the depth stencil texture to apply
  42500. */
  42501. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42502. /**
  42503. * Sets a texture to the webGL context from a postprocess
  42504. * @param channel defines the channel to use
  42505. * @param postProcess defines the source postprocess
  42506. */
  42507. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42508. /**
  42509. * Binds the output of the passed in post process to the texture channel specified
  42510. * @param channel The channel the texture should be bound to
  42511. * @param postProcess The post process which's output should be bound
  42512. */
  42513. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42514. protected _rebuildBuffers(): void;
  42515. /** @hidden */
  42516. _renderFrame(): void;
  42517. _renderLoop(): void;
  42518. /** @hidden */
  42519. _renderViews(): boolean;
  42520. /**
  42521. * Toggle full screen mode
  42522. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42523. */
  42524. switchFullscreen(requestPointerLock: boolean): void;
  42525. /**
  42526. * Enters full screen mode
  42527. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42528. */
  42529. enterFullscreen(requestPointerLock: boolean): void;
  42530. /**
  42531. * Exits full screen mode
  42532. */
  42533. exitFullscreen(): void;
  42534. /**
  42535. * Enters Pointerlock mode
  42536. */
  42537. enterPointerlock(): void;
  42538. /**
  42539. * Exits Pointerlock mode
  42540. */
  42541. exitPointerlock(): void;
  42542. /**
  42543. * Begin a new frame
  42544. */
  42545. beginFrame(): void;
  42546. /**
  42547. * Enf the current frame
  42548. */
  42549. endFrame(): void;
  42550. resize(): void;
  42551. /**
  42552. * Force a specific size of the canvas
  42553. * @param width defines the new canvas' width
  42554. * @param height defines the new canvas' height
  42555. * @returns true if the size was changed
  42556. */
  42557. setSize(width: number, height: number): boolean;
  42558. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42559. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42560. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42561. _releaseTexture(texture: InternalTexture): void;
  42562. /**
  42563. * @hidden
  42564. * Rescales a texture
  42565. * @param source input texutre
  42566. * @param destination destination texture
  42567. * @param scene scene to use to render the resize
  42568. * @param internalFormat format to use when resizing
  42569. * @param onComplete callback to be called when resize has completed
  42570. */
  42571. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42572. /**
  42573. * Gets the current framerate
  42574. * @returns a number representing the framerate
  42575. */
  42576. getFps(): number;
  42577. /**
  42578. * Gets the time spent between current and previous frame
  42579. * @returns a number representing the delta time in ms
  42580. */
  42581. getDeltaTime(): number;
  42582. private _measureFps;
  42583. /** @hidden */
  42584. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42585. /**
  42586. * Updates the sample count of a render target texture
  42587. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42588. * @param texture defines the texture to update
  42589. * @param samples defines the sample count to set
  42590. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42591. */
  42592. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42593. /**
  42594. * Updates a depth texture Comparison Mode and Function.
  42595. * If the comparison Function is equal to 0, the mode will be set to none.
  42596. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42597. * @param texture The texture to set the comparison function for
  42598. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42599. */
  42600. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42601. /**
  42602. * Creates a webGL buffer to use with instanciation
  42603. * @param capacity defines the size of the buffer
  42604. * @returns the webGL buffer
  42605. */
  42606. createInstancesBuffer(capacity: number): DataBuffer;
  42607. /**
  42608. * Delete a webGL buffer used with instanciation
  42609. * @param buffer defines the webGL buffer to delete
  42610. */
  42611. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42612. private _clientWaitAsync;
  42613. /** @hidden */
  42614. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42615. dispose(): void;
  42616. private _disableTouchAction;
  42617. /**
  42618. * Display the loading screen
  42619. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42620. */
  42621. displayLoadingUI(): void;
  42622. /**
  42623. * Hide the loading screen
  42624. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42625. */
  42626. hideLoadingUI(): void;
  42627. /**
  42628. * Gets the current loading screen object
  42629. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42630. */
  42631. get loadingScreen(): ILoadingScreen;
  42632. /**
  42633. * Sets the current loading screen object
  42634. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42635. */
  42636. set loadingScreen(loadingScreen: ILoadingScreen);
  42637. /**
  42638. * Sets the current loading screen text
  42639. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42640. */
  42641. set loadingUIText(text: string);
  42642. /**
  42643. * Sets the current loading screen background color
  42644. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42645. */
  42646. set loadingUIBackgroundColor(color: string);
  42647. /** Pointerlock and fullscreen */
  42648. /**
  42649. * Ask the browser to promote the current element to pointerlock mode
  42650. * @param element defines the DOM element to promote
  42651. */
  42652. static _RequestPointerlock(element: HTMLElement): void;
  42653. /**
  42654. * Asks the browser to exit pointerlock mode
  42655. */
  42656. static _ExitPointerlock(): void;
  42657. /**
  42658. * Ask the browser to promote the current element to fullscreen rendering mode
  42659. * @param element defines the DOM element to promote
  42660. */
  42661. static _RequestFullscreen(element: HTMLElement): void;
  42662. /**
  42663. * Asks the browser to exit fullscreen mode
  42664. */
  42665. static _ExitFullscreen(): void;
  42666. }
  42667. }
  42668. declare module "babylonjs/Engines/engineStore" {
  42669. import { Nullable } from "babylonjs/types";
  42670. import { Engine } from "babylonjs/Engines/engine";
  42671. import { Scene } from "babylonjs/scene";
  42672. /**
  42673. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42674. * during the life time of the application.
  42675. */
  42676. export class EngineStore {
  42677. /** Gets the list of created engines */
  42678. static Instances: import("babylonjs/Engines/engine").Engine[];
  42679. /** @hidden */
  42680. static _LastCreatedScene: Nullable<Scene>;
  42681. /**
  42682. * Gets the latest created engine
  42683. */
  42684. static get LastCreatedEngine(): Nullable<Engine>;
  42685. /**
  42686. * Gets the latest created scene
  42687. */
  42688. static get LastCreatedScene(): Nullable<Scene>;
  42689. /**
  42690. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42691. * @ignorenaming
  42692. */
  42693. static UseFallbackTexture: boolean;
  42694. /**
  42695. * Texture content used if a texture cannot loaded
  42696. * @ignorenaming
  42697. */
  42698. static FallbackTexture: string;
  42699. }
  42700. }
  42701. declare module "babylonjs/Misc/promise" {
  42702. /**
  42703. * Helper class that provides a small promise polyfill
  42704. */
  42705. export class PromisePolyfill {
  42706. /**
  42707. * Static function used to check if the polyfill is required
  42708. * If this is the case then the function will inject the polyfill to window.Promise
  42709. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42710. */
  42711. static Apply(force?: boolean): void;
  42712. }
  42713. }
  42714. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42715. /**
  42716. * Interface for screenshot methods with describe argument called `size` as object with options
  42717. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42718. */
  42719. export interface IScreenshotSize {
  42720. /**
  42721. * number in pixels for canvas height
  42722. */
  42723. height?: number;
  42724. /**
  42725. * multiplier allowing render at a higher or lower resolution
  42726. * If value is defined then height and width will be ignored and taken from camera
  42727. */
  42728. precision?: number;
  42729. /**
  42730. * number in pixels for canvas width
  42731. */
  42732. width?: number;
  42733. }
  42734. }
  42735. declare module "babylonjs/Misc/tools" {
  42736. import { Nullable, float } from "babylonjs/types";
  42737. import { DomManagement } from "babylonjs/Misc/domManagement";
  42738. import { WebRequest } from "babylonjs/Misc/webRequest";
  42739. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42740. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42741. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42742. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42743. import { Camera } from "babylonjs/Cameras/camera";
  42744. import { Engine } from "babylonjs/Engines/engine";
  42745. interface IColor4Like {
  42746. r: float;
  42747. g: float;
  42748. b: float;
  42749. a: float;
  42750. }
  42751. /**
  42752. * Class containing a set of static utilities functions
  42753. */
  42754. export class Tools {
  42755. /**
  42756. * Gets or sets the base URL to use to load assets
  42757. */
  42758. static get BaseUrl(): string;
  42759. static set BaseUrl(value: string);
  42760. /**
  42761. * Enable/Disable Custom HTTP Request Headers globally.
  42762. * default = false
  42763. * @see CustomRequestHeaders
  42764. */
  42765. static UseCustomRequestHeaders: boolean;
  42766. /**
  42767. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42768. * i.e. when loading files, where the server/service expects an Authorization header
  42769. */
  42770. static CustomRequestHeaders: {
  42771. [key: string]: string;
  42772. };
  42773. /**
  42774. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42775. */
  42776. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42777. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42778. /**
  42779. * Default behaviour for cors in the application.
  42780. * It can be a string if the expected behavior is identical in the entire app.
  42781. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42782. */
  42783. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42784. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42785. /**
  42786. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42787. * @ignorenaming
  42788. */
  42789. static get UseFallbackTexture(): boolean;
  42790. static set UseFallbackTexture(value: boolean);
  42791. /**
  42792. * Use this object to register external classes like custom textures or material
  42793. * to allow the laoders to instantiate them
  42794. */
  42795. static get RegisteredExternalClasses(): {
  42796. [key: string]: Object;
  42797. };
  42798. static set RegisteredExternalClasses(classes: {
  42799. [key: string]: Object;
  42800. });
  42801. /**
  42802. * Texture content used if a texture cannot loaded
  42803. * @ignorenaming
  42804. */
  42805. static get fallbackTexture(): string;
  42806. static set fallbackTexture(value: string);
  42807. /**
  42808. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42809. * @param u defines the coordinate on X axis
  42810. * @param v defines the coordinate on Y axis
  42811. * @param width defines the width of the source data
  42812. * @param height defines the height of the source data
  42813. * @param pixels defines the source byte array
  42814. * @param color defines the output color
  42815. */
  42816. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42817. /**
  42818. * Interpolates between a and b via alpha
  42819. * @param a The lower value (returned when alpha = 0)
  42820. * @param b The upper value (returned when alpha = 1)
  42821. * @param alpha The interpolation-factor
  42822. * @return The mixed value
  42823. */
  42824. static Mix(a: number, b: number, alpha: number): number;
  42825. /**
  42826. * Tries to instantiate a new object from a given class name
  42827. * @param className defines the class name to instantiate
  42828. * @returns the new object or null if the system was not able to do the instantiation
  42829. */
  42830. static Instantiate(className: string): any;
  42831. /**
  42832. * Provides a slice function that will work even on IE
  42833. * @param data defines the array to slice
  42834. * @param start defines the start of the data (optional)
  42835. * @param end defines the end of the data (optional)
  42836. * @returns the new sliced array
  42837. */
  42838. static Slice<T>(data: T, start?: number, end?: number): T;
  42839. /**
  42840. * Polyfill for setImmediate
  42841. * @param action defines the action to execute after the current execution block
  42842. */
  42843. static SetImmediate(action: () => void): void;
  42844. /**
  42845. * Function indicating if a number is an exponent of 2
  42846. * @param value defines the value to test
  42847. * @returns true if the value is an exponent of 2
  42848. */
  42849. static IsExponentOfTwo(value: number): boolean;
  42850. private static _tmpFloatArray;
  42851. /**
  42852. * Returns the nearest 32-bit single precision float representation of a Number
  42853. * @param value A Number. If the parameter is of a different type, it will get converted
  42854. * to a number or to NaN if it cannot be converted
  42855. * @returns number
  42856. */
  42857. static FloatRound(value: number): number;
  42858. /**
  42859. * Extracts the filename from a path
  42860. * @param path defines the path to use
  42861. * @returns the filename
  42862. */
  42863. static GetFilename(path: string): string;
  42864. /**
  42865. * Extracts the "folder" part of a path (everything before the filename).
  42866. * @param uri The URI to extract the info from
  42867. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42868. * @returns The "folder" part of the path
  42869. */
  42870. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42871. /**
  42872. * Extracts text content from a DOM element hierarchy
  42873. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42874. */
  42875. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42876. /**
  42877. * Convert an angle in radians to degrees
  42878. * @param angle defines the angle to convert
  42879. * @returns the angle in degrees
  42880. */
  42881. static ToDegrees(angle: number): number;
  42882. /**
  42883. * Convert an angle in degrees to radians
  42884. * @param angle defines the angle to convert
  42885. * @returns the angle in radians
  42886. */
  42887. static ToRadians(angle: number): number;
  42888. /**
  42889. * Returns an array if obj is not an array
  42890. * @param obj defines the object to evaluate as an array
  42891. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42892. * @returns either obj directly if obj is an array or a new array containing obj
  42893. */
  42894. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42895. /**
  42896. * Gets the pointer prefix to use
  42897. * @param engine defines the engine we are finding the prefix for
  42898. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42899. */
  42900. static GetPointerPrefix(engine: Engine): string;
  42901. /**
  42902. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42903. * @param url define the url we are trying
  42904. * @param element define the dom element where to configure the cors policy
  42905. */
  42906. static SetCorsBehavior(url: string | string[], element: {
  42907. crossOrigin: string | null;
  42908. }): void;
  42909. /**
  42910. * Removes unwanted characters from an url
  42911. * @param url defines the url to clean
  42912. * @returns the cleaned url
  42913. */
  42914. static CleanUrl(url: string): string;
  42915. /**
  42916. * Gets or sets a function used to pre-process url before using them to load assets
  42917. */
  42918. static get PreprocessUrl(): (url: string) => string;
  42919. static set PreprocessUrl(processor: (url: string) => string);
  42920. /**
  42921. * Loads an image as an HTMLImageElement.
  42922. * @param input url string, ArrayBuffer, or Blob to load
  42923. * @param onLoad callback called when the image successfully loads
  42924. * @param onError callback called when the image fails to load
  42925. * @param offlineProvider offline provider for caching
  42926. * @param mimeType optional mime type
  42927. * @returns the HTMLImageElement of the loaded image
  42928. */
  42929. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42930. /**
  42931. * Loads a file from a url
  42932. * @param url url string, ArrayBuffer, or Blob to load
  42933. * @param onSuccess callback called when the file successfully loads
  42934. * @param onProgress callback called while file is loading (if the server supports this mode)
  42935. * @param offlineProvider defines the offline provider for caching
  42936. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42937. * @param onError callback called when the file fails to load
  42938. * @returns a file request object
  42939. */
  42940. 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;
  42941. /**
  42942. * Loads a file from a url
  42943. * @param url the file url to load
  42944. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42945. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42946. */
  42947. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42948. /**
  42949. * Load a script (identified by an url). When the url returns, the
  42950. * content of this file is added into a new script element, attached to the DOM (body element)
  42951. * @param scriptUrl defines the url of the script to laod
  42952. * @param onSuccess defines the callback called when the script is loaded
  42953. * @param onError defines the callback to call if an error occurs
  42954. * @param scriptId defines the id of the script element
  42955. */
  42956. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42957. /**
  42958. * Load an asynchronous script (identified by an url). When the url returns, the
  42959. * content of this file is added into a new script element, attached to the DOM (body element)
  42960. * @param scriptUrl defines the url of the script to laod
  42961. * @param scriptId defines the id of the script element
  42962. * @returns a promise request object
  42963. */
  42964. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42965. /**
  42966. * Loads a file from a blob
  42967. * @param fileToLoad defines the blob to use
  42968. * @param callback defines the callback to call when data is loaded
  42969. * @param progressCallback defines the callback to call during loading process
  42970. * @returns a file request object
  42971. */
  42972. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42973. /**
  42974. * Reads a file from a File object
  42975. * @param file defines the file to load
  42976. * @param onSuccess defines the callback to call when data is loaded
  42977. * @param onProgress defines the callback to call during loading process
  42978. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42979. * @param onError defines the callback to call when an error occurs
  42980. * @returns a file request object
  42981. */
  42982. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42983. /**
  42984. * Creates a data url from a given string content
  42985. * @param content defines the content to convert
  42986. * @returns the new data url link
  42987. */
  42988. static FileAsURL(content: string): string;
  42989. /**
  42990. * Format the given number to a specific decimal format
  42991. * @param value defines the number to format
  42992. * @param decimals defines the number of decimals to use
  42993. * @returns the formatted string
  42994. */
  42995. static Format(value: number, decimals?: number): string;
  42996. /**
  42997. * Tries to copy an object by duplicating every property
  42998. * @param source defines the source object
  42999. * @param destination defines the target object
  43000. * @param doNotCopyList defines a list of properties to avoid
  43001. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43002. */
  43003. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43004. /**
  43005. * Gets a boolean indicating if the given object has no own property
  43006. * @param obj defines the object to test
  43007. * @returns true if object has no own property
  43008. */
  43009. static IsEmpty(obj: any): boolean;
  43010. /**
  43011. * Function used to register events at window level
  43012. * @param windowElement defines the Window object to use
  43013. * @param events defines the events to register
  43014. */
  43015. static RegisterTopRootEvents(windowElement: Window, events: {
  43016. name: string;
  43017. handler: Nullable<(e: FocusEvent) => any>;
  43018. }[]): void;
  43019. /**
  43020. * Function used to unregister events from window level
  43021. * @param windowElement defines the Window object to use
  43022. * @param events defines the events to unregister
  43023. */
  43024. static UnregisterTopRootEvents(windowElement: Window, events: {
  43025. name: string;
  43026. handler: Nullable<(e: FocusEvent) => any>;
  43027. }[]): void;
  43028. /**
  43029. * @ignore
  43030. */
  43031. static _ScreenshotCanvas: HTMLCanvasElement;
  43032. /**
  43033. * Dumps the current bound framebuffer
  43034. * @param width defines the rendering width
  43035. * @param height defines the rendering height
  43036. * @param engine defines the hosting engine
  43037. * @param successCallback defines the callback triggered once the data are available
  43038. * @param mimeType defines the mime type of the result
  43039. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43040. */
  43041. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43042. /**
  43043. * Converts the canvas data to blob.
  43044. * This acts as a polyfill for browsers not supporting the to blob function.
  43045. * @param canvas Defines the canvas to extract the data from
  43046. * @param successCallback Defines the callback triggered once the data are available
  43047. * @param mimeType Defines the mime type of the result
  43048. */
  43049. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43050. /**
  43051. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43052. * @param successCallback defines the callback triggered once the data are available
  43053. * @param mimeType defines the mime type of the result
  43054. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43055. */
  43056. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43057. /**
  43058. * Downloads a blob in the browser
  43059. * @param blob defines the blob to download
  43060. * @param fileName defines the name of the downloaded file
  43061. */
  43062. static Download(blob: Blob, fileName: string): void;
  43063. /**
  43064. * Captures a screenshot of the current rendering
  43065. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43066. * @param engine defines the rendering engine
  43067. * @param camera defines the source camera
  43068. * @param size This parameter can be set to a single number or to an object with the
  43069. * following (optional) properties: precision, width, height. If a single number is passed,
  43070. * it will be used for both width and height. If an object is passed, the screenshot size
  43071. * will be derived from the parameters. The precision property is a multiplier allowing
  43072. * rendering at a higher or lower resolution
  43073. * @param successCallback defines the callback receives a single parameter which contains the
  43074. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43075. * src parameter of an <img> to display it
  43076. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43077. * Check your browser for supported MIME types
  43078. */
  43079. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43080. /**
  43081. * Captures a screenshot of the current rendering
  43082. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43083. * @param engine defines the rendering engine
  43084. * @param camera defines the source camera
  43085. * @param size This parameter can be set to a single number or to an object with the
  43086. * following (optional) properties: precision, width, height. If a single number is passed,
  43087. * it will be used for both width and height. If an object is passed, the screenshot size
  43088. * will be derived from the parameters. The precision property is a multiplier allowing
  43089. * rendering at a higher or lower resolution
  43090. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43091. * Check your browser for supported MIME types
  43092. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43093. * to the src parameter of an <img> to display it
  43094. */
  43095. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43096. /**
  43097. * Generates an image screenshot from the specified camera.
  43098. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43099. * @param engine The engine to use for rendering
  43100. * @param camera The camera to use for rendering
  43101. * @param size This parameter can be set to a single number or to an object with the
  43102. * following (optional) properties: precision, width, height. If a single number is passed,
  43103. * it will be used for both width and height. If an object is passed, the screenshot size
  43104. * will be derived from the parameters. The precision property is a multiplier allowing
  43105. * rendering at a higher or lower resolution
  43106. * @param successCallback The callback receives a single parameter which contains the
  43107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43108. * src parameter of an <img> to display it
  43109. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43110. * Check your browser for supported MIME types
  43111. * @param samples Texture samples (default: 1)
  43112. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43113. * @param fileName A name for for the downloaded file.
  43114. */
  43115. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43116. /**
  43117. * Generates an image screenshot from the specified camera.
  43118. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43119. * @param engine The engine to use for rendering
  43120. * @param camera The camera to use for rendering
  43121. * @param size This parameter can be set to a single number or to an object with the
  43122. * following (optional) properties: precision, width, height. If a single number is passed,
  43123. * it will be used for both width and height. If an object is passed, the screenshot size
  43124. * will be derived from the parameters. The precision property is a multiplier allowing
  43125. * rendering at a higher or lower resolution
  43126. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43127. * Check your browser for supported MIME types
  43128. * @param samples Texture samples (default: 1)
  43129. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43130. * @param fileName A name for for the downloaded file.
  43131. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43132. * to the src parameter of an <img> to display it
  43133. */
  43134. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43135. /**
  43136. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43137. * Be aware Math.random() could cause collisions, but:
  43138. * "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"
  43139. * @returns a pseudo random id
  43140. */
  43141. static RandomId(): string;
  43142. /**
  43143. * Test if the given uri is a base64 string
  43144. * @param uri The uri to test
  43145. * @return True if the uri is a base64 string or false otherwise
  43146. */
  43147. static IsBase64(uri: string): boolean;
  43148. /**
  43149. * Decode the given base64 uri.
  43150. * @param uri The uri to decode
  43151. * @return The decoded base64 data.
  43152. */
  43153. static DecodeBase64(uri: string): ArrayBuffer;
  43154. /**
  43155. * Gets the absolute url.
  43156. * @param url the input url
  43157. * @return the absolute url
  43158. */
  43159. static GetAbsoluteUrl(url: string): string;
  43160. /**
  43161. * No log
  43162. */
  43163. static readonly NoneLogLevel: number;
  43164. /**
  43165. * Only message logs
  43166. */
  43167. static readonly MessageLogLevel: number;
  43168. /**
  43169. * Only warning logs
  43170. */
  43171. static readonly WarningLogLevel: number;
  43172. /**
  43173. * Only error logs
  43174. */
  43175. static readonly ErrorLogLevel: number;
  43176. /**
  43177. * All logs
  43178. */
  43179. static readonly AllLogLevel: number;
  43180. /**
  43181. * Gets a value indicating the number of loading errors
  43182. * @ignorenaming
  43183. */
  43184. static get errorsCount(): number;
  43185. /**
  43186. * Callback called when a new log is added
  43187. */
  43188. static OnNewCacheEntry: (entry: string) => void;
  43189. /**
  43190. * Log a message to the console
  43191. * @param message defines the message to log
  43192. */
  43193. static Log(message: string): void;
  43194. /**
  43195. * Write a warning message to the console
  43196. * @param message defines the message to log
  43197. */
  43198. static Warn(message: string): void;
  43199. /**
  43200. * Write an error message to the console
  43201. * @param message defines the message to log
  43202. */
  43203. static Error(message: string): void;
  43204. /**
  43205. * Gets current log cache (list of logs)
  43206. */
  43207. static get LogCache(): string;
  43208. /**
  43209. * Clears the log cache
  43210. */
  43211. static ClearLogCache(): void;
  43212. /**
  43213. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43214. */
  43215. static set LogLevels(level: number);
  43216. /**
  43217. * Checks if the window object exists
  43218. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43219. */
  43220. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43221. /**
  43222. * No performance log
  43223. */
  43224. static readonly PerformanceNoneLogLevel: number;
  43225. /**
  43226. * Use user marks to log performance
  43227. */
  43228. static readonly PerformanceUserMarkLogLevel: number;
  43229. /**
  43230. * Log performance to the console
  43231. */
  43232. static readonly PerformanceConsoleLogLevel: number;
  43233. private static _performance;
  43234. /**
  43235. * Sets the current performance log level
  43236. */
  43237. static set PerformanceLogLevel(level: number);
  43238. private static _StartPerformanceCounterDisabled;
  43239. private static _EndPerformanceCounterDisabled;
  43240. private static _StartUserMark;
  43241. private static _EndUserMark;
  43242. private static _StartPerformanceConsole;
  43243. private static _EndPerformanceConsole;
  43244. /**
  43245. * Starts a performance counter
  43246. */
  43247. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43248. /**
  43249. * Ends a specific performance coutner
  43250. */
  43251. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43252. /**
  43253. * Gets either window.performance.now() if supported or Date.now() else
  43254. */
  43255. static get Now(): number;
  43256. /**
  43257. * This method will return the name of the class used to create the instance of the given object.
  43258. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43259. * @param object the object to get the class name from
  43260. * @param isType defines if the object is actually a type
  43261. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43262. */
  43263. static GetClassName(object: any, isType?: boolean): string;
  43264. /**
  43265. * Gets the first element of an array satisfying a given predicate
  43266. * @param array defines the array to browse
  43267. * @param predicate defines the predicate to use
  43268. * @returns null if not found or the element
  43269. */
  43270. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43271. /**
  43272. * This method will return the name of the full name of the class, including its owning module (if any).
  43273. * 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).
  43274. * @param object the object to get the class name from
  43275. * @param isType defines if the object is actually a type
  43276. * @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.
  43277. * @ignorenaming
  43278. */
  43279. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43280. /**
  43281. * Returns a promise that resolves after the given amount of time.
  43282. * @param delay Number of milliseconds to delay
  43283. * @returns Promise that resolves after the given amount of time
  43284. */
  43285. static DelayAsync(delay: number): Promise<void>;
  43286. /**
  43287. * Utility function to detect if the current user agent is Safari
  43288. * @returns whether or not the current user agent is safari
  43289. */
  43290. static IsSafari(): boolean;
  43291. }
  43292. /**
  43293. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43294. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43295. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43296. * @param name The name of the class, case should be preserved
  43297. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43298. */
  43299. export function className(name: string, module?: string): (target: Object) => void;
  43300. /**
  43301. * An implementation of a loop for asynchronous functions.
  43302. */
  43303. export class AsyncLoop {
  43304. /**
  43305. * Defines the number of iterations for the loop
  43306. */
  43307. iterations: number;
  43308. /**
  43309. * Defines the current index of the loop.
  43310. */
  43311. index: number;
  43312. private _done;
  43313. private _fn;
  43314. private _successCallback;
  43315. /**
  43316. * Constructor.
  43317. * @param iterations the number of iterations.
  43318. * @param func the function to run each iteration
  43319. * @param successCallback the callback that will be called upon succesful execution
  43320. * @param offset starting offset.
  43321. */
  43322. constructor(
  43323. /**
  43324. * Defines the number of iterations for the loop
  43325. */
  43326. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43327. /**
  43328. * Execute the next iteration. Must be called after the last iteration was finished.
  43329. */
  43330. executeNext(): void;
  43331. /**
  43332. * Break the loop and run the success callback.
  43333. */
  43334. breakLoop(): void;
  43335. /**
  43336. * Create and run an async loop.
  43337. * @param iterations the number of iterations.
  43338. * @param fn the function to run each iteration
  43339. * @param successCallback the callback that will be called upon succesful execution
  43340. * @param offset starting offset.
  43341. * @returns the created async loop object
  43342. */
  43343. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43344. /**
  43345. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43346. * @param iterations total number of iterations
  43347. * @param syncedIterations number of synchronous iterations in each async iteration.
  43348. * @param fn the function to call each iteration.
  43349. * @param callback a success call back that will be called when iterating stops.
  43350. * @param breakFunction a break condition (optional)
  43351. * @param timeout timeout settings for the setTimeout function. default - 0.
  43352. * @returns the created async loop object
  43353. */
  43354. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43355. }
  43356. }
  43357. declare module "babylonjs/Misc/stringDictionary" {
  43358. import { Nullable } from "babylonjs/types";
  43359. /**
  43360. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43361. * The underlying implementation relies on an associative array to ensure the best performances.
  43362. * The value can be anything including 'null' but except 'undefined'
  43363. */
  43364. export class StringDictionary<T> {
  43365. /**
  43366. * This will clear this dictionary and copy the content from the 'source' one.
  43367. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43368. * @param source the dictionary to take the content from and copy to this dictionary
  43369. */
  43370. copyFrom(source: StringDictionary<T>): void;
  43371. /**
  43372. * Get a value based from its key
  43373. * @param key the given key to get the matching value from
  43374. * @return the value if found, otherwise undefined is returned
  43375. */
  43376. get(key: string): T | undefined;
  43377. /**
  43378. * Get a value from its key or add it if it doesn't exist.
  43379. * This method will ensure you that a given key/data will be present in the dictionary.
  43380. * @param key the given key to get the matching value from
  43381. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43382. * The factory will only be invoked if there's no data for the given key.
  43383. * @return the value corresponding to the key.
  43384. */
  43385. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43386. /**
  43387. * Get a value from its key if present in the dictionary otherwise add it
  43388. * @param key the key to get the value from
  43389. * @param val if there's no such key/value pair in the dictionary add it with this value
  43390. * @return the value corresponding to the key
  43391. */
  43392. getOrAdd(key: string, val: T): T;
  43393. /**
  43394. * Check if there's a given key in the dictionary
  43395. * @param key the key to check for
  43396. * @return true if the key is present, false otherwise
  43397. */
  43398. contains(key: string): boolean;
  43399. /**
  43400. * Add a new key and its corresponding value
  43401. * @param key the key to add
  43402. * @param value the value corresponding to the key
  43403. * @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
  43404. */
  43405. add(key: string, value: T): boolean;
  43406. /**
  43407. * Update a specific value associated to a key
  43408. * @param key defines the key to use
  43409. * @param value defines the value to store
  43410. * @returns true if the value was updated (or false if the key was not found)
  43411. */
  43412. set(key: string, value: T): boolean;
  43413. /**
  43414. * Get the element of the given key and remove it from the dictionary
  43415. * @param key defines the key to search
  43416. * @returns the value associated with the key or null if not found
  43417. */
  43418. getAndRemove(key: string): Nullable<T>;
  43419. /**
  43420. * Remove a key/value from the dictionary.
  43421. * @param key the key to remove
  43422. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43423. */
  43424. remove(key: string): boolean;
  43425. /**
  43426. * Clear the whole content of the dictionary
  43427. */
  43428. clear(): void;
  43429. /**
  43430. * Gets the current count
  43431. */
  43432. get count(): number;
  43433. /**
  43434. * Execute a callback on each key/val of the dictionary.
  43435. * Note that you can remove any element in this dictionary in the callback implementation
  43436. * @param callback the callback to execute on a given key/value pair
  43437. */
  43438. forEach(callback: (key: string, val: T) => void): void;
  43439. /**
  43440. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43441. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43442. * Note that you can remove any element in this dictionary in the callback implementation
  43443. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43444. * @returns the first item
  43445. */
  43446. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43447. private _count;
  43448. private _data;
  43449. }
  43450. }
  43451. declare module "babylonjs/Collisions/collisionCoordinator" {
  43452. import { Nullable } from "babylonjs/types";
  43453. import { Scene } from "babylonjs/scene";
  43454. import { Vector3 } from "babylonjs/Maths/math.vector";
  43455. import { Collider } from "babylonjs/Collisions/collider";
  43456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43457. /** @hidden */
  43458. export interface ICollisionCoordinator {
  43459. createCollider(): Collider;
  43460. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43461. init(scene: Scene): void;
  43462. }
  43463. /** @hidden */
  43464. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43465. private _scene;
  43466. private _scaledPosition;
  43467. private _scaledVelocity;
  43468. private _finalPosition;
  43469. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43470. createCollider(): Collider;
  43471. init(scene: Scene): void;
  43472. private _collideWithWorld;
  43473. }
  43474. }
  43475. declare module "babylonjs/Inputs/scene.inputManager" {
  43476. import { Nullable } from "babylonjs/types";
  43477. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43478. import { Vector2 } from "babylonjs/Maths/math.vector";
  43479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43480. import { Scene } from "babylonjs/scene";
  43481. /**
  43482. * Class used to manage all inputs for the scene.
  43483. */
  43484. export class InputManager {
  43485. /** The distance in pixel that you have to move to prevent some events */
  43486. static DragMovementThreshold: number;
  43487. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43488. static LongPressDelay: number;
  43489. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43490. static DoubleClickDelay: number;
  43491. /** If you need to check double click without raising a single click at first click, enable this flag */
  43492. static ExclusiveDoubleClickMode: boolean;
  43493. /** 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. */
  43494. private _alreadyAttached;
  43495. private _wheelEventName;
  43496. private _onPointerMove;
  43497. private _onPointerDown;
  43498. private _onPointerUp;
  43499. private _initClickEvent;
  43500. private _initActionManager;
  43501. private _delayedSimpleClick;
  43502. private _delayedSimpleClickTimeout;
  43503. private _previousDelayedSimpleClickTimeout;
  43504. private _meshPickProceed;
  43505. private _previousButtonPressed;
  43506. private _currentPickResult;
  43507. private _previousPickResult;
  43508. private _totalPointersPressed;
  43509. private _doubleClickOccured;
  43510. private _pointerOverMesh;
  43511. private _pickedDownMesh;
  43512. private _pickedUpMesh;
  43513. private _pointerX;
  43514. private _pointerY;
  43515. private _unTranslatedPointerX;
  43516. private _unTranslatedPointerY;
  43517. private _startingPointerPosition;
  43518. private _previousStartingPointerPosition;
  43519. private _startingPointerTime;
  43520. private _previousStartingPointerTime;
  43521. private _pointerCaptures;
  43522. private _meshUnderPointerId;
  43523. private _onKeyDown;
  43524. private _onKeyUp;
  43525. private _onCanvasFocusObserver;
  43526. private _onCanvasBlurObserver;
  43527. private _scene;
  43528. /**
  43529. * Creates a new InputManager
  43530. * @param scene defines the hosting scene
  43531. */
  43532. constructor(scene: Scene);
  43533. /**
  43534. * Gets the mesh that is currently under the pointer
  43535. */
  43536. get meshUnderPointer(): Nullable<AbstractMesh>;
  43537. /**
  43538. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43539. * @param pointerId the pointer id to use
  43540. * @returns The mesh under this pointer id or null if not found
  43541. */
  43542. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43543. /**
  43544. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43545. */
  43546. get unTranslatedPointer(): Vector2;
  43547. /**
  43548. * Gets or sets the current on-screen X position of the pointer
  43549. */
  43550. get pointerX(): number;
  43551. set pointerX(value: number);
  43552. /**
  43553. * Gets or sets the current on-screen Y position of the pointer
  43554. */
  43555. get pointerY(): number;
  43556. set pointerY(value: number);
  43557. private _updatePointerPosition;
  43558. private _processPointerMove;
  43559. private _setRayOnPointerInfo;
  43560. private _checkPrePointerObservable;
  43561. /**
  43562. * Use this method to simulate a pointer move on a mesh
  43563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43566. */
  43567. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43568. /**
  43569. * Use this method to simulate a pointer down on a mesh
  43570. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43571. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43572. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43573. */
  43574. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43575. private _processPointerDown;
  43576. /** @hidden */
  43577. _isPointerSwiping(): boolean;
  43578. /**
  43579. * Use this method to simulate a pointer up on a mesh
  43580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43583. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43584. */
  43585. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43586. private _processPointerUp;
  43587. /**
  43588. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43589. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43590. * @returns true if the pointer was captured
  43591. */
  43592. isPointerCaptured(pointerId?: number): boolean;
  43593. /**
  43594. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43595. * @param attachUp defines if you want to attach events to pointerup
  43596. * @param attachDown defines if you want to attach events to pointerdown
  43597. * @param attachMove defines if you want to attach events to pointermove
  43598. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43599. */
  43600. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43601. /**
  43602. * Detaches all event handlers
  43603. */
  43604. detachControl(): void;
  43605. /**
  43606. * Force the value of meshUnderPointer
  43607. * @param mesh defines the mesh to use
  43608. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43609. */
  43610. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43611. /**
  43612. * Gets the mesh under the pointer
  43613. * @returns a Mesh or null if no mesh is under the pointer
  43614. */
  43615. getPointerOverMesh(): Nullable<AbstractMesh>;
  43616. }
  43617. }
  43618. declare module "babylonjs/Animations/animationGroup" {
  43619. import { Animatable } from "babylonjs/Animations/animatable";
  43620. import { Animation } from "babylonjs/Animations/animation";
  43621. import { Scene, IDisposable } from "babylonjs/scene";
  43622. import { Observable } from "babylonjs/Misc/observable";
  43623. import { Nullable } from "babylonjs/types";
  43624. import "babylonjs/Animations/animatable";
  43625. /**
  43626. * This class defines the direct association between an animation and a target
  43627. */
  43628. export class TargetedAnimation {
  43629. /**
  43630. * Animation to perform
  43631. */
  43632. animation: Animation;
  43633. /**
  43634. * Target to animate
  43635. */
  43636. target: any;
  43637. /**
  43638. * Returns the string "TargetedAnimation"
  43639. * @returns "TargetedAnimation"
  43640. */
  43641. getClassName(): string;
  43642. /**
  43643. * Serialize the object
  43644. * @returns the JSON object representing the current entity
  43645. */
  43646. serialize(): any;
  43647. }
  43648. /**
  43649. * Use this class to create coordinated animations on multiple targets
  43650. */
  43651. export class AnimationGroup implements IDisposable {
  43652. /** The name of the animation group */
  43653. name: string;
  43654. private _scene;
  43655. private _targetedAnimations;
  43656. private _animatables;
  43657. private _from;
  43658. private _to;
  43659. private _isStarted;
  43660. private _isPaused;
  43661. private _speedRatio;
  43662. private _loopAnimation;
  43663. private _isAdditive;
  43664. /**
  43665. * Gets or sets the unique id of the node
  43666. */
  43667. uniqueId: number;
  43668. /**
  43669. * This observable will notify when one animation have ended
  43670. */
  43671. onAnimationEndObservable: Observable<TargetedAnimation>;
  43672. /**
  43673. * Observer raised when one animation loops
  43674. */
  43675. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43676. /**
  43677. * Observer raised when all animations have looped
  43678. */
  43679. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43680. /**
  43681. * This observable will notify when all animations have ended.
  43682. */
  43683. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43684. /**
  43685. * This observable will notify when all animations have paused.
  43686. */
  43687. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43688. /**
  43689. * This observable will notify when all animations are playing.
  43690. */
  43691. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43692. /**
  43693. * Gets the first frame
  43694. */
  43695. get from(): number;
  43696. /**
  43697. * Gets the last frame
  43698. */
  43699. get to(): number;
  43700. /**
  43701. * Define if the animations are started
  43702. */
  43703. get isStarted(): boolean;
  43704. /**
  43705. * Gets a value indicating that the current group is playing
  43706. */
  43707. get isPlaying(): boolean;
  43708. /**
  43709. * Gets or sets the speed ratio to use for all animations
  43710. */
  43711. get speedRatio(): number;
  43712. /**
  43713. * Gets or sets the speed ratio to use for all animations
  43714. */
  43715. set speedRatio(value: number);
  43716. /**
  43717. * Gets or sets if all animations should loop or not
  43718. */
  43719. get loopAnimation(): boolean;
  43720. set loopAnimation(value: boolean);
  43721. /**
  43722. * Gets or sets if all animations should be evaluated additively
  43723. */
  43724. get isAdditive(): boolean;
  43725. set isAdditive(value: boolean);
  43726. /**
  43727. * Gets the targeted animations for this animation group
  43728. */
  43729. get targetedAnimations(): Array<TargetedAnimation>;
  43730. /**
  43731. * returning the list of animatables controlled by this animation group.
  43732. */
  43733. get animatables(): Array<Animatable>;
  43734. /**
  43735. * Gets the list of target animations
  43736. */
  43737. get children(): TargetedAnimation[];
  43738. /**
  43739. * Instantiates a new Animation Group.
  43740. * This helps managing several animations at once.
  43741. * @see https://doc.babylonjs.com/how_to/group
  43742. * @param name Defines the name of the group
  43743. * @param scene Defines the scene the group belongs to
  43744. */
  43745. constructor(
  43746. /** The name of the animation group */
  43747. name: string, scene?: Nullable<Scene>);
  43748. /**
  43749. * Add an animation (with its target) in the group
  43750. * @param animation defines the animation we want to add
  43751. * @param target defines the target of the animation
  43752. * @returns the TargetedAnimation object
  43753. */
  43754. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43755. /**
  43756. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43757. * It can add constant keys at begin or end
  43758. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43759. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43760. * @returns the animation group
  43761. */
  43762. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43763. private _animationLoopCount;
  43764. private _animationLoopFlags;
  43765. private _processLoop;
  43766. /**
  43767. * Start all animations on given targets
  43768. * @param loop defines if animations must loop
  43769. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43770. * @param from defines the from key (optional)
  43771. * @param to defines the to key (optional)
  43772. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43773. * @returns the current animation group
  43774. */
  43775. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43776. /**
  43777. * Pause all animations
  43778. * @returns the animation group
  43779. */
  43780. pause(): AnimationGroup;
  43781. /**
  43782. * Play all animations to initial state
  43783. * This function will start() the animations if they were not started or will restart() them if they were paused
  43784. * @param loop defines if animations must loop
  43785. * @returns the animation group
  43786. */
  43787. play(loop?: boolean): AnimationGroup;
  43788. /**
  43789. * Reset all animations to initial state
  43790. * @returns the animation group
  43791. */
  43792. reset(): AnimationGroup;
  43793. /**
  43794. * Restart animations from key 0
  43795. * @returns the animation group
  43796. */
  43797. restart(): AnimationGroup;
  43798. /**
  43799. * Stop all animations
  43800. * @returns the animation group
  43801. */
  43802. stop(): AnimationGroup;
  43803. /**
  43804. * Set animation weight for all animatables
  43805. * @param weight defines the weight to use
  43806. * @return the animationGroup
  43807. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43808. */
  43809. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43810. /**
  43811. * Synchronize and normalize all animatables with a source animatable
  43812. * @param root defines the root animatable to synchronize with
  43813. * @return the animationGroup
  43814. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43815. */
  43816. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43817. /**
  43818. * Goes to a specific frame in this animation group
  43819. * @param frame the frame number to go to
  43820. * @return the animationGroup
  43821. */
  43822. goToFrame(frame: number): AnimationGroup;
  43823. /**
  43824. * Dispose all associated resources
  43825. */
  43826. dispose(): void;
  43827. private _checkAnimationGroupEnded;
  43828. /**
  43829. * Clone the current animation group and returns a copy
  43830. * @param newName defines the name of the new group
  43831. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43832. * @returns the new aniamtion group
  43833. */
  43834. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43835. /**
  43836. * Serializes the animationGroup to an object
  43837. * @returns Serialized object
  43838. */
  43839. serialize(): any;
  43840. /**
  43841. * Returns a new AnimationGroup object parsed from the source provided.
  43842. * @param parsedAnimationGroup defines the source
  43843. * @param scene defines the scene that will receive the animationGroup
  43844. * @returns a new AnimationGroup
  43845. */
  43846. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43847. /**
  43848. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43849. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43850. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43851. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43852. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43853. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43854. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43855. */
  43856. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43857. /**
  43858. * Returns the string "AnimationGroup"
  43859. * @returns "AnimationGroup"
  43860. */
  43861. getClassName(): string;
  43862. /**
  43863. * Creates a detailled string about the object
  43864. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43865. * @returns a string representing the object
  43866. */
  43867. toString(fullDetails?: boolean): string;
  43868. }
  43869. }
  43870. declare module "babylonjs/scene" {
  43871. import { Nullable } from "babylonjs/types";
  43872. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43873. import { Observable } from "babylonjs/Misc/observable";
  43874. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43875. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43876. import { Geometry } from "babylonjs/Meshes/geometry";
  43877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43880. import { Mesh } from "babylonjs/Meshes/mesh";
  43881. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43882. import { Bone } from "babylonjs/Bones/bone";
  43883. import { Skeleton } from "babylonjs/Bones/skeleton";
  43884. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43885. import { Camera } from "babylonjs/Cameras/camera";
  43886. import { AbstractScene } from "babylonjs/abstractScene";
  43887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43888. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43889. import { Material } from "babylonjs/Materials/material";
  43890. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43891. import { Effect } from "babylonjs/Materials/effect";
  43892. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43893. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43894. import { Light } from "babylonjs/Lights/light";
  43895. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43896. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43897. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43898. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43899. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43900. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43901. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43902. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43903. import { Engine } from "babylonjs/Engines/engine";
  43904. import { Node } from "babylonjs/node";
  43905. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43906. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43907. import { WebRequest } from "babylonjs/Misc/webRequest";
  43908. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43909. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43910. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43912. import { Plane } from "babylonjs/Maths/math.plane";
  43913. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43914. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43915. import { Ray } from "babylonjs/Culling/ray";
  43916. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43917. import { Animation } from "babylonjs/Animations/animation";
  43918. import { Animatable } from "babylonjs/Animations/animatable";
  43919. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43920. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43921. import { Collider } from "babylonjs/Collisions/collider";
  43922. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43923. /**
  43924. * Define an interface for all classes that will hold resources
  43925. */
  43926. export interface IDisposable {
  43927. /**
  43928. * Releases all held resources
  43929. */
  43930. dispose(): void;
  43931. }
  43932. /** Interface defining initialization parameters for Scene class */
  43933. export interface SceneOptions {
  43934. /**
  43935. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43936. * It will improve performance when the number of geometries becomes important.
  43937. */
  43938. useGeometryUniqueIdsMap?: boolean;
  43939. /**
  43940. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43941. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43942. */
  43943. useMaterialMeshMap?: boolean;
  43944. /**
  43945. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43946. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43947. */
  43948. useClonedMeshMap?: boolean;
  43949. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43950. virtual?: boolean;
  43951. }
  43952. /**
  43953. * Represents a scene to be rendered by the engine.
  43954. * @see https://doc.babylonjs.com/features/scene
  43955. */
  43956. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43957. /** The fog is deactivated */
  43958. static readonly FOGMODE_NONE: number;
  43959. /** The fog density is following an exponential function */
  43960. static readonly FOGMODE_EXP: number;
  43961. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43962. static readonly FOGMODE_EXP2: number;
  43963. /** The fog density is following a linear function. */
  43964. static readonly FOGMODE_LINEAR: number;
  43965. /**
  43966. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43967. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43968. */
  43969. static MinDeltaTime: number;
  43970. /**
  43971. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43972. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43973. */
  43974. static MaxDeltaTime: number;
  43975. /**
  43976. * Factory used to create the default material.
  43977. * @param name The name of the material to create
  43978. * @param scene The scene to create the material for
  43979. * @returns The default material
  43980. */
  43981. static DefaultMaterialFactory(scene: Scene): Material;
  43982. /**
  43983. * Factory used to create the a collision coordinator.
  43984. * @returns The collision coordinator
  43985. */
  43986. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43987. /** @hidden */
  43988. _inputManager: InputManager;
  43989. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  43990. cameraToUseForPointers: Nullable<Camera>;
  43991. /** @hidden */
  43992. readonly _isScene: boolean;
  43993. /** @hidden */
  43994. _blockEntityCollection: boolean;
  43995. /**
  43996. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  43997. */
  43998. autoClear: boolean;
  43999. /**
  44000. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44001. */
  44002. autoClearDepthAndStencil: boolean;
  44003. /**
  44004. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44005. */
  44006. clearColor: Color4;
  44007. /**
  44008. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44009. */
  44010. ambientColor: Color3;
  44011. /**
  44012. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44013. * It should only be one of the following (if not the default embedded one):
  44014. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44015. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44016. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44017. * The material properties need to be setup according to the type of texture in use.
  44018. */
  44019. environmentBRDFTexture: BaseTexture;
  44020. /**
  44021. * Texture used in all pbr material as the reflection texture.
  44022. * As in the majority of the scene they are the same (exception for multi room and so on),
  44023. * this is easier to reference from here than from all the materials.
  44024. */
  44025. get environmentTexture(): Nullable<BaseTexture>;
  44026. /**
  44027. * Texture used in all pbr material as the reflection texture.
  44028. * As in the majority of the scene they are the same (exception for multi room and so on),
  44029. * this is easier to set here than in all the materials.
  44030. */
  44031. set environmentTexture(value: Nullable<BaseTexture>);
  44032. /** @hidden */
  44033. protected _environmentIntensity: number;
  44034. /**
  44035. * Intensity of the environment in all pbr material.
  44036. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44037. * As in the majority of the scene they are the same (exception for multi room and so on),
  44038. * this is easier to reference from here than from all the materials.
  44039. */
  44040. get environmentIntensity(): number;
  44041. /**
  44042. * Intensity of the environment in all pbr material.
  44043. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44044. * As in the majority of the scene they are the same (exception for multi room and so on),
  44045. * this is easier to set here than in all the materials.
  44046. */
  44047. set environmentIntensity(value: number);
  44048. /** @hidden */
  44049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44050. /**
  44051. * Default image processing configuration used either in the rendering
  44052. * Forward main pass or through the imageProcessingPostProcess if present.
  44053. * As in the majority of the scene they are the same (exception for multi camera),
  44054. * this is easier to reference from here than from all the materials and post process.
  44055. *
  44056. * No setter as we it is a shared configuration, you can set the values instead.
  44057. */
  44058. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44059. private _forceWireframe;
  44060. /**
  44061. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44062. */
  44063. set forceWireframe(value: boolean);
  44064. get forceWireframe(): boolean;
  44065. private _skipFrustumClipping;
  44066. /**
  44067. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44068. */
  44069. set skipFrustumClipping(value: boolean);
  44070. get skipFrustumClipping(): boolean;
  44071. private _forcePointsCloud;
  44072. /**
  44073. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44074. */
  44075. set forcePointsCloud(value: boolean);
  44076. get forcePointsCloud(): boolean;
  44077. /**
  44078. * Gets or sets the active clipplane 1
  44079. */
  44080. clipPlane: Nullable<Plane>;
  44081. /**
  44082. * Gets or sets the active clipplane 2
  44083. */
  44084. clipPlane2: Nullable<Plane>;
  44085. /**
  44086. * Gets or sets the active clipplane 3
  44087. */
  44088. clipPlane3: Nullable<Plane>;
  44089. /**
  44090. * Gets or sets the active clipplane 4
  44091. */
  44092. clipPlane4: Nullable<Plane>;
  44093. /**
  44094. * Gets or sets the active clipplane 5
  44095. */
  44096. clipPlane5: Nullable<Plane>;
  44097. /**
  44098. * Gets or sets the active clipplane 6
  44099. */
  44100. clipPlane6: Nullable<Plane>;
  44101. /**
  44102. * Gets or sets a boolean indicating if animations are enabled
  44103. */
  44104. animationsEnabled: boolean;
  44105. private _animationPropertiesOverride;
  44106. /**
  44107. * Gets or sets the animation properties override
  44108. */
  44109. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44110. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44111. /**
  44112. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44113. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44114. */
  44115. useConstantAnimationDeltaTime: boolean;
  44116. /**
  44117. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44118. * Please note that it requires to run a ray cast through the scene on every frame
  44119. */
  44120. constantlyUpdateMeshUnderPointer: boolean;
  44121. /**
  44122. * Defines the HTML cursor to use when hovering over interactive elements
  44123. */
  44124. hoverCursor: string;
  44125. /**
  44126. * Defines the HTML default cursor to use (empty by default)
  44127. */
  44128. defaultCursor: string;
  44129. /**
  44130. * Defines whether cursors are handled by the scene.
  44131. */
  44132. doNotHandleCursors: boolean;
  44133. /**
  44134. * This is used to call preventDefault() on pointer down
  44135. * in order to block unwanted artifacts like system double clicks
  44136. */
  44137. preventDefaultOnPointerDown: boolean;
  44138. /**
  44139. * This is used to call preventDefault() on pointer up
  44140. * in order to block unwanted artifacts like system double clicks
  44141. */
  44142. preventDefaultOnPointerUp: boolean;
  44143. /**
  44144. * Gets or sets user defined metadata
  44145. */
  44146. metadata: any;
  44147. /**
  44148. * For internal use only. Please do not use.
  44149. */
  44150. reservedDataStore: any;
  44151. /**
  44152. * Gets the name of the plugin used to load this scene (null by default)
  44153. */
  44154. loadingPluginName: string;
  44155. /**
  44156. * Use this array to add regular expressions used to disable offline support for specific urls
  44157. */
  44158. disableOfflineSupportExceptionRules: RegExp[];
  44159. /**
  44160. * An event triggered when the scene is disposed.
  44161. */
  44162. onDisposeObservable: Observable<Scene>;
  44163. private _onDisposeObserver;
  44164. /** Sets a function to be executed when this scene is disposed. */
  44165. set onDispose(callback: () => void);
  44166. /**
  44167. * An event triggered before rendering the scene (right after animations and physics)
  44168. */
  44169. onBeforeRenderObservable: Observable<Scene>;
  44170. private _onBeforeRenderObserver;
  44171. /** Sets a function to be executed before rendering this scene */
  44172. set beforeRender(callback: Nullable<() => void>);
  44173. /**
  44174. * An event triggered after rendering the scene
  44175. */
  44176. onAfterRenderObservable: Observable<Scene>;
  44177. /**
  44178. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44179. */
  44180. onAfterRenderCameraObservable: Observable<Camera>;
  44181. private _onAfterRenderObserver;
  44182. /** Sets a function to be executed after rendering this scene */
  44183. set afterRender(callback: Nullable<() => void>);
  44184. /**
  44185. * An event triggered before animating the scene
  44186. */
  44187. onBeforeAnimationsObservable: Observable<Scene>;
  44188. /**
  44189. * An event triggered after animations processing
  44190. */
  44191. onAfterAnimationsObservable: Observable<Scene>;
  44192. /**
  44193. * An event triggered before draw calls are ready to be sent
  44194. */
  44195. onBeforeDrawPhaseObservable: Observable<Scene>;
  44196. /**
  44197. * An event triggered after draw calls have been sent
  44198. */
  44199. onAfterDrawPhaseObservable: Observable<Scene>;
  44200. /**
  44201. * An event triggered when the scene is ready
  44202. */
  44203. onReadyObservable: Observable<Scene>;
  44204. /**
  44205. * An event triggered before rendering a camera
  44206. */
  44207. onBeforeCameraRenderObservable: Observable<Camera>;
  44208. private _onBeforeCameraRenderObserver;
  44209. /** Sets a function to be executed before rendering a camera*/
  44210. set beforeCameraRender(callback: () => void);
  44211. /**
  44212. * An event triggered after rendering a camera
  44213. */
  44214. onAfterCameraRenderObservable: Observable<Camera>;
  44215. private _onAfterCameraRenderObserver;
  44216. /** Sets a function to be executed after rendering a camera*/
  44217. set afterCameraRender(callback: () => void);
  44218. /**
  44219. * An event triggered when active meshes evaluation is about to start
  44220. */
  44221. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44222. /**
  44223. * An event triggered when active meshes evaluation is done
  44224. */
  44225. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44226. /**
  44227. * An event triggered when particles rendering is about to start
  44228. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44229. */
  44230. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44231. /**
  44232. * An event triggered when particles rendering is done
  44233. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44234. */
  44235. onAfterParticlesRenderingObservable: Observable<Scene>;
  44236. /**
  44237. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44238. */
  44239. onDataLoadedObservable: Observable<Scene>;
  44240. /**
  44241. * An event triggered when a camera is created
  44242. */
  44243. onNewCameraAddedObservable: Observable<Camera>;
  44244. /**
  44245. * An event triggered when a camera is removed
  44246. */
  44247. onCameraRemovedObservable: Observable<Camera>;
  44248. /**
  44249. * An event triggered when a light is created
  44250. */
  44251. onNewLightAddedObservable: Observable<Light>;
  44252. /**
  44253. * An event triggered when a light is removed
  44254. */
  44255. onLightRemovedObservable: Observable<Light>;
  44256. /**
  44257. * An event triggered when a geometry is created
  44258. */
  44259. onNewGeometryAddedObservable: Observable<Geometry>;
  44260. /**
  44261. * An event triggered when a geometry is removed
  44262. */
  44263. onGeometryRemovedObservable: Observable<Geometry>;
  44264. /**
  44265. * An event triggered when a transform node is created
  44266. */
  44267. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44268. /**
  44269. * An event triggered when a transform node is removed
  44270. */
  44271. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44272. /**
  44273. * An event triggered when a mesh is created
  44274. */
  44275. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44276. /**
  44277. * An event triggered when a mesh is removed
  44278. */
  44279. onMeshRemovedObservable: Observable<AbstractMesh>;
  44280. /**
  44281. * An event triggered when a skeleton is created
  44282. */
  44283. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44284. /**
  44285. * An event triggered when a skeleton is removed
  44286. */
  44287. onSkeletonRemovedObservable: Observable<Skeleton>;
  44288. /**
  44289. * An event triggered when a material is created
  44290. */
  44291. onNewMaterialAddedObservable: Observable<Material>;
  44292. /**
  44293. * An event triggered when a material is removed
  44294. */
  44295. onMaterialRemovedObservable: Observable<Material>;
  44296. /**
  44297. * An event triggered when a texture is created
  44298. */
  44299. onNewTextureAddedObservable: Observable<BaseTexture>;
  44300. /**
  44301. * An event triggered when a texture is removed
  44302. */
  44303. onTextureRemovedObservable: Observable<BaseTexture>;
  44304. /**
  44305. * An event triggered when render targets are about to be rendered
  44306. * Can happen multiple times per frame.
  44307. */
  44308. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44309. /**
  44310. * An event triggered when render targets were rendered.
  44311. * Can happen multiple times per frame.
  44312. */
  44313. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44314. /**
  44315. * An event triggered before calculating deterministic simulation step
  44316. */
  44317. onBeforeStepObservable: Observable<Scene>;
  44318. /**
  44319. * An event triggered after calculating deterministic simulation step
  44320. */
  44321. onAfterStepObservable: Observable<Scene>;
  44322. /**
  44323. * An event triggered when the activeCamera property is updated
  44324. */
  44325. onActiveCameraChanged: Observable<Scene>;
  44326. /**
  44327. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44328. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44329. * 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)
  44330. */
  44331. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44332. /**
  44333. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44334. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44335. * 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)
  44336. */
  44337. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44338. /**
  44339. * This Observable will when a mesh has been imported into the scene.
  44340. */
  44341. onMeshImportedObservable: Observable<AbstractMesh>;
  44342. /**
  44343. * This Observable will when an animation file has been imported into the scene.
  44344. */
  44345. onAnimationFileImportedObservable: Observable<Scene>;
  44346. /**
  44347. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44348. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44349. */
  44350. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44351. /** @hidden */
  44352. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44353. /**
  44354. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44355. */
  44356. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44357. /**
  44358. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44359. */
  44360. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44361. /**
  44362. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44363. */
  44364. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44365. /** Callback called when a pointer move is detected */
  44366. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44367. /** Callback called when a pointer down is detected */
  44368. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44369. /** Callback called when a pointer up is detected */
  44370. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44371. /** Callback called when a pointer pick is detected */
  44372. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44373. /**
  44374. * 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).
  44375. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44376. */
  44377. onPrePointerObservable: Observable<PointerInfoPre>;
  44378. /**
  44379. * Observable event triggered each time an input event is received from the rendering canvas
  44380. */
  44381. onPointerObservable: Observable<PointerInfo>;
  44382. /**
  44383. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44384. */
  44385. get unTranslatedPointer(): Vector2;
  44386. /**
  44387. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44388. */
  44389. static get DragMovementThreshold(): number;
  44390. static set DragMovementThreshold(value: number);
  44391. /**
  44392. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44393. */
  44394. static get LongPressDelay(): number;
  44395. static set LongPressDelay(value: number);
  44396. /**
  44397. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44398. */
  44399. static get DoubleClickDelay(): number;
  44400. static set DoubleClickDelay(value: number);
  44401. /** If you need to check double click without raising a single click at first click, enable this flag */
  44402. static get ExclusiveDoubleClickMode(): boolean;
  44403. static set ExclusiveDoubleClickMode(value: boolean);
  44404. /** @hidden */
  44405. _mirroredCameraPosition: Nullable<Vector3>;
  44406. /**
  44407. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44408. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44409. */
  44410. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44411. /**
  44412. * Observable event triggered each time an keyboard event is received from the hosting window
  44413. */
  44414. onKeyboardObservable: Observable<KeyboardInfo>;
  44415. private _useRightHandedSystem;
  44416. /**
  44417. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44418. */
  44419. set useRightHandedSystem(value: boolean);
  44420. get useRightHandedSystem(): boolean;
  44421. private _timeAccumulator;
  44422. private _currentStepId;
  44423. private _currentInternalStep;
  44424. /**
  44425. * Sets the step Id used by deterministic lock step
  44426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44427. * @param newStepId defines the step Id
  44428. */
  44429. setStepId(newStepId: number): void;
  44430. /**
  44431. * Gets the step Id used by deterministic lock step
  44432. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44433. * @returns the step Id
  44434. */
  44435. getStepId(): number;
  44436. /**
  44437. * Gets the internal step used by deterministic lock step
  44438. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44439. * @returns the internal step
  44440. */
  44441. getInternalStep(): number;
  44442. private _fogEnabled;
  44443. /**
  44444. * Gets or sets a boolean indicating if fog is enabled on this scene
  44445. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44446. * (Default is true)
  44447. */
  44448. set fogEnabled(value: boolean);
  44449. get fogEnabled(): boolean;
  44450. private _fogMode;
  44451. /**
  44452. * Gets or sets the fog mode to use
  44453. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44454. * | mode | value |
  44455. * | --- | --- |
  44456. * | FOGMODE_NONE | 0 |
  44457. * | FOGMODE_EXP | 1 |
  44458. * | FOGMODE_EXP2 | 2 |
  44459. * | FOGMODE_LINEAR | 3 |
  44460. */
  44461. set fogMode(value: number);
  44462. get fogMode(): number;
  44463. /**
  44464. * Gets or sets the fog color to use
  44465. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44466. * (Default is Color3(0.2, 0.2, 0.3))
  44467. */
  44468. fogColor: Color3;
  44469. /**
  44470. * Gets or sets the fog density to use
  44471. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44472. * (Default is 0.1)
  44473. */
  44474. fogDensity: number;
  44475. /**
  44476. * Gets or sets the fog start distance to use
  44477. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44478. * (Default is 0)
  44479. */
  44480. fogStart: number;
  44481. /**
  44482. * Gets or sets the fog end distance to use
  44483. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44484. * (Default is 1000)
  44485. */
  44486. fogEnd: number;
  44487. /**
  44488. * Flag indicating that the frame buffer binding is handled by another component
  44489. */
  44490. prePass: boolean;
  44491. private _shadowsEnabled;
  44492. /**
  44493. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44494. */
  44495. set shadowsEnabled(value: boolean);
  44496. get shadowsEnabled(): boolean;
  44497. private _lightsEnabled;
  44498. /**
  44499. * Gets or sets a boolean indicating if lights are enabled on this scene
  44500. */
  44501. set lightsEnabled(value: boolean);
  44502. get lightsEnabled(): boolean;
  44503. /** All of the active cameras added to this scene. */
  44504. activeCameras: Camera[];
  44505. /** @hidden */
  44506. _activeCamera: Nullable<Camera>;
  44507. /** Gets or sets the current active camera */
  44508. get activeCamera(): Nullable<Camera>;
  44509. set activeCamera(value: Nullable<Camera>);
  44510. private _defaultMaterial;
  44511. /** The default material used on meshes when no material is affected */
  44512. get defaultMaterial(): Material;
  44513. /** The default material used on meshes when no material is affected */
  44514. set defaultMaterial(value: Material);
  44515. private _texturesEnabled;
  44516. /**
  44517. * Gets or sets a boolean indicating if textures are enabled on this scene
  44518. */
  44519. set texturesEnabled(value: boolean);
  44520. get texturesEnabled(): boolean;
  44521. /**
  44522. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44523. */
  44524. physicsEnabled: boolean;
  44525. /**
  44526. * Gets or sets a boolean indicating if particles are enabled on this scene
  44527. */
  44528. particlesEnabled: boolean;
  44529. /**
  44530. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44531. */
  44532. spritesEnabled: boolean;
  44533. private _skeletonsEnabled;
  44534. /**
  44535. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44536. */
  44537. set skeletonsEnabled(value: boolean);
  44538. get skeletonsEnabled(): boolean;
  44539. /**
  44540. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44541. */
  44542. lensFlaresEnabled: boolean;
  44543. /**
  44544. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44545. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44546. */
  44547. collisionsEnabled: boolean;
  44548. private _collisionCoordinator;
  44549. /** @hidden */
  44550. get collisionCoordinator(): ICollisionCoordinator;
  44551. /**
  44552. * Defines the gravity applied to this scene (used only for collisions)
  44553. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44554. */
  44555. gravity: Vector3;
  44556. /**
  44557. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44558. */
  44559. postProcessesEnabled: boolean;
  44560. /**
  44561. * Gets the current postprocess manager
  44562. */
  44563. postProcessManager: PostProcessManager;
  44564. /**
  44565. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44566. */
  44567. renderTargetsEnabled: boolean;
  44568. /**
  44569. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44570. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44571. */
  44572. dumpNextRenderTargets: boolean;
  44573. /**
  44574. * The list of user defined render targets added to the scene
  44575. */
  44576. customRenderTargets: RenderTargetTexture[];
  44577. /**
  44578. * Defines if texture loading must be delayed
  44579. * If true, textures will only be loaded when they need to be rendered
  44580. */
  44581. useDelayedTextureLoading: boolean;
  44582. /**
  44583. * Gets the list of meshes imported to the scene through SceneLoader
  44584. */
  44585. importedMeshesFiles: String[];
  44586. /**
  44587. * Gets or sets a boolean indicating if probes are enabled on this scene
  44588. */
  44589. probesEnabled: boolean;
  44590. /**
  44591. * Gets or sets the current offline provider to use to store scene data
  44592. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44593. */
  44594. offlineProvider: IOfflineProvider;
  44595. /**
  44596. * Gets or sets the action manager associated with the scene
  44597. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44598. */
  44599. actionManager: AbstractActionManager;
  44600. private _meshesForIntersections;
  44601. /**
  44602. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44603. */
  44604. proceduralTexturesEnabled: boolean;
  44605. private _engine;
  44606. private _totalVertices;
  44607. /** @hidden */
  44608. _activeIndices: PerfCounter;
  44609. /** @hidden */
  44610. _activeParticles: PerfCounter;
  44611. /** @hidden */
  44612. _activeBones: PerfCounter;
  44613. private _animationRatio;
  44614. /** @hidden */
  44615. _animationTimeLast: number;
  44616. /** @hidden */
  44617. _animationTime: number;
  44618. /**
  44619. * Gets or sets a general scale for animation speed
  44620. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44621. */
  44622. animationTimeScale: number;
  44623. /** @hidden */
  44624. _cachedMaterial: Nullable<Material>;
  44625. /** @hidden */
  44626. _cachedEffect: Nullable<Effect>;
  44627. /** @hidden */
  44628. _cachedVisibility: Nullable<number>;
  44629. private _renderId;
  44630. private _frameId;
  44631. private _executeWhenReadyTimeoutId;
  44632. private _intermediateRendering;
  44633. private _viewUpdateFlag;
  44634. private _projectionUpdateFlag;
  44635. /** @hidden */
  44636. _toBeDisposed: Nullable<IDisposable>[];
  44637. private _activeRequests;
  44638. /** @hidden */
  44639. _pendingData: any[];
  44640. private _isDisposed;
  44641. /**
  44642. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44643. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44644. */
  44645. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44646. private _activeMeshes;
  44647. private _processedMaterials;
  44648. private _renderTargets;
  44649. /** @hidden */
  44650. _activeParticleSystems: SmartArray<IParticleSystem>;
  44651. private _activeSkeletons;
  44652. private _softwareSkinnedMeshes;
  44653. private _renderingManager;
  44654. /** @hidden */
  44655. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44656. private _transformMatrix;
  44657. private _sceneUbo;
  44658. /** @hidden */
  44659. _viewMatrix: Matrix;
  44660. private _projectionMatrix;
  44661. /** @hidden */
  44662. _forcedViewPosition: Nullable<Vector3>;
  44663. /** @hidden */
  44664. _frustumPlanes: Plane[];
  44665. /**
  44666. * Gets the list of frustum planes (built from the active camera)
  44667. */
  44668. get frustumPlanes(): Plane[];
  44669. /**
  44670. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44671. * This is useful if there are more lights that the maximum simulteanous authorized
  44672. */
  44673. requireLightSorting: boolean;
  44674. /** @hidden */
  44675. readonly useMaterialMeshMap: boolean;
  44676. /** @hidden */
  44677. readonly useClonedMeshMap: boolean;
  44678. private _externalData;
  44679. private _uid;
  44680. /**
  44681. * @hidden
  44682. * Backing store of defined scene components.
  44683. */
  44684. _components: ISceneComponent[];
  44685. /**
  44686. * @hidden
  44687. * Backing store of defined scene components.
  44688. */
  44689. _serializableComponents: ISceneSerializableComponent[];
  44690. /**
  44691. * List of components to register on the next registration step.
  44692. */
  44693. private _transientComponents;
  44694. /**
  44695. * Registers the transient components if needed.
  44696. */
  44697. private _registerTransientComponents;
  44698. /**
  44699. * @hidden
  44700. * Add a component to the scene.
  44701. * Note that the ccomponent could be registered on th next frame if this is called after
  44702. * the register component stage.
  44703. * @param component Defines the component to add to the scene
  44704. */
  44705. _addComponent(component: ISceneComponent): void;
  44706. /**
  44707. * @hidden
  44708. * Gets a component from the scene.
  44709. * @param name defines the name of the component to retrieve
  44710. * @returns the component or null if not present
  44711. */
  44712. _getComponent(name: string): Nullable<ISceneComponent>;
  44713. /**
  44714. * @hidden
  44715. * Defines the actions happening before camera updates.
  44716. */
  44717. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44718. /**
  44719. * @hidden
  44720. * Defines the actions happening before clear the canvas.
  44721. */
  44722. _beforeClearStage: Stage<SimpleStageAction>;
  44723. /**
  44724. * @hidden
  44725. * Defines the actions when collecting render targets for the frame.
  44726. */
  44727. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44728. /**
  44729. * @hidden
  44730. * Defines the actions happening for one camera in the frame.
  44731. */
  44732. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44733. /**
  44734. * @hidden
  44735. * Defines the actions happening during the per mesh ready checks.
  44736. */
  44737. _isReadyForMeshStage: Stage<MeshStageAction>;
  44738. /**
  44739. * @hidden
  44740. * Defines the actions happening before evaluate active mesh checks.
  44741. */
  44742. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44743. /**
  44744. * @hidden
  44745. * Defines the actions happening during the evaluate sub mesh checks.
  44746. */
  44747. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44748. /**
  44749. * @hidden
  44750. * Defines the actions happening during the active mesh stage.
  44751. */
  44752. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44753. /**
  44754. * @hidden
  44755. * Defines the actions happening during the per camera render target step.
  44756. */
  44757. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44758. /**
  44759. * @hidden
  44760. * Defines the actions happening just before the active camera is drawing.
  44761. */
  44762. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44763. /**
  44764. * @hidden
  44765. * Defines the actions happening just before a render target is drawing.
  44766. */
  44767. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44768. /**
  44769. * @hidden
  44770. * Defines the actions happening just before a rendering group is drawing.
  44771. */
  44772. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44773. /**
  44774. * @hidden
  44775. * Defines the actions happening just before a mesh is drawing.
  44776. */
  44777. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44778. /**
  44779. * @hidden
  44780. * Defines the actions happening just after a mesh has been drawn.
  44781. */
  44782. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44783. /**
  44784. * @hidden
  44785. * Defines the actions happening just after a rendering group has been drawn.
  44786. */
  44787. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44788. /**
  44789. * @hidden
  44790. * Defines the actions happening just after the active camera has been drawn.
  44791. */
  44792. _afterCameraDrawStage: Stage<CameraStageAction>;
  44793. /**
  44794. * @hidden
  44795. * Defines the actions happening just after a render target has been drawn.
  44796. */
  44797. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44798. /**
  44799. * @hidden
  44800. * Defines the actions happening just after rendering all cameras and computing intersections.
  44801. */
  44802. _afterRenderStage: Stage<SimpleStageAction>;
  44803. /**
  44804. * @hidden
  44805. * Defines the actions happening when a pointer move event happens.
  44806. */
  44807. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44808. /**
  44809. * @hidden
  44810. * Defines the actions happening when a pointer down event happens.
  44811. */
  44812. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44813. /**
  44814. * @hidden
  44815. * Defines the actions happening when a pointer up event happens.
  44816. */
  44817. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44818. /**
  44819. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44820. */
  44821. private geometriesByUniqueId;
  44822. /**
  44823. * Creates a new Scene
  44824. * @param engine defines the engine to use to render this scene
  44825. * @param options defines the scene options
  44826. */
  44827. constructor(engine: Engine, options?: SceneOptions);
  44828. /**
  44829. * Gets a string identifying the name of the class
  44830. * @returns "Scene" string
  44831. */
  44832. getClassName(): string;
  44833. private _defaultMeshCandidates;
  44834. /**
  44835. * @hidden
  44836. */
  44837. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44838. private _defaultSubMeshCandidates;
  44839. /**
  44840. * @hidden
  44841. */
  44842. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44843. /**
  44844. * Sets the default candidate providers for the scene.
  44845. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44846. * and getCollidingSubMeshCandidates to their default function
  44847. */
  44848. setDefaultCandidateProviders(): void;
  44849. /**
  44850. * Gets the mesh that is currently under the pointer
  44851. */
  44852. get meshUnderPointer(): Nullable<AbstractMesh>;
  44853. /**
  44854. * Gets or sets the current on-screen X position of the pointer
  44855. */
  44856. get pointerX(): number;
  44857. set pointerX(value: number);
  44858. /**
  44859. * Gets or sets the current on-screen Y position of the pointer
  44860. */
  44861. get pointerY(): number;
  44862. set pointerY(value: number);
  44863. /**
  44864. * Gets the cached material (ie. the latest rendered one)
  44865. * @returns the cached material
  44866. */
  44867. getCachedMaterial(): Nullable<Material>;
  44868. /**
  44869. * Gets the cached effect (ie. the latest rendered one)
  44870. * @returns the cached effect
  44871. */
  44872. getCachedEffect(): Nullable<Effect>;
  44873. /**
  44874. * Gets the cached visibility state (ie. the latest rendered one)
  44875. * @returns the cached visibility state
  44876. */
  44877. getCachedVisibility(): Nullable<number>;
  44878. /**
  44879. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44880. * @param material defines the current material
  44881. * @param effect defines the current effect
  44882. * @param visibility defines the current visibility state
  44883. * @returns true if one parameter is not cached
  44884. */
  44885. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44886. /**
  44887. * Gets the engine associated with the scene
  44888. * @returns an Engine
  44889. */
  44890. getEngine(): Engine;
  44891. /**
  44892. * Gets the total number of vertices rendered per frame
  44893. * @returns the total number of vertices rendered per frame
  44894. */
  44895. getTotalVertices(): number;
  44896. /**
  44897. * Gets the performance counter for total vertices
  44898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44899. */
  44900. get totalVerticesPerfCounter(): PerfCounter;
  44901. /**
  44902. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44903. * @returns the total number of active indices rendered per frame
  44904. */
  44905. getActiveIndices(): number;
  44906. /**
  44907. * Gets the performance counter for active indices
  44908. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44909. */
  44910. get totalActiveIndicesPerfCounter(): PerfCounter;
  44911. /**
  44912. * Gets the total number of active particles rendered per frame
  44913. * @returns the total number of active particles rendered per frame
  44914. */
  44915. getActiveParticles(): number;
  44916. /**
  44917. * Gets the performance counter for active particles
  44918. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44919. */
  44920. get activeParticlesPerfCounter(): PerfCounter;
  44921. /**
  44922. * Gets the total number of active bones rendered per frame
  44923. * @returns the total number of active bones rendered per frame
  44924. */
  44925. getActiveBones(): number;
  44926. /**
  44927. * Gets the performance counter for active bones
  44928. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44929. */
  44930. get activeBonesPerfCounter(): PerfCounter;
  44931. /**
  44932. * Gets the array of active meshes
  44933. * @returns an array of AbstractMesh
  44934. */
  44935. getActiveMeshes(): SmartArray<AbstractMesh>;
  44936. /**
  44937. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44938. * @returns a number
  44939. */
  44940. getAnimationRatio(): number;
  44941. /**
  44942. * Gets an unique Id for the current render phase
  44943. * @returns a number
  44944. */
  44945. getRenderId(): number;
  44946. /**
  44947. * Gets an unique Id for the current frame
  44948. * @returns a number
  44949. */
  44950. getFrameId(): number;
  44951. /** Call this function if you want to manually increment the render Id*/
  44952. incrementRenderId(): void;
  44953. private _createUbo;
  44954. /**
  44955. * Use this method to simulate a pointer move on a mesh
  44956. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44957. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44958. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44959. * @returns the current scene
  44960. */
  44961. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44962. /**
  44963. * Use this method to simulate a pointer down on a mesh
  44964. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44965. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44966. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44967. * @returns the current scene
  44968. */
  44969. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44970. /**
  44971. * Use this method to simulate a pointer up on a mesh
  44972. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44973. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44974. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44975. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44976. * @returns the current scene
  44977. */
  44978. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44979. /**
  44980. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44981. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44982. * @returns true if the pointer was captured
  44983. */
  44984. isPointerCaptured(pointerId?: number): boolean;
  44985. /**
  44986. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44987. * @param attachUp defines if you want to attach events to pointerup
  44988. * @param attachDown defines if you want to attach events to pointerdown
  44989. * @param attachMove defines if you want to attach events to pointermove
  44990. */
  44991. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  44992. /** Detaches all event handlers*/
  44993. detachControl(): void;
  44994. /**
  44995. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  44996. * Delay loaded resources are not taking in account
  44997. * @return true if all required resources are ready
  44998. */
  44999. isReady(): boolean;
  45000. /** Resets all cached information relative to material (including effect and visibility) */
  45001. resetCachedMaterial(): void;
  45002. /**
  45003. * Registers a function to be called before every frame render
  45004. * @param func defines the function to register
  45005. */
  45006. registerBeforeRender(func: () => void): void;
  45007. /**
  45008. * Unregisters a function called before every frame render
  45009. * @param func defines the function to unregister
  45010. */
  45011. unregisterBeforeRender(func: () => void): void;
  45012. /**
  45013. * Registers a function to be called after every frame render
  45014. * @param func defines the function to register
  45015. */
  45016. registerAfterRender(func: () => void): void;
  45017. /**
  45018. * Unregisters a function called after every frame render
  45019. * @param func defines the function to unregister
  45020. */
  45021. unregisterAfterRender(func: () => void): void;
  45022. private _executeOnceBeforeRender;
  45023. /**
  45024. * The provided function will run before render once and will be disposed afterwards.
  45025. * A timeout delay can be provided so that the function will be executed in N ms.
  45026. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45027. * @param func The function to be executed.
  45028. * @param timeout optional delay in ms
  45029. */
  45030. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45031. /** @hidden */
  45032. _addPendingData(data: any): void;
  45033. /** @hidden */
  45034. _removePendingData(data: any): void;
  45035. /**
  45036. * Returns the number of items waiting to be loaded
  45037. * @returns the number of items waiting to be loaded
  45038. */
  45039. getWaitingItemsCount(): number;
  45040. /**
  45041. * Returns a boolean indicating if the scene is still loading data
  45042. */
  45043. get isLoading(): boolean;
  45044. /**
  45045. * Registers a function to be executed when the scene is ready
  45046. * @param {Function} func - the function to be executed
  45047. */
  45048. executeWhenReady(func: () => void): void;
  45049. /**
  45050. * Returns a promise that resolves when the scene is ready
  45051. * @returns A promise that resolves when the scene is ready
  45052. */
  45053. whenReadyAsync(): Promise<void>;
  45054. /** @hidden */
  45055. _checkIsReady(): void;
  45056. /**
  45057. * Gets all animatable attached to the scene
  45058. */
  45059. get animatables(): Animatable[];
  45060. /**
  45061. * Resets the last animation time frame.
  45062. * Useful to override when animations start running when loading a scene for the first time.
  45063. */
  45064. resetLastAnimationTimeFrame(): void;
  45065. /**
  45066. * Gets the current view matrix
  45067. * @returns a Matrix
  45068. */
  45069. getViewMatrix(): Matrix;
  45070. /**
  45071. * Gets the current projection matrix
  45072. * @returns a Matrix
  45073. */
  45074. getProjectionMatrix(): Matrix;
  45075. /**
  45076. * Gets the current transform matrix
  45077. * @returns a Matrix made of View * Projection
  45078. */
  45079. getTransformMatrix(): Matrix;
  45080. /**
  45081. * Sets the current transform matrix
  45082. * @param viewL defines the View matrix to use
  45083. * @param projectionL defines the Projection matrix to use
  45084. * @param viewR defines the right View matrix to use (if provided)
  45085. * @param projectionR defines the right Projection matrix to use (if provided)
  45086. */
  45087. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45088. /**
  45089. * Gets the uniform buffer used to store scene data
  45090. * @returns a UniformBuffer
  45091. */
  45092. getSceneUniformBuffer(): UniformBuffer;
  45093. /**
  45094. * Gets an unique (relatively to the current scene) Id
  45095. * @returns an unique number for the scene
  45096. */
  45097. getUniqueId(): number;
  45098. /**
  45099. * Add a mesh to the list of scene's meshes
  45100. * @param newMesh defines the mesh to add
  45101. * @param recursive if all child meshes should also be added to the scene
  45102. */
  45103. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45104. /**
  45105. * Remove a mesh for the list of scene's meshes
  45106. * @param toRemove defines the mesh to remove
  45107. * @param recursive if all child meshes should also be removed from the scene
  45108. * @returns the index where the mesh was in the mesh list
  45109. */
  45110. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45111. /**
  45112. * Add a transform node to the list of scene's transform nodes
  45113. * @param newTransformNode defines the transform node to add
  45114. */
  45115. addTransformNode(newTransformNode: TransformNode): void;
  45116. /**
  45117. * Remove a transform node for the list of scene's transform nodes
  45118. * @param toRemove defines the transform node to remove
  45119. * @returns the index where the transform node was in the transform node list
  45120. */
  45121. removeTransformNode(toRemove: TransformNode): number;
  45122. /**
  45123. * Remove a skeleton for the list of scene's skeletons
  45124. * @param toRemove defines the skeleton to remove
  45125. * @returns the index where the skeleton was in the skeleton list
  45126. */
  45127. removeSkeleton(toRemove: Skeleton): number;
  45128. /**
  45129. * Remove a morph target for the list of scene's morph targets
  45130. * @param toRemove defines the morph target to remove
  45131. * @returns the index where the morph target was in the morph target list
  45132. */
  45133. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45134. /**
  45135. * Remove a light for the list of scene's lights
  45136. * @param toRemove defines the light to remove
  45137. * @returns the index where the light was in the light list
  45138. */
  45139. removeLight(toRemove: Light): number;
  45140. /**
  45141. * Remove a camera for the list of scene's cameras
  45142. * @param toRemove defines the camera to remove
  45143. * @returns the index where the camera was in the camera list
  45144. */
  45145. removeCamera(toRemove: Camera): number;
  45146. /**
  45147. * Remove a particle system for the list of scene's particle systems
  45148. * @param toRemove defines the particle system to remove
  45149. * @returns the index where the particle system was in the particle system list
  45150. */
  45151. removeParticleSystem(toRemove: IParticleSystem): number;
  45152. /**
  45153. * Remove a animation for the list of scene's animations
  45154. * @param toRemove defines the animation to remove
  45155. * @returns the index where the animation was in the animation list
  45156. */
  45157. removeAnimation(toRemove: Animation): number;
  45158. /**
  45159. * Will stop the animation of the given target
  45160. * @param target - the target
  45161. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45162. * @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)
  45163. */
  45164. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45165. /**
  45166. * Removes the given animation group from this scene.
  45167. * @param toRemove The animation group to remove
  45168. * @returns The index of the removed animation group
  45169. */
  45170. removeAnimationGroup(toRemove: AnimationGroup): number;
  45171. /**
  45172. * Removes the given multi-material from this scene.
  45173. * @param toRemove The multi-material to remove
  45174. * @returns The index of the removed multi-material
  45175. */
  45176. removeMultiMaterial(toRemove: MultiMaterial): number;
  45177. /**
  45178. * Removes the given material from this scene.
  45179. * @param toRemove The material to remove
  45180. * @returns The index of the removed material
  45181. */
  45182. removeMaterial(toRemove: Material): number;
  45183. /**
  45184. * Removes the given action manager from this scene.
  45185. * @param toRemove The action manager to remove
  45186. * @returns The index of the removed action manager
  45187. */
  45188. removeActionManager(toRemove: AbstractActionManager): number;
  45189. /**
  45190. * Removes the given texture from this scene.
  45191. * @param toRemove The texture to remove
  45192. * @returns The index of the removed texture
  45193. */
  45194. removeTexture(toRemove: BaseTexture): number;
  45195. /**
  45196. * Adds the given light to this scene
  45197. * @param newLight The light to add
  45198. */
  45199. addLight(newLight: Light): void;
  45200. /**
  45201. * Sorts the list list based on light priorities
  45202. */
  45203. sortLightsByPriority(): void;
  45204. /**
  45205. * Adds the given camera to this scene
  45206. * @param newCamera The camera to add
  45207. */
  45208. addCamera(newCamera: Camera): void;
  45209. /**
  45210. * Adds the given skeleton to this scene
  45211. * @param newSkeleton The skeleton to add
  45212. */
  45213. addSkeleton(newSkeleton: Skeleton): void;
  45214. /**
  45215. * Adds the given particle system to this scene
  45216. * @param newParticleSystem The particle system to add
  45217. */
  45218. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45219. /**
  45220. * Adds the given animation to this scene
  45221. * @param newAnimation The animation to add
  45222. */
  45223. addAnimation(newAnimation: Animation): void;
  45224. /**
  45225. * Adds the given animation group to this scene.
  45226. * @param newAnimationGroup The animation group to add
  45227. */
  45228. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45229. /**
  45230. * Adds the given multi-material to this scene
  45231. * @param newMultiMaterial The multi-material to add
  45232. */
  45233. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45234. /**
  45235. * Adds the given material to this scene
  45236. * @param newMaterial The material to add
  45237. */
  45238. addMaterial(newMaterial: Material): void;
  45239. /**
  45240. * Adds the given morph target to this scene
  45241. * @param newMorphTargetManager The morph target to add
  45242. */
  45243. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45244. /**
  45245. * Adds the given geometry to this scene
  45246. * @param newGeometry The geometry to add
  45247. */
  45248. addGeometry(newGeometry: Geometry): void;
  45249. /**
  45250. * Adds the given action manager to this scene
  45251. * @param newActionManager The action manager to add
  45252. */
  45253. addActionManager(newActionManager: AbstractActionManager): void;
  45254. /**
  45255. * Adds the given texture to this scene.
  45256. * @param newTexture The texture to add
  45257. */
  45258. addTexture(newTexture: BaseTexture): void;
  45259. /**
  45260. * Switch active camera
  45261. * @param newCamera defines the new active camera
  45262. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45263. */
  45264. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45265. /**
  45266. * sets the active camera of the scene using its ID
  45267. * @param id defines the camera's ID
  45268. * @return the new active camera or null if none found.
  45269. */
  45270. setActiveCameraByID(id: string): Nullable<Camera>;
  45271. /**
  45272. * sets the active camera of the scene using its name
  45273. * @param name defines the camera's name
  45274. * @returns the new active camera or null if none found.
  45275. */
  45276. setActiveCameraByName(name: string): Nullable<Camera>;
  45277. /**
  45278. * get an animation group using its name
  45279. * @param name defines the material's name
  45280. * @return the animation group or null if none found.
  45281. */
  45282. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45283. /**
  45284. * Get a material using its unique id
  45285. * @param uniqueId defines the material's unique id
  45286. * @return the material or null if none found.
  45287. */
  45288. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45289. /**
  45290. * get a material using its id
  45291. * @param id defines the material's ID
  45292. * @return the material or null if none found.
  45293. */
  45294. getMaterialByID(id: string): Nullable<Material>;
  45295. /**
  45296. * Gets a the last added material using a given id
  45297. * @param id defines the material's ID
  45298. * @return the last material with the given id or null if none found.
  45299. */
  45300. getLastMaterialByID(id: string): Nullable<Material>;
  45301. /**
  45302. * Gets a material using its name
  45303. * @param name defines the material's name
  45304. * @return the material or null if none found.
  45305. */
  45306. getMaterialByName(name: string): Nullable<Material>;
  45307. /**
  45308. * Get a texture using its unique id
  45309. * @param uniqueId defines the texture's unique id
  45310. * @return the texture or null if none found.
  45311. */
  45312. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45313. /**
  45314. * Gets a camera using its id
  45315. * @param id defines the id to look for
  45316. * @returns the camera or null if not found
  45317. */
  45318. getCameraByID(id: string): Nullable<Camera>;
  45319. /**
  45320. * Gets a camera using its unique id
  45321. * @param uniqueId defines the unique id to look for
  45322. * @returns the camera or null if not found
  45323. */
  45324. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45325. /**
  45326. * Gets a camera using its name
  45327. * @param name defines the camera's name
  45328. * @return the camera or null if none found.
  45329. */
  45330. getCameraByName(name: string): Nullable<Camera>;
  45331. /**
  45332. * Gets a bone using its id
  45333. * @param id defines the bone's id
  45334. * @return the bone or null if not found
  45335. */
  45336. getBoneByID(id: string): Nullable<Bone>;
  45337. /**
  45338. * Gets a bone using its id
  45339. * @param name defines the bone's name
  45340. * @return the bone or null if not found
  45341. */
  45342. getBoneByName(name: string): Nullable<Bone>;
  45343. /**
  45344. * Gets a light node using its name
  45345. * @param name defines the the light's name
  45346. * @return the light or null if none found.
  45347. */
  45348. getLightByName(name: string): Nullable<Light>;
  45349. /**
  45350. * Gets a light node using its id
  45351. * @param id defines the light's id
  45352. * @return the light or null if none found.
  45353. */
  45354. getLightByID(id: string): Nullable<Light>;
  45355. /**
  45356. * Gets a light node using its scene-generated unique ID
  45357. * @param uniqueId defines the light's unique id
  45358. * @return the light or null if none found.
  45359. */
  45360. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45361. /**
  45362. * Gets a particle system by id
  45363. * @param id defines the particle system id
  45364. * @return the corresponding system or null if none found
  45365. */
  45366. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45367. /**
  45368. * Gets a geometry using its ID
  45369. * @param id defines the geometry's id
  45370. * @return the geometry or null if none found.
  45371. */
  45372. getGeometryByID(id: string): Nullable<Geometry>;
  45373. private _getGeometryByUniqueID;
  45374. /**
  45375. * Add a new geometry to this scene
  45376. * @param geometry defines the geometry to be added to the scene.
  45377. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45378. * @return a boolean defining if the geometry was added or not
  45379. */
  45380. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45381. /**
  45382. * Removes an existing geometry
  45383. * @param geometry defines the geometry to be removed from the scene
  45384. * @return a boolean defining if the geometry was removed or not
  45385. */
  45386. removeGeometry(geometry: Geometry): boolean;
  45387. /**
  45388. * Gets the list of geometries attached to the scene
  45389. * @returns an array of Geometry
  45390. */
  45391. getGeometries(): Geometry[];
  45392. /**
  45393. * Gets the first added mesh found of a given ID
  45394. * @param id defines the id to search for
  45395. * @return the mesh found or null if not found at all
  45396. */
  45397. getMeshByID(id: string): Nullable<AbstractMesh>;
  45398. /**
  45399. * Gets a list of meshes using their id
  45400. * @param id defines the id to search for
  45401. * @returns a list of meshes
  45402. */
  45403. getMeshesByID(id: string): Array<AbstractMesh>;
  45404. /**
  45405. * Gets the first added transform node found of a given ID
  45406. * @param id defines the id to search for
  45407. * @return the found transform node or null if not found at all.
  45408. */
  45409. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45410. /**
  45411. * Gets a transform node with its auto-generated unique id
  45412. * @param uniqueId efines the unique id to search for
  45413. * @return the found transform node or null if not found at all.
  45414. */
  45415. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45416. /**
  45417. * Gets a list of transform nodes using their id
  45418. * @param id defines the id to search for
  45419. * @returns a list of transform nodes
  45420. */
  45421. getTransformNodesByID(id: string): Array<TransformNode>;
  45422. /**
  45423. * Gets a mesh with its auto-generated unique id
  45424. * @param uniqueId defines the unique id to search for
  45425. * @return the found mesh or null if not found at all.
  45426. */
  45427. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45428. /**
  45429. * Gets a the last added mesh using a given id
  45430. * @param id defines the id to search for
  45431. * @return the found mesh or null if not found at all.
  45432. */
  45433. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45434. /**
  45435. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45436. * @param id defines the id to search for
  45437. * @return the found node or null if not found at all
  45438. */
  45439. getLastEntryByID(id: string): Nullable<Node>;
  45440. /**
  45441. * Gets a node (Mesh, Camera, Light) using a given id
  45442. * @param id defines the id to search for
  45443. * @return the found node or null if not found at all
  45444. */
  45445. getNodeByID(id: string): Nullable<Node>;
  45446. /**
  45447. * Gets a node (Mesh, Camera, Light) using a given name
  45448. * @param name defines the name to search for
  45449. * @return the found node or null if not found at all.
  45450. */
  45451. getNodeByName(name: string): Nullable<Node>;
  45452. /**
  45453. * Gets a mesh using a given name
  45454. * @param name defines the name to search for
  45455. * @return the found mesh or null if not found at all.
  45456. */
  45457. getMeshByName(name: string): Nullable<AbstractMesh>;
  45458. /**
  45459. * Gets a transform node using a given name
  45460. * @param name defines the name to search for
  45461. * @return the found transform node or null if not found at all.
  45462. */
  45463. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45464. /**
  45465. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45466. * @param id defines the id to search for
  45467. * @return the found skeleton or null if not found at all.
  45468. */
  45469. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45470. /**
  45471. * Gets a skeleton using a given auto generated unique id
  45472. * @param uniqueId defines the unique id to search for
  45473. * @return the found skeleton or null if not found at all.
  45474. */
  45475. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45476. /**
  45477. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45478. * @param id defines the id to search for
  45479. * @return the found skeleton or null if not found at all.
  45480. */
  45481. getSkeletonById(id: string): Nullable<Skeleton>;
  45482. /**
  45483. * Gets a skeleton using a given name
  45484. * @param name defines the name to search for
  45485. * @return the found skeleton or null if not found at all.
  45486. */
  45487. getSkeletonByName(name: string): Nullable<Skeleton>;
  45488. /**
  45489. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45490. * @param id defines the id to search for
  45491. * @return the found morph target manager or null if not found at all.
  45492. */
  45493. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45494. /**
  45495. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45496. * @param id defines the id to search for
  45497. * @return the found morph target or null if not found at all.
  45498. */
  45499. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45500. /**
  45501. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45502. * @param name defines the name to search for
  45503. * @return the found morph target or null if not found at all.
  45504. */
  45505. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45506. /**
  45507. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45508. * @param name defines the name to search for
  45509. * @return the found post process or null if not found at all.
  45510. */
  45511. getPostProcessByName(name: string): Nullable<PostProcess>;
  45512. /**
  45513. * Gets a boolean indicating if the given mesh is active
  45514. * @param mesh defines the mesh to look for
  45515. * @returns true if the mesh is in the active list
  45516. */
  45517. isActiveMesh(mesh: AbstractMesh): boolean;
  45518. /**
  45519. * Return a unique id as a string which can serve as an identifier for the scene
  45520. */
  45521. get uid(): string;
  45522. /**
  45523. * Add an externaly attached data from its key.
  45524. * This method call will fail and return false, if such key already exists.
  45525. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45526. * @param key the unique key that identifies the data
  45527. * @param data the data object to associate to the key for this Engine instance
  45528. * @return true if no such key were already present and the data was added successfully, false otherwise
  45529. */
  45530. addExternalData<T>(key: string, data: T): boolean;
  45531. /**
  45532. * Get an externaly attached data from its key
  45533. * @param key the unique key that identifies the data
  45534. * @return the associated data, if present (can be null), or undefined if not present
  45535. */
  45536. getExternalData<T>(key: string): Nullable<T>;
  45537. /**
  45538. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45539. * @param key the unique key that identifies the data
  45540. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45541. * @return the associated data, can be null if the factory returned null.
  45542. */
  45543. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45544. /**
  45545. * Remove an externaly attached data from the Engine instance
  45546. * @param key the unique key that identifies the data
  45547. * @return true if the data was successfully removed, false if it doesn't exist
  45548. */
  45549. removeExternalData(key: string): boolean;
  45550. private _evaluateSubMesh;
  45551. /**
  45552. * Clear the processed materials smart array preventing retention point in material dispose.
  45553. */
  45554. freeProcessedMaterials(): void;
  45555. private _preventFreeActiveMeshesAndRenderingGroups;
  45556. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45557. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45558. * when disposing several meshes in a row or a hierarchy of meshes.
  45559. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45560. */
  45561. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45562. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45563. /**
  45564. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45565. */
  45566. freeActiveMeshes(): void;
  45567. /**
  45568. * Clear the info related to rendering groups preventing retention points during dispose.
  45569. */
  45570. freeRenderingGroups(): void;
  45571. /** @hidden */
  45572. _isInIntermediateRendering(): boolean;
  45573. /**
  45574. * Lambda returning the list of potentially active meshes.
  45575. */
  45576. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45577. /**
  45578. * Lambda returning the list of potentially active sub meshes.
  45579. */
  45580. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45581. /**
  45582. * Lambda returning the list of potentially intersecting sub meshes.
  45583. */
  45584. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45585. /**
  45586. * Lambda returning the list of potentially colliding sub meshes.
  45587. */
  45588. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45589. private _activeMeshesFrozen;
  45590. private _skipEvaluateActiveMeshesCompletely;
  45591. /**
  45592. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45593. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45594. * @param onSuccess optional success callback
  45595. * @param onError optional error callback
  45596. * @returns the current scene
  45597. */
  45598. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45599. /**
  45600. * Use this function to restart evaluating active meshes on every frame
  45601. * @returns the current scene
  45602. */
  45603. unfreezeActiveMeshes(): Scene;
  45604. private _evaluateActiveMeshes;
  45605. private _activeMesh;
  45606. /**
  45607. * Update the transform matrix to update from the current active camera
  45608. * @param force defines a boolean used to force the update even if cache is up to date
  45609. */
  45610. updateTransformMatrix(force?: boolean): void;
  45611. private _bindFrameBuffer;
  45612. /** @hidden */
  45613. _allowPostProcessClearColor: boolean;
  45614. /** @hidden */
  45615. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45616. private _processSubCameras;
  45617. private _checkIntersections;
  45618. /** @hidden */
  45619. _advancePhysicsEngineStep(step: number): void;
  45620. /**
  45621. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45622. */
  45623. getDeterministicFrameTime: () => number;
  45624. /** @hidden */
  45625. _animate(): void;
  45626. /** Execute all animations (for a frame) */
  45627. animate(): void;
  45628. /**
  45629. * Render the scene
  45630. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45631. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45632. */
  45633. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45634. /**
  45635. * Freeze all materials
  45636. * A frozen material will not be updatable but should be faster to render
  45637. */
  45638. freezeMaterials(): void;
  45639. /**
  45640. * Unfreeze all materials
  45641. * A frozen material will not be updatable but should be faster to render
  45642. */
  45643. unfreezeMaterials(): void;
  45644. /**
  45645. * Releases all held ressources
  45646. */
  45647. dispose(): void;
  45648. /**
  45649. * Gets if the scene is already disposed
  45650. */
  45651. get isDisposed(): boolean;
  45652. /**
  45653. * Call this function to reduce memory footprint of the scene.
  45654. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45655. */
  45656. clearCachedVertexData(): void;
  45657. /**
  45658. * This function will remove the local cached buffer data from texture.
  45659. * It will save memory but will prevent the texture from being rebuilt
  45660. */
  45661. cleanCachedTextureBuffer(): void;
  45662. /**
  45663. * Get the world extend vectors with an optional filter
  45664. *
  45665. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45666. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45667. */
  45668. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45669. min: Vector3;
  45670. max: Vector3;
  45671. };
  45672. /**
  45673. * Creates a ray that can be used to pick in the scene
  45674. * @param x defines the x coordinate of the origin (on-screen)
  45675. * @param y defines the y coordinate of the origin (on-screen)
  45676. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45677. * @param camera defines the camera to use for the picking
  45678. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45679. * @returns a Ray
  45680. */
  45681. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45682. /**
  45683. * Creates a ray that can be used to pick in the scene
  45684. * @param x defines the x coordinate of the origin (on-screen)
  45685. * @param y defines the y coordinate of the origin (on-screen)
  45686. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45687. * @param result defines the ray where to store the picking ray
  45688. * @param camera defines the camera to use for the picking
  45689. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45690. * @returns the current scene
  45691. */
  45692. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45693. /**
  45694. * Creates a ray that can be used to pick in the scene
  45695. * @param x defines the x coordinate of the origin (on-screen)
  45696. * @param y defines the y coordinate of the origin (on-screen)
  45697. * @param camera defines the camera to use for the picking
  45698. * @returns a Ray
  45699. */
  45700. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45701. /**
  45702. * Creates a ray that can be used to pick in the scene
  45703. * @param x defines the x coordinate of the origin (on-screen)
  45704. * @param y defines the y coordinate of the origin (on-screen)
  45705. * @param result defines the ray where to store the picking ray
  45706. * @param camera defines the camera to use for the picking
  45707. * @returns the current scene
  45708. */
  45709. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45710. /** Launch a ray to try to pick a mesh in the scene
  45711. * @param x position on screen
  45712. * @param y position on screen
  45713. * @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
  45714. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45715. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45716. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45717. * @returns a PickingInfo
  45718. */
  45719. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45720. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45721. * @param x position on screen
  45722. * @param y position on screen
  45723. * @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
  45724. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45725. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45726. * @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)
  45727. */
  45728. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45729. /** Use the given ray to pick a mesh in the scene
  45730. * @param ray The ray to use to pick meshes
  45731. * @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
  45732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45734. * @returns a PickingInfo
  45735. */
  45736. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45737. /**
  45738. * Launch a ray to try to pick a mesh in the scene
  45739. * @param x X position on screen
  45740. * @param y Y position on screen
  45741. * @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
  45742. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45743. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45744. * @returns an array of PickingInfo
  45745. */
  45746. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45747. /**
  45748. * Launch a ray to try to pick a mesh in the scene
  45749. * @param ray Ray to use
  45750. * @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
  45751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45752. * @returns an array of PickingInfo
  45753. */
  45754. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45755. /**
  45756. * Force the value of meshUnderPointer
  45757. * @param mesh defines the mesh to use
  45758. * @param pointerId optional pointer id when using more than one pointer
  45759. */
  45760. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45761. /**
  45762. * Gets the mesh under the pointer
  45763. * @returns a Mesh or null if no mesh is under the pointer
  45764. */
  45765. getPointerOverMesh(): Nullable<AbstractMesh>;
  45766. /** @hidden */
  45767. _rebuildGeometries(): void;
  45768. /** @hidden */
  45769. _rebuildTextures(): void;
  45770. private _getByTags;
  45771. /**
  45772. * Get a list of meshes by tags
  45773. * @param tagsQuery defines the tags query to use
  45774. * @param forEach defines a predicate used to filter results
  45775. * @returns an array of Mesh
  45776. */
  45777. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45778. /**
  45779. * Get a list of cameras by tags
  45780. * @param tagsQuery defines the tags query to use
  45781. * @param forEach defines a predicate used to filter results
  45782. * @returns an array of Camera
  45783. */
  45784. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45785. /**
  45786. * Get a list of lights by tags
  45787. * @param tagsQuery defines the tags query to use
  45788. * @param forEach defines a predicate used to filter results
  45789. * @returns an array of Light
  45790. */
  45791. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45792. /**
  45793. * Get a list of materials by tags
  45794. * @param tagsQuery defines the tags query to use
  45795. * @param forEach defines a predicate used to filter results
  45796. * @returns an array of Material
  45797. */
  45798. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45799. /**
  45800. * Get a list of transform nodes by tags
  45801. * @param tagsQuery defines the tags query to use
  45802. * @param forEach defines a predicate used to filter results
  45803. * @returns an array of TransformNode
  45804. */
  45805. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45806. /**
  45807. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45808. * This allowed control for front to back rendering or reversly depending of the special needs.
  45809. *
  45810. * @param renderingGroupId The rendering group id corresponding to its index
  45811. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45812. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45813. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45814. */
  45815. 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;
  45816. /**
  45817. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45818. *
  45819. * @param renderingGroupId The rendering group id corresponding to its index
  45820. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45821. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45822. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45823. */
  45824. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45825. /**
  45826. * Gets the current auto clear configuration for one rendering group of the rendering
  45827. * manager.
  45828. * @param index the rendering group index to get the information for
  45829. * @returns The auto clear setup for the requested rendering group
  45830. */
  45831. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45832. private _blockMaterialDirtyMechanism;
  45833. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45834. get blockMaterialDirtyMechanism(): boolean;
  45835. set blockMaterialDirtyMechanism(value: boolean);
  45836. /**
  45837. * Will flag all materials as dirty to trigger new shader compilation
  45838. * @param flag defines the flag used to specify which material part must be marked as dirty
  45839. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45840. */
  45841. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45842. /** @hidden */
  45843. _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;
  45844. /** @hidden */
  45845. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45846. /** @hidden */
  45847. _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;
  45848. /** @hidden */
  45849. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45850. /** @hidden */
  45851. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45852. /** @hidden */
  45853. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45854. }
  45855. }
  45856. declare module "babylonjs/assetContainer" {
  45857. import { AbstractScene } from "babylonjs/abstractScene";
  45858. import { Scene } from "babylonjs/scene";
  45859. import { Mesh } from "babylonjs/Meshes/mesh";
  45860. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45861. import { Skeleton } from "babylonjs/Bones/skeleton";
  45862. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45863. import { Animatable } from "babylonjs/Animations/animatable";
  45864. import { Nullable } from "babylonjs/types";
  45865. import { Node } from "babylonjs/node";
  45866. /**
  45867. * Set of assets to keep when moving a scene into an asset container.
  45868. */
  45869. export class KeepAssets extends AbstractScene {
  45870. }
  45871. /**
  45872. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45873. */
  45874. export class InstantiatedEntries {
  45875. /**
  45876. * List of new root nodes (eg. nodes with no parent)
  45877. */
  45878. rootNodes: TransformNode[];
  45879. /**
  45880. * List of new skeletons
  45881. */
  45882. skeletons: Skeleton[];
  45883. /**
  45884. * List of new animation groups
  45885. */
  45886. animationGroups: AnimationGroup[];
  45887. }
  45888. /**
  45889. * Container with a set of assets that can be added or removed from a scene.
  45890. */
  45891. export class AssetContainer extends AbstractScene {
  45892. private _wasAddedToScene;
  45893. /**
  45894. * The scene the AssetContainer belongs to.
  45895. */
  45896. scene: Scene;
  45897. /**
  45898. * Instantiates an AssetContainer.
  45899. * @param scene The scene the AssetContainer belongs to.
  45900. */
  45901. constructor(scene: Scene);
  45902. /**
  45903. * Instantiate or clone all meshes and add the new ones to the scene.
  45904. * Skeletons and animation groups will all be cloned
  45905. * @param nameFunction defines an optional function used to get new names for clones
  45906. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45907. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45908. */
  45909. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45910. /**
  45911. * Adds all the assets from the container to the scene.
  45912. */
  45913. addAllToScene(): void;
  45914. /**
  45915. * Removes all the assets in the container from the scene
  45916. */
  45917. removeAllFromScene(): void;
  45918. /**
  45919. * Disposes all the assets in the container
  45920. */
  45921. dispose(): void;
  45922. private _moveAssets;
  45923. /**
  45924. * Removes all the assets contained in the scene and adds them to the container.
  45925. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45926. */
  45927. moveAllFromScene(keepAssets?: KeepAssets): void;
  45928. /**
  45929. * 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.
  45930. * @returns the root mesh
  45931. */
  45932. createRootMesh(): Mesh;
  45933. /**
  45934. * Merge animations (direct and animation groups) from this asset container into a scene
  45935. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45936. * @param animatables set of animatables to retarget to a node from the scene
  45937. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45938. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45939. */
  45940. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45941. }
  45942. }
  45943. declare module "babylonjs/abstractScene" {
  45944. import { Scene } from "babylonjs/scene";
  45945. import { Nullable } from "babylonjs/types";
  45946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45947. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45948. import { Geometry } from "babylonjs/Meshes/geometry";
  45949. import { Skeleton } from "babylonjs/Bones/skeleton";
  45950. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45951. import { AssetContainer } from "babylonjs/assetContainer";
  45952. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45953. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45955. import { Material } from "babylonjs/Materials/material";
  45956. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45957. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45958. import { Camera } from "babylonjs/Cameras/camera";
  45959. import { Light } from "babylonjs/Lights/light";
  45960. import { Node } from "babylonjs/node";
  45961. import { Animation } from "babylonjs/Animations/animation";
  45962. /**
  45963. * Defines how the parser contract is defined.
  45964. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45965. */
  45966. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45967. /**
  45968. * Defines how the individual parser contract is defined.
  45969. * These parser can parse an individual asset
  45970. */
  45971. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45972. /**
  45973. * Base class of the scene acting as a container for the different elements composing a scene.
  45974. * This class is dynamically extended by the different components of the scene increasing
  45975. * flexibility and reducing coupling
  45976. */
  45977. export abstract class AbstractScene {
  45978. /**
  45979. * Stores the list of available parsers in the application.
  45980. */
  45981. private static _BabylonFileParsers;
  45982. /**
  45983. * Stores the list of available individual parsers in the application.
  45984. */
  45985. private static _IndividualBabylonFileParsers;
  45986. /**
  45987. * Adds a parser in the list of available ones
  45988. * @param name Defines the name of the parser
  45989. * @param parser Defines the parser to add
  45990. */
  45991. static AddParser(name: string, parser: BabylonFileParser): void;
  45992. /**
  45993. * Gets a general parser from the list of avaialble ones
  45994. * @param name Defines the name of the parser
  45995. * @returns the requested parser or null
  45996. */
  45997. static GetParser(name: string): Nullable<BabylonFileParser>;
  45998. /**
  45999. * Adds n individual parser in the list of available ones
  46000. * @param name Defines the name of the parser
  46001. * @param parser Defines the parser to add
  46002. */
  46003. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46004. /**
  46005. * Gets an individual parser from the list of avaialble ones
  46006. * @param name Defines the name of the parser
  46007. * @returns the requested parser or null
  46008. */
  46009. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46010. /**
  46011. * Parser json data and populate both a scene and its associated container object
  46012. * @param jsonData Defines the data to parse
  46013. * @param scene Defines the scene to parse the data for
  46014. * @param container Defines the container attached to the parsing sequence
  46015. * @param rootUrl Defines the root url of the data
  46016. */
  46017. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46018. /**
  46019. * Gets the list of root nodes (ie. nodes with no parent)
  46020. */
  46021. rootNodes: Node[];
  46022. /** All of the cameras added to this scene
  46023. * @see https://doc.babylonjs.com/babylon101/cameras
  46024. */
  46025. cameras: Camera[];
  46026. /**
  46027. * All of the lights added to this scene
  46028. * @see https://doc.babylonjs.com/babylon101/lights
  46029. */
  46030. lights: Light[];
  46031. /**
  46032. * All of the (abstract) meshes added to this scene
  46033. */
  46034. meshes: AbstractMesh[];
  46035. /**
  46036. * The list of skeletons added to the scene
  46037. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46038. */
  46039. skeletons: Skeleton[];
  46040. /**
  46041. * All of the particle systems added to this scene
  46042. * @see https://doc.babylonjs.com/babylon101/particles
  46043. */
  46044. particleSystems: IParticleSystem[];
  46045. /**
  46046. * Gets a list of Animations associated with the scene
  46047. */
  46048. animations: Animation[];
  46049. /**
  46050. * All of the animation groups added to this scene
  46051. * @see https://doc.babylonjs.com/how_to/group
  46052. */
  46053. animationGroups: AnimationGroup[];
  46054. /**
  46055. * All of the multi-materials added to this scene
  46056. * @see https://doc.babylonjs.com/how_to/multi_materials
  46057. */
  46058. multiMaterials: MultiMaterial[];
  46059. /**
  46060. * All of the materials added to this scene
  46061. * In the context of a Scene, it is not supposed to be modified manually.
  46062. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46063. * Note also that the order of the Material within the array is not significant and might change.
  46064. * @see https://doc.babylonjs.com/babylon101/materials
  46065. */
  46066. materials: Material[];
  46067. /**
  46068. * The list of morph target managers added to the scene
  46069. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46070. */
  46071. morphTargetManagers: MorphTargetManager[];
  46072. /**
  46073. * The list of geometries used in the scene.
  46074. */
  46075. geometries: Geometry[];
  46076. /**
  46077. * All of the tranform nodes added to this scene
  46078. * In the context of a Scene, it is not supposed to be modified manually.
  46079. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46080. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46081. * @see https://doc.babylonjs.com/how_to/transformnode
  46082. */
  46083. transformNodes: TransformNode[];
  46084. /**
  46085. * ActionManagers available on the scene.
  46086. */
  46087. actionManagers: AbstractActionManager[];
  46088. /**
  46089. * Textures to keep.
  46090. */
  46091. textures: BaseTexture[];
  46092. /** @hidden */
  46093. protected _environmentTexture: Nullable<BaseTexture>;
  46094. /**
  46095. * Texture used in all pbr material as the reflection texture.
  46096. * As in the majority of the scene they are the same (exception for multi room and so on),
  46097. * this is easier to reference from here than from all the materials.
  46098. */
  46099. get environmentTexture(): Nullable<BaseTexture>;
  46100. set environmentTexture(value: Nullable<BaseTexture>);
  46101. /**
  46102. * The list of postprocesses added to the scene
  46103. */
  46104. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46105. /**
  46106. * @returns all meshes, lights, cameras, transformNodes and bones
  46107. */
  46108. getNodes(): Array<Node>;
  46109. }
  46110. }
  46111. declare module "babylonjs/Audio/sound" {
  46112. import { Observable } from "babylonjs/Misc/observable";
  46113. import { Vector3 } from "babylonjs/Maths/math.vector";
  46114. import { Nullable } from "babylonjs/types";
  46115. import { Scene } from "babylonjs/scene";
  46116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46117. /**
  46118. * Interface used to define options for Sound class
  46119. */
  46120. export interface ISoundOptions {
  46121. /**
  46122. * Does the sound autoplay once loaded.
  46123. */
  46124. autoplay?: boolean;
  46125. /**
  46126. * Does the sound loop after it finishes playing once.
  46127. */
  46128. loop?: boolean;
  46129. /**
  46130. * Sound's volume
  46131. */
  46132. volume?: number;
  46133. /**
  46134. * Is it a spatial sound?
  46135. */
  46136. spatialSound?: boolean;
  46137. /**
  46138. * Maximum distance to hear that sound
  46139. */
  46140. maxDistance?: number;
  46141. /**
  46142. * Uses user defined attenuation function
  46143. */
  46144. useCustomAttenuation?: boolean;
  46145. /**
  46146. * Define the roll off factor of spatial sounds.
  46147. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46148. */
  46149. rolloffFactor?: number;
  46150. /**
  46151. * Define the reference distance the sound should be heard perfectly.
  46152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46153. */
  46154. refDistance?: number;
  46155. /**
  46156. * Define the distance attenuation model the sound will follow.
  46157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46158. */
  46159. distanceModel?: string;
  46160. /**
  46161. * Defines the playback speed (1 by default)
  46162. */
  46163. playbackRate?: number;
  46164. /**
  46165. * Defines if the sound is from a streaming source
  46166. */
  46167. streaming?: boolean;
  46168. /**
  46169. * Defines an optional length (in seconds) inside the sound file
  46170. */
  46171. length?: number;
  46172. /**
  46173. * Defines an optional offset (in seconds) inside the sound file
  46174. */
  46175. offset?: number;
  46176. /**
  46177. * If true, URLs will not be required to state the audio file codec to use.
  46178. */
  46179. skipCodecCheck?: boolean;
  46180. }
  46181. /**
  46182. * Defines a sound that can be played in the application.
  46183. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46184. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46185. */
  46186. export class Sound {
  46187. /**
  46188. * The name of the sound in the scene.
  46189. */
  46190. name: string;
  46191. /**
  46192. * Does the sound autoplay once loaded.
  46193. */
  46194. autoplay: boolean;
  46195. /**
  46196. * Does the sound loop after it finishes playing once.
  46197. */
  46198. loop: boolean;
  46199. /**
  46200. * Does the sound use a custom attenuation curve to simulate the falloff
  46201. * happening when the source gets further away from the camera.
  46202. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46203. */
  46204. useCustomAttenuation: boolean;
  46205. /**
  46206. * The sound track id this sound belongs to.
  46207. */
  46208. soundTrackId: number;
  46209. /**
  46210. * Is this sound currently played.
  46211. */
  46212. isPlaying: boolean;
  46213. /**
  46214. * Is this sound currently paused.
  46215. */
  46216. isPaused: boolean;
  46217. /**
  46218. * Does this sound enables spatial sound.
  46219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46220. */
  46221. spatialSound: boolean;
  46222. /**
  46223. * Define the reference distance the sound should be heard perfectly.
  46224. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46225. */
  46226. refDistance: number;
  46227. /**
  46228. * Define the roll off factor of spatial sounds.
  46229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46230. */
  46231. rolloffFactor: number;
  46232. /**
  46233. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46235. */
  46236. maxDistance: number;
  46237. /**
  46238. * Define the distance attenuation model the sound will follow.
  46239. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46240. */
  46241. distanceModel: string;
  46242. /**
  46243. * @hidden
  46244. * Back Compat
  46245. **/
  46246. onended: () => any;
  46247. /**
  46248. * Gets or sets an object used to store user defined information for the sound.
  46249. */
  46250. metadata: any;
  46251. /**
  46252. * Observable event when the current playing sound finishes.
  46253. */
  46254. onEndedObservable: Observable<Sound>;
  46255. private _panningModel;
  46256. private _playbackRate;
  46257. private _streaming;
  46258. private _startTime;
  46259. private _startOffset;
  46260. private _position;
  46261. /** @hidden */
  46262. _positionInEmitterSpace: boolean;
  46263. private _localDirection;
  46264. private _volume;
  46265. private _isReadyToPlay;
  46266. private _isDirectional;
  46267. private _readyToPlayCallback;
  46268. private _audioBuffer;
  46269. private _soundSource;
  46270. private _streamingSource;
  46271. private _soundPanner;
  46272. private _soundGain;
  46273. private _inputAudioNode;
  46274. private _outputAudioNode;
  46275. private _coneInnerAngle;
  46276. private _coneOuterAngle;
  46277. private _coneOuterGain;
  46278. private _scene;
  46279. private _connectedTransformNode;
  46280. private _customAttenuationFunction;
  46281. private _registerFunc;
  46282. private _isOutputConnected;
  46283. private _htmlAudioElement;
  46284. private _urlType;
  46285. private _length?;
  46286. private _offset?;
  46287. /** @hidden */
  46288. static _SceneComponentInitialization: (scene: Scene) => void;
  46289. /**
  46290. * Create a sound and attach it to a scene
  46291. * @param name Name of your sound
  46292. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46293. * @param scene defines the scene the sound belongs to
  46294. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46295. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46296. */
  46297. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46298. /**
  46299. * Release the sound and its associated resources
  46300. */
  46301. dispose(): void;
  46302. /**
  46303. * Gets if the sounds is ready to be played or not.
  46304. * @returns true if ready, otherwise false
  46305. */
  46306. isReady(): boolean;
  46307. private _soundLoaded;
  46308. /**
  46309. * Sets the data of the sound from an audiobuffer
  46310. * @param audioBuffer The audioBuffer containing the data
  46311. */
  46312. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46313. /**
  46314. * Updates the current sounds options such as maxdistance, loop...
  46315. * @param options A JSON object containing values named as the object properties
  46316. */
  46317. updateOptions(options: ISoundOptions): void;
  46318. private _createSpatialParameters;
  46319. private _updateSpatialParameters;
  46320. /**
  46321. * Switch the panning model to HRTF:
  46322. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46324. */
  46325. switchPanningModelToHRTF(): void;
  46326. /**
  46327. * Switch the panning model to Equal Power:
  46328. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46329. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46330. */
  46331. switchPanningModelToEqualPower(): void;
  46332. private _switchPanningModel;
  46333. /**
  46334. * Connect this sound to a sound track audio node like gain...
  46335. * @param soundTrackAudioNode the sound track audio node to connect to
  46336. */
  46337. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46338. /**
  46339. * Transform this sound into a directional source
  46340. * @param coneInnerAngle Size of the inner cone in degree
  46341. * @param coneOuterAngle Size of the outer cone in degree
  46342. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46343. */
  46344. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46345. /**
  46346. * Gets or sets the inner angle for the directional cone.
  46347. */
  46348. get directionalConeInnerAngle(): number;
  46349. /**
  46350. * Gets or sets the inner angle for the directional cone.
  46351. */
  46352. set directionalConeInnerAngle(value: number);
  46353. /**
  46354. * Gets or sets the outer angle for the directional cone.
  46355. */
  46356. get directionalConeOuterAngle(): number;
  46357. /**
  46358. * Gets or sets the outer angle for the directional cone.
  46359. */
  46360. set directionalConeOuterAngle(value: number);
  46361. /**
  46362. * Sets the position of the emitter if spatial sound is enabled
  46363. * @param newPosition Defines the new posisiton
  46364. */
  46365. setPosition(newPosition: Vector3): void;
  46366. /**
  46367. * Sets the local direction of the emitter if spatial sound is enabled
  46368. * @param newLocalDirection Defines the new local direction
  46369. */
  46370. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46371. private _updateDirection;
  46372. /** @hidden */
  46373. updateDistanceFromListener(): void;
  46374. /**
  46375. * Sets a new custom attenuation function for the sound.
  46376. * @param callback Defines the function used for the attenuation
  46377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46378. */
  46379. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46380. /**
  46381. * Play the sound
  46382. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46383. * @param offset (optional) Start the sound at a specific time in seconds
  46384. * @param length (optional) Sound duration (in seconds)
  46385. */
  46386. play(time?: number, offset?: number, length?: number): void;
  46387. private _onended;
  46388. /**
  46389. * Stop the sound
  46390. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46391. */
  46392. stop(time?: number): void;
  46393. /**
  46394. * Put the sound in pause
  46395. */
  46396. pause(): void;
  46397. /**
  46398. * Sets a dedicated volume for this sounds
  46399. * @param newVolume Define the new volume of the sound
  46400. * @param time Define time for gradual change to new volume
  46401. */
  46402. setVolume(newVolume: number, time?: number): void;
  46403. /**
  46404. * Set the sound play back rate
  46405. * @param newPlaybackRate Define the playback rate the sound should be played at
  46406. */
  46407. setPlaybackRate(newPlaybackRate: number): void;
  46408. /**
  46409. * Gets the volume of the sound.
  46410. * @returns the volume of the sound
  46411. */
  46412. getVolume(): number;
  46413. /**
  46414. * Attach the sound to a dedicated mesh
  46415. * @param transformNode The transform node to connect the sound with
  46416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46417. */
  46418. attachToMesh(transformNode: TransformNode): void;
  46419. /**
  46420. * Detach the sound from the previously attached mesh
  46421. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46422. */
  46423. detachFromMesh(): void;
  46424. private _onRegisterAfterWorldMatrixUpdate;
  46425. /**
  46426. * Clone the current sound in the scene.
  46427. * @returns the new sound clone
  46428. */
  46429. clone(): Nullable<Sound>;
  46430. /**
  46431. * Gets the current underlying audio buffer containing the data
  46432. * @returns the audio buffer
  46433. */
  46434. getAudioBuffer(): Nullable<AudioBuffer>;
  46435. /**
  46436. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46437. * @returns the source node
  46438. */
  46439. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46440. /**
  46441. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46442. * @returns the gain node
  46443. */
  46444. getSoundGain(): Nullable<GainNode>;
  46445. /**
  46446. * Serializes the Sound in a JSON representation
  46447. * @returns the JSON representation of the sound
  46448. */
  46449. serialize(): any;
  46450. /**
  46451. * Parse a JSON representation of a sound to innstantiate in a given scene
  46452. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46453. * @param scene Define the scene the new parsed sound should be created in
  46454. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46455. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46456. * @returns the newly parsed sound
  46457. */
  46458. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46459. }
  46460. }
  46461. declare module "babylonjs/Actions/directAudioActions" {
  46462. import { Action } from "babylonjs/Actions/action";
  46463. import { Condition } from "babylonjs/Actions/condition";
  46464. import { Sound } from "babylonjs/Audio/sound";
  46465. /**
  46466. * This defines an action helpful to play a defined sound on a triggered action.
  46467. */
  46468. export class PlaySoundAction extends Action {
  46469. private _sound;
  46470. /**
  46471. * Instantiate the action
  46472. * @param triggerOptions defines the trigger options
  46473. * @param sound defines the sound to play
  46474. * @param condition defines the trigger related conditions
  46475. */
  46476. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46477. /** @hidden */
  46478. _prepare(): void;
  46479. /**
  46480. * Execute the action and play the sound.
  46481. */
  46482. execute(): void;
  46483. /**
  46484. * Serializes the actions and its related information.
  46485. * @param parent defines the object to serialize in
  46486. * @returns the serialized object
  46487. */
  46488. serialize(parent: any): any;
  46489. }
  46490. /**
  46491. * This defines an action helpful to stop a defined sound on a triggered action.
  46492. */
  46493. export class StopSoundAction extends Action {
  46494. private _sound;
  46495. /**
  46496. * Instantiate the action
  46497. * @param triggerOptions defines the trigger options
  46498. * @param sound defines the sound to stop
  46499. * @param condition defines the trigger related conditions
  46500. */
  46501. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46502. /** @hidden */
  46503. _prepare(): void;
  46504. /**
  46505. * Execute the action and stop the sound.
  46506. */
  46507. execute(): void;
  46508. /**
  46509. * Serializes the actions and its related information.
  46510. * @param parent defines the object to serialize in
  46511. * @returns the serialized object
  46512. */
  46513. serialize(parent: any): any;
  46514. }
  46515. }
  46516. declare module "babylonjs/Actions/interpolateValueAction" {
  46517. import { Action } from "babylonjs/Actions/action";
  46518. import { Condition } from "babylonjs/Actions/condition";
  46519. import { Observable } from "babylonjs/Misc/observable";
  46520. /**
  46521. * This defines an action responsible to change the value of a property
  46522. * by interpolating between its current value and the newly set one once triggered.
  46523. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46524. */
  46525. export class InterpolateValueAction extends Action {
  46526. /**
  46527. * Defines the path of the property where the value should be interpolated
  46528. */
  46529. propertyPath: string;
  46530. /**
  46531. * Defines the target value at the end of the interpolation.
  46532. */
  46533. value: any;
  46534. /**
  46535. * Defines the time it will take for the property to interpolate to the value.
  46536. */
  46537. duration: number;
  46538. /**
  46539. * Defines if the other scene animations should be stopped when the action has been triggered
  46540. */
  46541. stopOtherAnimations?: boolean;
  46542. /**
  46543. * Defines a callback raised once the interpolation animation has been done.
  46544. */
  46545. onInterpolationDone?: () => void;
  46546. /**
  46547. * Observable triggered once the interpolation animation has been done.
  46548. */
  46549. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46550. private _target;
  46551. private _effectiveTarget;
  46552. private _property;
  46553. /**
  46554. * Instantiate the action
  46555. * @param triggerOptions defines the trigger options
  46556. * @param target defines the object containing the value to interpolate
  46557. * @param propertyPath defines the path to the property in the target object
  46558. * @param value defines the target value at the end of the interpolation
  46559. * @param duration deines the time it will take for the property to interpolate to the value.
  46560. * @param condition defines the trigger related conditions
  46561. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46562. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46563. */
  46564. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46565. /** @hidden */
  46566. _prepare(): void;
  46567. /**
  46568. * Execute the action starts the value interpolation.
  46569. */
  46570. execute(): void;
  46571. /**
  46572. * Serializes the actions and its related information.
  46573. * @param parent defines the object to serialize in
  46574. * @returns the serialized object
  46575. */
  46576. serialize(parent: any): any;
  46577. }
  46578. }
  46579. declare module "babylonjs/Actions/index" {
  46580. export * from "babylonjs/Actions/abstractActionManager";
  46581. export * from "babylonjs/Actions/action";
  46582. export * from "babylonjs/Actions/actionEvent";
  46583. export * from "babylonjs/Actions/actionManager";
  46584. export * from "babylonjs/Actions/condition";
  46585. export * from "babylonjs/Actions/directActions";
  46586. export * from "babylonjs/Actions/directAudioActions";
  46587. export * from "babylonjs/Actions/interpolateValueAction";
  46588. }
  46589. declare module "babylonjs/Animations/index" {
  46590. export * from "babylonjs/Animations/animatable";
  46591. export * from "babylonjs/Animations/animation";
  46592. export * from "babylonjs/Animations/animationGroup";
  46593. export * from "babylonjs/Animations/animationPropertiesOverride";
  46594. export * from "babylonjs/Animations/easing";
  46595. export * from "babylonjs/Animations/runtimeAnimation";
  46596. export * from "babylonjs/Animations/animationEvent";
  46597. export * from "babylonjs/Animations/animationGroup";
  46598. export * from "babylonjs/Animations/animationKey";
  46599. export * from "babylonjs/Animations/animationRange";
  46600. export * from "babylonjs/Animations/animatable.interface";
  46601. }
  46602. declare module "babylonjs/Audio/soundTrack" {
  46603. import { Sound } from "babylonjs/Audio/sound";
  46604. import { Analyser } from "babylonjs/Audio/analyser";
  46605. import { Scene } from "babylonjs/scene";
  46606. /**
  46607. * Options allowed during the creation of a sound track.
  46608. */
  46609. export interface ISoundTrackOptions {
  46610. /**
  46611. * The volume the sound track should take during creation
  46612. */
  46613. volume?: number;
  46614. /**
  46615. * Define if the sound track is the main sound track of the scene
  46616. */
  46617. mainTrack?: boolean;
  46618. }
  46619. /**
  46620. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46621. * It will be also used in a future release to apply effects on a specific track.
  46622. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46623. */
  46624. export class SoundTrack {
  46625. /**
  46626. * The unique identifier of the sound track in the scene.
  46627. */
  46628. id: number;
  46629. /**
  46630. * The list of sounds included in the sound track.
  46631. */
  46632. soundCollection: Array<Sound>;
  46633. private _outputAudioNode;
  46634. private _scene;
  46635. private _connectedAnalyser;
  46636. private _options;
  46637. private _isInitialized;
  46638. /**
  46639. * Creates a new sound track.
  46640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46641. * @param scene Define the scene the sound track belongs to
  46642. * @param options
  46643. */
  46644. constructor(scene: Scene, options?: ISoundTrackOptions);
  46645. private _initializeSoundTrackAudioGraph;
  46646. /**
  46647. * Release the sound track and its associated resources
  46648. */
  46649. dispose(): void;
  46650. /**
  46651. * Adds a sound to this sound track
  46652. * @param sound define the cound to add
  46653. * @ignoreNaming
  46654. */
  46655. AddSound(sound: Sound): void;
  46656. /**
  46657. * Removes a sound to this sound track
  46658. * @param sound define the cound to remove
  46659. * @ignoreNaming
  46660. */
  46661. RemoveSound(sound: Sound): void;
  46662. /**
  46663. * Set a global volume for the full sound track.
  46664. * @param newVolume Define the new volume of the sound track
  46665. */
  46666. setVolume(newVolume: number): void;
  46667. /**
  46668. * Switch the panning model to HRTF:
  46669. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46670. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46671. */
  46672. switchPanningModelToHRTF(): void;
  46673. /**
  46674. * Switch the panning model to Equal Power:
  46675. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46676. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46677. */
  46678. switchPanningModelToEqualPower(): void;
  46679. /**
  46680. * Connect the sound track to an audio analyser allowing some amazing
  46681. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46682. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46683. * @param analyser The analyser to connect to the engine
  46684. */
  46685. connectToAnalyser(analyser: Analyser): void;
  46686. }
  46687. }
  46688. declare module "babylonjs/Audio/audioSceneComponent" {
  46689. import { Sound } from "babylonjs/Audio/sound";
  46690. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46691. import { Nullable } from "babylonjs/types";
  46692. import { Vector3 } from "babylonjs/Maths/math.vector";
  46693. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46694. import { Scene } from "babylonjs/scene";
  46695. import { AbstractScene } from "babylonjs/abstractScene";
  46696. import "babylonjs/Audio/audioEngine";
  46697. module "babylonjs/abstractScene" {
  46698. interface AbstractScene {
  46699. /**
  46700. * The list of sounds used in the scene.
  46701. */
  46702. sounds: Nullable<Array<Sound>>;
  46703. }
  46704. }
  46705. module "babylonjs/scene" {
  46706. interface Scene {
  46707. /**
  46708. * @hidden
  46709. * Backing field
  46710. */
  46711. _mainSoundTrack: SoundTrack;
  46712. /**
  46713. * The main sound track played by the scene.
  46714. * It cotains your primary collection of sounds.
  46715. */
  46716. mainSoundTrack: SoundTrack;
  46717. /**
  46718. * The list of sound tracks added to the scene
  46719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46720. */
  46721. soundTracks: Nullable<Array<SoundTrack>>;
  46722. /**
  46723. * Gets a sound using a given name
  46724. * @param name defines the name to search for
  46725. * @return the found sound or null if not found at all.
  46726. */
  46727. getSoundByName(name: string): Nullable<Sound>;
  46728. /**
  46729. * Gets or sets if audio support is enabled
  46730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46731. */
  46732. audioEnabled: boolean;
  46733. /**
  46734. * Gets or sets if audio will be output to headphones
  46735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46736. */
  46737. headphone: boolean;
  46738. /**
  46739. * Gets or sets custom audio listener position provider
  46740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46741. */
  46742. audioListenerPositionProvider: Nullable<() => Vector3>;
  46743. /**
  46744. * Gets or sets a refresh rate when using 3D audio positioning
  46745. */
  46746. audioPositioningRefreshRate: number;
  46747. }
  46748. }
  46749. /**
  46750. * Defines the sound scene component responsible to manage any sounds
  46751. * in a given scene.
  46752. */
  46753. export class AudioSceneComponent implements ISceneSerializableComponent {
  46754. private static _CameraDirectionLH;
  46755. private static _CameraDirectionRH;
  46756. /**
  46757. * The component name helpfull to identify the component in the list of scene components.
  46758. */
  46759. readonly name: string;
  46760. /**
  46761. * The scene the component belongs to.
  46762. */
  46763. scene: Scene;
  46764. private _audioEnabled;
  46765. /**
  46766. * Gets whether audio is enabled or not.
  46767. * Please use related enable/disable method to switch state.
  46768. */
  46769. get audioEnabled(): boolean;
  46770. private _headphone;
  46771. /**
  46772. * Gets whether audio is outputing to headphone or not.
  46773. * Please use the according Switch methods to change output.
  46774. */
  46775. get headphone(): boolean;
  46776. /**
  46777. * Gets or sets a refresh rate when using 3D audio positioning
  46778. */
  46779. audioPositioningRefreshRate: number;
  46780. private _audioListenerPositionProvider;
  46781. /**
  46782. * Gets the current audio listener position provider
  46783. */
  46784. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46785. /**
  46786. * Sets a custom listener position for all sounds in the scene
  46787. * By default, this is the position of the first active camera
  46788. */
  46789. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46790. /**
  46791. * Creates a new instance of the component for the given scene
  46792. * @param scene Defines the scene to register the component in
  46793. */
  46794. constructor(scene: Scene);
  46795. /**
  46796. * Registers the component in a given scene
  46797. */
  46798. register(): void;
  46799. /**
  46800. * Rebuilds the elements related to this component in case of
  46801. * context lost for instance.
  46802. */
  46803. rebuild(): void;
  46804. /**
  46805. * Serializes the component data to the specified json object
  46806. * @param serializationObject The object to serialize to
  46807. */
  46808. serialize(serializationObject: any): void;
  46809. /**
  46810. * Adds all the elements from the container to the scene
  46811. * @param container the container holding the elements
  46812. */
  46813. addFromContainer(container: AbstractScene): void;
  46814. /**
  46815. * Removes all the elements in the container from the scene
  46816. * @param container contains the elements to remove
  46817. * @param dispose if the removed element should be disposed (default: false)
  46818. */
  46819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46820. /**
  46821. * Disposes the component and the associated ressources.
  46822. */
  46823. dispose(): void;
  46824. /**
  46825. * Disables audio in the associated scene.
  46826. */
  46827. disableAudio(): void;
  46828. /**
  46829. * Enables audio in the associated scene.
  46830. */
  46831. enableAudio(): void;
  46832. /**
  46833. * Switch audio to headphone output.
  46834. */
  46835. switchAudioModeForHeadphones(): void;
  46836. /**
  46837. * Switch audio to normal speakers.
  46838. */
  46839. switchAudioModeForNormalSpeakers(): void;
  46840. private _cachedCameraDirection;
  46841. private _cachedCameraPosition;
  46842. private _lastCheck;
  46843. private _afterRender;
  46844. }
  46845. }
  46846. declare module "babylonjs/Audio/weightedsound" {
  46847. import { Sound } from "babylonjs/Audio/sound";
  46848. /**
  46849. * Wraps one or more Sound objects and selects one with random weight for playback.
  46850. */
  46851. export class WeightedSound {
  46852. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46853. loop: boolean;
  46854. private _coneInnerAngle;
  46855. private _coneOuterAngle;
  46856. private _volume;
  46857. /** A Sound is currently playing. */
  46858. isPlaying: boolean;
  46859. /** A Sound is currently paused. */
  46860. isPaused: boolean;
  46861. private _sounds;
  46862. private _weights;
  46863. private _currentIndex?;
  46864. /**
  46865. * Creates a new WeightedSound from the list of sounds given.
  46866. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46867. * @param sounds Array of Sounds that will be selected from.
  46868. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46869. */
  46870. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46871. /**
  46872. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46873. */
  46874. get directionalConeInnerAngle(): number;
  46875. /**
  46876. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46877. */
  46878. set directionalConeInnerAngle(value: number);
  46879. /**
  46880. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46881. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46882. */
  46883. get directionalConeOuterAngle(): number;
  46884. /**
  46885. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46886. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46887. */
  46888. set directionalConeOuterAngle(value: number);
  46889. /**
  46890. * Playback volume.
  46891. */
  46892. get volume(): number;
  46893. /**
  46894. * Playback volume.
  46895. */
  46896. set volume(value: number);
  46897. private _onended;
  46898. /**
  46899. * Suspend playback
  46900. */
  46901. pause(): void;
  46902. /**
  46903. * Stop playback
  46904. */
  46905. stop(): void;
  46906. /**
  46907. * Start playback.
  46908. * @param startOffset Position the clip head at a specific time in seconds.
  46909. */
  46910. play(startOffset?: number): void;
  46911. }
  46912. }
  46913. declare module "babylonjs/Audio/index" {
  46914. export * from "babylonjs/Audio/analyser";
  46915. export * from "babylonjs/Audio/audioEngine";
  46916. export * from "babylonjs/Audio/audioSceneComponent";
  46917. export * from "babylonjs/Audio/sound";
  46918. export * from "babylonjs/Audio/soundTrack";
  46919. export * from "babylonjs/Audio/weightedsound";
  46920. }
  46921. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46922. import { Behavior } from "babylonjs/Behaviors/behavior";
  46923. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46924. import { BackEase } from "babylonjs/Animations/easing";
  46925. /**
  46926. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46927. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46928. */
  46929. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46930. /**
  46931. * Gets the name of the behavior.
  46932. */
  46933. get name(): string;
  46934. /**
  46935. * The easing function used by animations
  46936. */
  46937. static EasingFunction: BackEase;
  46938. /**
  46939. * The easing mode used by animations
  46940. */
  46941. static EasingMode: number;
  46942. /**
  46943. * The duration of the animation, in milliseconds
  46944. */
  46945. transitionDuration: number;
  46946. /**
  46947. * Length of the distance animated by the transition when lower radius is reached
  46948. */
  46949. lowerRadiusTransitionRange: number;
  46950. /**
  46951. * Length of the distance animated by the transition when upper radius is reached
  46952. */
  46953. upperRadiusTransitionRange: number;
  46954. private _autoTransitionRange;
  46955. /**
  46956. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46957. */
  46958. get autoTransitionRange(): boolean;
  46959. /**
  46960. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46961. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46962. */
  46963. set autoTransitionRange(value: boolean);
  46964. private _attachedCamera;
  46965. private _onAfterCheckInputsObserver;
  46966. private _onMeshTargetChangedObserver;
  46967. /**
  46968. * Initializes the behavior.
  46969. */
  46970. init(): void;
  46971. /**
  46972. * Attaches the behavior to its arc rotate camera.
  46973. * @param camera Defines the camera to attach the behavior to
  46974. */
  46975. attach(camera: ArcRotateCamera): void;
  46976. /**
  46977. * Detaches the behavior from its current arc rotate camera.
  46978. */
  46979. detach(): void;
  46980. private _radiusIsAnimating;
  46981. private _radiusBounceTransition;
  46982. private _animatables;
  46983. private _cachedWheelPrecision;
  46984. /**
  46985. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46986. * @param radiusLimit The limit to check against.
  46987. * @return Bool to indicate if at limit.
  46988. */
  46989. private _isRadiusAtLimit;
  46990. /**
  46991. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  46992. * @param radiusDelta The delta by which to animate to. Can be negative.
  46993. */
  46994. private _applyBoundRadiusAnimation;
  46995. /**
  46996. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  46997. */
  46998. protected _clearAnimationLocks(): void;
  46999. /**
  47000. * Stops and removes all animations that have been applied to the camera
  47001. */
  47002. stopAllAnimations(): void;
  47003. }
  47004. }
  47005. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47006. import { Behavior } from "babylonjs/Behaviors/behavior";
  47007. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47008. import { ExponentialEase } from "babylonjs/Animations/easing";
  47009. import { Nullable } from "babylonjs/types";
  47010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47011. import { Vector3 } from "babylonjs/Maths/math.vector";
  47012. /**
  47013. * 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.
  47014. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47015. */
  47016. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47017. /**
  47018. * Gets the name of the behavior.
  47019. */
  47020. get name(): string;
  47021. private _mode;
  47022. private _radiusScale;
  47023. private _positionScale;
  47024. private _defaultElevation;
  47025. private _elevationReturnTime;
  47026. private _elevationReturnWaitTime;
  47027. private _zoomStopsAnimation;
  47028. private _framingTime;
  47029. /**
  47030. * The easing function used by animations
  47031. */
  47032. static EasingFunction: ExponentialEase;
  47033. /**
  47034. * The easing mode used by animations
  47035. */
  47036. static EasingMode: number;
  47037. /**
  47038. * Sets the current mode used by the behavior
  47039. */
  47040. set mode(mode: number);
  47041. /**
  47042. * Gets current mode used by the behavior.
  47043. */
  47044. get mode(): number;
  47045. /**
  47046. * Sets the scale applied to the radius (1 by default)
  47047. */
  47048. set radiusScale(radius: number);
  47049. /**
  47050. * Gets the scale applied to the radius
  47051. */
  47052. get radiusScale(): number;
  47053. /**
  47054. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47055. */
  47056. set positionScale(scale: number);
  47057. /**
  47058. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47059. */
  47060. get positionScale(): number;
  47061. /**
  47062. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47063. * behaviour is triggered, in radians.
  47064. */
  47065. set defaultElevation(elevation: number);
  47066. /**
  47067. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47068. * behaviour is triggered, in radians.
  47069. */
  47070. get defaultElevation(): number;
  47071. /**
  47072. * Sets the time (in milliseconds) taken to return to the default beta position.
  47073. * Negative value indicates camera should not return to default.
  47074. */
  47075. set elevationReturnTime(speed: number);
  47076. /**
  47077. * Gets the time (in milliseconds) taken to return to the default beta position.
  47078. * Negative value indicates camera should not return to default.
  47079. */
  47080. get elevationReturnTime(): number;
  47081. /**
  47082. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47083. */
  47084. set elevationReturnWaitTime(time: number);
  47085. /**
  47086. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47087. */
  47088. get elevationReturnWaitTime(): number;
  47089. /**
  47090. * Sets the flag that indicates if user zooming should stop animation.
  47091. */
  47092. set zoomStopsAnimation(flag: boolean);
  47093. /**
  47094. * Gets the flag that indicates if user zooming should stop animation.
  47095. */
  47096. get zoomStopsAnimation(): boolean;
  47097. /**
  47098. * Sets the transition time when framing the mesh, in milliseconds
  47099. */
  47100. set framingTime(time: number);
  47101. /**
  47102. * Gets the transition time when framing the mesh, in milliseconds
  47103. */
  47104. get framingTime(): number;
  47105. /**
  47106. * Define if the behavior should automatically change the configured
  47107. * camera limits and sensibilities.
  47108. */
  47109. autoCorrectCameraLimitsAndSensibility: boolean;
  47110. private _onPrePointerObservableObserver;
  47111. private _onAfterCheckInputsObserver;
  47112. private _onMeshTargetChangedObserver;
  47113. private _attachedCamera;
  47114. private _isPointerDown;
  47115. private _lastInteractionTime;
  47116. /**
  47117. * Initializes the behavior.
  47118. */
  47119. init(): void;
  47120. /**
  47121. * Attaches the behavior to its arc rotate camera.
  47122. * @param camera Defines the camera to attach the behavior to
  47123. */
  47124. attach(camera: ArcRotateCamera): void;
  47125. /**
  47126. * Detaches the behavior from its current arc rotate camera.
  47127. */
  47128. detach(): void;
  47129. private _animatables;
  47130. private _betaIsAnimating;
  47131. private _betaTransition;
  47132. private _radiusTransition;
  47133. private _vectorTransition;
  47134. /**
  47135. * Targets the given mesh and updates zoom level accordingly.
  47136. * @param mesh The mesh to target.
  47137. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47138. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47139. */
  47140. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47141. /**
  47142. * Targets the given mesh with its children and updates zoom level accordingly.
  47143. * @param mesh The mesh to target.
  47144. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47145. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47146. */
  47147. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47148. /**
  47149. * Targets the given meshes with their children and updates zoom level accordingly.
  47150. * @param meshes The mesh to target.
  47151. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47152. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47153. */
  47154. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47155. /**
  47156. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47157. * @param minimumWorld Determines the smaller position of the bounding box extend
  47158. * @param maximumWorld Determines the bigger position of the bounding box extend
  47159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47161. */
  47162. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47163. /**
  47164. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47165. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47166. * frustum width.
  47167. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47168. * to fully enclose the mesh in the viewing frustum.
  47169. */
  47170. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47171. /**
  47172. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47173. * is automatically returned to its default position (expected to be above ground plane).
  47174. */
  47175. private _maintainCameraAboveGround;
  47176. /**
  47177. * Returns the frustum slope based on the canvas ratio and camera FOV
  47178. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47179. */
  47180. private _getFrustumSlope;
  47181. /**
  47182. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47183. */
  47184. private _clearAnimationLocks;
  47185. /**
  47186. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47187. */
  47188. private _applyUserInteraction;
  47189. /**
  47190. * Stops and removes all animations that have been applied to the camera
  47191. */
  47192. stopAllAnimations(): void;
  47193. /**
  47194. * Gets a value indicating if the user is moving the camera
  47195. */
  47196. get isUserIsMoving(): boolean;
  47197. /**
  47198. * The camera can move all the way towards the mesh.
  47199. */
  47200. static IgnoreBoundsSizeMode: number;
  47201. /**
  47202. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47203. */
  47204. static FitFrustumSidesMode: number;
  47205. }
  47206. }
  47207. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47208. import { Nullable } from "babylonjs/types";
  47209. import { Camera } from "babylonjs/Cameras/camera";
  47210. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47211. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47212. /**
  47213. * Base class for Camera Pointer Inputs.
  47214. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47215. * for example usage.
  47216. */
  47217. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47218. /**
  47219. * Defines the camera the input is attached to.
  47220. */
  47221. abstract camera: Camera;
  47222. /**
  47223. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47224. */
  47225. protected _altKey: boolean;
  47226. protected _ctrlKey: boolean;
  47227. protected _metaKey: boolean;
  47228. protected _shiftKey: boolean;
  47229. /**
  47230. * Which mouse buttons were pressed at time of last mouse event.
  47231. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47232. */
  47233. protected _buttonsPressed: number;
  47234. /**
  47235. * Defines the buttons associated with the input to handle camera move.
  47236. */
  47237. buttons: number[];
  47238. /**
  47239. * Attach the input controls to a specific dom element to get the input from.
  47240. * @param element Defines the element the controls should be listened from
  47241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47242. */
  47243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47244. /**
  47245. * Detach the current controls from the specified dom element.
  47246. * @param element Defines the element to stop listening the inputs from
  47247. */
  47248. detachControl(element: Nullable<HTMLElement>): void;
  47249. /**
  47250. * Gets the class name of the current input.
  47251. * @returns the class name
  47252. */
  47253. getClassName(): string;
  47254. /**
  47255. * Get the friendly name associated with the input class.
  47256. * @returns the input friendly name
  47257. */
  47258. getSimpleName(): string;
  47259. /**
  47260. * Called on pointer POINTERDOUBLETAP event.
  47261. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47262. */
  47263. protected onDoubleTap(type: string): void;
  47264. /**
  47265. * Called on pointer POINTERMOVE event if only a single touch is active.
  47266. * Override this method to provide functionality.
  47267. */
  47268. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47269. /**
  47270. * Called on pointer POINTERMOVE event if multiple touches are active.
  47271. * Override this method to provide functionality.
  47272. */
  47273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47274. /**
  47275. * Called on JS contextmenu event.
  47276. * Override this method to provide functionality.
  47277. */
  47278. protected onContextMenu(evt: PointerEvent): void;
  47279. /**
  47280. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47281. * press.
  47282. * Override this method to provide functionality.
  47283. */
  47284. protected onButtonDown(evt: PointerEvent): void;
  47285. /**
  47286. * Called each time a new POINTERUP event occurs. Ie, for each button
  47287. * release.
  47288. * Override this method to provide functionality.
  47289. */
  47290. protected onButtonUp(evt: PointerEvent): void;
  47291. /**
  47292. * Called when window becomes inactive.
  47293. * Override this method to provide functionality.
  47294. */
  47295. protected onLostFocus(): void;
  47296. private _pointerInput;
  47297. private _observer;
  47298. private _onLostFocus;
  47299. private pointA;
  47300. private pointB;
  47301. }
  47302. }
  47303. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47304. import { Nullable } from "babylonjs/types";
  47305. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47306. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47307. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47308. /**
  47309. * Manage the pointers inputs to control an arc rotate camera.
  47310. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47311. */
  47312. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47313. /**
  47314. * Defines the camera the input is attached to.
  47315. */
  47316. camera: ArcRotateCamera;
  47317. /**
  47318. * Gets the class name of the current input.
  47319. * @returns the class name
  47320. */
  47321. getClassName(): string;
  47322. /**
  47323. * Defines the buttons associated with the input to handle camera move.
  47324. */
  47325. buttons: number[];
  47326. /**
  47327. * Defines the pointer angular sensibility along the X axis or how fast is
  47328. * the camera rotating.
  47329. */
  47330. angularSensibilityX: number;
  47331. /**
  47332. * Defines the pointer angular sensibility along the Y axis or how fast is
  47333. * the camera rotating.
  47334. */
  47335. angularSensibilityY: number;
  47336. /**
  47337. * Defines the pointer pinch precision or how fast is the camera zooming.
  47338. */
  47339. pinchPrecision: number;
  47340. /**
  47341. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47342. * from 0.
  47343. * It defines the percentage of current camera.radius to use as delta when
  47344. * pinch zoom is used.
  47345. */
  47346. pinchDeltaPercentage: number;
  47347. /**
  47348. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47349. * that any object in the plane at the camera's target point will scale
  47350. * perfectly with finger motion.
  47351. * Overrides pinchDeltaPercentage and pinchPrecision.
  47352. */
  47353. useNaturalPinchZoom: boolean;
  47354. /**
  47355. * Defines the pointer panning sensibility or how fast is the camera moving.
  47356. */
  47357. panningSensibility: number;
  47358. /**
  47359. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47360. */
  47361. multiTouchPanning: boolean;
  47362. /**
  47363. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47364. * zoom (pinch) through multitouch.
  47365. */
  47366. multiTouchPanAndZoom: boolean;
  47367. /**
  47368. * Revers pinch action direction.
  47369. */
  47370. pinchInwards: boolean;
  47371. private _isPanClick;
  47372. private _twoFingerActivityCount;
  47373. private _isPinching;
  47374. /**
  47375. * Called on pointer POINTERMOVE event if only a single touch is active.
  47376. */
  47377. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47378. /**
  47379. * Called on pointer POINTERDOUBLETAP event.
  47380. */
  47381. protected onDoubleTap(type: string): void;
  47382. /**
  47383. * Called on pointer POINTERMOVE event if multiple touches are active.
  47384. */
  47385. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47386. /**
  47387. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47388. * press.
  47389. */
  47390. protected onButtonDown(evt: PointerEvent): void;
  47391. /**
  47392. * Called each time a new POINTERUP event occurs. Ie, for each button
  47393. * release.
  47394. */
  47395. protected onButtonUp(evt: PointerEvent): void;
  47396. /**
  47397. * Called when window becomes inactive.
  47398. */
  47399. protected onLostFocus(): void;
  47400. }
  47401. }
  47402. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47403. import { Nullable } from "babylonjs/types";
  47404. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47405. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47406. /**
  47407. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47408. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47409. */
  47410. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47411. /**
  47412. * Defines the camera the input is attached to.
  47413. */
  47414. camera: ArcRotateCamera;
  47415. /**
  47416. * Defines the list of key codes associated with the up action (increase alpha)
  47417. */
  47418. keysUp: number[];
  47419. /**
  47420. * Defines the list of key codes associated with the down action (decrease alpha)
  47421. */
  47422. keysDown: number[];
  47423. /**
  47424. * Defines the list of key codes associated with the left action (increase beta)
  47425. */
  47426. keysLeft: number[];
  47427. /**
  47428. * Defines the list of key codes associated with the right action (decrease beta)
  47429. */
  47430. keysRight: number[];
  47431. /**
  47432. * Defines the list of key codes associated with the reset action.
  47433. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47434. */
  47435. keysReset: number[];
  47436. /**
  47437. * Defines the panning sensibility of the inputs.
  47438. * (How fast is the camera panning)
  47439. */
  47440. panningSensibility: number;
  47441. /**
  47442. * Defines the zooming sensibility of the inputs.
  47443. * (How fast is the camera zooming)
  47444. */
  47445. zoomingSensibility: number;
  47446. /**
  47447. * Defines whether maintaining the alt key down switch the movement mode from
  47448. * orientation to zoom.
  47449. */
  47450. useAltToZoom: boolean;
  47451. /**
  47452. * Rotation speed of the camera
  47453. */
  47454. angularSpeed: number;
  47455. private _keys;
  47456. private _ctrlPressed;
  47457. private _altPressed;
  47458. private _onCanvasBlurObserver;
  47459. private _onKeyboardObserver;
  47460. private _engine;
  47461. private _scene;
  47462. /**
  47463. * Attach the input controls to a specific dom element to get the input from.
  47464. * @param element Defines the element the controls should be listened from
  47465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47466. */
  47467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47468. /**
  47469. * Detach the current controls from the specified dom element.
  47470. * @param element Defines the element to stop listening the inputs from
  47471. */
  47472. detachControl(element: Nullable<HTMLElement>): void;
  47473. /**
  47474. * Update the current camera state depending on the inputs that have been used this frame.
  47475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47476. */
  47477. checkInputs(): void;
  47478. /**
  47479. * Gets the class name of the current intput.
  47480. * @returns the class name
  47481. */
  47482. getClassName(): string;
  47483. /**
  47484. * Get the friendly name associated with the input class.
  47485. * @returns the input friendly name
  47486. */
  47487. getSimpleName(): string;
  47488. }
  47489. }
  47490. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47491. import { Nullable } from "babylonjs/types";
  47492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47493. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47494. /**
  47495. * Manage the mouse wheel inputs to control an arc rotate camera.
  47496. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47497. */
  47498. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47499. /**
  47500. * Defines the camera the input is attached to.
  47501. */
  47502. camera: ArcRotateCamera;
  47503. /**
  47504. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47505. */
  47506. wheelPrecision: number;
  47507. /**
  47508. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47509. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47510. */
  47511. wheelDeltaPercentage: number;
  47512. private _wheel;
  47513. private _observer;
  47514. private computeDeltaFromMouseWheelLegacyEvent;
  47515. /**
  47516. * Attach the input controls to a specific dom element to get the input from.
  47517. * @param element Defines the element the controls should be listened from
  47518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47519. */
  47520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47521. /**
  47522. * Detach the current controls from the specified dom element.
  47523. * @param element Defines the element to stop listening the inputs from
  47524. */
  47525. detachControl(element: Nullable<HTMLElement>): void;
  47526. /**
  47527. * Gets the class name of the current intput.
  47528. * @returns the class name
  47529. */
  47530. getClassName(): string;
  47531. /**
  47532. * Get the friendly name associated with the input class.
  47533. * @returns the input friendly name
  47534. */
  47535. getSimpleName(): string;
  47536. }
  47537. }
  47538. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47540. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47541. /**
  47542. * Default Inputs manager for the ArcRotateCamera.
  47543. * It groups all the default supported inputs for ease of use.
  47544. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47545. */
  47546. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47547. /**
  47548. * Instantiates a new ArcRotateCameraInputsManager.
  47549. * @param camera Defines the camera the inputs belong to
  47550. */
  47551. constructor(camera: ArcRotateCamera);
  47552. /**
  47553. * Add mouse wheel input support to the input manager.
  47554. * @returns the current input manager
  47555. */
  47556. addMouseWheel(): ArcRotateCameraInputsManager;
  47557. /**
  47558. * Add pointers input support to the input manager.
  47559. * @returns the current input manager
  47560. */
  47561. addPointers(): ArcRotateCameraInputsManager;
  47562. /**
  47563. * Add keyboard input support to the input manager.
  47564. * @returns the current input manager
  47565. */
  47566. addKeyboard(): ArcRotateCameraInputsManager;
  47567. }
  47568. }
  47569. declare module "babylonjs/Cameras/arcRotateCamera" {
  47570. import { Observable } from "babylonjs/Misc/observable";
  47571. import { Nullable } from "babylonjs/types";
  47572. import { Scene } from "babylonjs/scene";
  47573. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47575. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47576. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47577. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47578. import { Camera } from "babylonjs/Cameras/camera";
  47579. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47580. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47581. import { Collider } from "babylonjs/Collisions/collider";
  47582. /**
  47583. * This represents an orbital type of camera.
  47584. *
  47585. * 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.
  47586. * 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.
  47587. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47588. */
  47589. export class ArcRotateCamera extends TargetCamera {
  47590. /**
  47591. * Defines the rotation angle of the camera along the longitudinal axis.
  47592. */
  47593. alpha: number;
  47594. /**
  47595. * Defines the rotation angle of the camera along the latitudinal axis.
  47596. */
  47597. beta: number;
  47598. /**
  47599. * Defines the radius of the camera from it s target point.
  47600. */
  47601. radius: number;
  47602. protected _target: Vector3;
  47603. protected _targetHost: Nullable<AbstractMesh>;
  47604. /**
  47605. * Defines the target point of the camera.
  47606. * The camera looks towards it form the radius distance.
  47607. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47608. */
  47609. get target(): Vector3;
  47610. set target(value: Vector3);
  47611. /**
  47612. * Define the current local position of the camera in the scene
  47613. */
  47614. get position(): Vector3;
  47615. set position(newPosition: Vector3);
  47616. protected _upToYMatrix: Matrix;
  47617. protected _YToUpMatrix: Matrix;
  47618. /**
  47619. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47620. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47621. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47622. */
  47623. set upVector(vec: Vector3);
  47624. get upVector(): Vector3;
  47625. /**
  47626. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47627. */
  47628. setMatUp(): void;
  47629. /**
  47630. * Current inertia value on the longitudinal axis.
  47631. * The bigger this number the longer it will take for the camera to stop.
  47632. */
  47633. inertialAlphaOffset: number;
  47634. /**
  47635. * Current inertia value on the latitudinal axis.
  47636. * The bigger this number the longer it will take for the camera to stop.
  47637. */
  47638. inertialBetaOffset: number;
  47639. /**
  47640. * Current inertia value on the radius axis.
  47641. * The bigger this number the longer it will take for the camera to stop.
  47642. */
  47643. inertialRadiusOffset: number;
  47644. /**
  47645. * Minimum allowed angle on the longitudinal axis.
  47646. * This can help limiting how the Camera is able to move in the scene.
  47647. */
  47648. lowerAlphaLimit: Nullable<number>;
  47649. /**
  47650. * Maximum allowed angle on the longitudinal axis.
  47651. * This can help limiting how the Camera is able to move in the scene.
  47652. */
  47653. upperAlphaLimit: Nullable<number>;
  47654. /**
  47655. * Minimum allowed angle on the latitudinal axis.
  47656. * This can help limiting how the Camera is able to move in the scene.
  47657. */
  47658. lowerBetaLimit: number;
  47659. /**
  47660. * Maximum allowed angle on the latitudinal axis.
  47661. * This can help limiting how the Camera is able to move in the scene.
  47662. */
  47663. upperBetaLimit: number;
  47664. /**
  47665. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47666. * This can help limiting how the Camera is able to move in the scene.
  47667. */
  47668. lowerRadiusLimit: Nullable<number>;
  47669. /**
  47670. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47671. * This can help limiting how the Camera is able to move in the scene.
  47672. */
  47673. upperRadiusLimit: Nullable<number>;
  47674. /**
  47675. * Defines the current inertia value used during panning of the camera along the X axis.
  47676. */
  47677. inertialPanningX: number;
  47678. /**
  47679. * Defines the current inertia value used during panning of the camera along the Y axis.
  47680. */
  47681. inertialPanningY: number;
  47682. /**
  47683. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47684. * Basically if your fingers moves away from more than this distance you will be considered
  47685. * in pinch mode.
  47686. */
  47687. pinchToPanMaxDistance: number;
  47688. /**
  47689. * Defines the maximum distance the camera can pan.
  47690. * This could help keeping the cammera always in your scene.
  47691. */
  47692. panningDistanceLimit: Nullable<number>;
  47693. /**
  47694. * Defines the target of the camera before paning.
  47695. */
  47696. panningOriginTarget: Vector3;
  47697. /**
  47698. * Defines the value of the inertia used during panning.
  47699. * 0 would mean stop inertia and one would mean no decelleration at all.
  47700. */
  47701. panningInertia: number;
  47702. /**
  47703. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47704. */
  47705. get angularSensibilityX(): number;
  47706. set angularSensibilityX(value: number);
  47707. /**
  47708. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47709. */
  47710. get angularSensibilityY(): number;
  47711. set angularSensibilityY(value: number);
  47712. /**
  47713. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47714. */
  47715. get pinchPrecision(): number;
  47716. set pinchPrecision(value: number);
  47717. /**
  47718. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47719. * It will be used instead of pinchDeltaPrecision if different from 0.
  47720. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47721. */
  47722. get pinchDeltaPercentage(): number;
  47723. set pinchDeltaPercentage(value: number);
  47724. /**
  47725. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47726. * and pinch delta percentage.
  47727. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47728. * that any object in the plane at the camera's target point will scale
  47729. * perfectly with finger motion.
  47730. */
  47731. get useNaturalPinchZoom(): boolean;
  47732. set useNaturalPinchZoom(value: boolean);
  47733. /**
  47734. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47735. */
  47736. get panningSensibility(): number;
  47737. set panningSensibility(value: number);
  47738. /**
  47739. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47740. */
  47741. get keysUp(): number[];
  47742. set keysUp(value: number[]);
  47743. /**
  47744. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47745. */
  47746. get keysDown(): number[];
  47747. set keysDown(value: number[]);
  47748. /**
  47749. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47750. */
  47751. get keysLeft(): number[];
  47752. set keysLeft(value: number[]);
  47753. /**
  47754. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47755. */
  47756. get keysRight(): number[];
  47757. set keysRight(value: number[]);
  47758. /**
  47759. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47760. */
  47761. get wheelPrecision(): number;
  47762. set wheelPrecision(value: number);
  47763. /**
  47764. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47765. * It will be used instead of pinchDeltaPrecision if different from 0.
  47766. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47767. */
  47768. get wheelDeltaPercentage(): number;
  47769. set wheelDeltaPercentage(value: number);
  47770. /**
  47771. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47772. */
  47773. zoomOnFactor: number;
  47774. /**
  47775. * Defines a screen offset for the camera position.
  47776. */
  47777. targetScreenOffset: Vector2;
  47778. /**
  47779. * Allows the camera to be completely reversed.
  47780. * If false the camera can not arrive upside down.
  47781. */
  47782. allowUpsideDown: boolean;
  47783. /**
  47784. * Define if double tap/click is used to restore the previously saved state of the camera.
  47785. */
  47786. useInputToRestoreState: boolean;
  47787. /** @hidden */
  47788. _viewMatrix: Matrix;
  47789. /** @hidden */
  47790. _useCtrlForPanning: boolean;
  47791. /** @hidden */
  47792. _panningMouseButton: number;
  47793. /**
  47794. * Defines the input associated to the camera.
  47795. */
  47796. inputs: ArcRotateCameraInputsManager;
  47797. /** @hidden */
  47798. _reset: () => void;
  47799. /**
  47800. * Defines the allowed panning axis.
  47801. */
  47802. panningAxis: Vector3;
  47803. protected _localDirection: Vector3;
  47804. protected _transformedDirection: Vector3;
  47805. private _bouncingBehavior;
  47806. /**
  47807. * Gets the bouncing behavior of the camera if it has been enabled.
  47808. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47809. */
  47810. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47811. /**
  47812. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47813. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47814. */
  47815. get useBouncingBehavior(): boolean;
  47816. set useBouncingBehavior(value: boolean);
  47817. private _framingBehavior;
  47818. /**
  47819. * Gets the framing behavior of the camera if it has been enabled.
  47820. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47821. */
  47822. get framingBehavior(): Nullable<FramingBehavior>;
  47823. /**
  47824. * Defines if the framing behavior of the camera is enabled on the camera.
  47825. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47826. */
  47827. get useFramingBehavior(): boolean;
  47828. set useFramingBehavior(value: boolean);
  47829. private _autoRotationBehavior;
  47830. /**
  47831. * Gets the auto rotation behavior of the camera if it has been enabled.
  47832. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47833. */
  47834. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47835. /**
  47836. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47837. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47838. */
  47839. get useAutoRotationBehavior(): boolean;
  47840. set useAutoRotationBehavior(value: boolean);
  47841. /**
  47842. * Observable triggered when the mesh target has been changed on the camera.
  47843. */
  47844. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47845. /**
  47846. * Event raised when the camera is colliding with a mesh.
  47847. */
  47848. onCollide: (collidedMesh: AbstractMesh) => void;
  47849. /**
  47850. * Defines whether the camera should check collision with the objects oh the scene.
  47851. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47852. */
  47853. checkCollisions: boolean;
  47854. /**
  47855. * Defines the collision radius of the camera.
  47856. * This simulates a sphere around the camera.
  47857. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47858. */
  47859. collisionRadius: Vector3;
  47860. protected _collider: Collider;
  47861. protected _previousPosition: Vector3;
  47862. protected _collisionVelocity: Vector3;
  47863. protected _newPosition: Vector3;
  47864. protected _previousAlpha: number;
  47865. protected _previousBeta: number;
  47866. protected _previousRadius: number;
  47867. protected _collisionTriggered: boolean;
  47868. protected _targetBoundingCenter: Nullable<Vector3>;
  47869. private _computationVector;
  47870. /**
  47871. * Instantiates a new ArcRotateCamera in a given scene
  47872. * @param name Defines the name of the camera
  47873. * @param alpha Defines the camera rotation along the logitudinal axis
  47874. * @param beta Defines the camera rotation along the latitudinal axis
  47875. * @param radius Defines the camera distance from its target
  47876. * @param target Defines the camera target
  47877. * @param scene Defines the scene the camera belongs to
  47878. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47879. */
  47880. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47881. /** @hidden */
  47882. _initCache(): void;
  47883. /** @hidden */
  47884. _updateCache(ignoreParentClass?: boolean): void;
  47885. protected _getTargetPosition(): Vector3;
  47886. private _storedAlpha;
  47887. private _storedBeta;
  47888. private _storedRadius;
  47889. private _storedTarget;
  47890. private _storedTargetScreenOffset;
  47891. /**
  47892. * Stores the current state of the camera (alpha, beta, radius and target)
  47893. * @returns the camera itself
  47894. */
  47895. storeState(): Camera;
  47896. /**
  47897. * @hidden
  47898. * Restored camera state. You must call storeState() first
  47899. */
  47900. _restoreStateValues(): boolean;
  47901. /** @hidden */
  47902. _isSynchronizedViewMatrix(): boolean;
  47903. /**
  47904. * Attached controls to the current camera.
  47905. * @param element Defines the element the controls should be listened from
  47906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47907. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47908. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47909. */
  47910. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47911. /**
  47912. * Detach the current controls from the camera.
  47913. * The camera will stop reacting to inputs.
  47914. * @param element Defines the element to stop listening the inputs from
  47915. */
  47916. detachControl(element: HTMLElement): void;
  47917. /** @hidden */
  47918. _checkInputs(): void;
  47919. protected _checkLimits(): void;
  47920. /**
  47921. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47922. */
  47923. rebuildAnglesAndRadius(): void;
  47924. /**
  47925. * Use a position to define the current camera related information like alpha, beta and radius
  47926. * @param position Defines the position to set the camera at
  47927. */
  47928. setPosition(position: Vector3): void;
  47929. /**
  47930. * Defines the target the camera should look at.
  47931. * This will automatically adapt alpha beta and radius to fit within the new target.
  47932. * @param target Defines the new target as a Vector or a mesh
  47933. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47934. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47935. */
  47936. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47937. /** @hidden */
  47938. _getViewMatrix(): Matrix;
  47939. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47940. /**
  47941. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47942. * @param meshes Defines the mesh to zoom on
  47943. * @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)
  47944. */
  47945. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47946. /**
  47947. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47948. * The target will be changed but the radius
  47949. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47950. * @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)
  47951. */
  47952. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47953. min: Vector3;
  47954. max: Vector3;
  47955. distance: number;
  47956. }, doNotUpdateMaxZ?: boolean): void;
  47957. /**
  47958. * @override
  47959. * Override Camera.createRigCamera
  47960. */
  47961. createRigCamera(name: string, cameraIndex: number): Camera;
  47962. /**
  47963. * @hidden
  47964. * @override
  47965. * Override Camera._updateRigCameras
  47966. */
  47967. _updateRigCameras(): void;
  47968. /**
  47969. * Destroy the camera and release the current resources hold by it.
  47970. */
  47971. dispose(): void;
  47972. /**
  47973. * Gets the current object class name.
  47974. * @return the class name
  47975. */
  47976. getClassName(): string;
  47977. }
  47978. }
  47979. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47980. import { Behavior } from "babylonjs/Behaviors/behavior";
  47981. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47982. /**
  47983. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47984. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47985. */
  47986. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47987. /**
  47988. * Gets the name of the behavior.
  47989. */
  47990. get name(): string;
  47991. private _zoomStopsAnimation;
  47992. private _idleRotationSpeed;
  47993. private _idleRotationWaitTime;
  47994. private _idleRotationSpinupTime;
  47995. /**
  47996. * Sets the flag that indicates if user zooming should stop animation.
  47997. */
  47998. set zoomStopsAnimation(flag: boolean);
  47999. /**
  48000. * Gets the flag that indicates if user zooming should stop animation.
  48001. */
  48002. get zoomStopsAnimation(): boolean;
  48003. /**
  48004. * Sets the default speed at which the camera rotates around the model.
  48005. */
  48006. set idleRotationSpeed(speed: number);
  48007. /**
  48008. * Gets the default speed at which the camera rotates around the model.
  48009. */
  48010. get idleRotationSpeed(): number;
  48011. /**
  48012. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48013. */
  48014. set idleRotationWaitTime(time: number);
  48015. /**
  48016. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48017. */
  48018. get idleRotationWaitTime(): number;
  48019. /**
  48020. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48021. */
  48022. set idleRotationSpinupTime(time: number);
  48023. /**
  48024. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48025. */
  48026. get idleRotationSpinupTime(): number;
  48027. /**
  48028. * Gets a value indicating if the camera is currently rotating because of this behavior
  48029. */
  48030. get rotationInProgress(): boolean;
  48031. private _onPrePointerObservableObserver;
  48032. private _onAfterCheckInputsObserver;
  48033. private _attachedCamera;
  48034. private _isPointerDown;
  48035. private _lastFrameTime;
  48036. private _lastInteractionTime;
  48037. private _cameraRotationSpeed;
  48038. /**
  48039. * Initializes the behavior.
  48040. */
  48041. init(): void;
  48042. /**
  48043. * Attaches the behavior to its arc rotate camera.
  48044. * @param camera Defines the camera to attach the behavior to
  48045. */
  48046. attach(camera: ArcRotateCamera): void;
  48047. /**
  48048. * Detaches the behavior from its current arc rotate camera.
  48049. */
  48050. detach(): void;
  48051. /**
  48052. * Returns true if user is scrolling.
  48053. * @return true if user is scrolling.
  48054. */
  48055. private _userIsZooming;
  48056. private _lastFrameRadius;
  48057. private _shouldAnimationStopForInteraction;
  48058. /**
  48059. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48060. */
  48061. private _applyUserInteraction;
  48062. private _userIsMoving;
  48063. }
  48064. }
  48065. declare module "babylonjs/Behaviors/Cameras/index" {
  48066. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48067. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48068. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48069. }
  48070. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48071. import { Mesh } from "babylonjs/Meshes/mesh";
  48072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48073. import { Behavior } from "babylonjs/Behaviors/behavior";
  48074. /**
  48075. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48076. */
  48077. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48078. private ui;
  48079. /**
  48080. * The name of the behavior
  48081. */
  48082. name: string;
  48083. /**
  48084. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48085. */
  48086. distanceAwayFromFace: number;
  48087. /**
  48088. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48089. */
  48090. distanceAwayFromBottomOfFace: number;
  48091. private _faceVectors;
  48092. private _target;
  48093. private _scene;
  48094. private _onRenderObserver;
  48095. private _tmpMatrix;
  48096. private _tmpVector;
  48097. /**
  48098. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48099. * @param ui The transform node that should be attched to the mesh
  48100. */
  48101. constructor(ui: TransformNode);
  48102. /**
  48103. * Initializes the behavior
  48104. */
  48105. init(): void;
  48106. private _closestFace;
  48107. private _zeroVector;
  48108. private _lookAtTmpMatrix;
  48109. private _lookAtToRef;
  48110. /**
  48111. * Attaches the AttachToBoxBehavior to the passed in mesh
  48112. * @param target The mesh that the specified node will be attached to
  48113. */
  48114. attach(target: Mesh): void;
  48115. /**
  48116. * Detaches the behavior from the mesh
  48117. */
  48118. detach(): void;
  48119. }
  48120. }
  48121. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48122. import { Behavior } from "babylonjs/Behaviors/behavior";
  48123. import { Mesh } from "babylonjs/Meshes/mesh";
  48124. /**
  48125. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48126. */
  48127. export class FadeInOutBehavior implements Behavior<Mesh> {
  48128. /**
  48129. * Time in milliseconds to delay before fading in (Default: 0)
  48130. */
  48131. delay: number;
  48132. /**
  48133. * Time in milliseconds for the mesh to fade in (Default: 300)
  48134. */
  48135. fadeInTime: number;
  48136. private _millisecondsPerFrame;
  48137. private _hovered;
  48138. private _hoverValue;
  48139. private _ownerNode;
  48140. /**
  48141. * Instatiates the FadeInOutBehavior
  48142. */
  48143. constructor();
  48144. /**
  48145. * The name of the behavior
  48146. */
  48147. get name(): string;
  48148. /**
  48149. * Initializes the behavior
  48150. */
  48151. init(): void;
  48152. /**
  48153. * Attaches the fade behavior on the passed in mesh
  48154. * @param ownerNode The mesh that will be faded in/out once attached
  48155. */
  48156. attach(ownerNode: Mesh): void;
  48157. /**
  48158. * Detaches the behavior from the mesh
  48159. */
  48160. detach(): void;
  48161. /**
  48162. * Triggers the mesh to begin fading in or out
  48163. * @param value if the object should fade in or out (true to fade in)
  48164. */
  48165. fadeIn(value: boolean): void;
  48166. private _update;
  48167. private _setAllVisibility;
  48168. }
  48169. }
  48170. declare module "babylonjs/Misc/pivotTools" {
  48171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48172. /**
  48173. * Class containing a set of static utilities functions for managing Pivots
  48174. * @hidden
  48175. */
  48176. export class PivotTools {
  48177. private static _PivotCached;
  48178. private static _OldPivotPoint;
  48179. private static _PivotTranslation;
  48180. private static _PivotTmpVector;
  48181. private static _PivotPostMultiplyPivotMatrix;
  48182. /** @hidden */
  48183. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48184. /** @hidden */
  48185. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48186. }
  48187. }
  48188. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48189. import { Scene } from "babylonjs/scene";
  48190. import { Vector4 } from "babylonjs/Maths/math.vector";
  48191. import { Mesh } from "babylonjs/Meshes/mesh";
  48192. import { Nullable } from "babylonjs/types";
  48193. import { Plane } from "babylonjs/Maths/math.plane";
  48194. /**
  48195. * Class containing static functions to help procedurally build meshes
  48196. */
  48197. export class PlaneBuilder {
  48198. /**
  48199. * Creates a plane mesh
  48200. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48201. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48202. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48206. * @param name defines the name of the mesh
  48207. * @param options defines the options used to create the mesh
  48208. * @param scene defines the hosting scene
  48209. * @returns the plane mesh
  48210. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48211. */
  48212. static CreatePlane(name: string, options: {
  48213. size?: number;
  48214. width?: number;
  48215. height?: number;
  48216. sideOrientation?: number;
  48217. frontUVs?: Vector4;
  48218. backUVs?: Vector4;
  48219. updatable?: boolean;
  48220. sourcePlane?: Plane;
  48221. }, scene?: Nullable<Scene>): Mesh;
  48222. }
  48223. }
  48224. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48225. import { Behavior } from "babylonjs/Behaviors/behavior";
  48226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48227. import { Observable } from "babylonjs/Misc/observable";
  48228. import { Vector3 } from "babylonjs/Maths/math.vector";
  48229. import { Ray } from "babylonjs/Culling/ray";
  48230. import "babylonjs/Meshes/Builders/planeBuilder";
  48231. /**
  48232. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48233. */
  48234. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48235. private static _AnyMouseID;
  48236. /**
  48237. * Abstract mesh the behavior is set on
  48238. */
  48239. attachedNode: AbstractMesh;
  48240. private _dragPlane;
  48241. private _scene;
  48242. private _pointerObserver;
  48243. private _beforeRenderObserver;
  48244. private static _planeScene;
  48245. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48246. /**
  48247. * 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)
  48248. */
  48249. maxDragAngle: number;
  48250. /**
  48251. * @hidden
  48252. */
  48253. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48254. /**
  48255. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48256. */
  48257. currentDraggingPointerID: number;
  48258. /**
  48259. * The last position where the pointer hit the drag plane in world space
  48260. */
  48261. lastDragPosition: Vector3;
  48262. /**
  48263. * If the behavior is currently in a dragging state
  48264. */
  48265. dragging: boolean;
  48266. /**
  48267. * 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)
  48268. */
  48269. dragDeltaRatio: number;
  48270. /**
  48271. * If the drag plane orientation should be updated during the dragging (Default: true)
  48272. */
  48273. updateDragPlane: boolean;
  48274. private _debugMode;
  48275. private _moving;
  48276. /**
  48277. * Fires each time the attached mesh is dragged with the pointer
  48278. * * delta between last drag position and current drag position in world space
  48279. * * dragDistance along the drag axis
  48280. * * dragPlaneNormal normal of the current drag plane used during the drag
  48281. * * dragPlanePoint in world space where the drag intersects the drag plane
  48282. */
  48283. onDragObservable: Observable<{
  48284. delta: Vector3;
  48285. dragPlanePoint: Vector3;
  48286. dragPlaneNormal: Vector3;
  48287. dragDistance: number;
  48288. pointerId: number;
  48289. }>;
  48290. /**
  48291. * Fires each time a drag begins (eg. mouse down on mesh)
  48292. */
  48293. onDragStartObservable: Observable<{
  48294. dragPlanePoint: Vector3;
  48295. pointerId: number;
  48296. }>;
  48297. /**
  48298. * Fires each time a drag ends (eg. mouse release after drag)
  48299. */
  48300. onDragEndObservable: Observable<{
  48301. dragPlanePoint: Vector3;
  48302. pointerId: number;
  48303. }>;
  48304. /**
  48305. * If the attached mesh should be moved when dragged
  48306. */
  48307. moveAttached: boolean;
  48308. /**
  48309. * If the drag behavior will react to drag events (Default: true)
  48310. */
  48311. enabled: boolean;
  48312. /**
  48313. * If pointer events should start and release the drag (Default: true)
  48314. */
  48315. startAndReleaseDragOnPointerEvents: boolean;
  48316. /**
  48317. * If camera controls should be detached during the drag
  48318. */
  48319. detachCameraControls: boolean;
  48320. /**
  48321. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48322. */
  48323. useObjectOrientationForDragging: boolean;
  48324. private _options;
  48325. /**
  48326. * Gets the options used by the behavior
  48327. */
  48328. get options(): {
  48329. dragAxis?: Vector3;
  48330. dragPlaneNormal?: Vector3;
  48331. };
  48332. /**
  48333. * Sets the options used by the behavior
  48334. */
  48335. set options(options: {
  48336. dragAxis?: Vector3;
  48337. dragPlaneNormal?: Vector3;
  48338. });
  48339. /**
  48340. * Creates a pointer drag behavior that can be attached to a mesh
  48341. * @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)
  48342. */
  48343. constructor(options?: {
  48344. dragAxis?: Vector3;
  48345. dragPlaneNormal?: Vector3;
  48346. });
  48347. /**
  48348. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48349. */
  48350. validateDrag: (targetPosition: Vector3) => boolean;
  48351. /**
  48352. * The name of the behavior
  48353. */
  48354. get name(): string;
  48355. /**
  48356. * Initializes the behavior
  48357. */
  48358. init(): void;
  48359. private _tmpVector;
  48360. private _alternatePickedPoint;
  48361. private _worldDragAxis;
  48362. private _targetPosition;
  48363. private _attachedElement;
  48364. /**
  48365. * Attaches the drag behavior the passed in mesh
  48366. * @param ownerNode The mesh that will be dragged around once attached
  48367. * @param predicate Predicate to use for pick filtering
  48368. */
  48369. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48370. /**
  48371. * Force relase the drag action by code.
  48372. */
  48373. releaseDrag(): void;
  48374. private _startDragRay;
  48375. private _lastPointerRay;
  48376. /**
  48377. * Simulates the start of a pointer drag event on the behavior
  48378. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48379. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48380. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48381. */
  48382. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48383. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48384. private _dragDelta;
  48385. protected _moveDrag(ray: Ray): void;
  48386. private _pickWithRayOnDragPlane;
  48387. private _pointA;
  48388. private _pointC;
  48389. private _localAxis;
  48390. private _lookAt;
  48391. private _updateDragPlanePosition;
  48392. /**
  48393. * Detaches the behavior from the mesh
  48394. */
  48395. detach(): void;
  48396. }
  48397. }
  48398. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48399. import { Mesh } from "babylonjs/Meshes/mesh";
  48400. import { Behavior } from "babylonjs/Behaviors/behavior";
  48401. /**
  48402. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48403. */
  48404. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48405. private _dragBehaviorA;
  48406. private _dragBehaviorB;
  48407. private _startDistance;
  48408. private _initialScale;
  48409. private _targetScale;
  48410. private _ownerNode;
  48411. private _sceneRenderObserver;
  48412. /**
  48413. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48414. */
  48415. constructor();
  48416. /**
  48417. * The name of the behavior
  48418. */
  48419. get name(): string;
  48420. /**
  48421. * Initializes the behavior
  48422. */
  48423. init(): void;
  48424. private _getCurrentDistance;
  48425. /**
  48426. * Attaches the scale behavior the passed in mesh
  48427. * @param ownerNode The mesh that will be scaled around once attached
  48428. */
  48429. attach(ownerNode: Mesh): void;
  48430. /**
  48431. * Detaches the behavior from the mesh
  48432. */
  48433. detach(): void;
  48434. }
  48435. }
  48436. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48437. import { Behavior } from "babylonjs/Behaviors/behavior";
  48438. import { Mesh } from "babylonjs/Meshes/mesh";
  48439. import { Observable } from "babylonjs/Misc/observable";
  48440. /**
  48441. * 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
  48442. */
  48443. export class SixDofDragBehavior implements Behavior<Mesh> {
  48444. private static _virtualScene;
  48445. private _ownerNode;
  48446. private _sceneRenderObserver;
  48447. private _scene;
  48448. private _targetPosition;
  48449. private _virtualOriginMesh;
  48450. private _virtualDragMesh;
  48451. private _pointerObserver;
  48452. private _moving;
  48453. private _startingOrientation;
  48454. private _attachedElement;
  48455. /**
  48456. * 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)
  48457. */
  48458. private zDragFactor;
  48459. /**
  48460. * If the object should rotate to face the drag origin
  48461. */
  48462. rotateDraggedObject: boolean;
  48463. /**
  48464. * If the behavior is currently in a dragging state
  48465. */
  48466. dragging: boolean;
  48467. /**
  48468. * 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)
  48469. */
  48470. dragDeltaRatio: number;
  48471. /**
  48472. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48473. */
  48474. currentDraggingPointerID: number;
  48475. /**
  48476. * If camera controls should be detached during the drag
  48477. */
  48478. detachCameraControls: boolean;
  48479. /**
  48480. * Fires each time a drag starts
  48481. */
  48482. onDragStartObservable: Observable<{}>;
  48483. /**
  48484. * Fires each time a drag ends (eg. mouse release after drag)
  48485. */
  48486. onDragEndObservable: Observable<{}>;
  48487. /**
  48488. * 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
  48489. */
  48490. constructor();
  48491. /**
  48492. * The name of the behavior
  48493. */
  48494. get name(): string;
  48495. /**
  48496. * Initializes the behavior
  48497. */
  48498. init(): void;
  48499. /**
  48500. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48501. */
  48502. private get _pointerCamera();
  48503. /**
  48504. * Attaches the scale behavior the passed in mesh
  48505. * @param ownerNode The mesh that will be scaled around once attached
  48506. */
  48507. attach(ownerNode: Mesh): void;
  48508. /**
  48509. * Detaches the behavior from the mesh
  48510. */
  48511. detach(): void;
  48512. }
  48513. }
  48514. declare module "babylonjs/Behaviors/Meshes/index" {
  48515. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48516. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48517. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48518. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48519. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48520. }
  48521. declare module "babylonjs/Behaviors/index" {
  48522. export * from "babylonjs/Behaviors/behavior";
  48523. export * from "babylonjs/Behaviors/Cameras/index";
  48524. export * from "babylonjs/Behaviors/Meshes/index";
  48525. }
  48526. declare module "babylonjs/Bones/boneIKController" {
  48527. import { Bone } from "babylonjs/Bones/bone";
  48528. import { Vector3 } from "babylonjs/Maths/math.vector";
  48529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48530. import { Nullable } from "babylonjs/types";
  48531. /**
  48532. * Class used to apply inverse kinematics to bones
  48533. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48534. */
  48535. export class BoneIKController {
  48536. private static _tmpVecs;
  48537. private static _tmpQuat;
  48538. private static _tmpMats;
  48539. /**
  48540. * Gets or sets the target mesh
  48541. */
  48542. targetMesh: AbstractMesh;
  48543. /** Gets or sets the mesh used as pole */
  48544. poleTargetMesh: AbstractMesh;
  48545. /**
  48546. * Gets or sets the bone used as pole
  48547. */
  48548. poleTargetBone: Nullable<Bone>;
  48549. /**
  48550. * Gets or sets the target position
  48551. */
  48552. targetPosition: Vector3;
  48553. /**
  48554. * Gets or sets the pole target position
  48555. */
  48556. poleTargetPosition: Vector3;
  48557. /**
  48558. * Gets or sets the pole target local offset
  48559. */
  48560. poleTargetLocalOffset: Vector3;
  48561. /**
  48562. * Gets or sets the pole angle
  48563. */
  48564. poleAngle: number;
  48565. /**
  48566. * Gets or sets the mesh associated with the controller
  48567. */
  48568. mesh: AbstractMesh;
  48569. /**
  48570. * 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)
  48571. */
  48572. slerpAmount: number;
  48573. private _bone1Quat;
  48574. private _bone1Mat;
  48575. private _bone2Ang;
  48576. private _bone1;
  48577. private _bone2;
  48578. private _bone1Length;
  48579. private _bone2Length;
  48580. private _maxAngle;
  48581. private _maxReach;
  48582. private _rightHandedSystem;
  48583. private _bendAxis;
  48584. private _slerping;
  48585. private _adjustRoll;
  48586. /**
  48587. * Gets or sets maximum allowed angle
  48588. */
  48589. get maxAngle(): number;
  48590. set maxAngle(value: number);
  48591. /**
  48592. * Creates a new BoneIKController
  48593. * @param mesh defines the mesh to control
  48594. * @param bone defines the bone to control
  48595. * @param options defines options to set up the controller
  48596. */
  48597. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48598. targetMesh?: AbstractMesh;
  48599. poleTargetMesh?: AbstractMesh;
  48600. poleTargetBone?: Bone;
  48601. poleTargetLocalOffset?: Vector3;
  48602. poleAngle?: number;
  48603. bendAxis?: Vector3;
  48604. maxAngle?: number;
  48605. slerpAmount?: number;
  48606. });
  48607. private _setMaxAngle;
  48608. /**
  48609. * Force the controller to update the bones
  48610. */
  48611. update(): void;
  48612. }
  48613. }
  48614. declare module "babylonjs/Bones/boneLookController" {
  48615. import { Vector3 } from "babylonjs/Maths/math.vector";
  48616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48617. import { Bone } from "babylonjs/Bones/bone";
  48618. import { Space } from "babylonjs/Maths/math.axis";
  48619. /**
  48620. * Class used to make a bone look toward a point in space
  48621. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48622. */
  48623. export class BoneLookController {
  48624. private static _tmpVecs;
  48625. private static _tmpQuat;
  48626. private static _tmpMats;
  48627. /**
  48628. * The target Vector3 that the bone will look at
  48629. */
  48630. target: Vector3;
  48631. /**
  48632. * The mesh that the bone is attached to
  48633. */
  48634. mesh: AbstractMesh;
  48635. /**
  48636. * The bone that will be looking to the target
  48637. */
  48638. bone: Bone;
  48639. /**
  48640. * The up axis of the coordinate system that is used when the bone is rotated
  48641. */
  48642. upAxis: Vector3;
  48643. /**
  48644. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48645. */
  48646. upAxisSpace: Space;
  48647. /**
  48648. * Used to make an adjustment to the yaw of the bone
  48649. */
  48650. adjustYaw: number;
  48651. /**
  48652. * Used to make an adjustment to the pitch of the bone
  48653. */
  48654. adjustPitch: number;
  48655. /**
  48656. * Used to make an adjustment to the roll of the bone
  48657. */
  48658. adjustRoll: number;
  48659. /**
  48660. * 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)
  48661. */
  48662. slerpAmount: number;
  48663. private _minYaw;
  48664. private _maxYaw;
  48665. private _minPitch;
  48666. private _maxPitch;
  48667. private _minYawSin;
  48668. private _minYawCos;
  48669. private _maxYawSin;
  48670. private _maxYawCos;
  48671. private _midYawConstraint;
  48672. private _minPitchTan;
  48673. private _maxPitchTan;
  48674. private _boneQuat;
  48675. private _slerping;
  48676. private _transformYawPitch;
  48677. private _transformYawPitchInv;
  48678. private _firstFrameSkipped;
  48679. private _yawRange;
  48680. private _fowardAxis;
  48681. /**
  48682. * Gets or sets the minimum yaw angle that the bone can look to
  48683. */
  48684. get minYaw(): number;
  48685. set minYaw(value: number);
  48686. /**
  48687. * Gets or sets the maximum yaw angle that the bone can look to
  48688. */
  48689. get maxYaw(): number;
  48690. set maxYaw(value: number);
  48691. /**
  48692. * Gets or sets the minimum pitch angle that the bone can look to
  48693. */
  48694. get minPitch(): number;
  48695. set minPitch(value: number);
  48696. /**
  48697. * Gets or sets the maximum pitch angle that the bone can look to
  48698. */
  48699. get maxPitch(): number;
  48700. set maxPitch(value: number);
  48701. /**
  48702. * Create a BoneLookController
  48703. * @param mesh the mesh that the bone belongs to
  48704. * @param bone the bone that will be looking to the target
  48705. * @param target the target Vector3 to look at
  48706. * @param options optional settings:
  48707. * * maxYaw: the maximum angle the bone will yaw to
  48708. * * minYaw: the minimum angle the bone will yaw to
  48709. * * maxPitch: the maximum angle the bone will pitch to
  48710. * * minPitch: the minimum angle the bone will yaw to
  48711. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48712. * * upAxis: the up axis of the coordinate system
  48713. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48714. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48715. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48716. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48717. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48718. * * adjustRoll: used to make an adjustment to the roll of the bone
  48719. **/
  48720. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48721. maxYaw?: number;
  48722. minYaw?: number;
  48723. maxPitch?: number;
  48724. minPitch?: number;
  48725. slerpAmount?: number;
  48726. upAxis?: Vector3;
  48727. upAxisSpace?: Space;
  48728. yawAxis?: Vector3;
  48729. pitchAxis?: Vector3;
  48730. adjustYaw?: number;
  48731. adjustPitch?: number;
  48732. adjustRoll?: number;
  48733. });
  48734. /**
  48735. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48736. */
  48737. update(): void;
  48738. private _getAngleDiff;
  48739. private _getAngleBetween;
  48740. private _isAngleBetween;
  48741. }
  48742. }
  48743. declare module "babylonjs/Bones/index" {
  48744. export * from "babylonjs/Bones/bone";
  48745. export * from "babylonjs/Bones/boneIKController";
  48746. export * from "babylonjs/Bones/boneLookController";
  48747. export * from "babylonjs/Bones/skeleton";
  48748. }
  48749. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48750. import { Nullable } from "babylonjs/types";
  48751. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48752. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48753. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48754. /**
  48755. * Manage the gamepad inputs to control an arc rotate camera.
  48756. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48757. */
  48758. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48759. /**
  48760. * Defines the camera the input is attached to.
  48761. */
  48762. camera: ArcRotateCamera;
  48763. /**
  48764. * Defines the gamepad the input is gathering event from.
  48765. */
  48766. gamepad: Nullable<Gamepad>;
  48767. /**
  48768. * Defines the gamepad rotation sensiblity.
  48769. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48770. */
  48771. gamepadRotationSensibility: number;
  48772. /**
  48773. * Defines the gamepad move sensiblity.
  48774. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48775. */
  48776. gamepadMoveSensibility: number;
  48777. private _yAxisScale;
  48778. /**
  48779. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48780. */
  48781. get invertYAxis(): boolean;
  48782. set invertYAxis(value: boolean);
  48783. private _onGamepadConnectedObserver;
  48784. private _onGamepadDisconnectedObserver;
  48785. /**
  48786. * Attach the input controls to a specific dom element to get the input from.
  48787. * @param element Defines the element the controls should be listened from
  48788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48789. */
  48790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48791. /**
  48792. * Detach the current controls from the specified dom element.
  48793. * @param element Defines the element to stop listening the inputs from
  48794. */
  48795. detachControl(element: Nullable<HTMLElement>): void;
  48796. /**
  48797. * Update the current camera state depending on the inputs that have been used this frame.
  48798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48799. */
  48800. checkInputs(): void;
  48801. /**
  48802. * Gets the class name of the current intput.
  48803. * @returns the class name
  48804. */
  48805. getClassName(): string;
  48806. /**
  48807. * Get the friendly name associated with the input class.
  48808. * @returns the input friendly name
  48809. */
  48810. getSimpleName(): string;
  48811. }
  48812. }
  48813. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48814. import { Nullable } from "babylonjs/types";
  48815. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48816. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48817. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48818. interface ArcRotateCameraInputsManager {
  48819. /**
  48820. * Add orientation input support to the input manager.
  48821. * @returns the current input manager
  48822. */
  48823. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48824. }
  48825. }
  48826. /**
  48827. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48828. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48829. */
  48830. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48831. /**
  48832. * Defines the camera the input is attached to.
  48833. */
  48834. camera: ArcRotateCamera;
  48835. /**
  48836. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48837. */
  48838. alphaCorrection: number;
  48839. /**
  48840. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48841. */
  48842. gammaCorrection: number;
  48843. private _alpha;
  48844. private _gamma;
  48845. private _dirty;
  48846. private _deviceOrientationHandler;
  48847. /**
  48848. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48849. */
  48850. constructor();
  48851. /**
  48852. * Attach the input controls to a specific dom element to get the input from.
  48853. * @param element Defines the element the controls should be listened from
  48854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48855. */
  48856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48857. /** @hidden */
  48858. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48859. /**
  48860. * Update the current camera state depending on the inputs that have been used this frame.
  48861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48862. */
  48863. checkInputs(): void;
  48864. /**
  48865. * Detach the current controls from the specified dom element.
  48866. * @param element Defines the element to stop listening the inputs from
  48867. */
  48868. detachControl(element: Nullable<HTMLElement>): void;
  48869. /**
  48870. * Gets the class name of the current intput.
  48871. * @returns the class name
  48872. */
  48873. getClassName(): string;
  48874. /**
  48875. * Get the friendly name associated with the input class.
  48876. * @returns the input friendly name
  48877. */
  48878. getSimpleName(): string;
  48879. }
  48880. }
  48881. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48882. import { Nullable } from "babylonjs/types";
  48883. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48884. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48885. /**
  48886. * Listen to mouse events to control the camera.
  48887. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48888. */
  48889. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48890. /**
  48891. * Defines the camera the input is attached to.
  48892. */
  48893. camera: FlyCamera;
  48894. /**
  48895. * Defines if touch is enabled. (Default is true.)
  48896. */
  48897. touchEnabled: boolean;
  48898. /**
  48899. * Defines the buttons associated with the input to handle camera rotation.
  48900. */
  48901. buttons: number[];
  48902. /**
  48903. * Assign buttons for Yaw control.
  48904. */
  48905. buttonsYaw: number[];
  48906. /**
  48907. * Assign buttons for Pitch control.
  48908. */
  48909. buttonsPitch: number[];
  48910. /**
  48911. * Assign buttons for Roll control.
  48912. */
  48913. buttonsRoll: number[];
  48914. /**
  48915. * Detect if any button is being pressed while mouse is moved.
  48916. * -1 = Mouse locked.
  48917. * 0 = Left button.
  48918. * 1 = Middle Button.
  48919. * 2 = Right Button.
  48920. */
  48921. activeButton: number;
  48922. /**
  48923. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48924. * Higher values reduce its sensitivity.
  48925. */
  48926. angularSensibility: number;
  48927. private _observer;
  48928. private _rollObserver;
  48929. private previousPosition;
  48930. private noPreventDefault;
  48931. private element;
  48932. /**
  48933. * Listen to mouse events to control the camera.
  48934. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48935. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48936. */
  48937. constructor(touchEnabled?: boolean);
  48938. /**
  48939. * Attach the mouse control to the HTML DOM element.
  48940. * @param element Defines the element that listens to the input events.
  48941. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48942. */
  48943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48944. /**
  48945. * Detach the current controls from the specified dom element.
  48946. * @param element Defines the element to stop listening the inputs from
  48947. */
  48948. detachControl(element: Nullable<HTMLElement>): void;
  48949. /**
  48950. * Gets the class name of the current input.
  48951. * @returns the class name.
  48952. */
  48953. getClassName(): string;
  48954. /**
  48955. * Get the friendly name associated with the input class.
  48956. * @returns the input's friendly name.
  48957. */
  48958. getSimpleName(): string;
  48959. private _pointerInput;
  48960. private _onMouseMove;
  48961. /**
  48962. * Rotate camera by mouse offset.
  48963. */
  48964. private rotateCamera;
  48965. }
  48966. }
  48967. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48968. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48969. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48970. /**
  48971. * Default Inputs manager for the FlyCamera.
  48972. * It groups all the default supported inputs for ease of use.
  48973. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48974. */
  48975. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48976. /**
  48977. * Instantiates a new FlyCameraInputsManager.
  48978. * @param camera Defines the camera the inputs belong to.
  48979. */
  48980. constructor(camera: FlyCamera);
  48981. /**
  48982. * Add keyboard input support to the input manager.
  48983. * @returns the new FlyCameraKeyboardMoveInput().
  48984. */
  48985. addKeyboard(): FlyCameraInputsManager;
  48986. /**
  48987. * Add mouse input support to the input manager.
  48988. * @param touchEnabled Enable touch screen support.
  48989. * @returns the new FlyCameraMouseInput().
  48990. */
  48991. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  48992. }
  48993. }
  48994. declare module "babylonjs/Cameras/flyCamera" {
  48995. import { Scene } from "babylonjs/scene";
  48996. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  48997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48998. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48999. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49000. /**
  49001. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49002. * such as in a 3D Space Shooter or a Flight Simulator.
  49003. */
  49004. export class FlyCamera extends TargetCamera {
  49005. /**
  49006. * Define the collision ellipsoid of the camera.
  49007. * This is helpful for simulating a camera body, like a player's body.
  49008. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49009. */
  49010. ellipsoid: Vector3;
  49011. /**
  49012. * Define an offset for the position of the ellipsoid around the camera.
  49013. * This can be helpful if the camera is attached away from the player's body center,
  49014. * such as at its head.
  49015. */
  49016. ellipsoidOffset: Vector3;
  49017. /**
  49018. * Enable or disable collisions of the camera with the rest of the scene objects.
  49019. */
  49020. checkCollisions: boolean;
  49021. /**
  49022. * Enable or disable gravity on the camera.
  49023. */
  49024. applyGravity: boolean;
  49025. /**
  49026. * Define the current direction the camera is moving to.
  49027. */
  49028. cameraDirection: Vector3;
  49029. /**
  49030. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49031. * This overrides and empties cameraRotation.
  49032. */
  49033. rotationQuaternion: Quaternion;
  49034. /**
  49035. * Track Roll to maintain the wanted Rolling when looking around.
  49036. */
  49037. _trackRoll: number;
  49038. /**
  49039. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49040. */
  49041. rollCorrect: number;
  49042. /**
  49043. * Mimic a banked turn, Rolling the camera when Yawing.
  49044. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49045. */
  49046. bankedTurn: boolean;
  49047. /**
  49048. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49049. */
  49050. bankedTurnLimit: number;
  49051. /**
  49052. * Value of 0 disables the banked Roll.
  49053. * Value of 1 is equal to the Yaw angle in radians.
  49054. */
  49055. bankedTurnMultiplier: number;
  49056. /**
  49057. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49058. */
  49059. inputs: FlyCameraInputsManager;
  49060. /**
  49061. * Gets the input sensibility for mouse input.
  49062. * Higher values reduce sensitivity.
  49063. */
  49064. get angularSensibility(): number;
  49065. /**
  49066. * Sets the input sensibility for a mouse input.
  49067. * Higher values reduce sensitivity.
  49068. */
  49069. set angularSensibility(value: number);
  49070. /**
  49071. * Get the keys for camera movement forward.
  49072. */
  49073. get keysForward(): number[];
  49074. /**
  49075. * Set the keys for camera movement forward.
  49076. */
  49077. set keysForward(value: number[]);
  49078. /**
  49079. * Get the keys for camera movement backward.
  49080. */
  49081. get keysBackward(): number[];
  49082. set keysBackward(value: number[]);
  49083. /**
  49084. * Get the keys for camera movement up.
  49085. */
  49086. get keysUp(): number[];
  49087. /**
  49088. * Set the keys for camera movement up.
  49089. */
  49090. set keysUp(value: number[]);
  49091. /**
  49092. * Get the keys for camera movement down.
  49093. */
  49094. get keysDown(): number[];
  49095. /**
  49096. * Set the keys for camera movement down.
  49097. */
  49098. set keysDown(value: number[]);
  49099. /**
  49100. * Get the keys for camera movement left.
  49101. */
  49102. get keysLeft(): number[];
  49103. /**
  49104. * Set the keys for camera movement left.
  49105. */
  49106. set keysLeft(value: number[]);
  49107. /**
  49108. * Set the keys for camera movement right.
  49109. */
  49110. get keysRight(): number[];
  49111. /**
  49112. * Set the keys for camera movement right.
  49113. */
  49114. set keysRight(value: number[]);
  49115. /**
  49116. * Event raised when the camera collides with a mesh in the scene.
  49117. */
  49118. onCollide: (collidedMesh: AbstractMesh) => void;
  49119. private _collider;
  49120. private _needMoveForGravity;
  49121. private _oldPosition;
  49122. private _diffPosition;
  49123. private _newPosition;
  49124. /** @hidden */
  49125. _localDirection: Vector3;
  49126. /** @hidden */
  49127. _transformedDirection: Vector3;
  49128. /**
  49129. * Instantiates a FlyCamera.
  49130. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49131. * such as in a 3D Space Shooter or a Flight Simulator.
  49132. * @param name Define the name of the camera in the scene.
  49133. * @param position Define the starting position of the camera in the scene.
  49134. * @param scene Define the scene the camera belongs to.
  49135. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49136. */
  49137. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49138. /**
  49139. * Attach a control to the HTML DOM element.
  49140. * @param element Defines the element that listens to the input events.
  49141. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49142. */
  49143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49144. /**
  49145. * Detach a control from the HTML DOM element.
  49146. * The camera will stop reacting to that input.
  49147. * @param element Defines the element that listens to the input events.
  49148. */
  49149. detachControl(element: HTMLElement): void;
  49150. private _collisionMask;
  49151. /**
  49152. * Get the mask that the camera ignores in collision events.
  49153. */
  49154. get collisionMask(): number;
  49155. /**
  49156. * Set the mask that the camera ignores in collision events.
  49157. */
  49158. set collisionMask(mask: number);
  49159. /** @hidden */
  49160. _collideWithWorld(displacement: Vector3): void;
  49161. /** @hidden */
  49162. private _onCollisionPositionChange;
  49163. /** @hidden */
  49164. _checkInputs(): void;
  49165. /** @hidden */
  49166. _decideIfNeedsToMove(): boolean;
  49167. /** @hidden */
  49168. _updatePosition(): void;
  49169. /**
  49170. * Restore the Roll to its target value at the rate specified.
  49171. * @param rate - Higher means slower restoring.
  49172. * @hidden
  49173. */
  49174. restoreRoll(rate: number): void;
  49175. /**
  49176. * Destroy the camera and release the current resources held by it.
  49177. */
  49178. dispose(): void;
  49179. /**
  49180. * Get the current object class name.
  49181. * @returns the class name.
  49182. */
  49183. getClassName(): string;
  49184. }
  49185. }
  49186. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49187. import { Nullable } from "babylonjs/types";
  49188. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49189. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49190. /**
  49191. * Listen to keyboard events to control the camera.
  49192. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49193. */
  49194. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49195. /**
  49196. * Defines the camera the input is attached to.
  49197. */
  49198. camera: FlyCamera;
  49199. /**
  49200. * The list of keyboard keys used to control the forward move of the camera.
  49201. */
  49202. keysForward: number[];
  49203. /**
  49204. * The list of keyboard keys used to control the backward move of the camera.
  49205. */
  49206. keysBackward: number[];
  49207. /**
  49208. * The list of keyboard keys used to control the forward move of the camera.
  49209. */
  49210. keysUp: number[];
  49211. /**
  49212. * The list of keyboard keys used to control the backward move of the camera.
  49213. */
  49214. keysDown: number[];
  49215. /**
  49216. * The list of keyboard keys used to control the right strafe move of the camera.
  49217. */
  49218. keysRight: number[];
  49219. /**
  49220. * The list of keyboard keys used to control the left strafe move of the camera.
  49221. */
  49222. keysLeft: number[];
  49223. private _keys;
  49224. private _onCanvasBlurObserver;
  49225. private _onKeyboardObserver;
  49226. private _engine;
  49227. private _scene;
  49228. /**
  49229. * Attach the input controls to a specific dom element to get the input from.
  49230. * @param element Defines the element the controls should be listened from
  49231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49232. */
  49233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49234. /**
  49235. * Detach the current controls from the specified dom element.
  49236. * @param element Defines the element to stop listening the inputs from
  49237. */
  49238. detachControl(element: Nullable<HTMLElement>): void;
  49239. /**
  49240. * Gets the class name of the current intput.
  49241. * @returns the class name
  49242. */
  49243. getClassName(): string;
  49244. /** @hidden */
  49245. _onLostFocus(e: FocusEvent): void;
  49246. /**
  49247. * Get the friendly name associated with the input class.
  49248. * @returns the input friendly name
  49249. */
  49250. getSimpleName(): string;
  49251. /**
  49252. * Update the current camera state depending on the inputs that have been used this frame.
  49253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49254. */
  49255. checkInputs(): void;
  49256. }
  49257. }
  49258. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49259. import { Nullable } from "babylonjs/types";
  49260. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49261. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49262. /**
  49263. * Manage the mouse wheel inputs to control a follow camera.
  49264. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49265. */
  49266. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49267. /**
  49268. * Defines the camera the input is attached to.
  49269. */
  49270. camera: FollowCamera;
  49271. /**
  49272. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49273. */
  49274. axisControlRadius: boolean;
  49275. /**
  49276. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49277. */
  49278. axisControlHeight: boolean;
  49279. /**
  49280. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49281. */
  49282. axisControlRotation: boolean;
  49283. /**
  49284. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49285. * relation to mouseWheel events.
  49286. */
  49287. wheelPrecision: number;
  49288. /**
  49289. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49290. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49291. */
  49292. wheelDeltaPercentage: number;
  49293. private _wheel;
  49294. private _observer;
  49295. /**
  49296. * Attach the input controls to a specific dom element to get the input from.
  49297. * @param element Defines the element the controls should be listened from
  49298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49299. */
  49300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49301. /**
  49302. * Detach the current controls from the specified dom element.
  49303. * @param element Defines the element to stop listening the inputs from
  49304. */
  49305. detachControl(element: Nullable<HTMLElement>): void;
  49306. /**
  49307. * Gets the class name of the current intput.
  49308. * @returns the class name
  49309. */
  49310. getClassName(): string;
  49311. /**
  49312. * Get the friendly name associated with the input class.
  49313. * @returns the input friendly name
  49314. */
  49315. getSimpleName(): string;
  49316. }
  49317. }
  49318. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49319. import { Nullable } from "babylonjs/types";
  49320. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49321. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49322. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49323. /**
  49324. * Manage the pointers inputs to control an follow camera.
  49325. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49326. */
  49327. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49328. /**
  49329. * Defines the camera the input is attached to.
  49330. */
  49331. camera: FollowCamera;
  49332. /**
  49333. * Gets the class name of the current input.
  49334. * @returns the class name
  49335. */
  49336. getClassName(): string;
  49337. /**
  49338. * Defines the pointer angular sensibility along the X axis or how fast is
  49339. * the camera rotating.
  49340. * A negative number will reverse the axis direction.
  49341. */
  49342. angularSensibilityX: number;
  49343. /**
  49344. * Defines the pointer angular sensibility along the Y axis or how fast is
  49345. * the camera rotating.
  49346. * A negative number will reverse the axis direction.
  49347. */
  49348. angularSensibilityY: number;
  49349. /**
  49350. * Defines the pointer pinch precision or how fast is the camera zooming.
  49351. * A negative number will reverse the axis direction.
  49352. */
  49353. pinchPrecision: number;
  49354. /**
  49355. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49356. * from 0.
  49357. * It defines the percentage of current camera.radius to use as delta when
  49358. * pinch zoom is used.
  49359. */
  49360. pinchDeltaPercentage: number;
  49361. /**
  49362. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49363. */
  49364. axisXControlRadius: boolean;
  49365. /**
  49366. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49367. */
  49368. axisXControlHeight: boolean;
  49369. /**
  49370. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49371. */
  49372. axisXControlRotation: boolean;
  49373. /**
  49374. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49375. */
  49376. axisYControlRadius: boolean;
  49377. /**
  49378. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49379. */
  49380. axisYControlHeight: boolean;
  49381. /**
  49382. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49383. */
  49384. axisYControlRotation: boolean;
  49385. /**
  49386. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49387. */
  49388. axisPinchControlRadius: boolean;
  49389. /**
  49390. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49391. */
  49392. axisPinchControlHeight: boolean;
  49393. /**
  49394. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49395. */
  49396. axisPinchControlRotation: boolean;
  49397. /**
  49398. * Log error messages if basic misconfiguration has occurred.
  49399. */
  49400. warningEnable: boolean;
  49401. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49402. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49403. private _warningCounter;
  49404. private _warning;
  49405. }
  49406. }
  49407. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49408. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49409. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49410. /**
  49411. * Default Inputs manager for the FollowCamera.
  49412. * It groups all the default supported inputs for ease of use.
  49413. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49414. */
  49415. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49416. /**
  49417. * Instantiates a new FollowCameraInputsManager.
  49418. * @param camera Defines the camera the inputs belong to
  49419. */
  49420. constructor(camera: FollowCamera);
  49421. /**
  49422. * Add keyboard input support to the input manager.
  49423. * @returns the current input manager
  49424. */
  49425. addKeyboard(): FollowCameraInputsManager;
  49426. /**
  49427. * Add mouse wheel input support to the input manager.
  49428. * @returns the current input manager
  49429. */
  49430. addMouseWheel(): FollowCameraInputsManager;
  49431. /**
  49432. * Add pointers input support to the input manager.
  49433. * @returns the current input manager
  49434. */
  49435. addPointers(): FollowCameraInputsManager;
  49436. /**
  49437. * Add orientation input support to the input manager.
  49438. * @returns the current input manager
  49439. */
  49440. addVRDeviceOrientation(): FollowCameraInputsManager;
  49441. }
  49442. }
  49443. declare module "babylonjs/Cameras/followCamera" {
  49444. import { Nullable } from "babylonjs/types";
  49445. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49446. import { Scene } from "babylonjs/scene";
  49447. import { Vector3 } from "babylonjs/Maths/math.vector";
  49448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49449. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49450. /**
  49451. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49452. * an arc rotate version arcFollowCamera are available.
  49453. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49454. */
  49455. export class FollowCamera extends TargetCamera {
  49456. /**
  49457. * Distance the follow camera should follow an object at
  49458. */
  49459. radius: number;
  49460. /**
  49461. * Minimum allowed distance of the camera to the axis of rotation
  49462. * (The camera can not get closer).
  49463. * This can help limiting how the Camera is able to move in the scene.
  49464. */
  49465. lowerRadiusLimit: Nullable<number>;
  49466. /**
  49467. * Maximum allowed distance of the camera to the axis of rotation
  49468. * (The camera can not get further).
  49469. * This can help limiting how the Camera is able to move in the scene.
  49470. */
  49471. upperRadiusLimit: Nullable<number>;
  49472. /**
  49473. * Define a rotation offset between the camera and the object it follows
  49474. */
  49475. rotationOffset: number;
  49476. /**
  49477. * Minimum allowed angle to camera position relative to target object.
  49478. * This can help limiting how the Camera is able to move in the scene.
  49479. */
  49480. lowerRotationOffsetLimit: Nullable<number>;
  49481. /**
  49482. * Maximum allowed angle to camera position relative to target object.
  49483. * This can help limiting how the Camera is able to move in the scene.
  49484. */
  49485. upperRotationOffsetLimit: Nullable<number>;
  49486. /**
  49487. * Define a height offset between the camera and the object it follows.
  49488. * It can help following an object from the top (like a car chaing a plane)
  49489. */
  49490. heightOffset: number;
  49491. /**
  49492. * Minimum allowed height of camera position relative to target object.
  49493. * This can help limiting how the Camera is able to move in the scene.
  49494. */
  49495. lowerHeightOffsetLimit: Nullable<number>;
  49496. /**
  49497. * Maximum allowed height of camera position relative to target object.
  49498. * This can help limiting how the Camera is able to move in the scene.
  49499. */
  49500. upperHeightOffsetLimit: Nullable<number>;
  49501. /**
  49502. * Define how fast the camera can accelerate to follow it s target.
  49503. */
  49504. cameraAcceleration: number;
  49505. /**
  49506. * Define the speed limit of the camera following an object.
  49507. */
  49508. maxCameraSpeed: number;
  49509. /**
  49510. * Define the target of the camera.
  49511. */
  49512. lockedTarget: Nullable<AbstractMesh>;
  49513. /**
  49514. * Defines the input associated with the camera.
  49515. */
  49516. inputs: FollowCameraInputsManager;
  49517. /**
  49518. * Instantiates the follow camera.
  49519. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49520. * @param name Define the name of the camera in the scene
  49521. * @param position Define the position of the camera
  49522. * @param scene Define the scene the camera belong to
  49523. * @param lockedTarget Define the target of the camera
  49524. */
  49525. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49526. private _follow;
  49527. /**
  49528. * Attached controls to the current camera.
  49529. * @param element Defines the element the controls should be listened from
  49530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49531. */
  49532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49533. /**
  49534. * Detach the current controls from the camera.
  49535. * The camera will stop reacting to inputs.
  49536. * @param element Defines the element to stop listening the inputs from
  49537. */
  49538. detachControl(element: HTMLElement): void;
  49539. /** @hidden */
  49540. _checkInputs(): void;
  49541. private _checkLimits;
  49542. /**
  49543. * Gets the camera class name.
  49544. * @returns the class name
  49545. */
  49546. getClassName(): string;
  49547. }
  49548. /**
  49549. * Arc Rotate version of the follow camera.
  49550. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49551. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49552. */
  49553. export class ArcFollowCamera extends TargetCamera {
  49554. /** The longitudinal angle of the camera */
  49555. alpha: number;
  49556. /** The latitudinal angle of the camera */
  49557. beta: number;
  49558. /** The radius of the camera from its target */
  49559. radius: number;
  49560. private _cartesianCoordinates;
  49561. /** Define the camera target (the mesh it should follow) */
  49562. private _meshTarget;
  49563. /**
  49564. * Instantiates a new ArcFollowCamera
  49565. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49566. * @param name Define the name of the camera
  49567. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49568. * @param beta Define the rotation angle of the camera around the elevation axis
  49569. * @param radius Define the radius of the camera from its target point
  49570. * @param target Define the target of the camera
  49571. * @param scene Define the scene the camera belongs to
  49572. */
  49573. constructor(name: string,
  49574. /** The longitudinal angle of the camera */
  49575. alpha: number,
  49576. /** The latitudinal angle of the camera */
  49577. beta: number,
  49578. /** The radius of the camera from its target */
  49579. radius: number,
  49580. /** Define the camera target (the mesh it should follow) */
  49581. target: Nullable<AbstractMesh>, scene: Scene);
  49582. private _follow;
  49583. /** @hidden */
  49584. _checkInputs(): void;
  49585. /**
  49586. * Returns the class name of the object.
  49587. * It is mostly used internally for serialization purposes.
  49588. */
  49589. getClassName(): string;
  49590. }
  49591. }
  49592. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49593. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49594. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49595. import { Nullable } from "babylonjs/types";
  49596. /**
  49597. * Manage the keyboard inputs to control the movement of a follow camera.
  49598. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49599. */
  49600. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49601. /**
  49602. * Defines the camera the input is attached to.
  49603. */
  49604. camera: FollowCamera;
  49605. /**
  49606. * Defines the list of key codes associated with the up action (increase heightOffset)
  49607. */
  49608. keysHeightOffsetIncr: number[];
  49609. /**
  49610. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49611. */
  49612. keysHeightOffsetDecr: number[];
  49613. /**
  49614. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49615. */
  49616. keysHeightOffsetModifierAlt: boolean;
  49617. /**
  49618. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49619. */
  49620. keysHeightOffsetModifierCtrl: boolean;
  49621. /**
  49622. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49623. */
  49624. keysHeightOffsetModifierShift: boolean;
  49625. /**
  49626. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49627. */
  49628. keysRotationOffsetIncr: number[];
  49629. /**
  49630. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49631. */
  49632. keysRotationOffsetDecr: number[];
  49633. /**
  49634. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49635. */
  49636. keysRotationOffsetModifierAlt: boolean;
  49637. /**
  49638. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49639. */
  49640. keysRotationOffsetModifierCtrl: boolean;
  49641. /**
  49642. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49643. */
  49644. keysRotationOffsetModifierShift: boolean;
  49645. /**
  49646. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49647. */
  49648. keysRadiusIncr: number[];
  49649. /**
  49650. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49651. */
  49652. keysRadiusDecr: number[];
  49653. /**
  49654. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49655. */
  49656. keysRadiusModifierAlt: boolean;
  49657. /**
  49658. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49659. */
  49660. keysRadiusModifierCtrl: boolean;
  49661. /**
  49662. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49663. */
  49664. keysRadiusModifierShift: boolean;
  49665. /**
  49666. * Defines the rate of change of heightOffset.
  49667. */
  49668. heightSensibility: number;
  49669. /**
  49670. * Defines the rate of change of rotationOffset.
  49671. */
  49672. rotationSensibility: number;
  49673. /**
  49674. * Defines the rate of change of radius.
  49675. */
  49676. radiusSensibility: number;
  49677. private _keys;
  49678. private _ctrlPressed;
  49679. private _altPressed;
  49680. private _shiftPressed;
  49681. private _onCanvasBlurObserver;
  49682. private _onKeyboardObserver;
  49683. private _engine;
  49684. private _scene;
  49685. /**
  49686. * Attach the input controls to a specific dom element to get the input from.
  49687. * @param element Defines the element the controls should be listened from
  49688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49689. */
  49690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49691. /**
  49692. * Detach the current controls from the specified dom element.
  49693. * @param element Defines the element to stop listening the inputs from
  49694. */
  49695. detachControl(element: Nullable<HTMLElement>): void;
  49696. /**
  49697. * Update the current camera state depending on the inputs that have been used this frame.
  49698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49699. */
  49700. checkInputs(): void;
  49701. /**
  49702. * Gets the class name of the current input.
  49703. * @returns the class name
  49704. */
  49705. getClassName(): string;
  49706. /**
  49707. * Get the friendly name associated with the input class.
  49708. * @returns the input friendly name
  49709. */
  49710. getSimpleName(): string;
  49711. /**
  49712. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49713. * allow modification of the heightOffset value.
  49714. */
  49715. private _modifierHeightOffset;
  49716. /**
  49717. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49718. * allow modification of the rotationOffset value.
  49719. */
  49720. private _modifierRotationOffset;
  49721. /**
  49722. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49723. * allow modification of the radius value.
  49724. */
  49725. private _modifierRadius;
  49726. }
  49727. }
  49728. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49729. import { Nullable } from "babylonjs/types";
  49730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49731. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49732. import { Observable } from "babylonjs/Misc/observable";
  49733. module "babylonjs/Cameras/freeCameraInputsManager" {
  49734. interface FreeCameraInputsManager {
  49735. /**
  49736. * @hidden
  49737. */
  49738. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49739. /**
  49740. * Add orientation input support to the input manager.
  49741. * @returns the current input manager
  49742. */
  49743. addDeviceOrientation(): FreeCameraInputsManager;
  49744. }
  49745. }
  49746. /**
  49747. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49748. * Screen rotation is taken into account.
  49749. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49750. */
  49751. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49752. private _camera;
  49753. private _screenOrientationAngle;
  49754. private _constantTranform;
  49755. private _screenQuaternion;
  49756. private _alpha;
  49757. private _beta;
  49758. private _gamma;
  49759. /**
  49760. * Can be used to detect if a device orientation sensor is available on a device
  49761. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49762. * @returns a promise that will resolve on orientation change
  49763. */
  49764. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49765. /**
  49766. * @hidden
  49767. */
  49768. _onDeviceOrientationChangedObservable: Observable<void>;
  49769. /**
  49770. * Instantiates a new input
  49771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49772. */
  49773. constructor();
  49774. /**
  49775. * Define the camera controlled by the input.
  49776. */
  49777. get camera(): FreeCamera;
  49778. set camera(camera: FreeCamera);
  49779. /**
  49780. * Attach the input controls to a specific dom element to get the input from.
  49781. * @param element Defines the element the controls should be listened from
  49782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49783. */
  49784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49785. private _orientationChanged;
  49786. private _deviceOrientation;
  49787. /**
  49788. * Detach the current controls from the specified dom element.
  49789. * @param element Defines the element to stop listening the inputs from
  49790. */
  49791. detachControl(element: Nullable<HTMLElement>): void;
  49792. /**
  49793. * Update the current camera state depending on the inputs that have been used this frame.
  49794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49795. */
  49796. checkInputs(): void;
  49797. /**
  49798. * Gets the class name of the current intput.
  49799. * @returns the class name
  49800. */
  49801. getClassName(): string;
  49802. /**
  49803. * Get the friendly name associated with the input class.
  49804. * @returns the input friendly name
  49805. */
  49806. getSimpleName(): string;
  49807. }
  49808. }
  49809. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49810. import { Nullable } from "babylonjs/types";
  49811. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49812. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49813. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49814. /**
  49815. * Manage the gamepad inputs to control a free camera.
  49816. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49817. */
  49818. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49819. /**
  49820. * Define the camera the input is attached to.
  49821. */
  49822. camera: FreeCamera;
  49823. /**
  49824. * Define the Gamepad controlling the input
  49825. */
  49826. gamepad: Nullable<Gamepad>;
  49827. /**
  49828. * Defines the gamepad rotation sensiblity.
  49829. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49830. */
  49831. gamepadAngularSensibility: number;
  49832. /**
  49833. * Defines the gamepad move sensiblity.
  49834. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49835. */
  49836. gamepadMoveSensibility: number;
  49837. private _yAxisScale;
  49838. /**
  49839. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49840. */
  49841. get invertYAxis(): boolean;
  49842. set invertYAxis(value: boolean);
  49843. private _onGamepadConnectedObserver;
  49844. private _onGamepadDisconnectedObserver;
  49845. private _cameraTransform;
  49846. private _deltaTransform;
  49847. private _vector3;
  49848. private _vector2;
  49849. /**
  49850. * Attach the input controls to a specific dom element to get the input from.
  49851. * @param element Defines the element the controls should be listened from
  49852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49853. */
  49854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49855. /**
  49856. * Detach the current controls from the specified dom element.
  49857. * @param element Defines the element to stop listening the inputs from
  49858. */
  49859. detachControl(element: Nullable<HTMLElement>): void;
  49860. /**
  49861. * Update the current camera state depending on the inputs that have been used this frame.
  49862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49863. */
  49864. checkInputs(): void;
  49865. /**
  49866. * Gets the class name of the current intput.
  49867. * @returns the class name
  49868. */
  49869. getClassName(): string;
  49870. /**
  49871. * Get the friendly name associated with the input class.
  49872. * @returns the input friendly name
  49873. */
  49874. getSimpleName(): string;
  49875. }
  49876. }
  49877. declare module "babylonjs/Misc/virtualJoystick" {
  49878. import { Nullable } from "babylonjs/types";
  49879. import { Vector3 } from "babylonjs/Maths/math.vector";
  49880. /**
  49881. * Defines the potential axis of a Joystick
  49882. */
  49883. export enum JoystickAxis {
  49884. /** X axis */
  49885. X = 0,
  49886. /** Y axis */
  49887. Y = 1,
  49888. /** Z axis */
  49889. Z = 2
  49890. }
  49891. /**
  49892. * Represents the different customization options available
  49893. * for VirtualJoystick
  49894. */
  49895. interface VirtualJoystickCustomizations {
  49896. /**
  49897. * Size of the joystick's puck
  49898. */
  49899. puckSize: number;
  49900. /**
  49901. * Size of the joystick's container
  49902. */
  49903. containerSize: number;
  49904. /**
  49905. * Color of the joystick && puck
  49906. */
  49907. color: string;
  49908. /**
  49909. * Image URL for the joystick's puck
  49910. */
  49911. puckImage?: string;
  49912. /**
  49913. * Image URL for the joystick's container
  49914. */
  49915. containerImage?: string;
  49916. /**
  49917. * Defines the unmoving position of the joystick container
  49918. */
  49919. position?: {
  49920. x: number;
  49921. y: number;
  49922. };
  49923. /**
  49924. * Defines whether or not the joystick container is always visible
  49925. */
  49926. alwaysVisible: boolean;
  49927. /**
  49928. * Defines whether or not to limit the movement of the puck to the joystick's container
  49929. */
  49930. limitToContainer: boolean;
  49931. }
  49932. /**
  49933. * Class used to define virtual joystick (used in touch mode)
  49934. */
  49935. export class VirtualJoystick {
  49936. /**
  49937. * Gets or sets a boolean indicating that left and right values must be inverted
  49938. */
  49939. reverseLeftRight: boolean;
  49940. /**
  49941. * Gets or sets a boolean indicating that up and down values must be inverted
  49942. */
  49943. reverseUpDown: boolean;
  49944. /**
  49945. * Gets the offset value for the position (ie. the change of the position value)
  49946. */
  49947. deltaPosition: Vector3;
  49948. /**
  49949. * Gets a boolean indicating if the virtual joystick was pressed
  49950. */
  49951. pressed: boolean;
  49952. /**
  49953. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49954. */
  49955. static Canvas: Nullable<HTMLCanvasElement>;
  49956. /**
  49957. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49958. */
  49959. limitToContainer: boolean;
  49960. private static _globalJoystickIndex;
  49961. private static _alwaysVisibleSticks;
  49962. private static vjCanvasContext;
  49963. private static vjCanvasWidth;
  49964. private static vjCanvasHeight;
  49965. private static halfWidth;
  49966. private static _GetDefaultOptions;
  49967. private _action;
  49968. private _axisTargetedByLeftAndRight;
  49969. private _axisTargetedByUpAndDown;
  49970. private _joystickSensibility;
  49971. private _inversedSensibility;
  49972. private _joystickPointerID;
  49973. private _joystickColor;
  49974. private _joystickPointerPos;
  49975. private _joystickPreviousPointerPos;
  49976. private _joystickPointerStartPos;
  49977. private _deltaJoystickVector;
  49978. private _leftJoystick;
  49979. private _touches;
  49980. private _joystickPosition;
  49981. private _alwaysVisible;
  49982. private _puckImage;
  49983. private _containerImage;
  49984. private _joystickPuckSize;
  49985. private _joystickContainerSize;
  49986. private _clearPuckSize;
  49987. private _clearContainerSize;
  49988. private _clearPuckSizeOffset;
  49989. private _clearContainerSizeOffset;
  49990. private _onPointerDownHandlerRef;
  49991. private _onPointerMoveHandlerRef;
  49992. private _onPointerUpHandlerRef;
  49993. private _onResize;
  49994. /**
  49995. * Creates a new virtual joystick
  49996. * @param leftJoystick defines that the joystick is for left hand (false by default)
  49997. * @param customizations Defines the options we want to customize the VirtualJoystick
  49998. */
  49999. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50000. /**
  50001. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50002. * @param newJoystickSensibility defines the new sensibility
  50003. */
  50004. setJoystickSensibility(newJoystickSensibility: number): void;
  50005. private _onPointerDown;
  50006. private _onPointerMove;
  50007. private _onPointerUp;
  50008. /**
  50009. * Change the color of the virtual joystick
  50010. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50011. */
  50012. setJoystickColor(newColor: string): void;
  50013. /**
  50014. * Size of the joystick's container
  50015. */
  50016. set containerSize(newSize: number);
  50017. get containerSize(): number;
  50018. /**
  50019. * Size of the joystick's puck
  50020. */
  50021. set puckSize(newSize: number);
  50022. get puckSize(): number;
  50023. /**
  50024. * Clears the set position of the joystick
  50025. */
  50026. clearPosition(): void;
  50027. /**
  50028. * Defines whether or not the joystick container is always visible
  50029. */
  50030. set alwaysVisible(value: boolean);
  50031. get alwaysVisible(): boolean;
  50032. /**
  50033. * Sets the constant position of the Joystick container
  50034. * @param x X axis coordinate
  50035. * @param y Y axis coordinate
  50036. */
  50037. setPosition(x: number, y: number): void;
  50038. /**
  50039. * Defines a callback to call when the joystick is touched
  50040. * @param action defines the callback
  50041. */
  50042. setActionOnTouch(action: () => any): void;
  50043. /**
  50044. * Defines which axis you'd like to control for left & right
  50045. * @param axis defines the axis to use
  50046. */
  50047. setAxisForLeftRight(axis: JoystickAxis): void;
  50048. /**
  50049. * Defines which axis you'd like to control for up & down
  50050. * @param axis defines the axis to use
  50051. */
  50052. setAxisForUpDown(axis: JoystickAxis): void;
  50053. /**
  50054. * Clears the canvas from the previous puck / container draw
  50055. */
  50056. private _clearPreviousDraw;
  50057. /**
  50058. * Loads `urlPath` to be used for the container's image
  50059. * @param urlPath defines the urlPath of an image to use
  50060. */
  50061. setContainerImage(urlPath: string): void;
  50062. /**
  50063. * Loads `urlPath` to be used for the puck's image
  50064. * @param urlPath defines the urlPath of an image to use
  50065. */
  50066. setPuckImage(urlPath: string): void;
  50067. /**
  50068. * Draws the Virtual Joystick's container
  50069. */
  50070. private _drawContainer;
  50071. /**
  50072. * Draws the Virtual Joystick's puck
  50073. */
  50074. private _drawPuck;
  50075. private _drawVirtualJoystick;
  50076. /**
  50077. * Release internal HTML canvas
  50078. */
  50079. releaseCanvas(): void;
  50080. }
  50081. }
  50082. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50083. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50084. import { Nullable } from "babylonjs/types";
  50085. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50086. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50087. module "babylonjs/Cameras/freeCameraInputsManager" {
  50088. interface FreeCameraInputsManager {
  50089. /**
  50090. * Add virtual joystick input support to the input manager.
  50091. * @returns the current input manager
  50092. */
  50093. addVirtualJoystick(): FreeCameraInputsManager;
  50094. }
  50095. }
  50096. /**
  50097. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50098. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50099. */
  50100. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50101. /**
  50102. * Defines the camera the input is attached to.
  50103. */
  50104. camera: FreeCamera;
  50105. private _leftjoystick;
  50106. private _rightjoystick;
  50107. /**
  50108. * Gets the left stick of the virtual joystick.
  50109. * @returns The virtual Joystick
  50110. */
  50111. getLeftJoystick(): VirtualJoystick;
  50112. /**
  50113. * Gets the right stick of the virtual joystick.
  50114. * @returns The virtual Joystick
  50115. */
  50116. getRightJoystick(): VirtualJoystick;
  50117. /**
  50118. * Update the current camera state depending on the inputs that have been used this frame.
  50119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50120. */
  50121. checkInputs(): void;
  50122. /**
  50123. * Attach the input controls to a specific dom element to get the input from.
  50124. * @param element Defines the element the controls should be listened from
  50125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50126. */
  50127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50128. /**
  50129. * Detach the current controls from the specified dom element.
  50130. * @param element Defines the element to stop listening the inputs from
  50131. */
  50132. detachControl(element: Nullable<HTMLElement>): void;
  50133. /**
  50134. * Gets the class name of the current intput.
  50135. * @returns the class name
  50136. */
  50137. getClassName(): string;
  50138. /**
  50139. * Get the friendly name associated with the input class.
  50140. * @returns the input friendly name
  50141. */
  50142. getSimpleName(): string;
  50143. }
  50144. }
  50145. declare module "babylonjs/Cameras/Inputs/index" {
  50146. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50147. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50148. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50149. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50150. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50151. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50152. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50153. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50154. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50155. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50156. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50157. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50158. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50159. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50160. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50161. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50162. }
  50163. declare module "babylonjs/Cameras/touchCamera" {
  50164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50165. import { Scene } from "babylonjs/scene";
  50166. import { Vector3 } from "babylonjs/Maths/math.vector";
  50167. /**
  50168. * This represents a FPS type of camera controlled by touch.
  50169. * This is like a universal camera minus the Gamepad controls.
  50170. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50171. */
  50172. export class TouchCamera extends FreeCamera {
  50173. /**
  50174. * Defines the touch sensibility for rotation.
  50175. * The higher the faster.
  50176. */
  50177. get touchAngularSensibility(): number;
  50178. set touchAngularSensibility(value: number);
  50179. /**
  50180. * Defines the touch sensibility for move.
  50181. * The higher the faster.
  50182. */
  50183. get touchMoveSensibility(): number;
  50184. set touchMoveSensibility(value: number);
  50185. /**
  50186. * Instantiates a new touch camera.
  50187. * This represents a FPS type of camera controlled by touch.
  50188. * This is like a universal camera minus the Gamepad controls.
  50189. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50190. * @param name Define the name of the camera in the scene
  50191. * @param position Define the start position of the camera in the scene
  50192. * @param scene Define the scene the camera belongs to
  50193. */
  50194. constructor(name: string, position: Vector3, scene: Scene);
  50195. /**
  50196. * Gets the current object class name.
  50197. * @return the class name
  50198. */
  50199. getClassName(): string;
  50200. /** @hidden */
  50201. _setupInputs(): void;
  50202. }
  50203. }
  50204. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50206. import { Scene } from "babylonjs/scene";
  50207. import { Vector3 } from "babylonjs/Maths/math.vector";
  50208. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50209. import { Axis } from "babylonjs/Maths/math.axis";
  50210. /**
  50211. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50212. * being tilted forward or back and left or right.
  50213. */
  50214. export class DeviceOrientationCamera extends FreeCamera {
  50215. private _initialQuaternion;
  50216. private _quaternionCache;
  50217. private _tmpDragQuaternion;
  50218. private _disablePointerInputWhenUsingDeviceOrientation;
  50219. /**
  50220. * Creates a new device orientation camera
  50221. * @param name The name of the camera
  50222. * @param position The start position camera
  50223. * @param scene The scene the camera belongs to
  50224. */
  50225. constructor(name: string, position: Vector3, scene: Scene);
  50226. /**
  50227. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50228. */
  50229. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50230. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50231. private _dragFactor;
  50232. /**
  50233. * Enabled turning on the y axis when the orientation sensor is active
  50234. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50235. */
  50236. enableHorizontalDragging(dragFactor?: number): void;
  50237. /**
  50238. * Gets the current instance class name ("DeviceOrientationCamera").
  50239. * This helps avoiding instanceof at run time.
  50240. * @returns the class name
  50241. */
  50242. getClassName(): string;
  50243. /**
  50244. * @hidden
  50245. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50246. */
  50247. _checkInputs(): void;
  50248. /**
  50249. * Reset the camera to its default orientation on the specified axis only.
  50250. * @param axis The axis to reset
  50251. */
  50252. resetToCurrentRotation(axis?: Axis): void;
  50253. }
  50254. }
  50255. declare module "babylonjs/Gamepads/xboxGamepad" {
  50256. import { Observable } from "babylonjs/Misc/observable";
  50257. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50258. /**
  50259. * Defines supported buttons for XBox360 compatible gamepads
  50260. */
  50261. export enum Xbox360Button {
  50262. /** A */
  50263. A = 0,
  50264. /** B */
  50265. B = 1,
  50266. /** X */
  50267. X = 2,
  50268. /** Y */
  50269. Y = 3,
  50270. /** Left button */
  50271. LB = 4,
  50272. /** Right button */
  50273. RB = 5,
  50274. /** Back */
  50275. Back = 8,
  50276. /** Start */
  50277. Start = 9,
  50278. /** Left stick */
  50279. LeftStick = 10,
  50280. /** Right stick */
  50281. RightStick = 11
  50282. }
  50283. /** Defines values for XBox360 DPad */
  50284. export enum Xbox360Dpad {
  50285. /** Up */
  50286. Up = 12,
  50287. /** Down */
  50288. Down = 13,
  50289. /** Left */
  50290. Left = 14,
  50291. /** Right */
  50292. Right = 15
  50293. }
  50294. /**
  50295. * Defines a XBox360 gamepad
  50296. */
  50297. export class Xbox360Pad extends Gamepad {
  50298. private _leftTrigger;
  50299. private _rightTrigger;
  50300. private _onlefttriggerchanged;
  50301. private _onrighttriggerchanged;
  50302. private _onbuttondown;
  50303. private _onbuttonup;
  50304. private _ondpaddown;
  50305. private _ondpadup;
  50306. /** Observable raised when a button is pressed */
  50307. onButtonDownObservable: Observable<Xbox360Button>;
  50308. /** Observable raised when a button is released */
  50309. onButtonUpObservable: Observable<Xbox360Button>;
  50310. /** Observable raised when a pad is pressed */
  50311. onPadDownObservable: Observable<Xbox360Dpad>;
  50312. /** Observable raised when a pad is released */
  50313. onPadUpObservable: Observable<Xbox360Dpad>;
  50314. private _buttonA;
  50315. private _buttonB;
  50316. private _buttonX;
  50317. private _buttonY;
  50318. private _buttonBack;
  50319. private _buttonStart;
  50320. private _buttonLB;
  50321. private _buttonRB;
  50322. private _buttonLeftStick;
  50323. private _buttonRightStick;
  50324. private _dPadUp;
  50325. private _dPadDown;
  50326. private _dPadLeft;
  50327. private _dPadRight;
  50328. private _isXboxOnePad;
  50329. /**
  50330. * Creates a new XBox360 gamepad object
  50331. * @param id defines the id of this gamepad
  50332. * @param index defines its index
  50333. * @param gamepad defines the internal HTML gamepad object
  50334. * @param xboxOne defines if it is a XBox One gamepad
  50335. */
  50336. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50337. /**
  50338. * Defines the callback to call when left trigger is pressed
  50339. * @param callback defines the callback to use
  50340. */
  50341. onlefttriggerchanged(callback: (value: number) => void): void;
  50342. /**
  50343. * Defines the callback to call when right trigger is pressed
  50344. * @param callback defines the callback to use
  50345. */
  50346. onrighttriggerchanged(callback: (value: number) => void): void;
  50347. /**
  50348. * Gets the left trigger value
  50349. */
  50350. get leftTrigger(): number;
  50351. /**
  50352. * Sets the left trigger value
  50353. */
  50354. set leftTrigger(newValue: number);
  50355. /**
  50356. * Gets the right trigger value
  50357. */
  50358. get rightTrigger(): number;
  50359. /**
  50360. * Sets the right trigger value
  50361. */
  50362. set rightTrigger(newValue: number);
  50363. /**
  50364. * Defines the callback to call when a button is pressed
  50365. * @param callback defines the callback to use
  50366. */
  50367. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50368. /**
  50369. * Defines the callback to call when a button is released
  50370. * @param callback defines the callback to use
  50371. */
  50372. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50373. /**
  50374. * Defines the callback to call when a pad is pressed
  50375. * @param callback defines the callback to use
  50376. */
  50377. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50378. /**
  50379. * Defines the callback to call when a pad is released
  50380. * @param callback defines the callback to use
  50381. */
  50382. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50383. private _setButtonValue;
  50384. private _setDPadValue;
  50385. /**
  50386. * Gets the value of the `A` button
  50387. */
  50388. get buttonA(): number;
  50389. /**
  50390. * Sets the value of the `A` button
  50391. */
  50392. set buttonA(value: number);
  50393. /**
  50394. * Gets the value of the `B` button
  50395. */
  50396. get buttonB(): number;
  50397. /**
  50398. * Sets the value of the `B` button
  50399. */
  50400. set buttonB(value: number);
  50401. /**
  50402. * Gets the value of the `X` button
  50403. */
  50404. get buttonX(): number;
  50405. /**
  50406. * Sets the value of the `X` button
  50407. */
  50408. set buttonX(value: number);
  50409. /**
  50410. * Gets the value of the `Y` button
  50411. */
  50412. get buttonY(): number;
  50413. /**
  50414. * Sets the value of the `Y` button
  50415. */
  50416. set buttonY(value: number);
  50417. /**
  50418. * Gets the value of the `Start` button
  50419. */
  50420. get buttonStart(): number;
  50421. /**
  50422. * Sets the value of the `Start` button
  50423. */
  50424. set buttonStart(value: number);
  50425. /**
  50426. * Gets the value of the `Back` button
  50427. */
  50428. get buttonBack(): number;
  50429. /**
  50430. * Sets the value of the `Back` button
  50431. */
  50432. set buttonBack(value: number);
  50433. /**
  50434. * Gets the value of the `Left` button
  50435. */
  50436. get buttonLB(): number;
  50437. /**
  50438. * Sets the value of the `Left` button
  50439. */
  50440. set buttonLB(value: number);
  50441. /**
  50442. * Gets the value of the `Right` button
  50443. */
  50444. get buttonRB(): number;
  50445. /**
  50446. * Sets the value of the `Right` button
  50447. */
  50448. set buttonRB(value: number);
  50449. /**
  50450. * Gets the value of the Left joystick
  50451. */
  50452. get buttonLeftStick(): number;
  50453. /**
  50454. * Sets the value of the Left joystick
  50455. */
  50456. set buttonLeftStick(value: number);
  50457. /**
  50458. * Gets the value of the Right joystick
  50459. */
  50460. get buttonRightStick(): number;
  50461. /**
  50462. * Sets the value of the Right joystick
  50463. */
  50464. set buttonRightStick(value: number);
  50465. /**
  50466. * Gets the value of D-pad up
  50467. */
  50468. get dPadUp(): number;
  50469. /**
  50470. * Sets the value of D-pad up
  50471. */
  50472. set dPadUp(value: number);
  50473. /**
  50474. * Gets the value of D-pad down
  50475. */
  50476. get dPadDown(): number;
  50477. /**
  50478. * Sets the value of D-pad down
  50479. */
  50480. set dPadDown(value: number);
  50481. /**
  50482. * Gets the value of D-pad left
  50483. */
  50484. get dPadLeft(): number;
  50485. /**
  50486. * Sets the value of D-pad left
  50487. */
  50488. set dPadLeft(value: number);
  50489. /**
  50490. * Gets the value of D-pad right
  50491. */
  50492. get dPadRight(): number;
  50493. /**
  50494. * Sets the value of D-pad right
  50495. */
  50496. set dPadRight(value: number);
  50497. /**
  50498. * Force the gamepad to synchronize with device values
  50499. */
  50500. update(): void;
  50501. /**
  50502. * Disposes the gamepad
  50503. */
  50504. dispose(): void;
  50505. }
  50506. }
  50507. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50508. import { Observable } from "babylonjs/Misc/observable";
  50509. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50510. /**
  50511. * Defines supported buttons for DualShock compatible gamepads
  50512. */
  50513. export enum DualShockButton {
  50514. /** Cross */
  50515. Cross = 0,
  50516. /** Circle */
  50517. Circle = 1,
  50518. /** Square */
  50519. Square = 2,
  50520. /** Triangle */
  50521. Triangle = 3,
  50522. /** L1 */
  50523. L1 = 4,
  50524. /** R1 */
  50525. R1 = 5,
  50526. /** Share */
  50527. Share = 8,
  50528. /** Options */
  50529. Options = 9,
  50530. /** Left stick */
  50531. LeftStick = 10,
  50532. /** Right stick */
  50533. RightStick = 11
  50534. }
  50535. /** Defines values for DualShock DPad */
  50536. export enum DualShockDpad {
  50537. /** Up */
  50538. Up = 12,
  50539. /** Down */
  50540. Down = 13,
  50541. /** Left */
  50542. Left = 14,
  50543. /** Right */
  50544. Right = 15
  50545. }
  50546. /**
  50547. * Defines a DualShock gamepad
  50548. */
  50549. export class DualShockPad extends Gamepad {
  50550. private _leftTrigger;
  50551. private _rightTrigger;
  50552. private _onlefttriggerchanged;
  50553. private _onrighttriggerchanged;
  50554. private _onbuttondown;
  50555. private _onbuttonup;
  50556. private _ondpaddown;
  50557. private _ondpadup;
  50558. /** Observable raised when a button is pressed */
  50559. onButtonDownObservable: Observable<DualShockButton>;
  50560. /** Observable raised when a button is released */
  50561. onButtonUpObservable: Observable<DualShockButton>;
  50562. /** Observable raised when a pad is pressed */
  50563. onPadDownObservable: Observable<DualShockDpad>;
  50564. /** Observable raised when a pad is released */
  50565. onPadUpObservable: Observable<DualShockDpad>;
  50566. private _buttonCross;
  50567. private _buttonCircle;
  50568. private _buttonSquare;
  50569. private _buttonTriangle;
  50570. private _buttonShare;
  50571. private _buttonOptions;
  50572. private _buttonL1;
  50573. private _buttonR1;
  50574. private _buttonLeftStick;
  50575. private _buttonRightStick;
  50576. private _dPadUp;
  50577. private _dPadDown;
  50578. private _dPadLeft;
  50579. private _dPadRight;
  50580. /**
  50581. * Creates a new DualShock gamepad object
  50582. * @param id defines the id of this gamepad
  50583. * @param index defines its index
  50584. * @param gamepad defines the internal HTML gamepad object
  50585. */
  50586. constructor(id: string, index: number, gamepad: any);
  50587. /**
  50588. * Defines the callback to call when left trigger is pressed
  50589. * @param callback defines the callback to use
  50590. */
  50591. onlefttriggerchanged(callback: (value: number) => void): void;
  50592. /**
  50593. * Defines the callback to call when right trigger is pressed
  50594. * @param callback defines the callback to use
  50595. */
  50596. onrighttriggerchanged(callback: (value: number) => void): void;
  50597. /**
  50598. * Gets the left trigger value
  50599. */
  50600. get leftTrigger(): number;
  50601. /**
  50602. * Sets the left trigger value
  50603. */
  50604. set leftTrigger(newValue: number);
  50605. /**
  50606. * Gets the right trigger value
  50607. */
  50608. get rightTrigger(): number;
  50609. /**
  50610. * Sets the right trigger value
  50611. */
  50612. set rightTrigger(newValue: number);
  50613. /**
  50614. * Defines the callback to call when a button is pressed
  50615. * @param callback defines the callback to use
  50616. */
  50617. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50618. /**
  50619. * Defines the callback to call when a button is released
  50620. * @param callback defines the callback to use
  50621. */
  50622. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50623. /**
  50624. * Defines the callback to call when a pad is pressed
  50625. * @param callback defines the callback to use
  50626. */
  50627. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50628. /**
  50629. * Defines the callback to call when a pad is released
  50630. * @param callback defines the callback to use
  50631. */
  50632. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50633. private _setButtonValue;
  50634. private _setDPadValue;
  50635. /**
  50636. * Gets the value of the `Cross` button
  50637. */
  50638. get buttonCross(): number;
  50639. /**
  50640. * Sets the value of the `Cross` button
  50641. */
  50642. set buttonCross(value: number);
  50643. /**
  50644. * Gets the value of the `Circle` button
  50645. */
  50646. get buttonCircle(): number;
  50647. /**
  50648. * Sets the value of the `Circle` button
  50649. */
  50650. set buttonCircle(value: number);
  50651. /**
  50652. * Gets the value of the `Square` button
  50653. */
  50654. get buttonSquare(): number;
  50655. /**
  50656. * Sets the value of the `Square` button
  50657. */
  50658. set buttonSquare(value: number);
  50659. /**
  50660. * Gets the value of the `Triangle` button
  50661. */
  50662. get buttonTriangle(): number;
  50663. /**
  50664. * Sets the value of the `Triangle` button
  50665. */
  50666. set buttonTriangle(value: number);
  50667. /**
  50668. * Gets the value of the `Options` button
  50669. */
  50670. get buttonOptions(): number;
  50671. /**
  50672. * Sets the value of the `Options` button
  50673. */
  50674. set buttonOptions(value: number);
  50675. /**
  50676. * Gets the value of the `Share` button
  50677. */
  50678. get buttonShare(): number;
  50679. /**
  50680. * Sets the value of the `Share` button
  50681. */
  50682. set buttonShare(value: number);
  50683. /**
  50684. * Gets the value of the `L1` button
  50685. */
  50686. get buttonL1(): number;
  50687. /**
  50688. * Sets the value of the `L1` button
  50689. */
  50690. set buttonL1(value: number);
  50691. /**
  50692. * Gets the value of the `R1` button
  50693. */
  50694. get buttonR1(): number;
  50695. /**
  50696. * Sets the value of the `R1` button
  50697. */
  50698. set buttonR1(value: number);
  50699. /**
  50700. * Gets the value of the Left joystick
  50701. */
  50702. get buttonLeftStick(): number;
  50703. /**
  50704. * Sets the value of the Left joystick
  50705. */
  50706. set buttonLeftStick(value: number);
  50707. /**
  50708. * Gets the value of the Right joystick
  50709. */
  50710. get buttonRightStick(): number;
  50711. /**
  50712. * Sets the value of the Right joystick
  50713. */
  50714. set buttonRightStick(value: number);
  50715. /**
  50716. * Gets the value of D-pad up
  50717. */
  50718. get dPadUp(): number;
  50719. /**
  50720. * Sets the value of D-pad up
  50721. */
  50722. set dPadUp(value: number);
  50723. /**
  50724. * Gets the value of D-pad down
  50725. */
  50726. get dPadDown(): number;
  50727. /**
  50728. * Sets the value of D-pad down
  50729. */
  50730. set dPadDown(value: number);
  50731. /**
  50732. * Gets the value of D-pad left
  50733. */
  50734. get dPadLeft(): number;
  50735. /**
  50736. * Sets the value of D-pad left
  50737. */
  50738. set dPadLeft(value: number);
  50739. /**
  50740. * Gets the value of D-pad right
  50741. */
  50742. get dPadRight(): number;
  50743. /**
  50744. * Sets the value of D-pad right
  50745. */
  50746. set dPadRight(value: number);
  50747. /**
  50748. * Force the gamepad to synchronize with device values
  50749. */
  50750. update(): void;
  50751. /**
  50752. * Disposes the gamepad
  50753. */
  50754. dispose(): void;
  50755. }
  50756. }
  50757. declare module "babylonjs/Gamepads/gamepadManager" {
  50758. import { Observable } from "babylonjs/Misc/observable";
  50759. import { Nullable } from "babylonjs/types";
  50760. import { Scene } from "babylonjs/scene";
  50761. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50762. /**
  50763. * Manager for handling gamepads
  50764. */
  50765. export class GamepadManager {
  50766. private _scene?;
  50767. private _babylonGamepads;
  50768. private _oneGamepadConnected;
  50769. /** @hidden */
  50770. _isMonitoring: boolean;
  50771. private _gamepadEventSupported;
  50772. private _gamepadSupport?;
  50773. /**
  50774. * observable to be triggered when the gamepad controller has been connected
  50775. */
  50776. onGamepadConnectedObservable: Observable<Gamepad>;
  50777. /**
  50778. * observable to be triggered when the gamepad controller has been disconnected
  50779. */
  50780. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50781. private _onGamepadConnectedEvent;
  50782. private _onGamepadDisconnectedEvent;
  50783. /**
  50784. * Initializes the gamepad manager
  50785. * @param _scene BabylonJS scene
  50786. */
  50787. constructor(_scene?: Scene | undefined);
  50788. /**
  50789. * The gamepads in the game pad manager
  50790. */
  50791. get gamepads(): Gamepad[];
  50792. /**
  50793. * Get the gamepad controllers based on type
  50794. * @param type The type of gamepad controller
  50795. * @returns Nullable gamepad
  50796. */
  50797. getGamepadByType(type?: number): Nullable<Gamepad>;
  50798. /**
  50799. * Disposes the gamepad manager
  50800. */
  50801. dispose(): void;
  50802. private _addNewGamepad;
  50803. private _startMonitoringGamepads;
  50804. private _stopMonitoringGamepads;
  50805. /** @hidden */
  50806. _checkGamepadsStatus(): void;
  50807. private _updateGamepadObjects;
  50808. }
  50809. }
  50810. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50811. import { Nullable } from "babylonjs/types";
  50812. import { Scene } from "babylonjs/scene";
  50813. import { ISceneComponent } from "babylonjs/sceneComponent";
  50814. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50815. module "babylonjs/scene" {
  50816. interface Scene {
  50817. /** @hidden */
  50818. _gamepadManager: Nullable<GamepadManager>;
  50819. /**
  50820. * Gets the gamepad manager associated with the scene
  50821. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50822. */
  50823. gamepadManager: GamepadManager;
  50824. }
  50825. }
  50826. module "babylonjs/Cameras/freeCameraInputsManager" {
  50827. /**
  50828. * Interface representing a free camera inputs manager
  50829. */
  50830. interface FreeCameraInputsManager {
  50831. /**
  50832. * Adds gamepad input support to the FreeCameraInputsManager.
  50833. * @returns the FreeCameraInputsManager
  50834. */
  50835. addGamepad(): FreeCameraInputsManager;
  50836. }
  50837. }
  50838. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50839. /**
  50840. * Interface representing an arc rotate camera inputs manager
  50841. */
  50842. interface ArcRotateCameraInputsManager {
  50843. /**
  50844. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50845. * @returns the camera inputs manager
  50846. */
  50847. addGamepad(): ArcRotateCameraInputsManager;
  50848. }
  50849. }
  50850. /**
  50851. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50852. */
  50853. export class GamepadSystemSceneComponent implements ISceneComponent {
  50854. /**
  50855. * The component name helpfull to identify the component in the list of scene components.
  50856. */
  50857. readonly name: string;
  50858. /**
  50859. * The scene the component belongs to.
  50860. */
  50861. scene: Scene;
  50862. /**
  50863. * Creates a new instance of the component for the given scene
  50864. * @param scene Defines the scene to register the component in
  50865. */
  50866. constructor(scene: Scene);
  50867. /**
  50868. * Registers the component in a given scene
  50869. */
  50870. register(): void;
  50871. /**
  50872. * Rebuilds the elements related to this component in case of
  50873. * context lost for instance.
  50874. */
  50875. rebuild(): void;
  50876. /**
  50877. * Disposes the component and the associated ressources
  50878. */
  50879. dispose(): void;
  50880. private _beforeCameraUpdate;
  50881. }
  50882. }
  50883. declare module "babylonjs/Cameras/universalCamera" {
  50884. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50885. import { Scene } from "babylonjs/scene";
  50886. import { Vector3 } from "babylonjs/Maths/math.vector";
  50887. import "babylonjs/Gamepads/gamepadSceneComponent";
  50888. /**
  50889. * 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,
  50890. * which still works and will still be found in many Playgrounds.
  50891. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50892. */
  50893. export class UniversalCamera extends TouchCamera {
  50894. /**
  50895. * Defines the gamepad rotation sensiblity.
  50896. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50897. */
  50898. get gamepadAngularSensibility(): number;
  50899. set gamepadAngularSensibility(value: number);
  50900. /**
  50901. * Defines the gamepad move sensiblity.
  50902. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50903. */
  50904. get gamepadMoveSensibility(): number;
  50905. set gamepadMoveSensibility(value: number);
  50906. /**
  50907. * 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,
  50908. * which still works and will still be found in many Playgrounds.
  50909. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50910. * @param name Define the name of the camera in the scene
  50911. * @param position Define the start position of the camera in the scene
  50912. * @param scene Define the scene the camera belongs to
  50913. */
  50914. constructor(name: string, position: Vector3, scene: Scene);
  50915. /**
  50916. * Gets the current object class name.
  50917. * @return the class name
  50918. */
  50919. getClassName(): string;
  50920. }
  50921. }
  50922. declare module "babylonjs/Cameras/gamepadCamera" {
  50923. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50924. import { Scene } from "babylonjs/scene";
  50925. import { Vector3 } from "babylonjs/Maths/math.vector";
  50926. /**
  50927. * This represents a FPS type of camera. This is only here for back compat purpose.
  50928. * Please use the UniversalCamera instead as both are identical.
  50929. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50930. */
  50931. export class GamepadCamera extends UniversalCamera {
  50932. /**
  50933. * Instantiates a new Gamepad Camera
  50934. * This represents a FPS type of camera. This is only here for back compat purpose.
  50935. * Please use the UniversalCamera instead as both are identical.
  50936. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50937. * @param name Define the name of the camera in the scene
  50938. * @param position Define the start position of the camera in the scene
  50939. * @param scene Define the scene the camera belongs to
  50940. */
  50941. constructor(name: string, position: Vector3, scene: Scene);
  50942. /**
  50943. * Gets the current object class name.
  50944. * @return the class name
  50945. */
  50946. getClassName(): string;
  50947. }
  50948. }
  50949. declare module "babylonjs/Shaders/pass.fragment" {
  50950. /** @hidden */
  50951. export var passPixelShader: {
  50952. name: string;
  50953. shader: string;
  50954. };
  50955. }
  50956. declare module "babylonjs/Shaders/passCube.fragment" {
  50957. /** @hidden */
  50958. export var passCubePixelShader: {
  50959. name: string;
  50960. shader: string;
  50961. };
  50962. }
  50963. declare module "babylonjs/PostProcesses/passPostProcess" {
  50964. import { Nullable } from "babylonjs/types";
  50965. import { Camera } from "babylonjs/Cameras/camera";
  50966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50967. import { Engine } from "babylonjs/Engines/engine";
  50968. import "babylonjs/Shaders/pass.fragment";
  50969. import "babylonjs/Shaders/passCube.fragment";
  50970. import { Scene } from "babylonjs/scene";
  50971. /**
  50972. * PassPostProcess which produces an output the same as it's input
  50973. */
  50974. export class PassPostProcess extends PostProcess {
  50975. /**
  50976. * Gets a string identifying the name of the class
  50977. * @returns "PassPostProcess" string
  50978. */
  50979. getClassName(): string;
  50980. /**
  50981. * Creates the PassPostProcess
  50982. * @param name The name of the effect.
  50983. * @param options The required width/height ratio to downsize to before computing the render pass.
  50984. * @param camera The camera to apply the render pass to.
  50985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50986. * @param engine The engine which the post process will be applied. (default: current engine)
  50987. * @param reusable If the post process can be reused on the same frame. (default: false)
  50988. * @param textureType The type of texture to be used when performing the post processing.
  50989. * @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)
  50990. */
  50991. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50992. /** @hidden */
  50993. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  50994. }
  50995. /**
  50996. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  50997. */
  50998. export class PassCubePostProcess extends PostProcess {
  50999. private _face;
  51000. /**
  51001. * Gets or sets the cube face to display.
  51002. * * 0 is +X
  51003. * * 1 is -X
  51004. * * 2 is +Y
  51005. * * 3 is -Y
  51006. * * 4 is +Z
  51007. * * 5 is -Z
  51008. */
  51009. get face(): number;
  51010. set face(value: number);
  51011. /**
  51012. * Gets a string identifying the name of the class
  51013. * @returns "PassCubePostProcess" string
  51014. */
  51015. getClassName(): string;
  51016. /**
  51017. * Creates the PassCubePostProcess
  51018. * @param name The name of the effect.
  51019. * @param options The required width/height ratio to downsize to before computing the render pass.
  51020. * @param camera The camera to apply the render pass to.
  51021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51022. * @param engine The engine which the post process will be applied. (default: current engine)
  51023. * @param reusable If the post process can be reused on the same frame. (default: false)
  51024. * @param textureType The type of texture to be used when performing the post processing.
  51025. * @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)
  51026. */
  51027. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51028. /** @hidden */
  51029. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51030. }
  51031. }
  51032. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51033. /** @hidden */
  51034. export var anaglyphPixelShader: {
  51035. name: string;
  51036. shader: string;
  51037. };
  51038. }
  51039. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51040. import { Engine } from "babylonjs/Engines/engine";
  51041. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51042. import { Camera } from "babylonjs/Cameras/camera";
  51043. import "babylonjs/Shaders/anaglyph.fragment";
  51044. /**
  51045. * Postprocess used to generate anaglyphic rendering
  51046. */
  51047. export class AnaglyphPostProcess extends PostProcess {
  51048. private _passedProcess;
  51049. /**
  51050. * Gets a string identifying the name of the class
  51051. * @returns "AnaglyphPostProcess" string
  51052. */
  51053. getClassName(): string;
  51054. /**
  51055. * Creates a new AnaglyphPostProcess
  51056. * @param name defines postprocess name
  51057. * @param options defines creation options or target ratio scale
  51058. * @param rigCameras defines cameras using this postprocess
  51059. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51060. * @param engine defines hosting engine
  51061. * @param reusable defines if the postprocess will be reused multiple times per frame
  51062. */
  51063. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51064. }
  51065. }
  51066. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51067. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51068. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51069. import { Scene } from "babylonjs/scene";
  51070. import { Vector3 } from "babylonjs/Maths/math.vector";
  51071. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51072. /**
  51073. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51074. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51075. */
  51076. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51077. /**
  51078. * Creates a new AnaglyphArcRotateCamera
  51079. * @param name defines camera name
  51080. * @param alpha defines alpha angle (in radians)
  51081. * @param beta defines beta angle (in radians)
  51082. * @param radius defines radius
  51083. * @param target defines camera target
  51084. * @param interaxialDistance defines distance between each color axis
  51085. * @param scene defines the hosting scene
  51086. */
  51087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51088. /**
  51089. * Gets camera class name
  51090. * @returns AnaglyphArcRotateCamera
  51091. */
  51092. getClassName(): string;
  51093. }
  51094. }
  51095. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51096. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51097. import { Scene } from "babylonjs/scene";
  51098. import { Vector3 } from "babylonjs/Maths/math.vector";
  51099. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51100. /**
  51101. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51102. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51103. */
  51104. export class AnaglyphFreeCamera extends FreeCamera {
  51105. /**
  51106. * Creates a new AnaglyphFreeCamera
  51107. * @param name defines camera name
  51108. * @param position defines initial position
  51109. * @param interaxialDistance defines distance between each color axis
  51110. * @param scene defines the hosting scene
  51111. */
  51112. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51113. /**
  51114. * Gets camera class name
  51115. * @returns AnaglyphFreeCamera
  51116. */
  51117. getClassName(): string;
  51118. }
  51119. }
  51120. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51121. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51122. import { Scene } from "babylonjs/scene";
  51123. import { Vector3 } from "babylonjs/Maths/math.vector";
  51124. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51125. /**
  51126. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51127. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51128. */
  51129. export class AnaglyphGamepadCamera extends GamepadCamera {
  51130. /**
  51131. * Creates a new AnaglyphGamepadCamera
  51132. * @param name defines camera name
  51133. * @param position defines initial position
  51134. * @param interaxialDistance defines distance between each color axis
  51135. * @param scene defines the hosting scene
  51136. */
  51137. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51138. /**
  51139. * Gets camera class name
  51140. * @returns AnaglyphGamepadCamera
  51141. */
  51142. getClassName(): string;
  51143. }
  51144. }
  51145. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51146. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51147. import { Scene } from "babylonjs/scene";
  51148. import { Vector3 } from "babylonjs/Maths/math.vector";
  51149. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51150. /**
  51151. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51152. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51153. */
  51154. export class AnaglyphUniversalCamera extends UniversalCamera {
  51155. /**
  51156. * Creates a new AnaglyphUniversalCamera
  51157. * @param name defines camera name
  51158. * @param position defines initial position
  51159. * @param interaxialDistance defines distance between each color axis
  51160. * @param scene defines the hosting scene
  51161. */
  51162. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51163. /**
  51164. * Gets camera class name
  51165. * @returns AnaglyphUniversalCamera
  51166. */
  51167. getClassName(): string;
  51168. }
  51169. }
  51170. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51171. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51172. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51173. import { Scene } from "babylonjs/scene";
  51174. import { Vector3 } from "babylonjs/Maths/math.vector";
  51175. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51176. /**
  51177. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51178. * @see https://doc.babylonjs.com/features/cameras
  51179. */
  51180. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51181. /**
  51182. * Creates a new StereoscopicArcRotateCamera
  51183. * @param name defines camera name
  51184. * @param alpha defines alpha angle (in radians)
  51185. * @param beta defines beta angle (in radians)
  51186. * @param radius defines radius
  51187. * @param target defines camera target
  51188. * @param interaxialDistance defines distance between each color axis
  51189. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51190. * @param scene defines the hosting scene
  51191. */
  51192. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51193. /**
  51194. * Gets camera class name
  51195. * @returns StereoscopicArcRotateCamera
  51196. */
  51197. getClassName(): string;
  51198. }
  51199. }
  51200. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51201. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51202. import { Scene } from "babylonjs/scene";
  51203. import { Vector3 } from "babylonjs/Maths/math.vector";
  51204. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51205. /**
  51206. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51207. * @see https://doc.babylonjs.com/features/cameras
  51208. */
  51209. export class StereoscopicFreeCamera extends FreeCamera {
  51210. /**
  51211. * Creates a new StereoscopicFreeCamera
  51212. * @param name defines camera name
  51213. * @param position defines initial position
  51214. * @param interaxialDistance defines distance between each color axis
  51215. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51216. * @param scene defines the hosting scene
  51217. */
  51218. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51219. /**
  51220. * Gets camera class name
  51221. * @returns StereoscopicFreeCamera
  51222. */
  51223. getClassName(): string;
  51224. }
  51225. }
  51226. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51227. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51228. import { Scene } from "babylonjs/scene";
  51229. import { Vector3 } from "babylonjs/Maths/math.vector";
  51230. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51231. /**
  51232. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51233. * @see https://doc.babylonjs.com/features/cameras
  51234. */
  51235. export class StereoscopicGamepadCamera extends GamepadCamera {
  51236. /**
  51237. * Creates a new StereoscopicGamepadCamera
  51238. * @param name defines camera name
  51239. * @param position defines initial position
  51240. * @param interaxialDistance defines distance between each color axis
  51241. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51242. * @param scene defines the hosting scene
  51243. */
  51244. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51245. /**
  51246. * Gets camera class name
  51247. * @returns StereoscopicGamepadCamera
  51248. */
  51249. getClassName(): string;
  51250. }
  51251. }
  51252. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51253. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51254. import { Scene } from "babylonjs/scene";
  51255. import { Vector3 } from "babylonjs/Maths/math.vector";
  51256. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51257. /**
  51258. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51259. * @see https://doc.babylonjs.com/features/cameras
  51260. */
  51261. export class StereoscopicUniversalCamera extends UniversalCamera {
  51262. /**
  51263. * Creates a new StereoscopicUniversalCamera
  51264. * @param name defines camera name
  51265. * @param position defines initial position
  51266. * @param interaxialDistance defines distance between each color axis
  51267. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51268. * @param scene defines the hosting scene
  51269. */
  51270. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51271. /**
  51272. * Gets camera class name
  51273. * @returns StereoscopicUniversalCamera
  51274. */
  51275. getClassName(): string;
  51276. }
  51277. }
  51278. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51279. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51280. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51281. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51282. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51283. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51284. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51285. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51286. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51287. }
  51288. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51289. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51290. import { Scene } from "babylonjs/scene";
  51291. import { Vector3 } from "babylonjs/Maths/math.vector";
  51292. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51293. /**
  51294. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51295. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51296. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51297. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51298. */
  51299. export class VirtualJoysticksCamera extends FreeCamera {
  51300. /**
  51301. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51302. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51303. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51304. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51305. * @param name Define the name of the camera in the scene
  51306. * @param position Define the start position of the camera in the scene
  51307. * @param scene Define the scene the camera belongs to
  51308. */
  51309. constructor(name: string, position: Vector3, scene: Scene);
  51310. /**
  51311. * Gets the current object class name.
  51312. * @return the class name
  51313. */
  51314. getClassName(): string;
  51315. }
  51316. }
  51317. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51318. import { Matrix } from "babylonjs/Maths/math.vector";
  51319. /**
  51320. * This represents all the required metrics to create a VR camera.
  51321. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51322. */
  51323. export class VRCameraMetrics {
  51324. /**
  51325. * Define the horizontal resolution off the screen.
  51326. */
  51327. hResolution: number;
  51328. /**
  51329. * Define the vertical resolution off the screen.
  51330. */
  51331. vResolution: number;
  51332. /**
  51333. * Define the horizontal screen size.
  51334. */
  51335. hScreenSize: number;
  51336. /**
  51337. * Define the vertical screen size.
  51338. */
  51339. vScreenSize: number;
  51340. /**
  51341. * Define the vertical screen center position.
  51342. */
  51343. vScreenCenter: number;
  51344. /**
  51345. * Define the distance of the eyes to the screen.
  51346. */
  51347. eyeToScreenDistance: number;
  51348. /**
  51349. * Define the distance between both lenses
  51350. */
  51351. lensSeparationDistance: number;
  51352. /**
  51353. * Define the distance between both viewer's eyes.
  51354. */
  51355. interpupillaryDistance: number;
  51356. /**
  51357. * Define the distortion factor of the VR postprocess.
  51358. * Please, touch with care.
  51359. */
  51360. distortionK: number[];
  51361. /**
  51362. * Define the chromatic aberration correction factors for the VR post process.
  51363. */
  51364. chromaAbCorrection: number[];
  51365. /**
  51366. * Define the scale factor of the post process.
  51367. * The smaller the better but the slower.
  51368. */
  51369. postProcessScaleFactor: number;
  51370. /**
  51371. * Define an offset for the lens center.
  51372. */
  51373. lensCenterOffset: number;
  51374. /**
  51375. * Define if the current vr camera should compensate the distortion of the lense or not.
  51376. */
  51377. compensateDistortion: boolean;
  51378. /**
  51379. * Defines if multiview should be enabled when rendering (Default: false)
  51380. */
  51381. multiviewEnabled: boolean;
  51382. /**
  51383. * Gets the rendering aspect ratio based on the provided resolutions.
  51384. */
  51385. get aspectRatio(): number;
  51386. /**
  51387. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51388. */
  51389. get aspectRatioFov(): number;
  51390. /**
  51391. * @hidden
  51392. */
  51393. get leftHMatrix(): Matrix;
  51394. /**
  51395. * @hidden
  51396. */
  51397. get rightHMatrix(): Matrix;
  51398. /**
  51399. * @hidden
  51400. */
  51401. get leftPreViewMatrix(): Matrix;
  51402. /**
  51403. * @hidden
  51404. */
  51405. get rightPreViewMatrix(): Matrix;
  51406. /**
  51407. * Get the default VRMetrics based on the most generic setup.
  51408. * @returns the default vr metrics
  51409. */
  51410. static GetDefault(): VRCameraMetrics;
  51411. }
  51412. }
  51413. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51414. /** @hidden */
  51415. export var vrDistortionCorrectionPixelShader: {
  51416. name: string;
  51417. shader: string;
  51418. };
  51419. }
  51420. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51421. import { Camera } from "babylonjs/Cameras/camera";
  51422. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51424. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51425. /**
  51426. * VRDistortionCorrectionPostProcess used for mobile VR
  51427. */
  51428. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51429. private _isRightEye;
  51430. private _distortionFactors;
  51431. private _postProcessScaleFactor;
  51432. private _lensCenterOffset;
  51433. private _scaleIn;
  51434. private _scaleFactor;
  51435. private _lensCenter;
  51436. /**
  51437. * Gets a string identifying the name of the class
  51438. * @returns "VRDistortionCorrectionPostProcess" string
  51439. */
  51440. getClassName(): string;
  51441. /**
  51442. * Initializes the VRDistortionCorrectionPostProcess
  51443. * @param name The name of the effect.
  51444. * @param camera The camera to apply the render pass to.
  51445. * @param isRightEye If this is for the right eye distortion
  51446. * @param vrMetrics All the required metrics for the VR camera
  51447. */
  51448. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51449. }
  51450. }
  51451. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51452. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51453. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51454. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51455. import { Scene } from "babylonjs/scene";
  51456. import { Vector3 } from "babylonjs/Maths/math.vector";
  51457. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51458. import "babylonjs/Cameras/RigModes/vrRigMode";
  51459. /**
  51460. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51461. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51462. */
  51463. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51464. /**
  51465. * Creates a new VRDeviceOrientationArcRotateCamera
  51466. * @param name defines camera name
  51467. * @param alpha defines the camera rotation along the logitudinal axis
  51468. * @param beta defines the camera rotation along the latitudinal axis
  51469. * @param radius defines the camera distance from its target
  51470. * @param target defines the camera target
  51471. * @param scene defines the scene the camera belongs to
  51472. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51473. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51474. */
  51475. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51476. /**
  51477. * Gets camera class name
  51478. * @returns VRDeviceOrientationArcRotateCamera
  51479. */
  51480. getClassName(): string;
  51481. }
  51482. }
  51483. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51484. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51485. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51486. import { Scene } from "babylonjs/scene";
  51487. import { Vector3 } from "babylonjs/Maths/math.vector";
  51488. import "babylonjs/Cameras/RigModes/vrRigMode";
  51489. /**
  51490. * Camera used to simulate VR rendering (based on FreeCamera)
  51491. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51492. */
  51493. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51494. /**
  51495. * Creates a new VRDeviceOrientationFreeCamera
  51496. * @param name defines camera name
  51497. * @param position defines the start position of the camera
  51498. * @param scene defines the scene the camera belongs to
  51499. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51500. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51501. */
  51502. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51503. /**
  51504. * Gets camera class name
  51505. * @returns VRDeviceOrientationFreeCamera
  51506. */
  51507. getClassName(): string;
  51508. }
  51509. }
  51510. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51511. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51512. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51513. import { Scene } from "babylonjs/scene";
  51514. import { Vector3 } from "babylonjs/Maths/math.vector";
  51515. import "babylonjs/Gamepads/gamepadSceneComponent";
  51516. /**
  51517. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51518. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51519. */
  51520. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51521. /**
  51522. * Creates a new VRDeviceOrientationGamepadCamera
  51523. * @param name defines camera name
  51524. * @param position defines the start position of the camera
  51525. * @param scene defines the scene the camera belongs to
  51526. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51527. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51528. */
  51529. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51530. /**
  51531. * Gets camera class name
  51532. * @returns VRDeviceOrientationGamepadCamera
  51533. */
  51534. getClassName(): string;
  51535. }
  51536. }
  51537. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51538. import { Scene } from "babylonjs/scene";
  51539. import { Texture } from "babylonjs/Materials/Textures/texture";
  51540. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51541. /**
  51542. * A class extending Texture allowing drawing on a texture
  51543. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51544. */
  51545. export class DynamicTexture extends Texture {
  51546. private _generateMipMaps;
  51547. private _canvas;
  51548. private _context;
  51549. /**
  51550. * Creates a DynamicTexture
  51551. * @param name defines the name of the texture
  51552. * @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
  51553. * @param scene defines the scene where you want the texture
  51554. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51555. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51556. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51557. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51558. */
  51559. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51560. /**
  51561. * Get the current class name of the texture useful for serialization or dynamic coding.
  51562. * @returns "DynamicTexture"
  51563. */
  51564. getClassName(): string;
  51565. /**
  51566. * Gets the current state of canRescale
  51567. */
  51568. get canRescale(): boolean;
  51569. private _recreate;
  51570. /**
  51571. * Scales the texture
  51572. * @param ratio the scale factor to apply to both width and height
  51573. */
  51574. scale(ratio: number): void;
  51575. /**
  51576. * Resizes the texture
  51577. * @param width the new width
  51578. * @param height the new height
  51579. */
  51580. scaleTo(width: number, height: number): void;
  51581. /**
  51582. * Gets the context of the canvas used by the texture
  51583. * @returns the canvas context of the dynamic texture
  51584. */
  51585. getContext(): CanvasRenderingContext2D;
  51586. /**
  51587. * Clears the texture
  51588. */
  51589. clear(): void;
  51590. /**
  51591. * Updates the texture
  51592. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51593. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51594. */
  51595. update(invertY?: boolean, premulAlpha?: boolean): void;
  51596. /**
  51597. * Draws text onto the texture
  51598. * @param text defines the text to be drawn
  51599. * @param x defines the placement of the text from the left
  51600. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51601. * @param font defines the font to be used with font-style, font-size, font-name
  51602. * @param color defines the color used for the text
  51603. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51604. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51605. * @param update defines whether texture is immediately update (default is true)
  51606. */
  51607. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51608. /**
  51609. * Clones the texture
  51610. * @returns the clone of the texture.
  51611. */
  51612. clone(): DynamicTexture;
  51613. /**
  51614. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51615. * @returns a serialized dynamic texture object
  51616. */
  51617. serialize(): any;
  51618. private _IsCanvasElement;
  51619. /** @hidden */
  51620. _rebuild(): void;
  51621. }
  51622. }
  51623. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51624. import { Scene } from "babylonjs/scene";
  51625. import { Color3 } from "babylonjs/Maths/math.color";
  51626. import { Mesh } from "babylonjs/Meshes/mesh";
  51627. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51628. import { Nullable } from "babylonjs/types";
  51629. /**
  51630. * Class containing static functions to help procedurally build meshes
  51631. */
  51632. export class GroundBuilder {
  51633. /**
  51634. * Creates a ground mesh
  51635. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51636. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51638. * @param name defines the name of the mesh
  51639. * @param options defines the options used to create the mesh
  51640. * @param scene defines the hosting scene
  51641. * @returns the ground mesh
  51642. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51643. */
  51644. static CreateGround(name: string, options: {
  51645. width?: number;
  51646. height?: number;
  51647. subdivisions?: number;
  51648. subdivisionsX?: number;
  51649. subdivisionsY?: number;
  51650. updatable?: boolean;
  51651. }, scene: any): Mesh;
  51652. /**
  51653. * Creates a tiled ground mesh
  51654. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51655. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51656. * * 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
  51657. * * 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
  51658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51659. * @param name defines the name of the mesh
  51660. * @param options defines the options used to create the mesh
  51661. * @param scene defines the hosting scene
  51662. * @returns the tiled ground mesh
  51663. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51664. */
  51665. static CreateTiledGround(name: string, options: {
  51666. xmin: number;
  51667. zmin: number;
  51668. xmax: number;
  51669. zmax: number;
  51670. subdivisions?: {
  51671. w: number;
  51672. h: number;
  51673. };
  51674. precision?: {
  51675. w: number;
  51676. h: number;
  51677. };
  51678. updatable?: boolean;
  51679. }, scene?: Nullable<Scene>): Mesh;
  51680. /**
  51681. * Creates a ground mesh from a height map
  51682. * * The parameter `url` sets the URL of the height map image resource.
  51683. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51684. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51685. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51686. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51687. * * 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.
  51688. * * 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).
  51689. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51691. * @param name defines the name of the mesh
  51692. * @param url defines the url to the height map
  51693. * @param options defines the options used to create the mesh
  51694. * @param scene defines the hosting scene
  51695. * @returns the ground mesh
  51696. * @see https://doc.babylonjs.com/babylon101/height_map
  51697. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51698. */
  51699. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51700. width?: number;
  51701. height?: number;
  51702. subdivisions?: number;
  51703. minHeight?: number;
  51704. maxHeight?: number;
  51705. colorFilter?: Color3;
  51706. alphaFilter?: number;
  51707. updatable?: boolean;
  51708. onReady?: (mesh: GroundMesh) => void;
  51709. }, scene?: Nullable<Scene>): GroundMesh;
  51710. }
  51711. }
  51712. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51713. import { Vector4 } from "babylonjs/Maths/math.vector";
  51714. import { Mesh } from "babylonjs/Meshes/mesh";
  51715. /**
  51716. * Class containing static functions to help procedurally build meshes
  51717. */
  51718. export class TorusBuilder {
  51719. /**
  51720. * Creates a torus mesh
  51721. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51722. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51723. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51727. * @param name defines the name of the mesh
  51728. * @param options defines the options used to create the mesh
  51729. * @param scene defines the hosting scene
  51730. * @returns the torus mesh
  51731. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51732. */
  51733. static CreateTorus(name: string, options: {
  51734. diameter?: number;
  51735. thickness?: number;
  51736. tessellation?: number;
  51737. updatable?: boolean;
  51738. sideOrientation?: number;
  51739. frontUVs?: Vector4;
  51740. backUVs?: Vector4;
  51741. }, scene: any): Mesh;
  51742. }
  51743. }
  51744. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51745. import { Vector4 } from "babylonjs/Maths/math.vector";
  51746. import { Color4 } from "babylonjs/Maths/math.color";
  51747. import { Mesh } from "babylonjs/Meshes/mesh";
  51748. /**
  51749. * Class containing static functions to help procedurally build meshes
  51750. */
  51751. export class CylinderBuilder {
  51752. /**
  51753. * Creates a cylinder or a cone mesh
  51754. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51755. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51756. * * 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.
  51757. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51758. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51759. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51760. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51761. * * 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).
  51762. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51763. * * 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).
  51764. * * 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
  51765. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51766. * * 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
  51767. * * 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.
  51768. * * If `enclose` is false, a ring surface is one element.
  51769. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51770. * * 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
  51771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51774. * @param name defines the name of the mesh
  51775. * @param options defines the options used to create the mesh
  51776. * @param scene defines the hosting scene
  51777. * @returns the cylinder mesh
  51778. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51779. */
  51780. static CreateCylinder(name: string, options: {
  51781. height?: number;
  51782. diameterTop?: number;
  51783. diameterBottom?: number;
  51784. diameter?: number;
  51785. tessellation?: number;
  51786. subdivisions?: number;
  51787. arc?: number;
  51788. faceColors?: Color4[];
  51789. faceUV?: Vector4[];
  51790. updatable?: boolean;
  51791. hasRings?: boolean;
  51792. enclose?: boolean;
  51793. cap?: number;
  51794. sideOrientation?: number;
  51795. frontUVs?: Vector4;
  51796. backUVs?: Vector4;
  51797. }, scene: any): Mesh;
  51798. }
  51799. }
  51800. declare module "babylonjs/XR/webXRTypes" {
  51801. import { Nullable } from "babylonjs/types";
  51802. import { IDisposable } from "babylonjs/scene";
  51803. /**
  51804. * States of the webXR experience
  51805. */
  51806. export enum WebXRState {
  51807. /**
  51808. * Transitioning to being in XR mode
  51809. */
  51810. ENTERING_XR = 0,
  51811. /**
  51812. * Transitioning to non XR mode
  51813. */
  51814. EXITING_XR = 1,
  51815. /**
  51816. * In XR mode and presenting
  51817. */
  51818. IN_XR = 2,
  51819. /**
  51820. * Not entered XR mode
  51821. */
  51822. NOT_IN_XR = 3
  51823. }
  51824. /**
  51825. * The state of the XR camera's tracking
  51826. */
  51827. export enum WebXRTrackingState {
  51828. /**
  51829. * No transformation received, device is not being tracked
  51830. */
  51831. NOT_TRACKING = 0,
  51832. /**
  51833. * Tracking lost - using emulated position
  51834. */
  51835. TRACKING_LOST = 1,
  51836. /**
  51837. * Transformation tracking works normally
  51838. */
  51839. TRACKING = 2
  51840. }
  51841. /**
  51842. * Abstraction of the XR render target
  51843. */
  51844. export interface WebXRRenderTarget extends IDisposable {
  51845. /**
  51846. * xrpresent context of the canvas which can be used to display/mirror xr content
  51847. */
  51848. canvasContext: WebGLRenderingContext;
  51849. /**
  51850. * xr layer for the canvas
  51851. */
  51852. xrLayer: Nullable<XRWebGLLayer>;
  51853. /**
  51854. * Initializes the xr layer for the session
  51855. * @param xrSession xr session
  51856. * @returns a promise that will resolve once the XR Layer has been created
  51857. */
  51858. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51859. }
  51860. }
  51861. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51862. import { Nullable } from "babylonjs/types";
  51863. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51864. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51865. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51866. import { Observable } from "babylonjs/Misc/observable";
  51867. /**
  51868. * COnfiguration object for WebXR output canvas
  51869. */
  51870. export class WebXRManagedOutputCanvasOptions {
  51871. /**
  51872. * An optional canvas in case you wish to create it yourself and provide it here.
  51873. * If not provided, a new canvas will be created
  51874. */
  51875. canvasElement?: HTMLCanvasElement;
  51876. /**
  51877. * Options for this XR Layer output
  51878. */
  51879. canvasOptions?: XRWebGLLayerOptions;
  51880. /**
  51881. * CSS styling for a newly created canvas (if not provided)
  51882. */
  51883. newCanvasCssStyle?: string;
  51884. /**
  51885. * Get the default values of the configuration object
  51886. * @param engine defines the engine to use (can be null)
  51887. * @returns default values of this configuration object
  51888. */
  51889. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51890. }
  51891. /**
  51892. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51893. */
  51894. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51895. private _options;
  51896. private _canvas;
  51897. private _engine;
  51898. private _originalCanvasSize;
  51899. /**
  51900. * Rendering context of the canvas which can be used to display/mirror xr content
  51901. */
  51902. canvasContext: WebGLRenderingContext;
  51903. /**
  51904. * xr layer for the canvas
  51905. */
  51906. xrLayer: Nullable<XRWebGLLayer>;
  51907. /**
  51908. * Obseervers registered here will be triggered when the xr layer was initialized
  51909. */
  51910. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51911. /**
  51912. * Initializes the canvas to be added/removed upon entering/exiting xr
  51913. * @param _xrSessionManager The XR Session manager
  51914. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51915. */
  51916. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51917. /**
  51918. * Disposes of the object
  51919. */
  51920. dispose(): void;
  51921. /**
  51922. * Initializes the xr layer for the session
  51923. * @param xrSession xr session
  51924. * @returns a promise that will resolve once the XR Layer has been created
  51925. */
  51926. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51927. private _addCanvas;
  51928. private _removeCanvas;
  51929. private _setCanvasSize;
  51930. private _setManagedOutputCanvas;
  51931. }
  51932. }
  51933. declare module "babylonjs/XR/webXRSessionManager" {
  51934. import { Observable } from "babylonjs/Misc/observable";
  51935. import { Nullable } from "babylonjs/types";
  51936. import { IDisposable, Scene } from "babylonjs/scene";
  51937. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51938. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51939. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51940. /**
  51941. * Manages an XRSession to work with Babylon's engine
  51942. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51943. */
  51944. export class WebXRSessionManager implements IDisposable {
  51945. /** The scene which the session should be created for */
  51946. scene: Scene;
  51947. private _referenceSpace;
  51948. private _rttProvider;
  51949. private _sessionEnded;
  51950. private _xrNavigator;
  51951. private baseLayer;
  51952. /**
  51953. * The base reference space from which the session started. good if you want to reset your
  51954. * reference space
  51955. */
  51956. baseReferenceSpace: XRReferenceSpace;
  51957. /**
  51958. * Current XR frame
  51959. */
  51960. currentFrame: Nullable<XRFrame>;
  51961. /** WebXR timestamp updated every frame */
  51962. currentTimestamp: number;
  51963. /**
  51964. * Used just in case of a failure to initialize an immersive session.
  51965. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51966. */
  51967. defaultHeightCompensation: number;
  51968. /**
  51969. * Fires every time a new xrFrame arrives which can be used to update the camera
  51970. */
  51971. onXRFrameObservable: Observable<XRFrame>;
  51972. /**
  51973. * Fires when the reference space changed
  51974. */
  51975. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51976. /**
  51977. * Fires when the xr session is ended either by the device or manually done
  51978. */
  51979. onXRSessionEnded: Observable<any>;
  51980. /**
  51981. * Fires when the xr session is ended either by the device or manually done
  51982. */
  51983. onXRSessionInit: Observable<XRSession>;
  51984. /**
  51985. * Underlying xr session
  51986. */
  51987. session: XRSession;
  51988. /**
  51989. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  51990. * or get the offset the player is currently at.
  51991. */
  51992. viewerReferenceSpace: XRReferenceSpace;
  51993. /**
  51994. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  51995. * @param scene The scene which the session should be created for
  51996. */
  51997. constructor(
  51998. /** The scene which the session should be created for */
  51999. scene: Scene);
  52000. /**
  52001. * The current reference space used in this session. This reference space can constantly change!
  52002. * It is mainly used to offset the camera's position.
  52003. */
  52004. get referenceSpace(): XRReferenceSpace;
  52005. /**
  52006. * Set a new reference space and triggers the observable
  52007. */
  52008. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52009. /**
  52010. * Disposes of the session manager
  52011. */
  52012. dispose(): void;
  52013. /**
  52014. * Stops the xrSession and restores the render loop
  52015. * @returns Promise which resolves after it exits XR
  52016. */
  52017. exitXRAsync(): Promise<void>;
  52018. /**
  52019. * Gets the correct render target texture to be rendered this frame for this eye
  52020. * @param eye the eye for which to get the render target
  52021. * @returns the render target for the specified eye
  52022. */
  52023. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52024. /**
  52025. * Creates a WebXRRenderTarget object for the XR session
  52026. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52027. * @param options optional options to provide when creating a new render target
  52028. * @returns a WebXR render target to which the session can render
  52029. */
  52030. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52031. /**
  52032. * Initializes the manager
  52033. * After initialization enterXR can be called to start an XR session
  52034. * @returns Promise which resolves after it is initialized
  52035. */
  52036. initializeAsync(): Promise<void>;
  52037. /**
  52038. * Initializes an xr session
  52039. * @param xrSessionMode mode to initialize
  52040. * @param xrSessionInit defines optional and required values to pass to the session builder
  52041. * @returns a promise which will resolve once the session has been initialized
  52042. */
  52043. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52044. /**
  52045. * Checks if a session would be supported for the creation options specified
  52046. * @param sessionMode session mode to check if supported eg. immersive-vr
  52047. * @returns A Promise that resolves to true if supported and false if not
  52048. */
  52049. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52050. /**
  52051. * Resets the reference space to the one started the session
  52052. */
  52053. resetReferenceSpace(): void;
  52054. /**
  52055. * Starts rendering to the xr layer
  52056. */
  52057. runXRRenderLoop(): void;
  52058. /**
  52059. * Sets the reference space on the xr session
  52060. * @param referenceSpaceType space to set
  52061. * @returns a promise that will resolve once the reference space has been set
  52062. */
  52063. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52064. /**
  52065. * Updates the render state of the session
  52066. * @param state state to set
  52067. * @returns a promise that resolves once the render state has been updated
  52068. */
  52069. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52070. /**
  52071. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52072. * @param sessionMode defines the session to test
  52073. * @returns a promise with boolean as final value
  52074. */
  52075. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52076. private _createRenderTargetTexture;
  52077. }
  52078. }
  52079. declare module "babylonjs/XR/webXRCamera" {
  52080. import { Vector3 } from "babylonjs/Maths/math.vector";
  52081. import { Scene } from "babylonjs/scene";
  52082. import { Camera } from "babylonjs/Cameras/camera";
  52083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52084. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52085. import { Observable } from "babylonjs/Misc/observable";
  52086. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52087. /**
  52088. * WebXR Camera which holds the views for the xrSession
  52089. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52090. */
  52091. export class WebXRCamera extends FreeCamera {
  52092. private _xrSessionManager;
  52093. private _firstFrame;
  52094. private _referenceQuaternion;
  52095. private _referencedPosition;
  52096. private _xrInvPositionCache;
  52097. private _xrInvQuaternionCache;
  52098. private _trackingState;
  52099. /**
  52100. * Observable raised before camera teleportation
  52101. */
  52102. onBeforeCameraTeleport: Observable<Vector3>;
  52103. /**
  52104. * Observable raised after camera teleportation
  52105. */
  52106. onAfterCameraTeleport: Observable<Vector3>;
  52107. /**
  52108. * Notifies when the camera's tracking state has changed.
  52109. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52110. */
  52111. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52112. /**
  52113. * Should position compensation execute on first frame.
  52114. * This is used when copying the position from a native (non XR) camera
  52115. */
  52116. compensateOnFirstFrame: boolean;
  52117. /**
  52118. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52119. * @param name the name of the camera
  52120. * @param scene the scene to add the camera to
  52121. * @param _xrSessionManager a constructed xr session manager
  52122. */
  52123. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52124. /**
  52125. * Get the current XR tracking state of the camera
  52126. */
  52127. get trackingState(): WebXRTrackingState;
  52128. private _setTrackingState;
  52129. /**
  52130. * Return the user's height, unrelated to the current ground.
  52131. * This will be the y position of this camera, when ground level is 0.
  52132. */
  52133. get realWorldHeight(): number;
  52134. /** @hidden */
  52135. _updateForDualEyeDebugging(): void;
  52136. /**
  52137. * Sets this camera's transformation based on a non-vr camera
  52138. * @param otherCamera the non-vr camera to copy the transformation from
  52139. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52140. */
  52141. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52142. /**
  52143. * Gets the current instance class name ("WebXRCamera").
  52144. * @returns the class name
  52145. */
  52146. getClassName(): string;
  52147. private _rotate180;
  52148. private _updateFromXRSession;
  52149. private _updateNumberOfRigCameras;
  52150. private _updateReferenceSpace;
  52151. private _updateReferenceSpaceOffset;
  52152. }
  52153. }
  52154. declare module "babylonjs/XR/webXRFeaturesManager" {
  52155. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52156. import { IDisposable } from "babylonjs/scene";
  52157. /**
  52158. * Defining the interface required for a (webxr) feature
  52159. */
  52160. export interface IWebXRFeature extends IDisposable {
  52161. /**
  52162. * Is this feature attached
  52163. */
  52164. attached: boolean;
  52165. /**
  52166. * Should auto-attach be disabled?
  52167. */
  52168. disableAutoAttach: boolean;
  52169. /**
  52170. * Attach the feature to the session
  52171. * Will usually be called by the features manager
  52172. *
  52173. * @param force should attachment be forced (even when already attached)
  52174. * @returns true if successful.
  52175. */
  52176. attach(force?: boolean): boolean;
  52177. /**
  52178. * Detach the feature from the session
  52179. * Will usually be called by the features manager
  52180. *
  52181. * @returns true if successful.
  52182. */
  52183. detach(): boolean;
  52184. /**
  52185. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52186. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52187. *
  52188. * @returns whether or not the feature is compatible in this environment
  52189. */
  52190. isCompatible(): boolean;
  52191. /**
  52192. * Was this feature disposed;
  52193. */
  52194. isDisposed: boolean;
  52195. /**
  52196. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52197. */
  52198. xrNativeFeatureName?: string;
  52199. /**
  52200. * A list of (Babylon WebXR) features this feature depends on
  52201. */
  52202. dependsOn?: string[];
  52203. }
  52204. /**
  52205. * A list of the currently available features without referencing them
  52206. */
  52207. export class WebXRFeatureName {
  52208. /**
  52209. * The name of the anchor system feature
  52210. */
  52211. static readonly ANCHOR_SYSTEM: string;
  52212. /**
  52213. * The name of the background remover feature
  52214. */
  52215. static readonly BACKGROUND_REMOVER: string;
  52216. /**
  52217. * The name of the hit test feature
  52218. */
  52219. static readonly HIT_TEST: string;
  52220. /**
  52221. * physics impostors for xr controllers feature
  52222. */
  52223. static readonly PHYSICS_CONTROLLERS: string;
  52224. /**
  52225. * The name of the plane detection feature
  52226. */
  52227. static readonly PLANE_DETECTION: string;
  52228. /**
  52229. * The name of the pointer selection feature
  52230. */
  52231. static readonly POINTER_SELECTION: string;
  52232. /**
  52233. * The name of the teleportation feature
  52234. */
  52235. static readonly TELEPORTATION: string;
  52236. /**
  52237. * The name of the feature points feature.
  52238. */
  52239. static readonly FEATURE_POINTS: string;
  52240. /**
  52241. * The name of the hand tracking feature.
  52242. */
  52243. static readonly HAND_TRACKING: string;
  52244. }
  52245. /**
  52246. * Defining the constructor of a feature. Used to register the modules.
  52247. */
  52248. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52249. /**
  52250. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52251. * It is mainly used in AR sessions.
  52252. *
  52253. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52254. */
  52255. export class WebXRFeaturesManager implements IDisposable {
  52256. private _xrSessionManager;
  52257. private static readonly _AvailableFeatures;
  52258. private _features;
  52259. /**
  52260. * constructs a new features manages.
  52261. *
  52262. * @param _xrSessionManager an instance of WebXRSessionManager
  52263. */
  52264. constructor(_xrSessionManager: WebXRSessionManager);
  52265. /**
  52266. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52267. * Mainly used internally.
  52268. *
  52269. * @param featureName the name of the feature to register
  52270. * @param constructorFunction the function used to construct the module
  52271. * @param version the (babylon) version of the module
  52272. * @param stable is that a stable version of this module
  52273. */
  52274. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52275. /**
  52276. * Returns a constructor of a specific feature.
  52277. *
  52278. * @param featureName the name of the feature to construct
  52279. * @param version the version of the feature to load
  52280. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52281. * @param options optional options provided to the module.
  52282. * @returns a function that, when called, will return a new instance of this feature
  52283. */
  52284. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52285. /**
  52286. * Can be used to return the list of features currently registered
  52287. *
  52288. * @returns an Array of available features
  52289. */
  52290. static GetAvailableFeatures(): string[];
  52291. /**
  52292. * Gets the versions available for a specific feature
  52293. * @param featureName the name of the feature
  52294. * @returns an array with the available versions
  52295. */
  52296. static GetAvailableVersions(featureName: string): string[];
  52297. /**
  52298. * Return the latest unstable version of this feature
  52299. * @param featureName the name of the feature to search
  52300. * @returns the version number. if not found will return -1
  52301. */
  52302. static GetLatestVersionOfFeature(featureName: string): number;
  52303. /**
  52304. * Return the latest stable version of this feature
  52305. * @param featureName the name of the feature to search
  52306. * @returns the version number. if not found will return -1
  52307. */
  52308. static GetStableVersionOfFeature(featureName: string): number;
  52309. /**
  52310. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52311. * Can be used during a session to start a feature
  52312. * @param featureName the name of feature to attach
  52313. */
  52314. attachFeature(featureName: string): void;
  52315. /**
  52316. * Can be used inside a session or when the session ends to detach a specific feature
  52317. * @param featureName the name of the feature to detach
  52318. */
  52319. detachFeature(featureName: string): void;
  52320. /**
  52321. * Used to disable an already-enabled feature
  52322. * The feature will be disposed and will be recreated once enabled.
  52323. * @param featureName the feature to disable
  52324. * @returns true if disable was successful
  52325. */
  52326. disableFeature(featureName: string | {
  52327. Name: string;
  52328. }): boolean;
  52329. /**
  52330. * dispose this features manager
  52331. */
  52332. dispose(): void;
  52333. /**
  52334. * 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.
  52335. * 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.
  52336. *
  52337. * @param featureName the name of the feature to load or the class of the feature
  52338. * @param version optional version to load. if not provided the latest version will be enabled
  52339. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52340. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52341. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52342. * @returns a new constructed feature or throws an error if feature not found.
  52343. */
  52344. enableFeature(featureName: string | {
  52345. Name: string;
  52346. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52347. /**
  52348. * get the implementation of an enabled feature.
  52349. * @param featureName the name of the feature to load
  52350. * @returns the feature class, if found
  52351. */
  52352. getEnabledFeature(featureName: string): IWebXRFeature;
  52353. /**
  52354. * Get the list of enabled features
  52355. * @returns an array of enabled features
  52356. */
  52357. getEnabledFeatures(): string[];
  52358. /**
  52359. * This function will exten the session creation configuration object with enabled features.
  52360. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52361. * according to the defined "required" variable, provided during enableFeature call
  52362. * @param xrSessionInit the xr Session init object to extend
  52363. *
  52364. * @returns an extended XRSessionInit object
  52365. */
  52366. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52367. }
  52368. }
  52369. declare module "babylonjs/XR/webXRExperienceHelper" {
  52370. import { Observable } from "babylonjs/Misc/observable";
  52371. import { IDisposable, Scene } from "babylonjs/scene";
  52372. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52373. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52374. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52375. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52376. /**
  52377. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52378. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52379. */
  52380. export class WebXRExperienceHelper implements IDisposable {
  52381. private scene;
  52382. private _nonVRCamera;
  52383. private _originalSceneAutoClear;
  52384. private _supported;
  52385. /**
  52386. * Camera used to render xr content
  52387. */
  52388. camera: WebXRCamera;
  52389. /** A features manager for this xr session */
  52390. featuresManager: WebXRFeaturesManager;
  52391. /**
  52392. * Observers registered here will be triggered after the camera's initial transformation is set
  52393. * This can be used to set a different ground level or an extra rotation.
  52394. *
  52395. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52396. * to the position set after this observable is done executing.
  52397. */
  52398. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52399. /**
  52400. * Fires when the state of the experience helper has changed
  52401. */
  52402. onStateChangedObservable: Observable<WebXRState>;
  52403. /** Session manager used to keep track of xr session */
  52404. sessionManager: WebXRSessionManager;
  52405. /**
  52406. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52407. */
  52408. state: WebXRState;
  52409. /**
  52410. * Creates a WebXRExperienceHelper
  52411. * @param scene The scene the helper should be created in
  52412. */
  52413. private constructor();
  52414. /**
  52415. * Creates the experience helper
  52416. * @param scene the scene to attach the experience helper to
  52417. * @returns a promise for the experience helper
  52418. */
  52419. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52420. /**
  52421. * Disposes of the experience helper
  52422. */
  52423. dispose(): void;
  52424. /**
  52425. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52426. * @param sessionMode options for the XR session
  52427. * @param referenceSpaceType frame of reference of the XR session
  52428. * @param renderTarget the output canvas that will be used to enter XR mode
  52429. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52430. * @returns promise that resolves after xr mode has entered
  52431. */
  52432. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52433. /**
  52434. * Exits XR mode and returns the scene to its original state
  52435. * @returns promise that resolves after xr mode has exited
  52436. */
  52437. exitXRAsync(): Promise<void>;
  52438. private _nonXRToXRCamera;
  52439. private _setState;
  52440. }
  52441. }
  52442. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52443. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52444. import { Observable } from "babylonjs/Misc/observable";
  52445. import { IDisposable } from "babylonjs/scene";
  52446. /**
  52447. * X-Y values for axes in WebXR
  52448. */
  52449. export interface IWebXRMotionControllerAxesValue {
  52450. /**
  52451. * The value of the x axis
  52452. */
  52453. x: number;
  52454. /**
  52455. * The value of the y-axis
  52456. */
  52457. y: number;
  52458. }
  52459. /**
  52460. * changed / previous values for the values of this component
  52461. */
  52462. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52463. /**
  52464. * current (this frame) value
  52465. */
  52466. current: T;
  52467. /**
  52468. * previous (last change) value
  52469. */
  52470. previous: T;
  52471. }
  52472. /**
  52473. * Represents changes in the component between current frame and last values recorded
  52474. */
  52475. export interface IWebXRMotionControllerComponentChanges {
  52476. /**
  52477. * will be populated with previous and current values if axes changed
  52478. */
  52479. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52480. /**
  52481. * will be populated with previous and current values if pressed changed
  52482. */
  52483. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52484. /**
  52485. * will be populated with previous and current values if touched changed
  52486. */
  52487. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52488. /**
  52489. * will be populated with previous and current values if value changed
  52490. */
  52491. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52492. }
  52493. /**
  52494. * This class represents a single component (for example button or thumbstick) of a motion controller
  52495. */
  52496. export class WebXRControllerComponent implements IDisposable {
  52497. /**
  52498. * the id of this component
  52499. */
  52500. id: string;
  52501. /**
  52502. * the type of the component
  52503. */
  52504. type: MotionControllerComponentType;
  52505. private _buttonIndex;
  52506. private _axesIndices;
  52507. private _axes;
  52508. private _changes;
  52509. private _currentValue;
  52510. private _hasChanges;
  52511. private _pressed;
  52512. private _touched;
  52513. /**
  52514. * button component type
  52515. */
  52516. static BUTTON_TYPE: MotionControllerComponentType;
  52517. /**
  52518. * squeeze component type
  52519. */
  52520. static SQUEEZE_TYPE: MotionControllerComponentType;
  52521. /**
  52522. * Thumbstick component type
  52523. */
  52524. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52525. /**
  52526. * Touchpad component type
  52527. */
  52528. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52529. /**
  52530. * trigger component type
  52531. */
  52532. static TRIGGER_TYPE: MotionControllerComponentType;
  52533. /**
  52534. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52535. * the axes data changes
  52536. */
  52537. onAxisValueChangedObservable: Observable<{
  52538. x: number;
  52539. y: number;
  52540. }>;
  52541. /**
  52542. * Observers registered here will be triggered when the state of a button changes
  52543. * State change is either pressed / touched / value
  52544. */
  52545. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52546. /**
  52547. * Creates a new component for a motion controller.
  52548. * It is created by the motion controller itself
  52549. *
  52550. * @param id the id of this component
  52551. * @param type the type of the component
  52552. * @param _buttonIndex index in the buttons array of the gamepad
  52553. * @param _axesIndices indices of the values in the axes array of the gamepad
  52554. */
  52555. constructor(
  52556. /**
  52557. * the id of this component
  52558. */
  52559. id: string,
  52560. /**
  52561. * the type of the component
  52562. */
  52563. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52564. /**
  52565. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52566. */
  52567. get axes(): IWebXRMotionControllerAxesValue;
  52568. /**
  52569. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52570. */
  52571. get changes(): IWebXRMotionControllerComponentChanges;
  52572. /**
  52573. * Return whether or not the component changed the last frame
  52574. */
  52575. get hasChanges(): boolean;
  52576. /**
  52577. * is the button currently pressed
  52578. */
  52579. get pressed(): boolean;
  52580. /**
  52581. * is the button currently touched
  52582. */
  52583. get touched(): boolean;
  52584. /**
  52585. * Get the current value of this component
  52586. */
  52587. get value(): number;
  52588. /**
  52589. * Dispose this component
  52590. */
  52591. dispose(): void;
  52592. /**
  52593. * Are there axes correlating to this component
  52594. * @return true is axes data is available
  52595. */
  52596. isAxes(): boolean;
  52597. /**
  52598. * Is this component a button (hence - pressable)
  52599. * @returns true if can be pressed
  52600. */
  52601. isButton(): boolean;
  52602. /**
  52603. * update this component using the gamepad object it is in. Called on every frame
  52604. * @param nativeController the native gamepad controller object
  52605. */
  52606. update(nativeController: IMinimalMotionControllerObject): void;
  52607. }
  52608. }
  52609. declare module "babylonjs/Loading/sceneLoader" {
  52610. import { Observable } from "babylonjs/Misc/observable";
  52611. import { Nullable } from "babylonjs/types";
  52612. import { Scene } from "babylonjs/scene";
  52613. import { Engine } from "babylonjs/Engines/engine";
  52614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52615. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52616. import { AssetContainer } from "babylonjs/assetContainer";
  52617. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52618. import { Skeleton } from "babylonjs/Bones/skeleton";
  52619. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52620. import { WebRequest } from "babylonjs/Misc/webRequest";
  52621. /**
  52622. * Interface used to represent data loading progression
  52623. */
  52624. export interface ISceneLoaderProgressEvent {
  52625. /**
  52626. * Defines if data length to load can be evaluated
  52627. */
  52628. readonly lengthComputable: boolean;
  52629. /**
  52630. * Defines the loaded data length
  52631. */
  52632. readonly loaded: number;
  52633. /**
  52634. * Defines the data length to load
  52635. */
  52636. readonly total: number;
  52637. }
  52638. /**
  52639. * Interface used by SceneLoader plugins to define supported file extensions
  52640. */
  52641. export interface ISceneLoaderPluginExtensions {
  52642. /**
  52643. * Defines the list of supported extensions
  52644. */
  52645. [extension: string]: {
  52646. isBinary: boolean;
  52647. };
  52648. }
  52649. /**
  52650. * Interface used by SceneLoader plugin factory
  52651. */
  52652. export interface ISceneLoaderPluginFactory {
  52653. /**
  52654. * Defines the name of the factory
  52655. */
  52656. name: string;
  52657. /**
  52658. * Function called to create a new plugin
  52659. * @return the new plugin
  52660. */
  52661. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52662. /**
  52663. * The callback that returns true if the data can be directly loaded.
  52664. * @param data string containing the file data
  52665. * @returns if the data can be loaded directly
  52666. */
  52667. canDirectLoad?(data: string): boolean;
  52668. }
  52669. /**
  52670. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52671. */
  52672. export interface ISceneLoaderPluginBase {
  52673. /**
  52674. * The friendly name of this plugin.
  52675. */
  52676. name: string;
  52677. /**
  52678. * The file extensions supported by this plugin.
  52679. */
  52680. extensions: string | ISceneLoaderPluginExtensions;
  52681. /**
  52682. * The callback called when loading from a url.
  52683. * @param scene scene loading this url
  52684. * @param url url to load
  52685. * @param onSuccess callback called when the file successfully loads
  52686. * @param onProgress callback called while file is loading (if the server supports this mode)
  52687. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52688. * @param onError callback called when the file fails to load
  52689. * @returns a file request object
  52690. */
  52691. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52692. /**
  52693. * The callback called when loading from a file object.
  52694. * @param scene scene loading this file
  52695. * @param file defines the file to load
  52696. * @param onSuccess defines the callback to call when data is loaded
  52697. * @param onProgress defines the callback to call during loading process
  52698. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52699. * @param onError defines the callback to call when an error occurs
  52700. * @returns a file request object
  52701. */
  52702. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52703. /**
  52704. * The callback that returns true if the data can be directly loaded.
  52705. * @param data string containing the file data
  52706. * @returns if the data can be loaded directly
  52707. */
  52708. canDirectLoad?(data: string): boolean;
  52709. /**
  52710. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52711. * @param scene scene loading this data
  52712. * @param data string containing the data
  52713. * @returns data to pass to the plugin
  52714. */
  52715. directLoad?(scene: Scene, data: string): any;
  52716. /**
  52717. * The callback that allows custom handling of the root url based on the response url.
  52718. * @param rootUrl the original root url
  52719. * @param responseURL the response url if available
  52720. * @returns the new root url
  52721. */
  52722. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52723. }
  52724. /**
  52725. * Interface used to define a SceneLoader plugin
  52726. */
  52727. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52728. /**
  52729. * Import meshes into a scene.
  52730. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52731. * @param scene The scene to import into
  52732. * @param data The data to import
  52733. * @param rootUrl The root url for scene and resources
  52734. * @param meshes The meshes array to import into
  52735. * @param particleSystems The particle systems array to import into
  52736. * @param skeletons The skeletons array to import into
  52737. * @param onError The callback when import fails
  52738. * @returns True if successful or false otherwise
  52739. */
  52740. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52741. /**
  52742. * Load into a scene.
  52743. * @param scene The scene to load into
  52744. * @param data The data to import
  52745. * @param rootUrl The root url for scene and resources
  52746. * @param onError The callback when import fails
  52747. * @returns True if successful or false otherwise
  52748. */
  52749. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52750. /**
  52751. * Load into an asset container.
  52752. * @param scene The scene to load into
  52753. * @param data The data to import
  52754. * @param rootUrl The root url for scene and resources
  52755. * @param onError The callback when import fails
  52756. * @returns The loaded asset container
  52757. */
  52758. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52759. }
  52760. /**
  52761. * Interface used to define an async SceneLoader plugin
  52762. */
  52763. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52764. /**
  52765. * Import meshes into a scene.
  52766. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52767. * @param scene The scene to import into
  52768. * @param data The data to import
  52769. * @param rootUrl The root url for scene and resources
  52770. * @param onProgress The callback when the load progresses
  52771. * @param fileName Defines the name of the file to load
  52772. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52773. */
  52774. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52775. meshes: AbstractMesh[];
  52776. particleSystems: IParticleSystem[];
  52777. skeletons: Skeleton[];
  52778. animationGroups: AnimationGroup[];
  52779. }>;
  52780. /**
  52781. * Load into a scene.
  52782. * @param scene The scene to load into
  52783. * @param data The data to import
  52784. * @param rootUrl The root url for scene and resources
  52785. * @param onProgress The callback when the load progresses
  52786. * @param fileName Defines the name of the file to load
  52787. * @returns Nothing
  52788. */
  52789. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52790. /**
  52791. * Load into an asset container.
  52792. * @param scene The scene to load into
  52793. * @param data The data to import
  52794. * @param rootUrl The root url for scene and resources
  52795. * @param onProgress The callback when the load progresses
  52796. * @param fileName Defines the name of the file to load
  52797. * @returns The loaded asset container
  52798. */
  52799. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52800. }
  52801. /**
  52802. * Mode that determines how to handle old animation groups before loading new ones.
  52803. */
  52804. export enum SceneLoaderAnimationGroupLoadingMode {
  52805. /**
  52806. * Reset all old animations to initial state then dispose them.
  52807. */
  52808. Clean = 0,
  52809. /**
  52810. * Stop all old animations.
  52811. */
  52812. Stop = 1,
  52813. /**
  52814. * Restart old animations from first frame.
  52815. */
  52816. Sync = 2,
  52817. /**
  52818. * Old animations remains untouched.
  52819. */
  52820. NoSync = 3
  52821. }
  52822. /**
  52823. * Defines a plugin registered by the SceneLoader
  52824. */
  52825. interface IRegisteredPlugin {
  52826. /**
  52827. * Defines the plugin to use
  52828. */
  52829. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52830. /**
  52831. * Defines if the plugin supports binary data
  52832. */
  52833. isBinary: boolean;
  52834. }
  52835. /**
  52836. * Class used to load scene from various file formats using registered plugins
  52837. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52838. */
  52839. export class SceneLoader {
  52840. /**
  52841. * No logging while loading
  52842. */
  52843. static readonly NO_LOGGING: number;
  52844. /**
  52845. * Minimal logging while loading
  52846. */
  52847. static readonly MINIMAL_LOGGING: number;
  52848. /**
  52849. * Summary logging while loading
  52850. */
  52851. static readonly SUMMARY_LOGGING: number;
  52852. /**
  52853. * Detailled logging while loading
  52854. */
  52855. static readonly DETAILED_LOGGING: number;
  52856. /**
  52857. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52858. */
  52859. static get ForceFullSceneLoadingForIncremental(): boolean;
  52860. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52861. /**
  52862. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52863. */
  52864. static get ShowLoadingScreen(): boolean;
  52865. static set ShowLoadingScreen(value: boolean);
  52866. /**
  52867. * Defines the current logging level (while loading the scene)
  52868. * @ignorenaming
  52869. */
  52870. static get loggingLevel(): number;
  52871. static set loggingLevel(value: number);
  52872. /**
  52873. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52874. */
  52875. static get CleanBoneMatrixWeights(): boolean;
  52876. static set CleanBoneMatrixWeights(value: boolean);
  52877. /**
  52878. * Event raised when a plugin is used to load a scene
  52879. */
  52880. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52881. private static _registeredPlugins;
  52882. private static _showingLoadingScreen;
  52883. /**
  52884. * Gets the default plugin (used to load Babylon files)
  52885. * @returns the .babylon plugin
  52886. */
  52887. static GetDefaultPlugin(): IRegisteredPlugin;
  52888. private static _GetPluginForExtension;
  52889. private static _GetPluginForDirectLoad;
  52890. private static _GetPluginForFilename;
  52891. private static _GetDirectLoad;
  52892. private static _LoadData;
  52893. private static _GetFileInfo;
  52894. /**
  52895. * Gets a plugin that can load the given extension
  52896. * @param extension defines the extension to load
  52897. * @returns a plugin or null if none works
  52898. */
  52899. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52900. /**
  52901. * Gets a boolean indicating that the given extension can be loaded
  52902. * @param extension defines the extension to load
  52903. * @returns true if the extension is supported
  52904. */
  52905. static IsPluginForExtensionAvailable(extension: string): boolean;
  52906. /**
  52907. * Adds a new plugin to the list of registered plugins
  52908. * @param plugin defines the plugin to add
  52909. */
  52910. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52911. /**
  52912. * Import meshes into a scene
  52913. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52914. * @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)
  52915. * @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)
  52916. * @param scene the instance of BABYLON.Scene to append to
  52917. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52918. * @param onProgress a callback with a progress event for each file being loaded
  52919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52920. * @param pluginExtension the extension used to determine the plugin
  52921. * @returns The loaded plugin
  52922. */
  52923. 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>;
  52924. /**
  52925. * Import meshes into a scene
  52926. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52927. * @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)
  52928. * @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)
  52929. * @param scene the instance of BABYLON.Scene to append to
  52930. * @param onProgress a callback with a progress event for each file being loaded
  52931. * @param pluginExtension the extension used to determine the plugin
  52932. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52933. */
  52934. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52935. meshes: AbstractMesh[];
  52936. particleSystems: IParticleSystem[];
  52937. skeletons: Skeleton[];
  52938. animationGroups: AnimationGroup[];
  52939. }>;
  52940. /**
  52941. * Load a scene
  52942. * @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)
  52943. * @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)
  52944. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52945. * @param onSuccess a callback with the scene when import succeeds
  52946. * @param onProgress a callback with a progress event for each file being loaded
  52947. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52948. * @param pluginExtension the extension used to determine the plugin
  52949. * @returns The loaded plugin
  52950. */
  52951. 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>;
  52952. /**
  52953. * Load a scene
  52954. * @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)
  52955. * @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)
  52956. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52957. * @param onProgress a callback with a progress event for each file being loaded
  52958. * @param pluginExtension the extension used to determine the plugin
  52959. * @returns The loaded scene
  52960. */
  52961. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52962. /**
  52963. * Append a scene
  52964. * @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)
  52965. * @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)
  52966. * @param scene is the instance of BABYLON.Scene to append to
  52967. * @param onSuccess a callback with the scene when import succeeds
  52968. * @param onProgress a callback with a progress event for each file being loaded
  52969. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52970. * @param pluginExtension the extension used to determine the plugin
  52971. * @returns The loaded plugin
  52972. */
  52973. 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>;
  52974. /**
  52975. * Append a scene
  52976. * @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)
  52977. * @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)
  52978. * @param scene is the instance of BABYLON.Scene to append to
  52979. * @param onProgress a callback with a progress event for each file being loaded
  52980. * @param pluginExtension the extension used to determine the plugin
  52981. * @returns The given scene
  52982. */
  52983. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52984. /**
  52985. * Load a scene into an asset container
  52986. * @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)
  52987. * @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)
  52988. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52989. * @param onSuccess a callback with the scene when import succeeds
  52990. * @param onProgress a callback with a progress event for each file being loaded
  52991. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52992. * @param pluginExtension the extension used to determine the plugin
  52993. * @returns The loaded plugin
  52994. */
  52995. 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>;
  52996. /**
  52997. * Load a scene into an asset container
  52998. * @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)
  52999. * @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)
  53000. * @param scene is the instance of Scene to append to
  53001. * @param onProgress a callback with a progress event for each file being loaded
  53002. * @param pluginExtension the extension used to determine the plugin
  53003. * @returns The loaded asset container
  53004. */
  53005. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53006. /**
  53007. * Import animations from a file into a scene
  53008. * @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)
  53009. * @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)
  53010. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53011. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53012. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53013. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53014. * @param onSuccess a callback with the scene when import succeeds
  53015. * @param onProgress a callback with a progress event for each file being loaded
  53016. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53017. * @param pluginExtension the extension used to determine the plugin
  53018. */
  53019. 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;
  53020. /**
  53021. * Import animations from a file into a scene
  53022. * @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)
  53023. * @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)
  53024. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53025. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53026. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53027. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53028. * @param onSuccess a callback with the scene when import succeeds
  53029. * @param onProgress a callback with a progress event for each file being loaded
  53030. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53031. * @param pluginExtension the extension used to determine the plugin
  53032. * @returns the updated scene with imported animations
  53033. */
  53034. 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>;
  53035. }
  53036. }
  53037. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53038. import { IDisposable, Scene } from "babylonjs/scene";
  53039. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53040. import { Observable } from "babylonjs/Misc/observable";
  53041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53042. import { Nullable } from "babylonjs/types";
  53043. /**
  53044. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53045. */
  53046. export type MotionControllerHandedness = "none" | "left" | "right";
  53047. /**
  53048. * The type of components available in motion controllers.
  53049. * This is not the name of the component.
  53050. */
  53051. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53052. /**
  53053. * The state of a controller component
  53054. */
  53055. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53056. /**
  53057. * The schema of motion controller layout.
  53058. * No object will be initialized using this interface
  53059. * This is used just to define the profile.
  53060. */
  53061. export interface IMotionControllerLayout {
  53062. /**
  53063. * Path to load the assets. Usually relative to the base path
  53064. */
  53065. assetPath: string;
  53066. /**
  53067. * Available components (unsorted)
  53068. */
  53069. components: {
  53070. /**
  53071. * A map of component Ids
  53072. */
  53073. [componentId: string]: {
  53074. /**
  53075. * The type of input the component outputs
  53076. */
  53077. type: MotionControllerComponentType;
  53078. /**
  53079. * The indices of this component in the gamepad object
  53080. */
  53081. gamepadIndices: {
  53082. /**
  53083. * Index of button
  53084. */
  53085. button?: number;
  53086. /**
  53087. * If available, index of x-axis
  53088. */
  53089. xAxis?: number;
  53090. /**
  53091. * If available, index of y-axis
  53092. */
  53093. yAxis?: number;
  53094. };
  53095. /**
  53096. * The mesh's root node name
  53097. */
  53098. rootNodeName: string;
  53099. /**
  53100. * Animation definitions for this model
  53101. */
  53102. visualResponses: {
  53103. [stateKey: string]: {
  53104. /**
  53105. * What property will be animated
  53106. */
  53107. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53108. /**
  53109. * What states influence this visual response
  53110. */
  53111. states: MotionControllerComponentStateType[];
  53112. /**
  53113. * Type of animation - movement or visibility
  53114. */
  53115. valueNodeProperty: "transform" | "visibility";
  53116. /**
  53117. * Base node name to move. Its position will be calculated according to the min and max nodes
  53118. */
  53119. valueNodeName?: string;
  53120. /**
  53121. * Minimum movement node
  53122. */
  53123. minNodeName?: string;
  53124. /**
  53125. * Max movement node
  53126. */
  53127. maxNodeName?: string;
  53128. };
  53129. };
  53130. /**
  53131. * If touch enabled, what is the name of node to display user feedback
  53132. */
  53133. touchPointNodeName?: string;
  53134. };
  53135. };
  53136. /**
  53137. * Is it xr standard mapping or not
  53138. */
  53139. gamepadMapping: "" | "xr-standard";
  53140. /**
  53141. * Base root node of this entire model
  53142. */
  53143. rootNodeName: string;
  53144. /**
  53145. * Defines the main button component id
  53146. */
  53147. selectComponentId: string;
  53148. }
  53149. /**
  53150. * A definition for the layout map in the input profile
  53151. */
  53152. export interface IMotionControllerLayoutMap {
  53153. /**
  53154. * Layouts with handedness type as a key
  53155. */
  53156. [handedness: string]: IMotionControllerLayout;
  53157. }
  53158. /**
  53159. * The XR Input profile schema
  53160. * Profiles can be found here:
  53161. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53162. */
  53163. export interface IMotionControllerProfile {
  53164. /**
  53165. * fallback profiles for this profileId
  53166. */
  53167. fallbackProfileIds: string[];
  53168. /**
  53169. * The layout map, with handedness as key
  53170. */
  53171. layouts: IMotionControllerLayoutMap;
  53172. /**
  53173. * The id of this profile
  53174. * correlates to the profile(s) in the xrInput.profiles array
  53175. */
  53176. profileId: string;
  53177. }
  53178. /**
  53179. * A helper-interface for the 3 meshes needed for controller button animation
  53180. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53181. */
  53182. export interface IMotionControllerButtonMeshMap {
  53183. /**
  53184. * the mesh that defines the pressed value mesh position.
  53185. * This is used to find the max-position of this button
  53186. */
  53187. pressedMesh: AbstractMesh;
  53188. /**
  53189. * the mesh that defines the unpressed value mesh position.
  53190. * This is used to find the min (or initial) position of this button
  53191. */
  53192. unpressedMesh: AbstractMesh;
  53193. /**
  53194. * The mesh that will be changed when value changes
  53195. */
  53196. valueMesh: AbstractMesh;
  53197. }
  53198. /**
  53199. * A helper-interface for the 3 meshes needed for controller axis animation.
  53200. * This will be expanded when touchpad animations are fully supported
  53201. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53202. */
  53203. export interface IMotionControllerMeshMap {
  53204. /**
  53205. * the mesh that defines the maximum value mesh position.
  53206. */
  53207. maxMesh?: AbstractMesh;
  53208. /**
  53209. * the mesh that defines the minimum value mesh position.
  53210. */
  53211. minMesh?: AbstractMesh;
  53212. /**
  53213. * The mesh that will be changed when axis value changes
  53214. */
  53215. valueMesh?: AbstractMesh;
  53216. }
  53217. /**
  53218. * The elements needed for change-detection of the gamepad objects in motion controllers
  53219. */
  53220. export interface IMinimalMotionControllerObject {
  53221. /**
  53222. * Available axes of this controller
  53223. */
  53224. axes: number[];
  53225. /**
  53226. * An array of available buttons
  53227. */
  53228. buttons: Array<{
  53229. /**
  53230. * Value of the button/trigger
  53231. */
  53232. value: number;
  53233. /**
  53234. * If the button/trigger is currently touched
  53235. */
  53236. touched: boolean;
  53237. /**
  53238. * If the button/trigger is currently pressed
  53239. */
  53240. pressed: boolean;
  53241. }>;
  53242. /**
  53243. * EXPERIMENTAL haptic support.
  53244. */
  53245. hapticActuators?: Array<{
  53246. pulse: (value: number, duration: number) => Promise<boolean>;
  53247. }>;
  53248. }
  53249. /**
  53250. * An Abstract Motion controller
  53251. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53252. * Each component has an observable to check for changes in value and state
  53253. */
  53254. export abstract class WebXRAbstractMotionController implements IDisposable {
  53255. protected scene: Scene;
  53256. protected layout: IMotionControllerLayout;
  53257. /**
  53258. * The gamepad object correlating to this controller
  53259. */
  53260. gamepadObject: IMinimalMotionControllerObject;
  53261. /**
  53262. * handedness (left/right/none) of this controller
  53263. */
  53264. handedness: MotionControllerHandedness;
  53265. private _initComponent;
  53266. private _modelReady;
  53267. /**
  53268. * A map of components (WebXRControllerComponent) in this motion controller
  53269. * Components have a ComponentType and can also have both button and axis definitions
  53270. */
  53271. readonly components: {
  53272. [id: string]: WebXRControllerComponent;
  53273. };
  53274. /**
  53275. * Disable the model's animation. Can be set at any time.
  53276. */
  53277. disableAnimation: boolean;
  53278. /**
  53279. * Observers registered here will be triggered when the model of this controller is done loading
  53280. */
  53281. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53282. /**
  53283. * The profile id of this motion controller
  53284. */
  53285. abstract profileId: string;
  53286. /**
  53287. * The root mesh of the model. It is null if the model was not yet initialized
  53288. */
  53289. rootMesh: Nullable<AbstractMesh>;
  53290. /**
  53291. * constructs a new abstract motion controller
  53292. * @param scene the scene to which the model of the controller will be added
  53293. * @param layout The profile layout to load
  53294. * @param gamepadObject The gamepad object correlating to this controller
  53295. * @param handedness handedness (left/right/none) of this controller
  53296. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53297. */
  53298. constructor(scene: Scene, layout: IMotionControllerLayout,
  53299. /**
  53300. * The gamepad object correlating to this controller
  53301. */
  53302. gamepadObject: IMinimalMotionControllerObject,
  53303. /**
  53304. * handedness (left/right/none) of this controller
  53305. */
  53306. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53307. /**
  53308. * Dispose this controller, the model mesh and all its components
  53309. */
  53310. dispose(): void;
  53311. /**
  53312. * Returns all components of specific type
  53313. * @param type the type to search for
  53314. * @return an array of components with this type
  53315. */
  53316. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53317. /**
  53318. * get a component based an its component id as defined in layout.components
  53319. * @param id the id of the component
  53320. * @returns the component correlates to the id or undefined if not found
  53321. */
  53322. getComponent(id: string): WebXRControllerComponent;
  53323. /**
  53324. * Get the list of components available in this motion controller
  53325. * @returns an array of strings correlating to available components
  53326. */
  53327. getComponentIds(): string[];
  53328. /**
  53329. * Get the first component of specific type
  53330. * @param type type of component to find
  53331. * @return a controller component or null if not found
  53332. */
  53333. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53334. /**
  53335. * Get the main (Select) component of this controller as defined in the layout
  53336. * @returns the main component of this controller
  53337. */
  53338. getMainComponent(): WebXRControllerComponent;
  53339. /**
  53340. * Loads the model correlating to this controller
  53341. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53342. * @returns A promise fulfilled with the result of the model loading
  53343. */
  53344. loadModel(): Promise<boolean>;
  53345. /**
  53346. * Update this model using the current XRFrame
  53347. * @param xrFrame the current xr frame to use and update the model
  53348. */
  53349. updateFromXRFrame(xrFrame: XRFrame): void;
  53350. /**
  53351. * Backwards compatibility due to a deeply-integrated typo
  53352. */
  53353. get handness(): XREye;
  53354. /**
  53355. * Pulse (vibrate) this controller
  53356. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53357. * Consecutive calls to this function will cancel the last pulse call
  53358. *
  53359. * @param value the strength of the pulse in 0.0...1.0 range
  53360. * @param duration Duration of the pulse in milliseconds
  53361. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53362. * @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
  53363. */
  53364. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53365. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53366. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53367. /**
  53368. * Moves the axis on the controller mesh based on its current state
  53369. * @param axis the index of the axis
  53370. * @param axisValue the value of the axis which determines the meshes new position
  53371. * @hidden
  53372. */
  53373. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53374. /**
  53375. * Update the model itself with the current frame data
  53376. * @param xrFrame the frame to use for updating the model mesh
  53377. */
  53378. protected updateModel(xrFrame: XRFrame): void;
  53379. /**
  53380. * Get the filename and path for this controller's model
  53381. * @returns a map of filename and path
  53382. */
  53383. protected abstract _getFilenameAndPath(): {
  53384. filename: string;
  53385. path: string;
  53386. };
  53387. /**
  53388. * This function is called before the mesh is loaded. It checks for loading constraints.
  53389. * For example, this function can check if the GLB loader is available
  53390. * If this function returns false, the generic controller will be loaded instead
  53391. * @returns Is the client ready to load the mesh
  53392. */
  53393. protected abstract _getModelLoadingConstraints(): boolean;
  53394. /**
  53395. * This function will be called after the model was successfully loaded and can be used
  53396. * for mesh transformations before it is available for the user
  53397. * @param meshes the loaded meshes
  53398. */
  53399. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53400. /**
  53401. * Set the root mesh for this controller. Important for the WebXR controller class
  53402. * @param meshes the loaded meshes
  53403. */
  53404. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53405. /**
  53406. * A function executed each frame that updates the mesh (if needed)
  53407. * @param xrFrame the current xrFrame
  53408. */
  53409. protected abstract _updateModel(xrFrame: XRFrame): void;
  53410. private _getGenericFilenameAndPath;
  53411. private _getGenericParentMesh;
  53412. }
  53413. }
  53414. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53415. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53417. import { Scene } from "babylonjs/scene";
  53418. /**
  53419. * A generic trigger-only motion controller for WebXR
  53420. */
  53421. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53422. /**
  53423. * Static version of the profile id of this controller
  53424. */
  53425. static ProfileId: string;
  53426. profileId: string;
  53427. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53428. protected _getFilenameAndPath(): {
  53429. filename: string;
  53430. path: string;
  53431. };
  53432. protected _getModelLoadingConstraints(): boolean;
  53433. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53434. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53435. protected _updateModel(): void;
  53436. }
  53437. }
  53438. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53439. import { Vector4 } from "babylonjs/Maths/math.vector";
  53440. import { Mesh } from "babylonjs/Meshes/mesh";
  53441. import { Scene } from "babylonjs/scene";
  53442. import { Nullable } from "babylonjs/types";
  53443. /**
  53444. * Class containing static functions to help procedurally build meshes
  53445. */
  53446. export class SphereBuilder {
  53447. /**
  53448. * Creates a sphere mesh
  53449. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53450. * * 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`)
  53451. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53452. * * 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
  53453. * * 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)
  53454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53457. * @param name defines the name of the mesh
  53458. * @param options defines the options used to create the mesh
  53459. * @param scene defines the hosting scene
  53460. * @returns the sphere mesh
  53461. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53462. */
  53463. static CreateSphere(name: string, options: {
  53464. segments?: number;
  53465. diameter?: number;
  53466. diameterX?: number;
  53467. diameterY?: number;
  53468. diameterZ?: number;
  53469. arc?: number;
  53470. slice?: number;
  53471. sideOrientation?: number;
  53472. frontUVs?: Vector4;
  53473. backUVs?: Vector4;
  53474. updatable?: boolean;
  53475. }, scene?: Nullable<Scene>): Mesh;
  53476. }
  53477. }
  53478. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53480. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53481. import { Scene } from "babylonjs/scene";
  53482. /**
  53483. * A profiled motion controller has its profile loaded from an online repository.
  53484. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53485. */
  53486. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53487. private _repositoryUrl;
  53488. private _buttonMeshMapping;
  53489. private _touchDots;
  53490. /**
  53491. * The profile ID of this controller. Will be populated when the controller initializes.
  53492. */
  53493. profileId: string;
  53494. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53495. dispose(): void;
  53496. protected _getFilenameAndPath(): {
  53497. filename: string;
  53498. path: string;
  53499. };
  53500. protected _getModelLoadingConstraints(): boolean;
  53501. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53502. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53503. protected _updateModel(_xrFrame: XRFrame): void;
  53504. }
  53505. }
  53506. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53507. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53508. import { Scene } from "babylonjs/scene";
  53509. /**
  53510. * A construction function type to create a new controller based on an xrInput object
  53511. */
  53512. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53513. /**
  53514. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53515. *
  53516. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53517. * it should be replaced with auto-loaded controllers.
  53518. *
  53519. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53520. */
  53521. export class WebXRMotionControllerManager {
  53522. private static _AvailableControllers;
  53523. private static _Fallbacks;
  53524. private static _ProfileLoadingPromises;
  53525. private static _ProfilesList;
  53526. /**
  53527. * The base URL of the online controller repository. Can be changed at any time.
  53528. */
  53529. static BaseRepositoryUrl: string;
  53530. /**
  53531. * Which repository gets priority - local or online
  53532. */
  53533. static PrioritizeOnlineRepository: boolean;
  53534. /**
  53535. * Use the online repository, or use only locally-defined controllers
  53536. */
  53537. static UseOnlineRepository: boolean;
  53538. /**
  53539. * Clear the cache used for profile loading and reload when requested again
  53540. */
  53541. static ClearProfilesCache(): void;
  53542. /**
  53543. * Register the default fallbacks.
  53544. * This function is called automatically when this file is imported.
  53545. */
  53546. static DefaultFallbacks(): void;
  53547. /**
  53548. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53549. * @param profileId the profile to which a fallback needs to be found
  53550. * @return an array with corresponding fallback profiles
  53551. */
  53552. static FindFallbackWithProfileId(profileId: string): string[];
  53553. /**
  53554. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53555. * The order of search:
  53556. *
  53557. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53558. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53559. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53560. * 4) return the generic trigger controller if none were found
  53561. *
  53562. * @param xrInput the xrInput to which a new controller is initialized
  53563. * @param scene the scene to which the model will be added
  53564. * @param forceProfile force a certain profile for this controller
  53565. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53566. */
  53567. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53568. /**
  53569. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53570. *
  53571. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53572. *
  53573. * @param type the profile type to register
  53574. * @param constructFunction the function to be called when loading this profile
  53575. */
  53576. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53577. /**
  53578. * Register a fallback to a specific profile.
  53579. * @param profileId the profileId that will receive the fallbacks
  53580. * @param fallbacks A list of fallback profiles
  53581. */
  53582. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53583. /**
  53584. * Will update the list of profiles available in the repository
  53585. * @return a promise that resolves to a map of profiles available online
  53586. */
  53587. static UpdateProfilesList(): Promise<{
  53588. [profile: string]: string;
  53589. }>;
  53590. private static _LoadProfileFromRepository;
  53591. private static _LoadProfilesFromAvailableControllers;
  53592. }
  53593. }
  53594. declare module "babylonjs/XR/webXRInputSource" {
  53595. import { Observable } from "babylonjs/Misc/observable";
  53596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53597. import { Ray } from "babylonjs/Culling/ray";
  53598. import { Scene } from "babylonjs/scene";
  53599. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53600. /**
  53601. * Configuration options for the WebXR controller creation
  53602. */
  53603. export interface IWebXRControllerOptions {
  53604. /**
  53605. * Should the controller mesh be animated when a user interacts with it
  53606. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53607. */
  53608. disableMotionControllerAnimation?: boolean;
  53609. /**
  53610. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53611. */
  53612. doNotLoadControllerMesh?: boolean;
  53613. /**
  53614. * Force a specific controller type for this controller.
  53615. * This can be used when creating your own profile or when testing different controllers
  53616. */
  53617. forceControllerProfile?: string;
  53618. /**
  53619. * Defines a rendering group ID for meshes that will be loaded.
  53620. * This is for the default controllers only.
  53621. */
  53622. renderingGroupId?: number;
  53623. }
  53624. /**
  53625. * Represents an XR controller
  53626. */
  53627. export class WebXRInputSource {
  53628. private _scene;
  53629. /** The underlying input source for the controller */
  53630. inputSource: XRInputSource;
  53631. private _options;
  53632. private _tmpVector;
  53633. private _uniqueId;
  53634. private _disposed;
  53635. /**
  53636. * 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
  53637. */
  53638. grip?: AbstractMesh;
  53639. /**
  53640. * If available, this is the gamepad object related to this controller.
  53641. * Using this object it is possible to get click events and trackpad changes of the
  53642. * webxr controller that is currently being used.
  53643. */
  53644. motionController?: WebXRAbstractMotionController;
  53645. /**
  53646. * Event that fires when the controller is removed/disposed.
  53647. * The object provided as event data is this controller, after associated assets were disposed.
  53648. * uniqueId is still available.
  53649. */
  53650. onDisposeObservable: Observable<WebXRInputSource>;
  53651. /**
  53652. * Will be triggered when the mesh associated with the motion controller is done loading.
  53653. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53654. * A shortened version of controller -> motion controller -> on mesh loaded.
  53655. */
  53656. onMeshLoadedObservable: Observable<AbstractMesh>;
  53657. /**
  53658. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53659. */
  53660. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53661. /**
  53662. * Pointer which can be used to select objects or attach a visible laser to
  53663. */
  53664. pointer: AbstractMesh;
  53665. /**
  53666. * Creates the input source object
  53667. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53668. * @param _scene the scene which the controller should be associated to
  53669. * @param inputSource the underlying input source for the controller
  53670. * @param _options options for this controller creation
  53671. */
  53672. constructor(_scene: Scene,
  53673. /** The underlying input source for the controller */
  53674. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53675. /**
  53676. * Get this controllers unique id
  53677. */
  53678. get uniqueId(): string;
  53679. /**
  53680. * Disposes of the object
  53681. */
  53682. dispose(): void;
  53683. /**
  53684. * Gets a world space ray coming from the pointer or grip
  53685. * @param result the resulting ray
  53686. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53687. */
  53688. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53689. /**
  53690. * Updates the controller pose based on the given XRFrame
  53691. * @param xrFrame xr frame to update the pose with
  53692. * @param referenceSpace reference space to use
  53693. */
  53694. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53695. }
  53696. }
  53697. declare module "babylonjs/XR/webXRInput" {
  53698. import { Observable } from "babylonjs/Misc/observable";
  53699. import { IDisposable } from "babylonjs/scene";
  53700. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53701. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53702. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53703. /**
  53704. * The schema for initialization options of the XR Input class
  53705. */
  53706. export interface IWebXRInputOptions {
  53707. /**
  53708. * If set to true no model will be automatically loaded
  53709. */
  53710. doNotLoadControllerMeshes?: boolean;
  53711. /**
  53712. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53713. * If not found, the xr input profile data will be used.
  53714. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53715. */
  53716. forceInputProfile?: string;
  53717. /**
  53718. * Do not send a request to the controller repository to load the profile.
  53719. *
  53720. * Instead, use the controllers available in babylon itself.
  53721. */
  53722. disableOnlineControllerRepository?: boolean;
  53723. /**
  53724. * A custom URL for the controllers repository
  53725. */
  53726. customControllersRepositoryURL?: string;
  53727. /**
  53728. * Should the controller model's components not move according to the user input
  53729. */
  53730. disableControllerAnimation?: boolean;
  53731. /**
  53732. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53733. */
  53734. controllerOptions?: IWebXRControllerOptions;
  53735. }
  53736. /**
  53737. * XR input used to track XR inputs such as controllers/rays
  53738. */
  53739. export class WebXRInput implements IDisposable {
  53740. /**
  53741. * the xr session manager for this session
  53742. */
  53743. xrSessionManager: WebXRSessionManager;
  53744. /**
  53745. * the WebXR camera for this session. Mainly used for teleportation
  53746. */
  53747. xrCamera: WebXRCamera;
  53748. private readonly options;
  53749. /**
  53750. * XR controllers being tracked
  53751. */
  53752. controllers: Array<WebXRInputSource>;
  53753. private _frameObserver;
  53754. private _sessionEndedObserver;
  53755. private _sessionInitObserver;
  53756. /**
  53757. * Event when a controller has been connected/added
  53758. */
  53759. onControllerAddedObservable: Observable<WebXRInputSource>;
  53760. /**
  53761. * Event when a controller has been removed/disconnected
  53762. */
  53763. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53764. /**
  53765. * Initializes the WebXRInput
  53766. * @param xrSessionManager the xr session manager for this session
  53767. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53768. * @param options = initialization options for this xr input
  53769. */
  53770. constructor(
  53771. /**
  53772. * the xr session manager for this session
  53773. */
  53774. xrSessionManager: WebXRSessionManager,
  53775. /**
  53776. * the WebXR camera for this session. Mainly used for teleportation
  53777. */
  53778. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53779. private _onInputSourcesChange;
  53780. private _addAndRemoveControllers;
  53781. /**
  53782. * Disposes of the object
  53783. */
  53784. dispose(): void;
  53785. }
  53786. }
  53787. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53788. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53789. import { Observable, EventState } from "babylonjs/Misc/observable";
  53790. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53791. /**
  53792. * This is the base class for all WebXR features.
  53793. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53794. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53795. */
  53796. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53797. protected _xrSessionManager: WebXRSessionManager;
  53798. private _attached;
  53799. private _removeOnDetach;
  53800. /**
  53801. * Is this feature disposed?
  53802. */
  53803. isDisposed: boolean;
  53804. /**
  53805. * Should auto-attach be disabled?
  53806. */
  53807. disableAutoAttach: boolean;
  53808. /**
  53809. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53810. */
  53811. xrNativeFeatureName: string;
  53812. /**
  53813. * Construct a new (abstract) WebXR feature
  53814. * @param _xrSessionManager the xr session manager for this feature
  53815. */
  53816. constructor(_xrSessionManager: WebXRSessionManager);
  53817. /**
  53818. * Is this feature attached
  53819. */
  53820. get attached(): boolean;
  53821. /**
  53822. * attach this feature
  53823. *
  53824. * @param force should attachment be forced (even when already attached)
  53825. * @returns true if successful, false is failed or already attached
  53826. */
  53827. attach(force?: boolean): boolean;
  53828. /**
  53829. * detach this feature.
  53830. *
  53831. * @returns true if successful, false if failed or already detached
  53832. */
  53833. detach(): boolean;
  53834. /**
  53835. * Dispose this feature and all of the resources attached
  53836. */
  53837. dispose(): void;
  53838. /**
  53839. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53840. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53841. *
  53842. * @returns whether or not the feature is compatible in this environment
  53843. */
  53844. isCompatible(): boolean;
  53845. /**
  53846. * This is used to register callbacks that will automatically be removed when detach is called.
  53847. * @param observable the observable to which the observer will be attached
  53848. * @param callback the callback to register
  53849. */
  53850. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53851. /**
  53852. * Code in this function will be executed on each xrFrame received from the browser.
  53853. * This function will not execute after the feature is detached.
  53854. * @param _xrFrame the current frame
  53855. */
  53856. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53857. }
  53858. }
  53859. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53860. import { IDisposable, Scene } from "babylonjs/scene";
  53861. import { Nullable } from "babylonjs/types";
  53862. import { Observable } from "babylonjs/Misc/observable";
  53863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53864. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53865. import { Camera } from "babylonjs/Cameras/camera";
  53866. /**
  53867. * Renders a layer on top of an existing scene
  53868. */
  53869. export class UtilityLayerRenderer implements IDisposable {
  53870. /** the original scene that will be rendered on top of */
  53871. originalScene: Scene;
  53872. private _pointerCaptures;
  53873. private _lastPointerEvents;
  53874. private static _DefaultUtilityLayer;
  53875. private static _DefaultKeepDepthUtilityLayer;
  53876. private _sharedGizmoLight;
  53877. private _renderCamera;
  53878. /**
  53879. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53880. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53881. * @returns the camera that is used when rendering the utility layer
  53882. */
  53883. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53884. /**
  53885. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53886. * @param cam the camera that should be used when rendering the utility layer
  53887. */
  53888. setRenderCamera(cam: Nullable<Camera>): void;
  53889. /**
  53890. * @hidden
  53891. * Light which used by gizmos to get light shading
  53892. */
  53893. _getSharedGizmoLight(): HemisphericLight;
  53894. /**
  53895. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53896. */
  53897. pickUtilitySceneFirst: boolean;
  53898. /**
  53899. * 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)
  53900. */
  53901. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53902. /**
  53903. * 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)
  53904. */
  53905. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53906. /**
  53907. * The scene that is rendered on top of the original scene
  53908. */
  53909. utilityLayerScene: Scene;
  53910. /**
  53911. * If the utility layer should automatically be rendered on top of existing scene
  53912. */
  53913. shouldRender: boolean;
  53914. /**
  53915. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53916. */
  53917. onlyCheckPointerDownEvents: boolean;
  53918. /**
  53919. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53920. */
  53921. processAllEvents: boolean;
  53922. /**
  53923. * Observable raised when the pointer move from the utility layer scene to the main scene
  53924. */
  53925. onPointerOutObservable: Observable<number>;
  53926. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53927. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53928. private _afterRenderObserver;
  53929. private _sceneDisposeObserver;
  53930. private _originalPointerObserver;
  53931. /**
  53932. * Instantiates a UtilityLayerRenderer
  53933. * @param originalScene the original scene that will be rendered on top of
  53934. * @param handleEvents boolean indicating if the utility layer should handle events
  53935. */
  53936. constructor(
  53937. /** the original scene that will be rendered on top of */
  53938. originalScene: Scene, handleEvents?: boolean);
  53939. private _notifyObservers;
  53940. /**
  53941. * Renders the utility layers scene on top of the original scene
  53942. */
  53943. render(): void;
  53944. /**
  53945. * Disposes of the renderer
  53946. */
  53947. dispose(): void;
  53948. private _updateCamera;
  53949. }
  53950. }
  53951. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53952. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53954. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53955. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53956. import { Scene } from "babylonjs/scene";
  53957. import { Nullable } from "babylonjs/types";
  53958. import { Color3 } from "babylonjs/Maths/math.color";
  53959. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53960. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53961. /**
  53962. * Options interface for the pointer selection module
  53963. */
  53964. export interface IWebXRControllerPointerSelectionOptions {
  53965. /**
  53966. * if provided, this scene will be used to render meshes.
  53967. */
  53968. customUtilityLayerScene?: Scene;
  53969. /**
  53970. * 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)
  53971. * If not disabled, the last picked point will be used to execute a pointer up event
  53972. * If disabled, pointer up event will be triggered right after the pointer down event.
  53973. * Used in screen and gaze target ray mode only
  53974. */
  53975. disablePointerUpOnTouchOut: boolean;
  53976. /**
  53977. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53978. */
  53979. forceGazeMode: boolean;
  53980. /**
  53981. * 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
  53982. * to start a new countdown to the pointer down event.
  53983. * Defaults to 1.
  53984. */
  53985. gazeModePointerMovedFactor?: number;
  53986. /**
  53987. * Different button type to use instead of the main component
  53988. */
  53989. overrideButtonId?: string;
  53990. /**
  53991. * use this rendering group id for the meshes (optional)
  53992. */
  53993. renderingGroupId?: number;
  53994. /**
  53995. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  53996. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  53997. * 3000 means 3 seconds between pointing at something and selecting it
  53998. */
  53999. timeToSelect?: number;
  54000. /**
  54001. * Should meshes created here be added to a utility layer or the main scene
  54002. */
  54003. useUtilityLayer?: boolean;
  54004. /**
  54005. * Optional WebXR camera to be used for gaze selection
  54006. */
  54007. gazeCamera?: WebXRCamera;
  54008. /**
  54009. * the xr input to use with this pointer selection
  54010. */
  54011. xrInput: WebXRInput;
  54012. /**
  54013. * Should the scene pointerX and pointerY update be disabled
  54014. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54015. * Disable in VR, if not needed.
  54016. * The first rig camera (left eye) will be used to calculate the projection
  54017. */
  54018. disableScenePointerVectorUpdate: boolean;
  54019. }
  54020. /**
  54021. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54022. */
  54023. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54024. private readonly _options;
  54025. private static _idCounter;
  54026. private _attachController;
  54027. private _controllers;
  54028. private _scene;
  54029. private _tmpVectorForPickCompare;
  54030. /**
  54031. * The module's name
  54032. */
  54033. static readonly Name: string;
  54034. /**
  54035. * The (Babylon) version of this module.
  54036. * This is an integer representing the implementation version.
  54037. * This number does not correspond to the WebXR specs version
  54038. */
  54039. static readonly Version: number;
  54040. /**
  54041. * Disable lighting on the laser pointer (so it will always be visible)
  54042. */
  54043. disablePointerLighting: boolean;
  54044. /**
  54045. * Disable lighting on the selection mesh (so it will always be visible)
  54046. */
  54047. disableSelectionMeshLighting: boolean;
  54048. /**
  54049. * Should the laser pointer be displayed
  54050. */
  54051. displayLaserPointer: boolean;
  54052. /**
  54053. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54054. */
  54055. displaySelectionMesh: boolean;
  54056. /**
  54057. * This color will be set to the laser pointer when selection is triggered
  54058. */
  54059. laserPointerPickedColor: Color3;
  54060. /**
  54061. * Default color of the laser pointer
  54062. */
  54063. laserPointerDefaultColor: Color3;
  54064. /**
  54065. * default color of the selection ring
  54066. */
  54067. selectionMeshDefaultColor: Color3;
  54068. /**
  54069. * This color will be applied to the selection ring when selection is triggered
  54070. */
  54071. selectionMeshPickedColor: Color3;
  54072. /**
  54073. * Optional filter to be used for ray selection. This predicate shares behavior with
  54074. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54075. */
  54076. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54077. /**
  54078. * constructs a new background remover module
  54079. * @param _xrSessionManager the session manager for this module
  54080. * @param _options read-only options to be used in this module
  54081. */
  54082. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54083. /**
  54084. * attach this feature
  54085. * Will usually be called by the features manager
  54086. *
  54087. * @returns true if successful.
  54088. */
  54089. attach(): boolean;
  54090. /**
  54091. * detach this feature.
  54092. * Will usually be called by the features manager
  54093. *
  54094. * @returns true if successful.
  54095. */
  54096. detach(): boolean;
  54097. /**
  54098. * Will get the mesh under a specific pointer.
  54099. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54100. * @param controllerId the controllerId to check
  54101. * @returns The mesh under pointer or null if no mesh is under the pointer
  54102. */
  54103. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54104. /**
  54105. * Get the xr controller that correlates to the pointer id in the pointer event
  54106. *
  54107. * @param id the pointer id to search for
  54108. * @returns the controller that correlates to this id or null if not found
  54109. */
  54110. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54111. private _identityMatrix;
  54112. private _screenCoordinatesRef;
  54113. private _viewportRef;
  54114. protected _onXRFrame(_xrFrame: XRFrame): void;
  54115. private _attachGazeMode;
  54116. private _attachScreenRayMode;
  54117. private _attachTrackedPointerRayMode;
  54118. private _convertNormalToDirectionOfRay;
  54119. private _detachController;
  54120. private _generateNewMeshPair;
  54121. private _pickingMoved;
  54122. private _updatePointerDistance;
  54123. /** @hidden */
  54124. get lasterPointerDefaultColor(): Color3;
  54125. }
  54126. }
  54127. declare module "babylonjs/XR/webXREnterExitUI" {
  54128. import { Nullable } from "babylonjs/types";
  54129. import { Observable } from "babylonjs/Misc/observable";
  54130. import { IDisposable, Scene } from "babylonjs/scene";
  54131. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54132. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54133. /**
  54134. * Button which can be used to enter a different mode of XR
  54135. */
  54136. export class WebXREnterExitUIButton {
  54137. /** button element */
  54138. element: HTMLElement;
  54139. /** XR initialization options for the button */
  54140. sessionMode: XRSessionMode;
  54141. /** Reference space type */
  54142. referenceSpaceType: XRReferenceSpaceType;
  54143. /**
  54144. * Creates a WebXREnterExitUIButton
  54145. * @param element button element
  54146. * @param sessionMode XR initialization session mode
  54147. * @param referenceSpaceType the type of reference space to be used
  54148. */
  54149. constructor(
  54150. /** button element */
  54151. element: HTMLElement,
  54152. /** XR initialization options for the button */
  54153. sessionMode: XRSessionMode,
  54154. /** Reference space type */
  54155. referenceSpaceType: XRReferenceSpaceType);
  54156. /**
  54157. * Extendable function which can be used to update the button's visuals when the state changes
  54158. * @param activeButton the current active button in the UI
  54159. */
  54160. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54161. }
  54162. /**
  54163. * Options to create the webXR UI
  54164. */
  54165. export class WebXREnterExitUIOptions {
  54166. /**
  54167. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54168. */
  54169. customButtons?: Array<WebXREnterExitUIButton>;
  54170. /**
  54171. * A reference space type to use when creating the default button.
  54172. * Default is local-floor
  54173. */
  54174. referenceSpaceType?: XRReferenceSpaceType;
  54175. /**
  54176. * Context to enter xr with
  54177. */
  54178. renderTarget?: Nullable<WebXRRenderTarget>;
  54179. /**
  54180. * A session mode to use when creating the default button.
  54181. * Default is immersive-vr
  54182. */
  54183. sessionMode?: XRSessionMode;
  54184. /**
  54185. * A list of optional features to init the session with
  54186. */
  54187. optionalFeatures?: string[];
  54188. /**
  54189. * A list of optional features to init the session with
  54190. */
  54191. requiredFeatures?: string[];
  54192. }
  54193. /**
  54194. * UI to allow the user to enter/exit XR mode
  54195. */
  54196. export class WebXREnterExitUI implements IDisposable {
  54197. private scene;
  54198. /** version of the options passed to this UI */
  54199. options: WebXREnterExitUIOptions;
  54200. private _activeButton;
  54201. private _buttons;
  54202. /**
  54203. * The HTML Div Element to which buttons are added.
  54204. */
  54205. readonly overlay: HTMLDivElement;
  54206. /**
  54207. * Fired every time the active button is changed.
  54208. *
  54209. * When xr is entered via a button that launches xr that button will be the callback parameter
  54210. *
  54211. * When exiting xr the callback parameter will be null)
  54212. */
  54213. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54214. /**
  54215. *
  54216. * @param scene babylon scene object to use
  54217. * @param options (read-only) version of the options passed to this UI
  54218. */
  54219. private constructor();
  54220. /**
  54221. * Creates UI to allow the user to enter/exit XR mode
  54222. * @param scene the scene to add the ui to
  54223. * @param helper the xr experience helper to enter/exit xr with
  54224. * @param options options to configure the UI
  54225. * @returns the created ui
  54226. */
  54227. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54228. /**
  54229. * Disposes of the XR UI component
  54230. */
  54231. dispose(): void;
  54232. private _updateButtons;
  54233. }
  54234. }
  54235. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54236. import { Vector3 } from "babylonjs/Maths/math.vector";
  54237. import { Color4 } from "babylonjs/Maths/math.color";
  54238. import { Nullable } from "babylonjs/types";
  54239. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54240. import { Scene } from "babylonjs/scene";
  54241. /**
  54242. * Class containing static functions to help procedurally build meshes
  54243. */
  54244. export class LinesBuilder {
  54245. /**
  54246. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54247. * * 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
  54248. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54249. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54250. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54251. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54252. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54253. * * 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
  54254. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54257. * @param name defines the name of the new line system
  54258. * @param options defines the options used to create the line system
  54259. * @param scene defines the hosting scene
  54260. * @returns a new line system mesh
  54261. */
  54262. static CreateLineSystem(name: string, options: {
  54263. lines: Vector3[][];
  54264. updatable?: boolean;
  54265. instance?: Nullable<LinesMesh>;
  54266. colors?: Nullable<Color4[][]>;
  54267. useVertexAlpha?: boolean;
  54268. }, scene: Nullable<Scene>): LinesMesh;
  54269. /**
  54270. * Creates a line mesh
  54271. * 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
  54272. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54273. * * The parameter `points` is an array successive Vector3
  54274. * * 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
  54275. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54276. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54277. * * When updating an instance, remember that only point positions can change, not the number of points
  54278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54280. * @param name defines the name of the new line system
  54281. * @param options defines the options used to create the line system
  54282. * @param scene defines the hosting scene
  54283. * @returns a new line mesh
  54284. */
  54285. static CreateLines(name: string, options: {
  54286. points: Vector3[];
  54287. updatable?: boolean;
  54288. instance?: Nullable<LinesMesh>;
  54289. colors?: Color4[];
  54290. useVertexAlpha?: boolean;
  54291. }, scene?: Nullable<Scene>): LinesMesh;
  54292. /**
  54293. * Creates a dashed line mesh
  54294. * * 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
  54295. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54296. * * The parameter `points` is an array successive Vector3
  54297. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54298. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54299. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54300. * * 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
  54301. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54302. * * When updating an instance, remember that only point positions can change, not the number of points
  54303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54304. * @param name defines the name of the mesh
  54305. * @param options defines the options used to create the mesh
  54306. * @param scene defines the hosting scene
  54307. * @returns the dashed line mesh
  54308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54309. */
  54310. static CreateDashedLines(name: string, options: {
  54311. points: Vector3[];
  54312. dashSize?: number;
  54313. gapSize?: number;
  54314. dashNb?: number;
  54315. updatable?: boolean;
  54316. instance?: LinesMesh;
  54317. useVertexAlpha?: boolean;
  54318. }, scene?: Nullable<Scene>): LinesMesh;
  54319. }
  54320. }
  54321. declare module "babylonjs/Misc/timer" {
  54322. import { Observable, Observer } from "babylonjs/Misc/observable";
  54323. import { Nullable } from "babylonjs/types";
  54324. import { IDisposable } from "babylonjs/scene";
  54325. /**
  54326. * Construction options for a timer
  54327. */
  54328. export interface ITimerOptions<T> {
  54329. /**
  54330. * Time-to-end
  54331. */
  54332. timeout: number;
  54333. /**
  54334. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54335. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54336. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54337. */
  54338. contextObservable: Observable<T>;
  54339. /**
  54340. * Optional parameters when adding an observer to the observable
  54341. */
  54342. observableParameters?: {
  54343. mask?: number;
  54344. insertFirst?: boolean;
  54345. scope?: any;
  54346. };
  54347. /**
  54348. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54349. */
  54350. breakCondition?: (data?: ITimerData<T>) => boolean;
  54351. /**
  54352. * Will be triggered when the time condition has met
  54353. */
  54354. onEnded?: (data: ITimerData<any>) => void;
  54355. /**
  54356. * Will be triggered when the break condition has met (prematurely ended)
  54357. */
  54358. onAborted?: (data: ITimerData<any>) => void;
  54359. /**
  54360. * Optional function to execute on each tick (or count)
  54361. */
  54362. onTick?: (data: ITimerData<any>) => void;
  54363. }
  54364. /**
  54365. * An interface defining the data sent by the timer
  54366. */
  54367. export interface ITimerData<T> {
  54368. /**
  54369. * When did it start
  54370. */
  54371. startTime: number;
  54372. /**
  54373. * Time now
  54374. */
  54375. currentTime: number;
  54376. /**
  54377. * Time passed since started
  54378. */
  54379. deltaTime: number;
  54380. /**
  54381. * How much is completed, in [0.0...1.0].
  54382. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54383. */
  54384. completeRate: number;
  54385. /**
  54386. * What the registered observable sent in the last count
  54387. */
  54388. payload: T;
  54389. }
  54390. /**
  54391. * The current state of the timer
  54392. */
  54393. export enum TimerState {
  54394. /**
  54395. * Timer initialized, not yet started
  54396. */
  54397. INIT = 0,
  54398. /**
  54399. * Timer started and counting
  54400. */
  54401. STARTED = 1,
  54402. /**
  54403. * Timer ended (whether aborted or time reached)
  54404. */
  54405. ENDED = 2
  54406. }
  54407. /**
  54408. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54409. *
  54410. * @param options options with which to initialize this timer
  54411. */
  54412. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54413. /**
  54414. * An advanced implementation of a timer class
  54415. */
  54416. export class AdvancedTimer<T = any> implements IDisposable {
  54417. /**
  54418. * Will notify each time the timer calculates the remaining time
  54419. */
  54420. onEachCountObservable: Observable<ITimerData<T>>;
  54421. /**
  54422. * Will trigger when the timer was aborted due to the break condition
  54423. */
  54424. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54425. /**
  54426. * Will trigger when the timer ended successfully
  54427. */
  54428. onTimerEndedObservable: Observable<ITimerData<T>>;
  54429. /**
  54430. * Will trigger when the timer state has changed
  54431. */
  54432. onStateChangedObservable: Observable<TimerState>;
  54433. private _observer;
  54434. private _contextObservable;
  54435. private _observableParameters;
  54436. private _startTime;
  54437. private _timer;
  54438. private _state;
  54439. private _breakCondition;
  54440. private _timeToEnd;
  54441. private _breakOnNextTick;
  54442. /**
  54443. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54444. * @param options construction options for this advanced timer
  54445. */
  54446. constructor(options: ITimerOptions<T>);
  54447. /**
  54448. * set a breaking condition for this timer. Default is to never break during count
  54449. * @param predicate the new break condition. Returns true to break, false otherwise
  54450. */
  54451. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54452. /**
  54453. * Reset ALL associated observables in this advanced timer
  54454. */
  54455. clearObservables(): void;
  54456. /**
  54457. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54458. *
  54459. * @param timeToEnd how much time to measure until timer ended
  54460. */
  54461. start(timeToEnd?: number): void;
  54462. /**
  54463. * Will force a stop on the next tick.
  54464. */
  54465. stop(): void;
  54466. /**
  54467. * Dispose this timer, clearing all resources
  54468. */
  54469. dispose(): void;
  54470. private _setState;
  54471. private _tick;
  54472. private _stop;
  54473. }
  54474. }
  54475. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54476. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54477. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54478. import { Nullable } from "babylonjs/types";
  54479. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54481. import { Vector3 } from "babylonjs/Maths/math.vector";
  54482. import { Material } from "babylonjs/Materials/material";
  54483. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54484. import { Scene } from "babylonjs/scene";
  54485. /**
  54486. * The options container for the teleportation module
  54487. */
  54488. export interface IWebXRTeleportationOptions {
  54489. /**
  54490. * if provided, this scene will be used to render meshes.
  54491. */
  54492. customUtilityLayerScene?: Scene;
  54493. /**
  54494. * Values to configure the default target mesh
  54495. */
  54496. defaultTargetMeshOptions?: {
  54497. /**
  54498. * Fill color of the teleportation area
  54499. */
  54500. teleportationFillColor?: string;
  54501. /**
  54502. * Border color for the teleportation area
  54503. */
  54504. teleportationBorderColor?: string;
  54505. /**
  54506. * Disable the mesh's animation sequence
  54507. */
  54508. disableAnimation?: boolean;
  54509. /**
  54510. * Disable lighting on the material or the ring and arrow
  54511. */
  54512. disableLighting?: boolean;
  54513. /**
  54514. * Override the default material of the torus and arrow
  54515. */
  54516. torusArrowMaterial?: Material;
  54517. };
  54518. /**
  54519. * A list of meshes to use as floor meshes.
  54520. * Meshes can be added and removed after initializing the feature using the
  54521. * addFloorMesh and removeFloorMesh functions
  54522. * If empty, rotation will still work
  54523. */
  54524. floorMeshes?: AbstractMesh[];
  54525. /**
  54526. * use this rendering group id for the meshes (optional)
  54527. */
  54528. renderingGroupId?: number;
  54529. /**
  54530. * Should teleportation move only to snap points
  54531. */
  54532. snapPointsOnly?: boolean;
  54533. /**
  54534. * An array of points to which the teleportation will snap to.
  54535. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54536. */
  54537. snapPositions?: Vector3[];
  54538. /**
  54539. * How close should the teleportation ray be in order to snap to position.
  54540. * Default to 0.8 units (meters)
  54541. */
  54542. snapToPositionRadius?: number;
  54543. /**
  54544. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54545. * If you want to support rotation, make sure your mesh has a direction indicator.
  54546. *
  54547. * When left untouched, the default mesh will be initialized.
  54548. */
  54549. teleportationTargetMesh?: AbstractMesh;
  54550. /**
  54551. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54552. */
  54553. timeToTeleport?: number;
  54554. /**
  54555. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54556. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54557. */
  54558. useMainComponentOnly?: boolean;
  54559. /**
  54560. * Should meshes created here be added to a utility layer or the main scene
  54561. */
  54562. useUtilityLayer?: boolean;
  54563. /**
  54564. * Babylon XR Input class for controller
  54565. */
  54566. xrInput: WebXRInput;
  54567. /**
  54568. * Meshes that the teleportation ray cannot go through
  54569. */
  54570. pickBlockerMeshes?: AbstractMesh[];
  54571. }
  54572. /**
  54573. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54574. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54575. * the input of the attached controllers.
  54576. */
  54577. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54578. private _options;
  54579. private _controllers;
  54580. private _currentTeleportationControllerId;
  54581. private _floorMeshes;
  54582. private _quadraticBezierCurve;
  54583. private _selectionFeature;
  54584. private _snapToPositions;
  54585. private _snappedToPoint;
  54586. private _teleportationRingMaterial?;
  54587. private _tmpRay;
  54588. private _tmpVector;
  54589. private _tmpQuaternion;
  54590. /**
  54591. * The module's name
  54592. */
  54593. static readonly Name: string;
  54594. /**
  54595. * The (Babylon) version of this module.
  54596. * This is an integer representing the implementation version.
  54597. * This number does not correspond to the webxr specs version
  54598. */
  54599. static readonly Version: number;
  54600. /**
  54601. * Is movement backwards enabled
  54602. */
  54603. backwardsMovementEnabled: boolean;
  54604. /**
  54605. * Distance to travel when moving backwards
  54606. */
  54607. backwardsTeleportationDistance: number;
  54608. /**
  54609. * The distance from the user to the inspection point in the direction of the controller
  54610. * A higher number will allow the user to move further
  54611. * defaults to 5 (meters, in xr units)
  54612. */
  54613. parabolicCheckRadius: number;
  54614. /**
  54615. * Should the module support parabolic ray on top of direct ray
  54616. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54617. * Very helpful when moving between floors / different heights
  54618. */
  54619. parabolicRayEnabled: boolean;
  54620. /**
  54621. * How much rotation should be applied when rotating right and left
  54622. */
  54623. rotationAngle: number;
  54624. /**
  54625. * Is rotation enabled when moving forward?
  54626. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54627. */
  54628. rotationEnabled: boolean;
  54629. /**
  54630. * constructs a new anchor system
  54631. * @param _xrSessionManager an instance of WebXRSessionManager
  54632. * @param _options configuration object for this feature
  54633. */
  54634. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54635. /**
  54636. * Get the snapPointsOnly flag
  54637. */
  54638. get snapPointsOnly(): boolean;
  54639. /**
  54640. * Sets the snapPointsOnly flag
  54641. * @param snapToPoints should teleportation be exclusively to snap points
  54642. */
  54643. set snapPointsOnly(snapToPoints: boolean);
  54644. /**
  54645. * Add a new mesh to the floor meshes array
  54646. * @param mesh the mesh to use as floor mesh
  54647. */
  54648. addFloorMesh(mesh: AbstractMesh): void;
  54649. /**
  54650. * Add a new snap-to point to fix teleportation to this position
  54651. * @param newSnapPoint The new Snap-To point
  54652. */
  54653. addSnapPoint(newSnapPoint: Vector3): void;
  54654. attach(): boolean;
  54655. detach(): boolean;
  54656. dispose(): void;
  54657. /**
  54658. * Remove a mesh from the floor meshes array
  54659. * @param mesh the mesh to remove
  54660. */
  54661. removeFloorMesh(mesh: AbstractMesh): void;
  54662. /**
  54663. * Remove a mesh from the floor meshes array using its name
  54664. * @param name the mesh name to remove
  54665. */
  54666. removeFloorMeshByName(name: string): void;
  54667. /**
  54668. * 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
  54669. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54670. * @returns was the point found and removed or not
  54671. */
  54672. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54673. /**
  54674. * This function sets a selection feature that will be disabled when
  54675. * the forward ray is shown and will be reattached when hidden.
  54676. * This is used to remove the selection rays when moving.
  54677. * @param selectionFeature the feature to disable when forward movement is enabled
  54678. */
  54679. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54680. protected _onXRFrame(_xrFrame: XRFrame): void;
  54681. private _attachController;
  54682. private _createDefaultTargetMesh;
  54683. private _detachController;
  54684. private _findClosestSnapPointWithRadius;
  54685. private _setTargetMeshPosition;
  54686. private _setTargetMeshVisibility;
  54687. private _showParabolicPath;
  54688. private _teleportForward;
  54689. }
  54690. }
  54691. declare module "babylonjs/XR/webXRDefaultExperience" {
  54692. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54693. import { Scene } from "babylonjs/scene";
  54694. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54695. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54696. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54697. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54699. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54700. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54701. /**
  54702. * Options for the default xr helper
  54703. */
  54704. export class WebXRDefaultExperienceOptions {
  54705. /**
  54706. * Enable or disable default UI to enter XR
  54707. */
  54708. disableDefaultUI?: boolean;
  54709. /**
  54710. * Should teleportation not initialize. defaults to false.
  54711. */
  54712. disableTeleportation?: boolean;
  54713. /**
  54714. * Floor meshes that will be used for teleport
  54715. */
  54716. floorMeshes?: Array<AbstractMesh>;
  54717. /**
  54718. * If set to true, the first frame will not be used to reset position
  54719. * The first frame is mainly used when copying transformation from the old camera
  54720. * Mainly used in AR
  54721. */
  54722. ignoreNativeCameraTransformation?: boolean;
  54723. /**
  54724. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54725. */
  54726. inputOptions?: IWebXRInputOptions;
  54727. /**
  54728. * optional configuration for the output canvas
  54729. */
  54730. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54731. /**
  54732. * optional UI options. This can be used among other to change session mode and reference space type
  54733. */
  54734. uiOptions?: WebXREnterExitUIOptions;
  54735. /**
  54736. * When loading teleportation and pointer select, use stable versions instead of latest.
  54737. */
  54738. useStablePlugins?: boolean;
  54739. /**
  54740. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54741. */
  54742. renderingGroupId?: number;
  54743. /**
  54744. * A list of optional features to init the session with
  54745. * If set to true, all features we support will be added
  54746. */
  54747. optionalFeatures?: boolean | string[];
  54748. }
  54749. /**
  54750. * Default experience which provides a similar setup to the previous webVRExperience
  54751. */
  54752. export class WebXRDefaultExperience {
  54753. /**
  54754. * Base experience
  54755. */
  54756. baseExperience: WebXRExperienceHelper;
  54757. /**
  54758. * Enables ui for entering/exiting xr
  54759. */
  54760. enterExitUI: WebXREnterExitUI;
  54761. /**
  54762. * Input experience extension
  54763. */
  54764. input: WebXRInput;
  54765. /**
  54766. * Enables laser pointer and selection
  54767. */
  54768. pointerSelection: WebXRControllerPointerSelection;
  54769. /**
  54770. * Default target xr should render to
  54771. */
  54772. renderTarget: WebXRRenderTarget;
  54773. /**
  54774. * Enables teleportation
  54775. */
  54776. teleportation: WebXRMotionControllerTeleportation;
  54777. private constructor();
  54778. /**
  54779. * Creates the default xr experience
  54780. * @param scene scene
  54781. * @param options options for basic configuration
  54782. * @returns resulting WebXRDefaultExperience
  54783. */
  54784. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54785. /**
  54786. * DIsposes of the experience helper
  54787. */
  54788. dispose(): void;
  54789. }
  54790. }
  54791. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54792. import { Observable } from "babylonjs/Misc/observable";
  54793. import { Nullable } from "babylonjs/types";
  54794. import { Camera } from "babylonjs/Cameras/camera";
  54795. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54796. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54797. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54798. import { Scene } from "babylonjs/scene";
  54799. import { Vector3 } from "babylonjs/Maths/math.vector";
  54800. import { Color3 } from "babylonjs/Maths/math.color";
  54801. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54803. import { Mesh } from "babylonjs/Meshes/mesh";
  54804. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54805. import { EasingFunction } from "babylonjs/Animations/easing";
  54806. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54807. import "babylonjs/Meshes/Builders/groundBuilder";
  54808. import "babylonjs/Meshes/Builders/torusBuilder";
  54809. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54810. import "babylonjs/Gamepads/gamepadSceneComponent";
  54811. import "babylonjs/Animations/animatable";
  54812. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54813. /**
  54814. * Options to modify the vr teleportation behavior.
  54815. */
  54816. export interface VRTeleportationOptions {
  54817. /**
  54818. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54819. */
  54820. floorMeshName?: string;
  54821. /**
  54822. * A list of meshes to be used as the teleportation floor. (default: empty)
  54823. */
  54824. floorMeshes?: Mesh[];
  54825. /**
  54826. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54827. */
  54828. teleportationMode?: number;
  54829. /**
  54830. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54831. */
  54832. teleportationTime?: number;
  54833. /**
  54834. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54835. */
  54836. teleportationSpeed?: number;
  54837. /**
  54838. * The easing function used in the animation or null for Linear. (default CircleEase)
  54839. */
  54840. easingFunction?: EasingFunction;
  54841. }
  54842. /**
  54843. * Options to modify the vr experience helper's behavior.
  54844. */
  54845. export interface VRExperienceHelperOptions extends WebVROptions {
  54846. /**
  54847. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54848. */
  54849. createDeviceOrientationCamera?: boolean;
  54850. /**
  54851. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54852. */
  54853. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54854. /**
  54855. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54856. */
  54857. laserToggle?: boolean;
  54858. /**
  54859. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54860. */
  54861. floorMeshes?: Mesh[];
  54862. /**
  54863. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54864. */
  54865. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54866. /**
  54867. * Defines if WebXR should be used instead of WebVR (if available)
  54868. */
  54869. useXR?: boolean;
  54870. }
  54871. /**
  54872. * Event containing information after VR has been entered
  54873. */
  54874. export class OnAfterEnteringVRObservableEvent {
  54875. /**
  54876. * If entering vr was successful
  54877. */
  54878. success: boolean;
  54879. }
  54880. /**
  54881. * Helps to quickly add VR support to an existing scene.
  54882. * See https://doc.babylonjs.com/how_to/webvr_helper
  54883. */
  54884. export class VRExperienceHelper {
  54885. /** Options to modify the vr experience helper's behavior. */
  54886. webVROptions: VRExperienceHelperOptions;
  54887. private _scene;
  54888. private _position;
  54889. private _btnVR;
  54890. private _btnVRDisplayed;
  54891. private _webVRsupported;
  54892. private _webVRready;
  54893. private _webVRrequesting;
  54894. private _webVRpresenting;
  54895. private _hasEnteredVR;
  54896. private _fullscreenVRpresenting;
  54897. private _inputElement;
  54898. private _webVRCamera;
  54899. private _vrDeviceOrientationCamera;
  54900. private _deviceOrientationCamera;
  54901. private _existingCamera;
  54902. private _onKeyDown;
  54903. private _onVrDisplayPresentChange;
  54904. private _onVRDisplayChanged;
  54905. private _onVRRequestPresentStart;
  54906. private _onVRRequestPresentComplete;
  54907. /**
  54908. * 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)
  54909. */
  54910. enableGazeEvenWhenNoPointerLock: boolean;
  54911. /**
  54912. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54913. */
  54914. exitVROnDoubleTap: boolean;
  54915. /**
  54916. * Observable raised right before entering VR.
  54917. */
  54918. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54919. /**
  54920. * Observable raised when entering VR has completed.
  54921. */
  54922. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54923. /**
  54924. * Observable raised when exiting VR.
  54925. */
  54926. onExitingVRObservable: Observable<VRExperienceHelper>;
  54927. /**
  54928. * Observable raised when controller mesh is loaded.
  54929. */
  54930. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54931. /** Return this.onEnteringVRObservable
  54932. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54933. */
  54934. get onEnteringVR(): Observable<VRExperienceHelper>;
  54935. /** Return this.onExitingVRObservable
  54936. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54937. */
  54938. get onExitingVR(): Observable<VRExperienceHelper>;
  54939. /** Return this.onControllerMeshLoadedObservable
  54940. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54941. */
  54942. get onControllerMeshLoaded(): Observable<WebVRController>;
  54943. private _rayLength;
  54944. private _useCustomVRButton;
  54945. private _teleportationRequested;
  54946. private _teleportActive;
  54947. private _floorMeshName;
  54948. private _floorMeshesCollection;
  54949. private _teleportationMode;
  54950. private _teleportationTime;
  54951. private _teleportationSpeed;
  54952. private _teleportationEasing;
  54953. private _rotationAllowed;
  54954. private _teleportBackwardsVector;
  54955. private _teleportationTarget;
  54956. private _isDefaultTeleportationTarget;
  54957. private _postProcessMove;
  54958. private _teleportationFillColor;
  54959. private _teleportationBorderColor;
  54960. private _rotationAngle;
  54961. private _haloCenter;
  54962. private _cameraGazer;
  54963. private _padSensibilityUp;
  54964. private _padSensibilityDown;
  54965. private _leftController;
  54966. private _rightController;
  54967. private _gazeColor;
  54968. private _laserColor;
  54969. private _pickedLaserColor;
  54970. private _pickedGazeColor;
  54971. /**
  54972. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54973. */
  54974. onNewMeshSelected: Observable<AbstractMesh>;
  54975. /**
  54976. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54977. * This observable will provide the mesh and the controller used to select the mesh
  54978. */
  54979. onMeshSelectedWithController: Observable<{
  54980. mesh: AbstractMesh;
  54981. controller: WebVRController;
  54982. }>;
  54983. /**
  54984. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54985. */
  54986. onNewMeshPicked: Observable<PickingInfo>;
  54987. private _circleEase;
  54988. /**
  54989. * Observable raised before camera teleportation
  54990. */
  54991. onBeforeCameraTeleport: Observable<Vector3>;
  54992. /**
  54993. * Observable raised after camera teleportation
  54994. */
  54995. onAfterCameraTeleport: Observable<Vector3>;
  54996. /**
  54997. * Observable raised when current selected mesh gets unselected
  54998. */
  54999. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55000. private _raySelectionPredicate;
  55001. /**
  55002. * To be optionaly changed by user to define custom ray selection
  55003. */
  55004. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55005. /**
  55006. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55007. */
  55008. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55009. /**
  55010. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55011. */
  55012. teleportationEnabled: boolean;
  55013. private _defaultHeight;
  55014. private _teleportationInitialized;
  55015. private _interactionsEnabled;
  55016. private _interactionsRequested;
  55017. private _displayGaze;
  55018. private _displayLaserPointer;
  55019. /**
  55020. * The mesh used to display where the user is going to teleport.
  55021. */
  55022. get teleportationTarget(): Mesh;
  55023. /**
  55024. * Sets the mesh to be used to display where the user is going to teleport.
  55025. */
  55026. set teleportationTarget(value: Mesh);
  55027. /**
  55028. * 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
  55029. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55030. * See https://doc.babylonjs.com/resources/baking_transformations
  55031. */
  55032. get gazeTrackerMesh(): Mesh;
  55033. set gazeTrackerMesh(value: Mesh);
  55034. /**
  55035. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55036. */
  55037. updateGazeTrackerScale: boolean;
  55038. /**
  55039. * If the gaze trackers color should be updated when selecting meshes
  55040. */
  55041. updateGazeTrackerColor: boolean;
  55042. /**
  55043. * If the controller laser color should be updated when selecting meshes
  55044. */
  55045. updateControllerLaserColor: boolean;
  55046. /**
  55047. * The gaze tracking mesh corresponding to the left controller
  55048. */
  55049. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55050. /**
  55051. * The gaze tracking mesh corresponding to the right controller
  55052. */
  55053. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55054. /**
  55055. * If the ray of the gaze should be displayed.
  55056. */
  55057. get displayGaze(): boolean;
  55058. /**
  55059. * Sets if the ray of the gaze should be displayed.
  55060. */
  55061. set displayGaze(value: boolean);
  55062. /**
  55063. * If the ray of the LaserPointer should be displayed.
  55064. */
  55065. get displayLaserPointer(): boolean;
  55066. /**
  55067. * Sets if the ray of the LaserPointer should be displayed.
  55068. */
  55069. set displayLaserPointer(value: boolean);
  55070. /**
  55071. * The deviceOrientationCamera used as the camera when not in VR.
  55072. */
  55073. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55074. /**
  55075. * Based on the current WebVR support, returns the current VR camera used.
  55076. */
  55077. get currentVRCamera(): Nullable<Camera>;
  55078. /**
  55079. * The webVRCamera which is used when in VR.
  55080. */
  55081. get webVRCamera(): WebVRFreeCamera;
  55082. /**
  55083. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55084. */
  55085. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55086. /**
  55087. * The html button that is used to trigger entering into VR.
  55088. */
  55089. get vrButton(): Nullable<HTMLButtonElement>;
  55090. private get _teleportationRequestInitiated();
  55091. /**
  55092. * Defines whether or not Pointer lock should be requested when switching to
  55093. * full screen.
  55094. */
  55095. requestPointerLockOnFullScreen: boolean;
  55096. /**
  55097. * If asking to force XR, this will be populated with the default xr experience
  55098. */
  55099. xr: WebXRDefaultExperience;
  55100. /**
  55101. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55102. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55103. */
  55104. xrTestDone: boolean;
  55105. /**
  55106. * Instantiates a VRExperienceHelper.
  55107. * Helps to quickly add VR support to an existing scene.
  55108. * @param scene The scene the VRExperienceHelper belongs to.
  55109. * @param webVROptions Options to modify the vr experience helper's behavior.
  55110. */
  55111. constructor(scene: Scene,
  55112. /** Options to modify the vr experience helper's behavior. */
  55113. webVROptions?: VRExperienceHelperOptions);
  55114. private completeVRInit;
  55115. private _onDefaultMeshLoaded;
  55116. private _onResize;
  55117. private _onFullscreenChange;
  55118. /**
  55119. * Gets a value indicating if we are currently in VR mode.
  55120. */
  55121. get isInVRMode(): boolean;
  55122. private onVrDisplayPresentChange;
  55123. private onVRDisplayChanged;
  55124. private moveButtonToBottomRight;
  55125. private displayVRButton;
  55126. private updateButtonVisibility;
  55127. private _cachedAngularSensibility;
  55128. /**
  55129. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55130. * Otherwise, will use the fullscreen API.
  55131. */
  55132. enterVR(): void;
  55133. /**
  55134. * Attempt to exit VR, or fullscreen.
  55135. */
  55136. exitVR(): void;
  55137. /**
  55138. * The position of the vr experience helper.
  55139. */
  55140. get position(): Vector3;
  55141. /**
  55142. * Sets the position of the vr experience helper.
  55143. */
  55144. set position(value: Vector3);
  55145. /**
  55146. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55147. */
  55148. enableInteractions(): void;
  55149. private get _noControllerIsActive();
  55150. private beforeRender;
  55151. private _isTeleportationFloor;
  55152. /**
  55153. * Adds a floor mesh to be used for teleportation.
  55154. * @param floorMesh the mesh to be used for teleportation.
  55155. */
  55156. addFloorMesh(floorMesh: Mesh): void;
  55157. /**
  55158. * Removes a floor mesh from being used for teleportation.
  55159. * @param floorMesh the mesh to be removed.
  55160. */
  55161. removeFloorMesh(floorMesh: Mesh): void;
  55162. /**
  55163. * Enables interactions and teleportation using the VR controllers and gaze.
  55164. * @param vrTeleportationOptions options to modify teleportation behavior.
  55165. */
  55166. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55167. private _onNewGamepadConnected;
  55168. private _tryEnableInteractionOnController;
  55169. private _onNewGamepadDisconnected;
  55170. private _enableInteractionOnController;
  55171. private _checkTeleportWithRay;
  55172. private _checkRotate;
  55173. private _checkTeleportBackwards;
  55174. private _enableTeleportationOnController;
  55175. private _createTeleportationCircles;
  55176. private _displayTeleportationTarget;
  55177. private _hideTeleportationTarget;
  55178. private _rotateCamera;
  55179. private _moveTeleportationSelectorTo;
  55180. private _workingVector;
  55181. private _workingQuaternion;
  55182. private _workingMatrix;
  55183. /**
  55184. * Time Constant Teleportation Mode
  55185. */
  55186. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55187. /**
  55188. * Speed Constant Teleportation Mode
  55189. */
  55190. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55191. /**
  55192. * Teleports the users feet to the desired location
  55193. * @param location The location where the user's feet should be placed
  55194. */
  55195. teleportCamera(location: Vector3): void;
  55196. private _convertNormalToDirectionOfRay;
  55197. private _castRayAndSelectObject;
  55198. private _notifySelectedMeshUnselected;
  55199. /**
  55200. * Permanently set new colors for the laser pointer
  55201. * @param color the new laser color
  55202. * @param pickedColor the new laser color when picked mesh detected
  55203. */
  55204. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55205. /**
  55206. * Set lighting enabled / disabled on the laser pointer of both controllers
  55207. * @param enabled should the lighting be enabled on the laser pointer
  55208. */
  55209. setLaserLightingState(enabled?: boolean): void;
  55210. /**
  55211. * Permanently set new colors for the gaze pointer
  55212. * @param color the new gaze color
  55213. * @param pickedColor the new gaze color when picked mesh detected
  55214. */
  55215. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55216. /**
  55217. * Sets the color of the laser ray from the vr controllers.
  55218. * @param color new color for the ray.
  55219. */
  55220. changeLaserColor(color: Color3): void;
  55221. /**
  55222. * Sets the color of the ray from the vr headsets gaze.
  55223. * @param color new color for the ray.
  55224. */
  55225. changeGazeColor(color: Color3): void;
  55226. /**
  55227. * Exits VR and disposes of the vr experience helper
  55228. */
  55229. dispose(): void;
  55230. /**
  55231. * Gets the name of the VRExperienceHelper class
  55232. * @returns "VRExperienceHelper"
  55233. */
  55234. getClassName(): string;
  55235. }
  55236. }
  55237. declare module "babylonjs/Cameras/VR/index" {
  55238. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55239. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55240. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55241. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55242. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55243. export * from "babylonjs/Cameras/VR/webVRCamera";
  55244. }
  55245. declare module "babylonjs/Cameras/RigModes/index" {
  55246. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55247. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55248. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55249. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55250. }
  55251. declare module "babylonjs/Cameras/index" {
  55252. export * from "babylonjs/Cameras/Inputs/index";
  55253. export * from "babylonjs/Cameras/cameraInputsManager";
  55254. export * from "babylonjs/Cameras/camera";
  55255. export * from "babylonjs/Cameras/targetCamera";
  55256. export * from "babylonjs/Cameras/freeCamera";
  55257. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55258. export * from "babylonjs/Cameras/touchCamera";
  55259. export * from "babylonjs/Cameras/arcRotateCamera";
  55260. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55261. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55262. export * from "babylonjs/Cameras/flyCamera";
  55263. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55264. export * from "babylonjs/Cameras/followCamera";
  55265. export * from "babylonjs/Cameras/followCameraInputsManager";
  55266. export * from "babylonjs/Cameras/gamepadCamera";
  55267. export * from "babylonjs/Cameras/Stereoscopic/index";
  55268. export * from "babylonjs/Cameras/universalCamera";
  55269. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55270. export * from "babylonjs/Cameras/VR/index";
  55271. export * from "babylonjs/Cameras/RigModes/index";
  55272. }
  55273. declare module "babylonjs/Collisions/index" {
  55274. export * from "babylonjs/Collisions/collider";
  55275. export * from "babylonjs/Collisions/collisionCoordinator";
  55276. export * from "babylonjs/Collisions/pickingInfo";
  55277. export * from "babylonjs/Collisions/intersectionInfo";
  55278. export * from "babylonjs/Collisions/meshCollisionData";
  55279. }
  55280. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55281. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55282. import { Vector3 } from "babylonjs/Maths/math.vector";
  55283. import { Ray } from "babylonjs/Culling/ray";
  55284. import { Plane } from "babylonjs/Maths/math.plane";
  55285. /**
  55286. * Contains an array of blocks representing the octree
  55287. */
  55288. export interface IOctreeContainer<T> {
  55289. /**
  55290. * Blocks within the octree
  55291. */
  55292. blocks: Array<OctreeBlock<T>>;
  55293. }
  55294. /**
  55295. * Class used to store a cell in an octree
  55296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55297. */
  55298. export class OctreeBlock<T> {
  55299. /**
  55300. * Gets the content of the current block
  55301. */
  55302. entries: T[];
  55303. /**
  55304. * Gets the list of block children
  55305. */
  55306. blocks: Array<OctreeBlock<T>>;
  55307. private _depth;
  55308. private _maxDepth;
  55309. private _capacity;
  55310. private _minPoint;
  55311. private _maxPoint;
  55312. private _boundingVectors;
  55313. private _creationFunc;
  55314. /**
  55315. * Creates a new block
  55316. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55317. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55318. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55319. * @param depth defines the current depth of this block in the octree
  55320. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55321. * @param creationFunc defines a callback to call when an element is added to the block
  55322. */
  55323. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55324. /**
  55325. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55326. */
  55327. get capacity(): number;
  55328. /**
  55329. * Gets the minimum vector (in world space) of the block's bounding box
  55330. */
  55331. get minPoint(): Vector3;
  55332. /**
  55333. * Gets the maximum vector (in world space) of the block's bounding box
  55334. */
  55335. get maxPoint(): Vector3;
  55336. /**
  55337. * Add a new element to this block
  55338. * @param entry defines the element to add
  55339. */
  55340. addEntry(entry: T): void;
  55341. /**
  55342. * Remove an element from this block
  55343. * @param entry defines the element to remove
  55344. */
  55345. removeEntry(entry: T): void;
  55346. /**
  55347. * Add an array of elements to this block
  55348. * @param entries defines the array of elements to add
  55349. */
  55350. addEntries(entries: T[]): void;
  55351. /**
  55352. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55353. * @param frustumPlanes defines the frustum planes to test
  55354. * @param selection defines the array to store current content if selection is positive
  55355. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55356. */
  55357. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55358. /**
  55359. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55360. * @param sphereCenter defines the bounding sphere center
  55361. * @param sphereRadius defines the bounding sphere radius
  55362. * @param selection defines the array to store current content if selection is positive
  55363. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55364. */
  55365. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55366. /**
  55367. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55368. * @param ray defines the ray to test with
  55369. * @param selection defines the array to store current content if selection is positive
  55370. */
  55371. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55372. /**
  55373. * Subdivide the content into child blocks (this block will then be empty)
  55374. */
  55375. createInnerBlocks(): void;
  55376. /**
  55377. * @hidden
  55378. */
  55379. 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;
  55380. }
  55381. }
  55382. declare module "babylonjs/Culling/Octrees/octree" {
  55383. import { SmartArray } from "babylonjs/Misc/smartArray";
  55384. import { Vector3 } from "babylonjs/Maths/math.vector";
  55385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55387. import { Ray } from "babylonjs/Culling/ray";
  55388. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55389. import { Plane } from "babylonjs/Maths/math.plane";
  55390. /**
  55391. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55392. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55393. */
  55394. export class Octree<T> {
  55395. /** 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.) */
  55396. maxDepth: number;
  55397. /**
  55398. * Blocks within the octree containing objects
  55399. */
  55400. blocks: Array<OctreeBlock<T>>;
  55401. /**
  55402. * Content stored in the octree
  55403. */
  55404. dynamicContent: T[];
  55405. private _maxBlockCapacity;
  55406. private _selectionContent;
  55407. private _creationFunc;
  55408. /**
  55409. * Creates a octree
  55410. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55411. * @param creationFunc function to be used to instatiate the octree
  55412. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55413. * @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.)
  55414. */
  55415. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55416. /** 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.) */
  55417. maxDepth?: number);
  55418. /**
  55419. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55420. * @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);
  55421. * @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);
  55422. * @param entries meshes to be added to the octree blocks
  55423. */
  55424. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55425. /**
  55426. * Adds a mesh to the octree
  55427. * @param entry Mesh to add to the octree
  55428. */
  55429. addMesh(entry: T): void;
  55430. /**
  55431. * Remove an element from the octree
  55432. * @param entry defines the element to remove
  55433. */
  55434. removeMesh(entry: T): void;
  55435. /**
  55436. * Selects an array of meshes within the frustum
  55437. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55438. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55439. * @returns array of meshes within the frustum
  55440. */
  55441. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55442. /**
  55443. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55444. * @param sphereCenter defines the bounding sphere center
  55445. * @param sphereRadius defines the bounding sphere radius
  55446. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55447. * @returns an array of objects that intersect the sphere
  55448. */
  55449. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55450. /**
  55451. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55452. * @param ray defines the ray to test with
  55453. * @returns array of intersected objects
  55454. */
  55455. intersectsRay(ray: Ray): SmartArray<T>;
  55456. /**
  55457. * Adds a mesh into the octree block if it intersects the block
  55458. */
  55459. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55460. /**
  55461. * Adds a submesh into the octree block if it intersects the block
  55462. */
  55463. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55464. }
  55465. }
  55466. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55467. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55468. import { Scene } from "babylonjs/scene";
  55469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55471. import { Ray } from "babylonjs/Culling/ray";
  55472. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55473. import { Collider } from "babylonjs/Collisions/collider";
  55474. module "babylonjs/scene" {
  55475. interface Scene {
  55476. /**
  55477. * @hidden
  55478. * Backing Filed
  55479. */
  55480. _selectionOctree: Octree<AbstractMesh>;
  55481. /**
  55482. * Gets the octree used to boost mesh selection (picking)
  55483. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55484. */
  55485. selectionOctree: Octree<AbstractMesh>;
  55486. /**
  55487. * Creates or updates the octree used to boost selection (picking)
  55488. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55489. * @param maxCapacity defines the maximum capacity per leaf
  55490. * @param maxDepth defines the maximum depth of the octree
  55491. * @returns an octree of AbstractMesh
  55492. */
  55493. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55494. }
  55495. }
  55496. module "babylonjs/Meshes/abstractMesh" {
  55497. interface AbstractMesh {
  55498. /**
  55499. * @hidden
  55500. * Backing Field
  55501. */
  55502. _submeshesOctree: Octree<SubMesh>;
  55503. /**
  55504. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55505. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55506. * @param maxCapacity defines the maximum size of each block (64 by default)
  55507. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55508. * @returns the new octree
  55509. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55510. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55511. */
  55512. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55513. }
  55514. }
  55515. /**
  55516. * Defines the octree scene component responsible to manage any octrees
  55517. * in a given scene.
  55518. */
  55519. export class OctreeSceneComponent {
  55520. /**
  55521. * The component name help to identify the component in the list of scene components.
  55522. */
  55523. readonly name: string;
  55524. /**
  55525. * The scene the component belongs to.
  55526. */
  55527. scene: Scene;
  55528. /**
  55529. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55530. */
  55531. readonly checksIsEnabled: boolean;
  55532. /**
  55533. * Creates a new instance of the component for the given scene
  55534. * @param scene Defines the scene to register the component in
  55535. */
  55536. constructor(scene: Scene);
  55537. /**
  55538. * Registers the component in a given scene
  55539. */
  55540. register(): void;
  55541. /**
  55542. * Return the list of active meshes
  55543. * @returns the list of active meshes
  55544. */
  55545. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55546. /**
  55547. * Return the list of active sub meshes
  55548. * @param mesh The mesh to get the candidates sub meshes from
  55549. * @returns the list of active sub meshes
  55550. */
  55551. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55552. private _tempRay;
  55553. /**
  55554. * Return the list of sub meshes intersecting with a given local ray
  55555. * @param mesh defines the mesh to find the submesh for
  55556. * @param localRay defines the ray in local space
  55557. * @returns the list of intersecting sub meshes
  55558. */
  55559. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55560. /**
  55561. * Return the list of sub meshes colliding with a collider
  55562. * @param mesh defines the mesh to find the submesh for
  55563. * @param collider defines the collider to evaluate the collision against
  55564. * @returns the list of colliding sub meshes
  55565. */
  55566. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55567. /**
  55568. * Rebuilds the elements related to this component in case of
  55569. * context lost for instance.
  55570. */
  55571. rebuild(): void;
  55572. /**
  55573. * Disposes the component and the associated ressources.
  55574. */
  55575. dispose(): void;
  55576. }
  55577. }
  55578. declare module "babylonjs/Culling/Octrees/index" {
  55579. export * from "babylonjs/Culling/Octrees/octree";
  55580. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55581. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55582. }
  55583. declare module "babylonjs/Culling/index" {
  55584. export * from "babylonjs/Culling/boundingBox";
  55585. export * from "babylonjs/Culling/boundingInfo";
  55586. export * from "babylonjs/Culling/boundingSphere";
  55587. export * from "babylonjs/Culling/Octrees/index";
  55588. export * from "babylonjs/Culling/ray";
  55589. }
  55590. declare module "babylonjs/Gizmos/gizmo" {
  55591. import { Nullable } from "babylonjs/types";
  55592. import { IDisposable } from "babylonjs/scene";
  55593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55594. import { Mesh } from "babylonjs/Meshes/mesh";
  55595. import { Node } from "babylonjs/node";
  55596. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55597. /**
  55598. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55599. */
  55600. export class Gizmo implements IDisposable {
  55601. /** The utility layer the gizmo will be added to */
  55602. gizmoLayer: UtilityLayerRenderer;
  55603. /**
  55604. * The root mesh of the gizmo
  55605. */
  55606. _rootMesh: Mesh;
  55607. private _attachedMesh;
  55608. private _attachedNode;
  55609. /**
  55610. * Ratio for the scale of the gizmo (Default: 1)
  55611. */
  55612. protected _scaleRatio: number;
  55613. /**
  55614. * boolean updated by pointermove when a gizmo mesh is hovered
  55615. */
  55616. protected _isHovered: boolean;
  55617. /**
  55618. * Ratio for the scale of the gizmo (Default: 1)
  55619. */
  55620. set scaleRatio(value: number);
  55621. get scaleRatio(): number;
  55622. /**
  55623. * True when the mouse pointer is hovered a gizmo mesh
  55624. */
  55625. get isHovered(): boolean;
  55626. /**
  55627. * If a custom mesh has been set (Default: false)
  55628. */
  55629. protected _customMeshSet: boolean;
  55630. /**
  55631. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55632. * * When set, interactions will be enabled
  55633. */
  55634. get attachedMesh(): Nullable<AbstractMesh>;
  55635. set attachedMesh(value: Nullable<AbstractMesh>);
  55636. /**
  55637. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55638. * * When set, interactions will be enabled
  55639. */
  55640. get attachedNode(): Nullable<Node>;
  55641. set attachedNode(value: Nullable<Node>);
  55642. /**
  55643. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55644. * @param mesh The mesh to replace the default mesh of the gizmo
  55645. */
  55646. setCustomMesh(mesh: Mesh): void;
  55647. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55648. /**
  55649. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55650. */
  55651. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55652. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55653. /**
  55654. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55655. */
  55656. updateGizmoPositionToMatchAttachedMesh: boolean;
  55657. /**
  55658. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55659. */
  55660. updateScale: boolean;
  55661. protected _interactionsEnabled: boolean;
  55662. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55663. private _beforeRenderObserver;
  55664. private _tempQuaternion;
  55665. private _tempVector;
  55666. private _tempVector2;
  55667. private _tempMatrix1;
  55668. private _tempMatrix2;
  55669. private _rightHandtoLeftHandMatrix;
  55670. /**
  55671. * Creates a gizmo
  55672. * @param gizmoLayer The utility layer the gizmo will be added to
  55673. */
  55674. constructor(
  55675. /** The utility layer the gizmo will be added to */
  55676. gizmoLayer?: UtilityLayerRenderer);
  55677. /**
  55678. * Updates the gizmo to match the attached mesh's position/rotation
  55679. */
  55680. protected _update(): void;
  55681. /**
  55682. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55683. * @param value Node, TransformNode or mesh
  55684. */
  55685. protected _matrixChanged(): void;
  55686. /**
  55687. * Disposes of the gizmo
  55688. */
  55689. dispose(): void;
  55690. }
  55691. }
  55692. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55693. import { Observable } from "babylonjs/Misc/observable";
  55694. import { Nullable } from "babylonjs/types";
  55695. import { Vector3 } from "babylonjs/Maths/math.vector";
  55696. import { Color3 } from "babylonjs/Maths/math.color";
  55697. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55698. import { Node } from "babylonjs/node";
  55699. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55700. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55701. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55702. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55703. import { Scene } from "babylonjs/scene";
  55704. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55705. /**
  55706. * Single plane drag gizmo
  55707. */
  55708. export class PlaneDragGizmo extends Gizmo {
  55709. /**
  55710. * Drag behavior responsible for the gizmos dragging interactions
  55711. */
  55712. dragBehavior: PointerDragBehavior;
  55713. private _pointerObserver;
  55714. /**
  55715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55716. */
  55717. snapDistance: number;
  55718. /**
  55719. * Event that fires each time the gizmo snaps to a new location.
  55720. * * snapDistance is the the change in distance
  55721. */
  55722. onSnapObservable: Observable<{
  55723. snapDistance: number;
  55724. }>;
  55725. private _plane;
  55726. private _coloredMaterial;
  55727. private _hoverMaterial;
  55728. private _isEnabled;
  55729. private _parent;
  55730. /** @hidden */
  55731. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55732. /** @hidden */
  55733. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55734. /**
  55735. * Creates a PlaneDragGizmo
  55736. * @param gizmoLayer The utility layer the gizmo will be added to
  55737. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55738. * @param color The color of the gizmo
  55739. */
  55740. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55741. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55742. /**
  55743. * If the gizmo is enabled
  55744. */
  55745. set isEnabled(value: boolean);
  55746. get isEnabled(): boolean;
  55747. /**
  55748. * Disposes of the gizmo
  55749. */
  55750. dispose(): void;
  55751. }
  55752. }
  55753. declare module "babylonjs/Gizmos/positionGizmo" {
  55754. import { Observable } from "babylonjs/Misc/observable";
  55755. import { Nullable } from "babylonjs/types";
  55756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55757. import { Node } from "babylonjs/node";
  55758. import { Mesh } from "babylonjs/Meshes/mesh";
  55759. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55760. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55761. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55762. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55763. /**
  55764. * Gizmo that enables dragging a mesh along 3 axis
  55765. */
  55766. export class PositionGizmo extends Gizmo {
  55767. /**
  55768. * Internal gizmo used for interactions on the x axis
  55769. */
  55770. xGizmo: AxisDragGizmo;
  55771. /**
  55772. * Internal gizmo used for interactions on the y axis
  55773. */
  55774. yGizmo: AxisDragGizmo;
  55775. /**
  55776. * Internal gizmo used for interactions on the z axis
  55777. */
  55778. zGizmo: AxisDragGizmo;
  55779. /**
  55780. * Internal gizmo used for interactions on the yz plane
  55781. */
  55782. xPlaneGizmo: PlaneDragGizmo;
  55783. /**
  55784. * Internal gizmo used for interactions on the xz plane
  55785. */
  55786. yPlaneGizmo: PlaneDragGizmo;
  55787. /**
  55788. * Internal gizmo used for interactions on the xy plane
  55789. */
  55790. zPlaneGizmo: PlaneDragGizmo;
  55791. /**
  55792. * private variables
  55793. */
  55794. private _meshAttached;
  55795. private _nodeAttached;
  55796. private _snapDistance;
  55797. /** Fires an event when any of it's sub gizmos are dragged */
  55798. onDragStartObservable: Observable<unknown>;
  55799. /** Fires an event when any of it's sub gizmos are released from dragging */
  55800. onDragEndObservable: Observable<unknown>;
  55801. /**
  55802. * If set to true, planar drag is enabled
  55803. */
  55804. private _planarGizmoEnabled;
  55805. get attachedMesh(): Nullable<AbstractMesh>;
  55806. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55807. get attachedNode(): Nullable<Node>;
  55808. set attachedNode(node: Nullable<Node>);
  55809. /**
  55810. * True when the mouse pointer is hovering a gizmo mesh
  55811. */
  55812. get isHovered(): boolean;
  55813. /**
  55814. * Creates a PositionGizmo
  55815. * @param gizmoLayer The utility layer the gizmo will be added to
  55816. @param thickness display gizmo axis thickness
  55817. */
  55818. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55819. /**
  55820. * If the planar drag gizmo is enabled
  55821. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55822. */
  55823. set planarGizmoEnabled(value: boolean);
  55824. get planarGizmoEnabled(): boolean;
  55825. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55826. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55827. /**
  55828. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55829. */
  55830. set snapDistance(value: number);
  55831. get snapDistance(): number;
  55832. /**
  55833. * Ratio for the scale of the gizmo (Default: 1)
  55834. */
  55835. set scaleRatio(value: number);
  55836. get scaleRatio(): number;
  55837. /**
  55838. * Disposes of the gizmo
  55839. */
  55840. dispose(): void;
  55841. /**
  55842. * CustomMeshes are not supported by this gizmo
  55843. * @param mesh The mesh to replace the default mesh of the gizmo
  55844. */
  55845. setCustomMesh(mesh: Mesh): void;
  55846. }
  55847. }
  55848. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55849. import { Observable } from "babylonjs/Misc/observable";
  55850. import { Nullable } from "babylonjs/types";
  55851. import { Vector3 } from "babylonjs/Maths/math.vector";
  55852. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55853. import { Node } from "babylonjs/node";
  55854. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55855. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55856. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55857. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55858. import { Scene } from "babylonjs/scene";
  55859. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55860. import { Color3 } from "babylonjs/Maths/math.color";
  55861. /**
  55862. * Single axis drag gizmo
  55863. */
  55864. export class AxisDragGizmo extends Gizmo {
  55865. /**
  55866. * Drag behavior responsible for the gizmos dragging interactions
  55867. */
  55868. dragBehavior: PointerDragBehavior;
  55869. private _pointerObserver;
  55870. /**
  55871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55872. */
  55873. snapDistance: number;
  55874. /**
  55875. * Event that fires each time the gizmo snaps to a new location.
  55876. * * snapDistance is the the change in distance
  55877. */
  55878. onSnapObservable: Observable<{
  55879. snapDistance: number;
  55880. }>;
  55881. private _isEnabled;
  55882. private _parent;
  55883. private _arrow;
  55884. private _coloredMaterial;
  55885. private _hoverMaterial;
  55886. /** @hidden */
  55887. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55888. /** @hidden */
  55889. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55890. /**
  55891. * Creates an AxisDragGizmo
  55892. * @param gizmoLayer The utility layer the gizmo will be added to
  55893. * @param dragAxis The axis which the gizmo will be able to drag on
  55894. * @param color The color of the gizmo
  55895. * @param thickness display gizmo axis thickness
  55896. */
  55897. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55898. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55899. /**
  55900. * If the gizmo is enabled
  55901. */
  55902. set isEnabled(value: boolean);
  55903. get isEnabled(): boolean;
  55904. /**
  55905. * Disposes of the gizmo
  55906. */
  55907. dispose(): void;
  55908. }
  55909. }
  55910. declare module "babylonjs/Debug/axesViewer" {
  55911. import { Vector3 } from "babylonjs/Maths/math.vector";
  55912. import { Nullable } from "babylonjs/types";
  55913. import { Scene } from "babylonjs/scene";
  55914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55915. /**
  55916. * The Axes viewer will show 3 axes in a specific point in space
  55917. */
  55918. export class AxesViewer {
  55919. private _xAxis;
  55920. private _yAxis;
  55921. private _zAxis;
  55922. private _scaleLinesFactor;
  55923. private _instanced;
  55924. /**
  55925. * Gets the hosting scene
  55926. */
  55927. scene: Nullable<Scene>;
  55928. /**
  55929. * Gets or sets a number used to scale line length
  55930. */
  55931. scaleLines: number;
  55932. /** Gets the node hierarchy used to render x-axis */
  55933. get xAxis(): TransformNode;
  55934. /** Gets the node hierarchy used to render y-axis */
  55935. get yAxis(): TransformNode;
  55936. /** Gets the node hierarchy used to render z-axis */
  55937. get zAxis(): TransformNode;
  55938. /**
  55939. * Creates a new AxesViewer
  55940. * @param scene defines the hosting scene
  55941. * @param scaleLines defines a number used to scale line length (1 by default)
  55942. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55943. * @param xAxis defines the node hierarchy used to render the x-axis
  55944. * @param yAxis defines the node hierarchy used to render the y-axis
  55945. * @param zAxis defines the node hierarchy used to render the z-axis
  55946. */
  55947. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55948. /**
  55949. * Force the viewer to update
  55950. * @param position defines the position of the viewer
  55951. * @param xaxis defines the x axis of the viewer
  55952. * @param yaxis defines the y axis of the viewer
  55953. * @param zaxis defines the z axis of the viewer
  55954. */
  55955. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55956. /**
  55957. * Creates an instance of this axes viewer.
  55958. * @returns a new axes viewer with instanced meshes
  55959. */
  55960. createInstance(): AxesViewer;
  55961. /** Releases resources */
  55962. dispose(): void;
  55963. private static _SetRenderingGroupId;
  55964. }
  55965. }
  55966. declare module "babylonjs/Debug/boneAxesViewer" {
  55967. import { Nullable } from "babylonjs/types";
  55968. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55969. import { Vector3 } from "babylonjs/Maths/math.vector";
  55970. import { Mesh } from "babylonjs/Meshes/mesh";
  55971. import { Bone } from "babylonjs/Bones/bone";
  55972. import { Scene } from "babylonjs/scene";
  55973. /**
  55974. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55975. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55976. */
  55977. export class BoneAxesViewer extends AxesViewer {
  55978. /**
  55979. * Gets or sets the target mesh where to display the axes viewer
  55980. */
  55981. mesh: Nullable<Mesh>;
  55982. /**
  55983. * Gets or sets the target bone where to display the axes viewer
  55984. */
  55985. bone: Nullable<Bone>;
  55986. /** Gets current position */
  55987. pos: Vector3;
  55988. /** Gets direction of X axis */
  55989. xaxis: Vector3;
  55990. /** Gets direction of Y axis */
  55991. yaxis: Vector3;
  55992. /** Gets direction of Z axis */
  55993. zaxis: Vector3;
  55994. /**
  55995. * Creates a new BoneAxesViewer
  55996. * @param scene defines the hosting scene
  55997. * @param bone defines the target bone
  55998. * @param mesh defines the target mesh
  55999. * @param scaleLines defines a scaling factor for line length (1 by default)
  56000. */
  56001. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56002. /**
  56003. * Force the viewer to update
  56004. */
  56005. update(): void;
  56006. /** Releases resources */
  56007. dispose(): void;
  56008. }
  56009. }
  56010. declare module "babylonjs/Debug/debugLayer" {
  56011. import { Scene } from "babylonjs/scene";
  56012. /**
  56013. * Interface used to define scene explorer extensibility option
  56014. */
  56015. export interface IExplorerExtensibilityOption {
  56016. /**
  56017. * Define the option label
  56018. */
  56019. label: string;
  56020. /**
  56021. * Defines the action to execute on click
  56022. */
  56023. action: (entity: any) => void;
  56024. }
  56025. /**
  56026. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56027. */
  56028. export interface IExplorerExtensibilityGroup {
  56029. /**
  56030. * Defines a predicate to test if a given type mut be extended
  56031. */
  56032. predicate: (entity: any) => boolean;
  56033. /**
  56034. * Gets the list of options added to a type
  56035. */
  56036. entries: IExplorerExtensibilityOption[];
  56037. }
  56038. /**
  56039. * Interface used to define the options to use to create the Inspector
  56040. */
  56041. export interface IInspectorOptions {
  56042. /**
  56043. * Display in overlay mode (default: false)
  56044. */
  56045. overlay?: boolean;
  56046. /**
  56047. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56048. */
  56049. globalRoot?: HTMLElement;
  56050. /**
  56051. * Display the Scene explorer
  56052. */
  56053. showExplorer?: boolean;
  56054. /**
  56055. * Display the property inspector
  56056. */
  56057. showInspector?: boolean;
  56058. /**
  56059. * Display in embed mode (both panes on the right)
  56060. */
  56061. embedMode?: boolean;
  56062. /**
  56063. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56064. */
  56065. handleResize?: boolean;
  56066. /**
  56067. * Allow the panes to popup (default: true)
  56068. */
  56069. enablePopup?: boolean;
  56070. /**
  56071. * Allow the panes to be closed by users (default: true)
  56072. */
  56073. enableClose?: boolean;
  56074. /**
  56075. * Optional list of extensibility entries
  56076. */
  56077. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56078. /**
  56079. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56080. */
  56081. inspectorURL?: string;
  56082. /**
  56083. * Optional initial tab (default to DebugLayerTab.Properties)
  56084. */
  56085. initialTab?: DebugLayerTab;
  56086. }
  56087. module "babylonjs/scene" {
  56088. interface Scene {
  56089. /**
  56090. * @hidden
  56091. * Backing field
  56092. */
  56093. _debugLayer: DebugLayer;
  56094. /**
  56095. * Gets the debug layer (aka Inspector) associated with the scene
  56096. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56097. */
  56098. debugLayer: DebugLayer;
  56099. }
  56100. }
  56101. /**
  56102. * Enum of inspector action tab
  56103. */
  56104. export enum DebugLayerTab {
  56105. /**
  56106. * Properties tag (default)
  56107. */
  56108. Properties = 0,
  56109. /**
  56110. * Debug tab
  56111. */
  56112. Debug = 1,
  56113. /**
  56114. * Statistics tab
  56115. */
  56116. Statistics = 2,
  56117. /**
  56118. * Tools tab
  56119. */
  56120. Tools = 3,
  56121. /**
  56122. * Settings tab
  56123. */
  56124. Settings = 4
  56125. }
  56126. /**
  56127. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56128. * what is happening in your scene
  56129. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56130. */
  56131. export class DebugLayer {
  56132. /**
  56133. * Define the url to get the inspector script from.
  56134. * By default it uses the babylonjs CDN.
  56135. * @ignoreNaming
  56136. */
  56137. static InspectorURL: string;
  56138. private _scene;
  56139. private BJSINSPECTOR;
  56140. private _onPropertyChangedObservable?;
  56141. /**
  56142. * Observable triggered when a property is changed through the inspector.
  56143. */
  56144. get onPropertyChangedObservable(): any;
  56145. /**
  56146. * Instantiates a new debug layer.
  56147. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56148. * what is happening in your scene
  56149. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56150. * @param scene Defines the scene to inspect
  56151. */
  56152. constructor(scene: Scene);
  56153. /** Creates the inspector window. */
  56154. private _createInspector;
  56155. /**
  56156. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56157. * @param entity defines the entity to select
  56158. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56159. */
  56160. select(entity: any, lineContainerTitles?: string | string[]): void;
  56161. /** Get the inspector from bundle or global */
  56162. private _getGlobalInspector;
  56163. /**
  56164. * Get if the inspector is visible or not.
  56165. * @returns true if visible otherwise, false
  56166. */
  56167. isVisible(): boolean;
  56168. /**
  56169. * Hide the inspector and close its window.
  56170. */
  56171. hide(): void;
  56172. /**
  56173. * Update the scene in the inspector
  56174. */
  56175. setAsActiveScene(): void;
  56176. /**
  56177. * Launch the debugLayer.
  56178. * @param config Define the configuration of the inspector
  56179. * @return a promise fulfilled when the debug layer is visible
  56180. */
  56181. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56182. }
  56183. }
  56184. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56185. import { Nullable } from "babylonjs/types";
  56186. import { Scene } from "babylonjs/scene";
  56187. import { Vector4 } from "babylonjs/Maths/math.vector";
  56188. import { Color4 } from "babylonjs/Maths/math.color";
  56189. import { Mesh } from "babylonjs/Meshes/mesh";
  56190. /**
  56191. * Class containing static functions to help procedurally build meshes
  56192. */
  56193. export class BoxBuilder {
  56194. /**
  56195. * Creates a box mesh
  56196. * * The parameter `size` sets the size (float) of each box side (default 1)
  56197. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56198. * * 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)
  56199. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56203. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56204. * @param name defines the name of the mesh
  56205. * @param options defines the options used to create the mesh
  56206. * @param scene defines the hosting scene
  56207. * @returns the box mesh
  56208. */
  56209. static CreateBox(name: string, options: {
  56210. size?: number;
  56211. width?: number;
  56212. height?: number;
  56213. depth?: number;
  56214. faceUV?: Vector4[];
  56215. faceColors?: Color4[];
  56216. sideOrientation?: number;
  56217. frontUVs?: Vector4;
  56218. backUVs?: Vector4;
  56219. wrap?: boolean;
  56220. topBaseAt?: number;
  56221. bottomBaseAt?: number;
  56222. updatable?: boolean;
  56223. }, scene?: Nullable<Scene>): Mesh;
  56224. }
  56225. }
  56226. declare module "babylonjs/Debug/physicsViewer" {
  56227. import { Nullable } from "babylonjs/types";
  56228. import { Scene } from "babylonjs/scene";
  56229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56230. import { Mesh } from "babylonjs/Meshes/mesh";
  56231. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56232. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56233. /**
  56234. * Used to show the physics impostor around the specific mesh
  56235. */
  56236. export class PhysicsViewer {
  56237. /** @hidden */
  56238. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56239. /** @hidden */
  56240. protected _meshes: Array<Nullable<AbstractMesh>>;
  56241. /** @hidden */
  56242. protected _scene: Nullable<Scene>;
  56243. /** @hidden */
  56244. protected _numMeshes: number;
  56245. /** @hidden */
  56246. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56247. private _renderFunction;
  56248. private _utilityLayer;
  56249. private _debugBoxMesh;
  56250. private _debugSphereMesh;
  56251. private _debugCylinderMesh;
  56252. private _debugMaterial;
  56253. private _debugMeshMeshes;
  56254. /**
  56255. * Creates a new PhysicsViewer
  56256. * @param scene defines the hosting scene
  56257. */
  56258. constructor(scene: Scene);
  56259. /** @hidden */
  56260. protected _updateDebugMeshes(): void;
  56261. /**
  56262. * Renders a specified physic impostor
  56263. * @param impostor defines the impostor to render
  56264. * @param targetMesh defines the mesh represented by the impostor
  56265. * @returns the new debug mesh used to render the impostor
  56266. */
  56267. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56268. /**
  56269. * Hides a specified physic impostor
  56270. * @param impostor defines the impostor to hide
  56271. */
  56272. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56273. private _getDebugMaterial;
  56274. private _getDebugBoxMesh;
  56275. private _getDebugSphereMesh;
  56276. private _getDebugCylinderMesh;
  56277. private _getDebugMeshMesh;
  56278. private _getDebugMesh;
  56279. /** Releases all resources */
  56280. dispose(): void;
  56281. }
  56282. }
  56283. declare module "babylonjs/Debug/rayHelper" {
  56284. import { Nullable } from "babylonjs/types";
  56285. import { Ray } from "babylonjs/Culling/ray";
  56286. import { Vector3 } from "babylonjs/Maths/math.vector";
  56287. import { Color3 } from "babylonjs/Maths/math.color";
  56288. import { Scene } from "babylonjs/scene";
  56289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56290. import "babylonjs/Meshes/Builders/linesBuilder";
  56291. /**
  56292. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56293. * in order to better appreciate the issue one might have.
  56294. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56295. */
  56296. export class RayHelper {
  56297. /**
  56298. * Defines the ray we are currently tryin to visualize.
  56299. */
  56300. ray: Nullable<Ray>;
  56301. private _renderPoints;
  56302. private _renderLine;
  56303. private _renderFunction;
  56304. private _scene;
  56305. private _onAfterRenderObserver;
  56306. private _onAfterStepObserver;
  56307. private _attachedToMesh;
  56308. private _meshSpaceDirection;
  56309. private _meshSpaceOrigin;
  56310. /**
  56311. * Helper function to create a colored helper in a scene in one line.
  56312. * @param ray Defines the ray we are currently tryin to visualize
  56313. * @param scene Defines the scene the ray is used in
  56314. * @param color Defines the color we want to see the ray in
  56315. * @returns The newly created ray helper.
  56316. */
  56317. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56318. /**
  56319. * Instantiate a new ray helper.
  56320. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56321. * in order to better appreciate the issue one might have.
  56322. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56323. * @param ray Defines the ray we are currently tryin to visualize
  56324. */
  56325. constructor(ray: Ray);
  56326. /**
  56327. * Shows the ray we are willing to debug.
  56328. * @param scene Defines the scene the ray needs to be rendered in
  56329. * @param color Defines the color the ray needs to be rendered in
  56330. */
  56331. show(scene: Scene, color?: Color3): void;
  56332. /**
  56333. * Hides the ray we are debugging.
  56334. */
  56335. hide(): void;
  56336. private _render;
  56337. /**
  56338. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56339. * @param mesh Defines the mesh we want the helper attached to
  56340. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56341. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56342. * @param length Defines the length of the ray
  56343. */
  56344. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56345. /**
  56346. * Detach the ray helper from the mesh it has previously been attached to.
  56347. */
  56348. detachFromMesh(): void;
  56349. private _updateToMesh;
  56350. /**
  56351. * Dispose the helper and release its associated resources.
  56352. */
  56353. dispose(): void;
  56354. }
  56355. }
  56356. declare module "babylonjs/Debug/ISkeletonViewer" {
  56357. import { Skeleton } from "babylonjs/Bones/skeleton";
  56358. import { Color3 } from "babylonjs/Maths/math.color";
  56359. /**
  56360. * Defines the options associated with the creation of a SkeletonViewer.
  56361. */
  56362. export interface ISkeletonViewerOptions {
  56363. /** Should the system pause animations before building the Viewer? */
  56364. pauseAnimations: boolean;
  56365. /** Should the system return the skeleton to rest before building? */
  56366. returnToRest: boolean;
  56367. /** public Display Mode of the Viewer */
  56368. displayMode: number;
  56369. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56370. displayOptions: ISkeletonViewerDisplayOptions;
  56371. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56372. computeBonesUsingShaders: boolean;
  56373. /** Flag ignore non weighted bones */
  56374. useAllBones: boolean;
  56375. }
  56376. /**
  56377. * Defines how to display the various bone meshes for the viewer.
  56378. */
  56379. export interface ISkeletonViewerDisplayOptions {
  56380. /** How far down to start tapering the bone spurs */
  56381. midStep?: number;
  56382. /** How big is the midStep? */
  56383. midStepFactor?: number;
  56384. /** Base for the Sphere Size */
  56385. sphereBaseSize?: number;
  56386. /** The ratio of the sphere to the longest bone in units */
  56387. sphereScaleUnit?: number;
  56388. /** Ratio for the Sphere Size */
  56389. sphereFactor?: number;
  56390. /** Whether a spur should attach its far end to the child bone position */
  56391. spurFollowsChild?: boolean;
  56392. /** Whether to show local axes or not */
  56393. showLocalAxes?: boolean;
  56394. /** Length of each local axis */
  56395. localAxesSize?: number;
  56396. }
  56397. /**
  56398. * Defines the constructor options for the BoneWeight Shader.
  56399. */
  56400. export interface IBoneWeightShaderOptions {
  56401. /** Skeleton to Map */
  56402. skeleton: Skeleton;
  56403. /** Colors for Uninfluenced bones */
  56404. colorBase?: Color3;
  56405. /** Colors for 0.0-0.25 Weight bones */
  56406. colorZero?: Color3;
  56407. /** Color for 0.25-0.5 Weight Influence */
  56408. colorQuarter?: Color3;
  56409. /** Color for 0.5-0.75 Weight Influence */
  56410. colorHalf?: Color3;
  56411. /** Color for 0.75-1 Weight Influence */
  56412. colorFull?: Color3;
  56413. /** Color for Zero Weight Influence */
  56414. targetBoneIndex?: number;
  56415. }
  56416. /**
  56417. * Simple structure of the gradient steps for the Color Map.
  56418. */
  56419. export interface ISkeletonMapShaderColorMapKnot {
  56420. /** Color of the Knot */
  56421. color: Color3;
  56422. /** Location of the Knot */
  56423. location: number;
  56424. }
  56425. /**
  56426. * Defines the constructor options for the SkeletonMap Shader.
  56427. */
  56428. export interface ISkeletonMapShaderOptions {
  56429. /** Skeleton to Map */
  56430. skeleton: Skeleton;
  56431. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56432. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56433. }
  56434. }
  56435. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56436. import { Nullable } from "babylonjs/types";
  56437. import { Scene } from "babylonjs/scene";
  56438. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56439. import { Color4 } from "babylonjs/Maths/math.color";
  56440. import { Mesh } from "babylonjs/Meshes/mesh";
  56441. /**
  56442. * Class containing static functions to help procedurally build meshes
  56443. */
  56444. export class RibbonBuilder {
  56445. /**
  56446. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56447. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56448. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56449. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56450. * * 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
  56451. * * 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
  56452. * * 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
  56453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56456. * * 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
  56457. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56458. * * 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
  56459. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56461. * @param name defines the name of the mesh
  56462. * @param options defines the options used to create the mesh
  56463. * @param scene defines the hosting scene
  56464. * @returns the ribbon mesh
  56465. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56467. */
  56468. static CreateRibbon(name: string, options: {
  56469. pathArray: Vector3[][];
  56470. closeArray?: boolean;
  56471. closePath?: boolean;
  56472. offset?: number;
  56473. updatable?: boolean;
  56474. sideOrientation?: number;
  56475. frontUVs?: Vector4;
  56476. backUVs?: Vector4;
  56477. instance?: Mesh;
  56478. invertUV?: boolean;
  56479. uvs?: Vector2[];
  56480. colors?: Color4[];
  56481. }, scene?: Nullable<Scene>): Mesh;
  56482. }
  56483. }
  56484. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56485. import { Nullable } from "babylonjs/types";
  56486. import { Scene } from "babylonjs/scene";
  56487. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56488. import { Mesh } from "babylonjs/Meshes/mesh";
  56489. /**
  56490. * Class containing static functions to help procedurally build meshes
  56491. */
  56492. export class ShapeBuilder {
  56493. /**
  56494. * 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.
  56495. * * 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.
  56496. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56497. * * 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.
  56498. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56499. * * 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
  56500. * * 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
  56501. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56506. * @param name defines the name of the mesh
  56507. * @param options defines the options used to create the mesh
  56508. * @param scene defines the hosting scene
  56509. * @returns the extruded shape mesh
  56510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56512. */
  56513. static ExtrudeShape(name: string, options: {
  56514. shape: Vector3[];
  56515. path: Vector3[];
  56516. scale?: number;
  56517. rotation?: number;
  56518. cap?: number;
  56519. updatable?: boolean;
  56520. sideOrientation?: number;
  56521. frontUVs?: Vector4;
  56522. backUVs?: Vector4;
  56523. instance?: Mesh;
  56524. invertUV?: boolean;
  56525. }, scene?: Nullable<Scene>): Mesh;
  56526. /**
  56527. * Creates an custom extruded shape mesh.
  56528. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56529. * * 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.
  56530. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56531. * * 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
  56532. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56533. * * 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
  56534. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56535. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56536. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56537. * * 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
  56538. * * 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
  56539. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56544. * @param name defines the name of the mesh
  56545. * @param options defines the options used to create the mesh
  56546. * @param scene defines the hosting scene
  56547. * @returns the custom extruded shape mesh
  56548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56551. */
  56552. static ExtrudeShapeCustom(name: string, options: {
  56553. shape: Vector3[];
  56554. path: Vector3[];
  56555. scaleFunction?: any;
  56556. rotationFunction?: any;
  56557. ribbonCloseArray?: boolean;
  56558. ribbonClosePath?: boolean;
  56559. cap?: number;
  56560. updatable?: boolean;
  56561. sideOrientation?: number;
  56562. frontUVs?: Vector4;
  56563. backUVs?: Vector4;
  56564. instance?: Mesh;
  56565. invertUV?: boolean;
  56566. }, scene?: Nullable<Scene>): Mesh;
  56567. private static _ExtrudeShapeGeneric;
  56568. }
  56569. }
  56570. declare module "babylonjs/Debug/skeletonViewer" {
  56571. import { Color3 } from "babylonjs/Maths/math.color";
  56572. import { Scene } from "babylonjs/scene";
  56573. import { Nullable } from "babylonjs/types";
  56574. import { Skeleton } from "babylonjs/Bones/skeleton";
  56575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56576. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56577. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56578. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56579. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56580. /**
  56581. * Class used to render a debug view of a given skeleton
  56582. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56583. */
  56584. export class SkeletonViewer {
  56585. /** defines the skeleton to render */
  56586. skeleton: Skeleton;
  56587. /** defines the mesh attached to the skeleton */
  56588. mesh: AbstractMesh;
  56589. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56590. autoUpdateBonesMatrices: boolean;
  56591. /** defines the rendering group id to use with the viewer */
  56592. renderingGroupId: number;
  56593. /** is the options for the viewer */
  56594. options: Partial<ISkeletonViewerOptions>;
  56595. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56596. static readonly DISPLAY_LINES: number;
  56597. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56598. static readonly DISPLAY_SPHERES: number;
  56599. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56600. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56601. /** public static method to create a BoneWeight Shader
  56602. * @param options The constructor options
  56603. * @param scene The scene that the shader is scoped to
  56604. * @returns The created ShaderMaterial
  56605. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56606. */
  56607. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56608. /** public static method to create a BoneWeight Shader
  56609. * @param options The constructor options
  56610. * @param scene The scene that the shader is scoped to
  56611. * @returns The created ShaderMaterial
  56612. */
  56613. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56614. /** private static method to create a BoneWeight Shader
  56615. * @param size The size of the buffer to create (usually the bone count)
  56616. * @param colorMap The gradient data to generate
  56617. * @param scene The scene that the shader is scoped to
  56618. * @returns an Array of floats from the color gradient values
  56619. */
  56620. private static _CreateBoneMapColorBuffer;
  56621. /** If SkeletonViewer scene scope. */
  56622. private _scene;
  56623. /** Gets or sets the color used to render the skeleton */
  56624. color: Color3;
  56625. /** Array of the points of the skeleton fo the line view. */
  56626. private _debugLines;
  56627. /** The SkeletonViewers Mesh. */
  56628. private _debugMesh;
  56629. /** The local axes Meshes. */
  56630. private _localAxes;
  56631. /** If SkeletonViewer is enabled. */
  56632. private _isEnabled;
  56633. /** If SkeletonViewer is ready. */
  56634. private _ready;
  56635. /** SkeletonViewer render observable. */
  56636. private _obs;
  56637. /** The Utility Layer to render the gizmos in. */
  56638. private _utilityLayer;
  56639. private _boneIndices;
  56640. /** Gets the Scene. */
  56641. get scene(): Scene;
  56642. /** Gets the utilityLayer. */
  56643. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56644. /** Checks Ready Status. */
  56645. get isReady(): Boolean;
  56646. /** Sets Ready Status. */
  56647. set ready(value: boolean);
  56648. /** Gets the debugMesh */
  56649. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56650. /** Sets the debugMesh */
  56651. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56652. /** Gets the displayMode */
  56653. get displayMode(): number;
  56654. /** Sets the displayMode */
  56655. set displayMode(value: number);
  56656. /**
  56657. * Creates a new SkeletonViewer
  56658. * @param skeleton defines the skeleton to render
  56659. * @param mesh defines the mesh attached to the skeleton
  56660. * @param scene defines the hosting scene
  56661. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56662. * @param renderingGroupId defines the rendering group id to use with the viewer
  56663. * @param options All of the extra constructor options for the SkeletonViewer
  56664. */
  56665. constructor(
  56666. /** defines the skeleton to render */
  56667. skeleton: Skeleton,
  56668. /** defines the mesh attached to the skeleton */
  56669. mesh: AbstractMesh,
  56670. /** The Scene scope*/
  56671. scene: Scene,
  56672. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56673. autoUpdateBonesMatrices?: boolean,
  56674. /** defines the rendering group id to use with the viewer */
  56675. renderingGroupId?: number,
  56676. /** is the options for the viewer */
  56677. options?: Partial<ISkeletonViewerOptions>);
  56678. /** The Dynamic bindings for the update functions */
  56679. private _bindObs;
  56680. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56681. update(): void;
  56682. /** Gets or sets a boolean indicating if the viewer is enabled */
  56683. set isEnabled(value: boolean);
  56684. get isEnabled(): boolean;
  56685. private _getBonePosition;
  56686. private _getLinesForBonesWithLength;
  56687. private _getLinesForBonesNoLength;
  56688. /** function to revert the mesh and scene back to the initial state. */
  56689. private _revert;
  56690. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56691. private _getAbsoluteBindPoseToRef;
  56692. /** function to build and bind sphere joint points and spur bone representations. */
  56693. private _buildSpheresAndSpurs;
  56694. private _buildLocalAxes;
  56695. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56696. private _displayLinesUpdate;
  56697. /** Changes the displayMode of the skeleton viewer
  56698. * @param mode The displayMode numerical value
  56699. */
  56700. changeDisplayMode(mode: number): void;
  56701. /** Sets a display option of the skeleton viewer
  56702. *
  56703. * | Option | Type | Default | Description |
  56704. * | ---------------- | ------- | ------- | ----------- |
  56705. * | 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`. |
  56706. * | 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`. |
  56707. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56708. * | 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`. |
  56709. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56710. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56711. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56712. *
  56713. * @param option String of the option name
  56714. * @param value The numerical option value
  56715. */
  56716. changeDisplayOptions(option: string, value: number): void;
  56717. /** Release associated resources */
  56718. dispose(): void;
  56719. }
  56720. }
  56721. declare module "babylonjs/Debug/index" {
  56722. export * from "babylonjs/Debug/axesViewer";
  56723. export * from "babylonjs/Debug/boneAxesViewer";
  56724. export * from "babylonjs/Debug/debugLayer";
  56725. export * from "babylonjs/Debug/physicsViewer";
  56726. export * from "babylonjs/Debug/rayHelper";
  56727. export * from "babylonjs/Debug/skeletonViewer";
  56728. export * from "babylonjs/Debug/ISkeletonViewer";
  56729. }
  56730. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56731. /**
  56732. * Enum for Device Types
  56733. */
  56734. export enum DeviceType {
  56735. /** Generic */
  56736. Generic = 0,
  56737. /** Keyboard */
  56738. Keyboard = 1,
  56739. /** Mouse */
  56740. Mouse = 2,
  56741. /** Touch Pointers */
  56742. Touch = 3,
  56743. /** PS4 Dual Shock */
  56744. DualShock = 4,
  56745. /** Xbox */
  56746. Xbox = 5,
  56747. /** Switch Controller */
  56748. Switch = 6
  56749. }
  56750. /**
  56751. * Enum for All Pointers (Touch/Mouse)
  56752. */
  56753. export enum PointerInput {
  56754. /** Horizontal Axis */
  56755. Horizontal = 0,
  56756. /** Vertical Axis */
  56757. Vertical = 1,
  56758. /** Left Click or Touch */
  56759. LeftClick = 2,
  56760. /** Middle Click */
  56761. MiddleClick = 3,
  56762. /** Right Click */
  56763. RightClick = 4,
  56764. /** Browser Back */
  56765. BrowserBack = 5,
  56766. /** Browser Forward */
  56767. BrowserForward = 6
  56768. }
  56769. /**
  56770. * Enum for Dual Shock Gamepad
  56771. */
  56772. export enum DualShockInput {
  56773. /** Cross */
  56774. Cross = 0,
  56775. /** Circle */
  56776. Circle = 1,
  56777. /** Square */
  56778. Square = 2,
  56779. /** Triangle */
  56780. Triangle = 3,
  56781. /** L1 */
  56782. L1 = 4,
  56783. /** R1 */
  56784. R1 = 5,
  56785. /** L2 */
  56786. L2 = 6,
  56787. /** R2 */
  56788. R2 = 7,
  56789. /** Share */
  56790. Share = 8,
  56791. /** Options */
  56792. Options = 9,
  56793. /** L3 */
  56794. L3 = 10,
  56795. /** R3 */
  56796. R3 = 11,
  56797. /** DPadUp */
  56798. DPadUp = 12,
  56799. /** DPadDown */
  56800. DPadDown = 13,
  56801. /** DPadLeft */
  56802. DPadLeft = 14,
  56803. /** DRight */
  56804. DPadRight = 15,
  56805. /** Home */
  56806. Home = 16,
  56807. /** TouchPad */
  56808. TouchPad = 17,
  56809. /** LStickXAxis */
  56810. LStickXAxis = 18,
  56811. /** LStickYAxis */
  56812. LStickYAxis = 19,
  56813. /** RStickXAxis */
  56814. RStickXAxis = 20,
  56815. /** RStickYAxis */
  56816. RStickYAxis = 21
  56817. }
  56818. /**
  56819. * Enum for Xbox Gamepad
  56820. */
  56821. export enum XboxInput {
  56822. /** A */
  56823. A = 0,
  56824. /** B */
  56825. B = 1,
  56826. /** X */
  56827. X = 2,
  56828. /** Y */
  56829. Y = 3,
  56830. /** LB */
  56831. LB = 4,
  56832. /** RB */
  56833. RB = 5,
  56834. /** LT */
  56835. LT = 6,
  56836. /** RT */
  56837. RT = 7,
  56838. /** Back */
  56839. Back = 8,
  56840. /** Start */
  56841. Start = 9,
  56842. /** LS */
  56843. LS = 10,
  56844. /** RS */
  56845. RS = 11,
  56846. /** DPadUp */
  56847. DPadUp = 12,
  56848. /** DPadDown */
  56849. DPadDown = 13,
  56850. /** DPadLeft */
  56851. DPadLeft = 14,
  56852. /** DRight */
  56853. DPadRight = 15,
  56854. /** Home */
  56855. Home = 16,
  56856. /** LStickXAxis */
  56857. LStickXAxis = 17,
  56858. /** LStickYAxis */
  56859. LStickYAxis = 18,
  56860. /** RStickXAxis */
  56861. RStickXAxis = 19,
  56862. /** RStickYAxis */
  56863. RStickYAxis = 20
  56864. }
  56865. /**
  56866. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56867. */
  56868. export enum SwitchInput {
  56869. /** B */
  56870. B = 0,
  56871. /** A */
  56872. A = 1,
  56873. /** Y */
  56874. Y = 2,
  56875. /** X */
  56876. X = 3,
  56877. /** L */
  56878. L = 4,
  56879. /** R */
  56880. R = 5,
  56881. /** ZL */
  56882. ZL = 6,
  56883. /** ZR */
  56884. ZR = 7,
  56885. /** Minus */
  56886. Minus = 8,
  56887. /** Plus */
  56888. Plus = 9,
  56889. /** LS */
  56890. LS = 10,
  56891. /** RS */
  56892. RS = 11,
  56893. /** DPadUp */
  56894. DPadUp = 12,
  56895. /** DPadDown */
  56896. DPadDown = 13,
  56897. /** DPadLeft */
  56898. DPadLeft = 14,
  56899. /** DRight */
  56900. DPadRight = 15,
  56901. /** Home */
  56902. Home = 16,
  56903. /** Capture */
  56904. Capture = 17,
  56905. /** LStickXAxis */
  56906. LStickXAxis = 18,
  56907. /** LStickYAxis */
  56908. LStickYAxis = 19,
  56909. /** RStickXAxis */
  56910. RStickXAxis = 20,
  56911. /** RStickYAxis */
  56912. RStickYAxis = 21
  56913. }
  56914. }
  56915. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56916. import { Engine } from "babylonjs/Engines/engine";
  56917. import { IDisposable } from "babylonjs/scene";
  56918. import { Nullable } from "babylonjs/types";
  56919. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56920. /**
  56921. * This class will take all inputs from Keyboard, Pointer, and
  56922. * any Gamepads and provide a polling system that all devices
  56923. * will use. This class assumes that there will only be one
  56924. * pointer device and one keyboard.
  56925. */
  56926. export class DeviceInputSystem implements IDisposable {
  56927. /**
  56928. * Callback to be triggered when a device is connected
  56929. */
  56930. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56931. /**
  56932. * Callback to be triggered when a device is disconnected
  56933. */
  56934. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56935. /**
  56936. * Callback to be triggered when event driven input is updated
  56937. */
  56938. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56939. private _inputs;
  56940. private _gamepads;
  56941. private _keyboardActive;
  56942. private _pointerActive;
  56943. private _elementToAttachTo;
  56944. private _keyboardDownEvent;
  56945. private _keyboardUpEvent;
  56946. private _pointerMoveEvent;
  56947. private _pointerDownEvent;
  56948. private _pointerUpEvent;
  56949. private _gamepadConnectedEvent;
  56950. private _gamepadDisconnectedEvent;
  56951. private static _MAX_KEYCODES;
  56952. private static _MAX_POINTER_INPUTS;
  56953. private constructor();
  56954. /**
  56955. * Creates a new DeviceInputSystem instance
  56956. * @param engine Engine to pull input element from
  56957. * @returns The new instance
  56958. */
  56959. static Create(engine: Engine): DeviceInputSystem;
  56960. /**
  56961. * Checks for current device input value, given an id and input index
  56962. * @param deviceName Id of connected device
  56963. * @param inputIndex Index of device input
  56964. * @returns Current value of input
  56965. */
  56966. /**
  56967. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56968. * @param deviceType Enum specifiying device type
  56969. * @param deviceSlot "Slot" or index that device is referenced in
  56970. * @param inputIndex Id of input to be checked
  56971. * @returns Current value of input
  56972. */
  56973. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56974. /**
  56975. * Dispose of all the eventlisteners
  56976. */
  56977. dispose(): void;
  56978. /**
  56979. * Add device and inputs to device array
  56980. * @param deviceType Enum specifiying device type
  56981. * @param deviceSlot "Slot" or index that device is referenced in
  56982. * @param numberOfInputs Number of input entries to create for given device
  56983. */
  56984. private _registerDevice;
  56985. /**
  56986. * Given a specific device name, remove that device from the device map
  56987. * @param deviceType Enum specifiying device type
  56988. * @param deviceSlot "Slot" or index that device is referenced in
  56989. */
  56990. private _unregisterDevice;
  56991. /**
  56992. * Handle all actions that come from keyboard interaction
  56993. */
  56994. private _handleKeyActions;
  56995. /**
  56996. * Handle all actions that come from pointer interaction
  56997. */
  56998. private _handlePointerActions;
  56999. /**
  57000. * Handle all actions that come from gamepad interaction
  57001. */
  57002. private _handleGamepadActions;
  57003. /**
  57004. * Update all non-event based devices with each frame
  57005. * @param deviceType Enum specifiying device type
  57006. * @param deviceSlot "Slot" or index that device is referenced in
  57007. * @param inputIndex Id of input to be checked
  57008. */
  57009. private _updateDevice;
  57010. /**
  57011. * Gets DeviceType from the device name
  57012. * @param deviceName Name of Device from DeviceInputSystem
  57013. * @returns DeviceType enum value
  57014. */
  57015. private _getGamepadDeviceType;
  57016. }
  57017. }
  57018. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57019. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57020. /**
  57021. * Type to handle enforcement of inputs
  57022. */
  57023. 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;
  57024. }
  57025. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57026. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57027. import { Engine } from "babylonjs/Engines/engine";
  57028. import { IDisposable } from "babylonjs/scene";
  57029. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57030. import { Nullable } from "babylonjs/types";
  57031. import { Observable } from "babylonjs/Misc/observable";
  57032. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57033. /**
  57034. * Class that handles all input for a specific device
  57035. */
  57036. export class DeviceSource<T extends DeviceType> {
  57037. /** Type of device */
  57038. readonly deviceType: DeviceType;
  57039. /** "Slot" or index that device is referenced in */
  57040. readonly deviceSlot: number;
  57041. /**
  57042. * Observable to handle device input changes per device
  57043. */
  57044. readonly onInputChangedObservable: Observable<{
  57045. inputIndex: DeviceInput<T>;
  57046. previousState: Nullable<number>;
  57047. currentState: Nullable<number>;
  57048. }>;
  57049. private readonly _deviceInputSystem;
  57050. /**
  57051. * Default Constructor
  57052. * @param deviceInputSystem Reference to DeviceInputSystem
  57053. * @param deviceType Type of device
  57054. * @param deviceSlot "Slot" or index that device is referenced in
  57055. */
  57056. constructor(deviceInputSystem: DeviceInputSystem,
  57057. /** Type of device */
  57058. deviceType: DeviceType,
  57059. /** "Slot" or index that device is referenced in */
  57060. deviceSlot?: number);
  57061. /**
  57062. * Get input for specific input
  57063. * @param inputIndex index of specific input on device
  57064. * @returns Input value from DeviceInputSystem
  57065. */
  57066. getInput(inputIndex: DeviceInput<T>): number;
  57067. }
  57068. /**
  57069. * Class to keep track of devices
  57070. */
  57071. export class DeviceSourceManager implements IDisposable {
  57072. /**
  57073. * Observable to be triggered when before a device is connected
  57074. */
  57075. readonly onBeforeDeviceConnectedObservable: Observable<{
  57076. deviceType: DeviceType;
  57077. deviceSlot: number;
  57078. }>;
  57079. /**
  57080. * Observable to be triggered when before a device is disconnected
  57081. */
  57082. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57083. deviceType: DeviceType;
  57084. deviceSlot: number;
  57085. }>;
  57086. /**
  57087. * Observable to be triggered when after a device is connected
  57088. */
  57089. readonly onAfterDeviceConnectedObservable: Observable<{
  57090. deviceType: DeviceType;
  57091. deviceSlot: number;
  57092. }>;
  57093. /**
  57094. * Observable to be triggered when after a device is disconnected
  57095. */
  57096. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57097. deviceType: DeviceType;
  57098. deviceSlot: number;
  57099. }>;
  57100. private readonly _devices;
  57101. private readonly _firstDevice;
  57102. private readonly _deviceInputSystem;
  57103. /**
  57104. * Default Constructor
  57105. * @param engine engine to pull input element from
  57106. */
  57107. constructor(engine: Engine);
  57108. /**
  57109. * Gets a DeviceSource, given a type and slot
  57110. * @param deviceType Enum specifying device type
  57111. * @param deviceSlot "Slot" or index that device is referenced in
  57112. * @returns DeviceSource object
  57113. */
  57114. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57115. /**
  57116. * Gets an array of DeviceSource objects for a given device type
  57117. * @param deviceType Enum specifying device type
  57118. * @returns Array of DeviceSource objects
  57119. */
  57120. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57121. /**
  57122. * Dispose of DeviceInputSystem and other parts
  57123. */
  57124. dispose(): void;
  57125. /**
  57126. * Function to add device name to device list
  57127. * @param deviceType Enum specifying device type
  57128. * @param deviceSlot "Slot" or index that device is referenced in
  57129. */
  57130. private _addDevice;
  57131. /**
  57132. * Function to remove device name to device list
  57133. * @param deviceType Enum specifying device type
  57134. * @param deviceSlot "Slot" or index that device is referenced in
  57135. */
  57136. private _removeDevice;
  57137. /**
  57138. * Updates array storing first connected device of each type
  57139. * @param type Type of Device
  57140. */
  57141. private _updateFirstDevices;
  57142. }
  57143. }
  57144. declare module "babylonjs/DeviceInput/index" {
  57145. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57146. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57147. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57148. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57149. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57150. }
  57151. declare module "babylonjs/Engines/nullEngine" {
  57152. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57153. import { Engine } from "babylonjs/Engines/engine";
  57154. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57155. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57156. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57157. import { Effect } from "babylonjs/Materials/effect";
  57158. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57159. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57160. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57161. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57162. /**
  57163. * Options to create the null engine
  57164. */
  57165. export class NullEngineOptions {
  57166. /**
  57167. * Render width (Default: 512)
  57168. */
  57169. renderWidth: number;
  57170. /**
  57171. * Render height (Default: 256)
  57172. */
  57173. renderHeight: number;
  57174. /**
  57175. * Texture size (Default: 512)
  57176. */
  57177. textureSize: number;
  57178. /**
  57179. * If delta time between frames should be constant
  57180. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57181. */
  57182. deterministicLockstep: boolean;
  57183. /**
  57184. * Maximum about of steps between frames (Default: 4)
  57185. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57186. */
  57187. lockstepMaxSteps: number;
  57188. /**
  57189. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57190. */
  57191. useHighPrecisionMatrix?: boolean;
  57192. }
  57193. /**
  57194. * The null engine class provides support for headless version of babylon.js.
  57195. * This can be used in server side scenario or for testing purposes
  57196. */
  57197. export class NullEngine extends Engine {
  57198. private _options;
  57199. /**
  57200. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57201. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57202. * @returns true if engine is in deterministic lock step mode
  57203. */
  57204. isDeterministicLockStep(): boolean;
  57205. /**
  57206. * Gets the max steps when engine is running in deterministic lock step
  57207. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57208. * @returns the max steps
  57209. */
  57210. getLockstepMaxSteps(): number;
  57211. /**
  57212. * Gets the current hardware scaling level.
  57213. * By default the hardware scaling level is computed from the window device ratio.
  57214. * 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.
  57215. * @returns a number indicating the current hardware scaling level
  57216. */
  57217. getHardwareScalingLevel(): number;
  57218. constructor(options?: NullEngineOptions);
  57219. /**
  57220. * Creates a vertex buffer
  57221. * @param vertices the data for the vertex buffer
  57222. * @returns the new WebGL static buffer
  57223. */
  57224. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57225. /**
  57226. * Creates a new index buffer
  57227. * @param indices defines the content of the index buffer
  57228. * @param updatable defines if the index buffer must be updatable
  57229. * @returns a new webGL buffer
  57230. */
  57231. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57232. /**
  57233. * Clear the current render buffer or the current render target (if any is set up)
  57234. * @param color defines the color to use
  57235. * @param backBuffer defines if the back buffer must be cleared
  57236. * @param depth defines if the depth buffer must be cleared
  57237. * @param stencil defines if the stencil buffer must be cleared
  57238. */
  57239. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57240. /**
  57241. * Gets the current render width
  57242. * @param useScreen defines if screen size must be used (or the current render target if any)
  57243. * @returns a number defining the current render width
  57244. */
  57245. getRenderWidth(useScreen?: boolean): number;
  57246. /**
  57247. * Gets the current render height
  57248. * @param useScreen defines if screen size must be used (or the current render target if any)
  57249. * @returns a number defining the current render height
  57250. */
  57251. getRenderHeight(useScreen?: boolean): number;
  57252. /**
  57253. * Set the WebGL's viewport
  57254. * @param viewport defines the viewport element to be used
  57255. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57256. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57257. */
  57258. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57259. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57260. /**
  57261. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57262. * @param pipelineContext defines the pipeline context to use
  57263. * @param uniformsNames defines the list of uniform names
  57264. * @returns an array of webGL uniform locations
  57265. */
  57266. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57267. /**
  57268. * Gets the lsit of active attributes for a given webGL program
  57269. * @param pipelineContext defines the pipeline context to use
  57270. * @param attributesNames defines the list of attribute names to get
  57271. * @returns an array of indices indicating the offset of each attribute
  57272. */
  57273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57274. /**
  57275. * Binds an effect to the webGL context
  57276. * @param effect defines the effect to bind
  57277. */
  57278. bindSamplers(effect: Effect): void;
  57279. /**
  57280. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57281. * @param effect defines the effect to activate
  57282. */
  57283. enableEffect(effect: Effect): void;
  57284. /**
  57285. * Set various states to the webGL context
  57286. * @param culling defines backface culling state
  57287. * @param zOffset defines the value to apply to zOffset (0 by default)
  57288. * @param force defines if states must be applied even if cache is up to date
  57289. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57290. */
  57291. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57292. /**
  57293. * Set the value of an uniform to an array of int32
  57294. * @param uniform defines the webGL uniform location where to store the value
  57295. * @param array defines the array of int32 to store
  57296. * @returns true if value was set
  57297. */
  57298. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57299. /**
  57300. * Set the value of an uniform to an array of int32 (stored as vec2)
  57301. * @param uniform defines the webGL uniform location where to store the value
  57302. * @param array defines the array of int32 to store
  57303. * @returns true if value was set
  57304. */
  57305. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57306. /**
  57307. * Set the value of an uniform to an array of int32 (stored as vec3)
  57308. * @param uniform defines the webGL uniform location where to store the value
  57309. * @param array defines the array of int32 to store
  57310. * @returns true if value was set
  57311. */
  57312. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57313. /**
  57314. * Set the value of an uniform to an array of int32 (stored as vec4)
  57315. * @param uniform defines the webGL uniform location where to store the value
  57316. * @param array defines the array of int32 to store
  57317. * @returns true if value was set
  57318. */
  57319. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57320. /**
  57321. * Set the value of an uniform to an array of float32
  57322. * @param uniform defines the webGL uniform location where to store the value
  57323. * @param array defines the array of float32 to store
  57324. * @returns true if value was set
  57325. */
  57326. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57327. /**
  57328. * Set the value of an uniform to an array of float32 (stored as vec2)
  57329. * @param uniform defines the webGL uniform location where to store the value
  57330. * @param array defines the array of float32 to store
  57331. * @returns true if value was set
  57332. */
  57333. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57334. /**
  57335. * Set the value of an uniform to an array of float32 (stored as vec3)
  57336. * @param uniform defines the webGL uniform location where to store the value
  57337. * @param array defines the array of float32 to store
  57338. * @returns true if value was set
  57339. */
  57340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57341. /**
  57342. * Set the value of an uniform to an array of float32 (stored as vec4)
  57343. * @param uniform defines the webGL uniform location where to store the value
  57344. * @param array defines the array of float32 to store
  57345. * @returns true if value was set
  57346. */
  57347. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57348. /**
  57349. * Set the value of an uniform to an array of number
  57350. * @param uniform defines the webGL uniform location where to store the value
  57351. * @param array defines the array of number to store
  57352. * @returns true if value was set
  57353. */
  57354. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57355. /**
  57356. * Set the value of an uniform to an array of number (stored as vec2)
  57357. * @param uniform defines the webGL uniform location where to store the value
  57358. * @param array defines the array of number to store
  57359. * @returns true if value was set
  57360. */
  57361. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57362. /**
  57363. * Set the value of an uniform to an array of number (stored as vec3)
  57364. * @param uniform defines the webGL uniform location where to store the value
  57365. * @param array defines the array of number to store
  57366. * @returns true if value was set
  57367. */
  57368. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57369. /**
  57370. * Set the value of an uniform to an array of number (stored as vec4)
  57371. * @param uniform defines the webGL uniform location where to store the value
  57372. * @param array defines the array of number to store
  57373. * @returns true if value was set
  57374. */
  57375. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57376. /**
  57377. * Set the value of an uniform to an array of float32 (stored as matrices)
  57378. * @param uniform defines the webGL uniform location where to store the value
  57379. * @param matrices defines the array of float32 to store
  57380. * @returns true if value was set
  57381. */
  57382. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57383. /**
  57384. * Set the value of an uniform to a matrix (3x3)
  57385. * @param uniform defines the webGL uniform location where to store the value
  57386. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57387. * @returns true if value was set
  57388. */
  57389. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57390. /**
  57391. * Set the value of an uniform to a matrix (2x2)
  57392. * @param uniform defines the webGL uniform location where to store the value
  57393. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57394. * @returns true if value was set
  57395. */
  57396. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57397. /**
  57398. * Set the value of an uniform to a number (float)
  57399. * @param uniform defines the webGL uniform location where to store the value
  57400. * @param value defines the float number to store
  57401. * @returns true if value was set
  57402. */
  57403. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57404. /**
  57405. * Set the value of an uniform to a vec2
  57406. * @param uniform defines the webGL uniform location where to store the value
  57407. * @param x defines the 1st component of the value
  57408. * @param y defines the 2nd component of the value
  57409. * @returns true if value was set
  57410. */
  57411. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57412. /**
  57413. * Set the value of an uniform to a vec3
  57414. * @param uniform defines the webGL uniform location where to store the value
  57415. * @param x defines the 1st component of the value
  57416. * @param y defines the 2nd component of the value
  57417. * @param z defines the 3rd component of the value
  57418. * @returns true if value was set
  57419. */
  57420. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57421. /**
  57422. * Set the value of an uniform to a boolean
  57423. * @param uniform defines the webGL uniform location where to store the value
  57424. * @param bool defines the boolean to store
  57425. * @returns true if value was set
  57426. */
  57427. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57428. /**
  57429. * Set the value of an uniform to a vec4
  57430. * @param uniform defines the webGL uniform location where to store the value
  57431. * @param x defines the 1st component of the value
  57432. * @param y defines the 2nd component of the value
  57433. * @param z defines the 3rd component of the value
  57434. * @param w defines the 4th component of the value
  57435. * @returns true if value was set
  57436. */
  57437. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57438. /**
  57439. * Sets the current alpha mode
  57440. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57441. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57442. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57443. */
  57444. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57445. /**
  57446. * Bind webGl buffers directly to the webGL context
  57447. * @param vertexBuffers defines the vertex buffer to bind
  57448. * @param indexBuffer defines the index buffer to bind
  57449. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57450. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57451. * @param effect defines the effect associated with the vertex buffer
  57452. */
  57453. bindBuffers(vertexBuffers: {
  57454. [key: string]: VertexBuffer;
  57455. }, indexBuffer: DataBuffer, effect: Effect): void;
  57456. /**
  57457. * Force the entire cache to be cleared
  57458. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57459. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57460. */
  57461. wipeCaches(bruteForce?: boolean): void;
  57462. /**
  57463. * Send a draw order
  57464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57465. * @param indexStart defines the starting index
  57466. * @param indexCount defines the number of index to draw
  57467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57468. */
  57469. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57470. /**
  57471. * Draw a list of indexed primitives
  57472. * @param fillMode defines the primitive to use
  57473. * @param indexStart defines the starting index
  57474. * @param indexCount defines the number of index to draw
  57475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57476. */
  57477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57478. /**
  57479. * Draw a list of unindexed primitives
  57480. * @param fillMode defines the primitive to use
  57481. * @param verticesStart defines the index of first vertex to draw
  57482. * @param verticesCount defines the count of vertices to draw
  57483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57484. */
  57485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57486. /** @hidden */
  57487. _createTexture(): WebGLTexture;
  57488. /** @hidden */
  57489. _releaseTexture(texture: InternalTexture): void;
  57490. /**
  57491. * Usually called from Texture.ts.
  57492. * Passed information to create a WebGLTexture
  57493. * @param urlArg defines a value which contains one of the following:
  57494. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57495. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57496. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57498. * @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)
  57499. * @param scene needed for loading to the correct scene
  57500. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57501. * @param onLoad optional callback to be called upon successful completion
  57502. * @param onError optional callback to be called upon failure
  57503. * @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
  57504. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57505. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57506. * @param forcedExtension defines the extension to use to pick the right loader
  57507. * @param mimeType defines an optional mime type
  57508. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57509. */
  57510. 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;
  57511. /**
  57512. * Creates a new render target texture
  57513. * @param size defines the size of the texture
  57514. * @param options defines the options used to create the texture
  57515. * @returns a new render target texture stored in an InternalTexture
  57516. */
  57517. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57518. /**
  57519. * Update the sampling mode of a given texture
  57520. * @param samplingMode defines the required sampling mode
  57521. * @param texture defines the texture to update
  57522. */
  57523. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57524. /**
  57525. * Binds the frame buffer to the specified texture.
  57526. * @param texture The texture to render to or null for the default canvas
  57527. * @param faceIndex The face of the texture to render to in case of cube texture
  57528. * @param requiredWidth The width of the target to render to
  57529. * @param requiredHeight The height of the target to render to
  57530. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57531. * @param lodLevel defines le lod level to bind to the frame buffer
  57532. */
  57533. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57534. /**
  57535. * Unbind the current render target texture from the webGL context
  57536. * @param texture defines the render target texture to unbind
  57537. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57538. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57539. */
  57540. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57541. /**
  57542. * Creates a dynamic vertex buffer
  57543. * @param vertices the data for the dynamic vertex buffer
  57544. * @returns the new WebGL dynamic buffer
  57545. */
  57546. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57547. /**
  57548. * Update the content of a dynamic texture
  57549. * @param texture defines the texture to update
  57550. * @param canvas defines the canvas containing the source
  57551. * @param invertY defines if data must be stored with Y axis inverted
  57552. * @param premulAlpha defines if alpha is stored as premultiplied
  57553. * @param format defines the format of the data
  57554. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57555. */
  57556. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57557. /**
  57558. * Gets a boolean indicating if all created effects are ready
  57559. * @returns true if all effects are ready
  57560. */
  57561. areAllEffectsReady(): boolean;
  57562. /**
  57563. * @hidden
  57564. * Get the current error code of the webGL context
  57565. * @returns the error code
  57566. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57567. */
  57568. getError(): number;
  57569. /** @hidden */
  57570. _getUnpackAlignement(): number;
  57571. /** @hidden */
  57572. _unpackFlipY(value: boolean): void;
  57573. /**
  57574. * Update a dynamic index buffer
  57575. * @param indexBuffer defines the target index buffer
  57576. * @param indices defines the data to update
  57577. * @param offset defines the offset in the target index buffer where update should start
  57578. */
  57579. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57580. /**
  57581. * Updates a dynamic vertex buffer.
  57582. * @param vertexBuffer the vertex buffer to update
  57583. * @param vertices the data used to update the vertex buffer
  57584. * @param byteOffset the byte offset of the data (optional)
  57585. * @param byteLength the byte length of the data (optional)
  57586. */
  57587. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57588. /** @hidden */
  57589. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57590. /** @hidden */
  57591. _bindTexture(channel: number, texture: InternalTexture): void;
  57592. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57593. /**
  57594. * 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
  57595. */
  57596. releaseEffects(): void;
  57597. displayLoadingUI(): void;
  57598. hideLoadingUI(): void;
  57599. /** @hidden */
  57600. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57601. /** @hidden */
  57602. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57603. /** @hidden */
  57604. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57605. /** @hidden */
  57606. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57607. }
  57608. }
  57609. declare module "babylonjs/Instrumentation/timeToken" {
  57610. import { Nullable } from "babylonjs/types";
  57611. /**
  57612. * @hidden
  57613. **/
  57614. export class _TimeToken {
  57615. _startTimeQuery: Nullable<WebGLQuery>;
  57616. _endTimeQuery: Nullable<WebGLQuery>;
  57617. _timeElapsedQuery: Nullable<WebGLQuery>;
  57618. _timeElapsedQueryEnded: boolean;
  57619. }
  57620. }
  57621. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57622. import { Nullable, int } from "babylonjs/types";
  57623. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57624. /** @hidden */
  57625. export class _OcclusionDataStorage {
  57626. /** @hidden */
  57627. occlusionInternalRetryCounter: number;
  57628. /** @hidden */
  57629. isOcclusionQueryInProgress: boolean;
  57630. /** @hidden */
  57631. isOccluded: boolean;
  57632. /** @hidden */
  57633. occlusionRetryCount: number;
  57634. /** @hidden */
  57635. occlusionType: number;
  57636. /** @hidden */
  57637. occlusionQueryAlgorithmType: number;
  57638. }
  57639. module "babylonjs/Engines/engine" {
  57640. interface Engine {
  57641. /**
  57642. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57643. * @return the new query
  57644. */
  57645. createQuery(): WebGLQuery;
  57646. /**
  57647. * Delete and release a webGL query
  57648. * @param query defines the query to delete
  57649. * @return the current engine
  57650. */
  57651. deleteQuery(query: WebGLQuery): Engine;
  57652. /**
  57653. * Check if a given query has resolved and got its value
  57654. * @param query defines the query to check
  57655. * @returns true if the query got its value
  57656. */
  57657. isQueryResultAvailable(query: WebGLQuery): boolean;
  57658. /**
  57659. * Gets the value of a given query
  57660. * @param query defines the query to check
  57661. * @returns the value of the query
  57662. */
  57663. getQueryResult(query: WebGLQuery): number;
  57664. /**
  57665. * Initiates an occlusion query
  57666. * @param algorithmType defines the algorithm to use
  57667. * @param query defines the query to use
  57668. * @returns the current engine
  57669. * @see https://doc.babylonjs.com/features/occlusionquery
  57670. */
  57671. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57672. /**
  57673. * Ends an occlusion query
  57674. * @see https://doc.babylonjs.com/features/occlusionquery
  57675. * @param algorithmType defines the algorithm to use
  57676. * @returns the current engine
  57677. */
  57678. endOcclusionQuery(algorithmType: number): Engine;
  57679. /**
  57680. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57681. * Please note that only one query can be issued at a time
  57682. * @returns a time token used to track the time span
  57683. */
  57684. startTimeQuery(): Nullable<_TimeToken>;
  57685. /**
  57686. * Ends a time query
  57687. * @param token defines the token used to measure the time span
  57688. * @returns the time spent (in ns)
  57689. */
  57690. endTimeQuery(token: _TimeToken): int;
  57691. /** @hidden */
  57692. _currentNonTimestampToken: Nullable<_TimeToken>;
  57693. /** @hidden */
  57694. _createTimeQuery(): WebGLQuery;
  57695. /** @hidden */
  57696. _deleteTimeQuery(query: WebGLQuery): void;
  57697. /** @hidden */
  57698. _getGlAlgorithmType(algorithmType: number): number;
  57699. /** @hidden */
  57700. _getTimeQueryResult(query: WebGLQuery): any;
  57701. /** @hidden */
  57702. _getTimeQueryAvailability(query: WebGLQuery): any;
  57703. }
  57704. }
  57705. module "babylonjs/Meshes/abstractMesh" {
  57706. interface AbstractMesh {
  57707. /**
  57708. * Backing filed
  57709. * @hidden
  57710. */
  57711. __occlusionDataStorage: _OcclusionDataStorage;
  57712. /**
  57713. * Access property
  57714. * @hidden
  57715. */
  57716. _occlusionDataStorage: _OcclusionDataStorage;
  57717. /**
  57718. * 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.
  57719. * The default value is -1 which means don't break the query and wait till the result
  57720. * @see https://doc.babylonjs.com/features/occlusionquery
  57721. */
  57722. occlusionRetryCount: number;
  57723. /**
  57724. * 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:
  57725. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57726. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57727. * * 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.
  57728. * @see https://doc.babylonjs.com/features/occlusionquery
  57729. */
  57730. occlusionType: number;
  57731. /**
  57732. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57733. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57734. * * 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.
  57735. * @see https://doc.babylonjs.com/features/occlusionquery
  57736. */
  57737. occlusionQueryAlgorithmType: number;
  57738. /**
  57739. * 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
  57740. * @see https://doc.babylonjs.com/features/occlusionquery
  57741. */
  57742. isOccluded: boolean;
  57743. /**
  57744. * Flag to check the progress status of the query
  57745. * @see https://doc.babylonjs.com/features/occlusionquery
  57746. */
  57747. isOcclusionQueryInProgress: boolean;
  57748. }
  57749. }
  57750. }
  57751. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57752. import { Nullable } from "babylonjs/types";
  57753. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57754. /** @hidden */
  57755. export var _forceTransformFeedbackToBundle: boolean;
  57756. module "babylonjs/Engines/engine" {
  57757. interface Engine {
  57758. /**
  57759. * Creates a webGL transform feedback object
  57760. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57761. * @returns the webGL transform feedback object
  57762. */
  57763. createTransformFeedback(): WebGLTransformFeedback;
  57764. /**
  57765. * Delete a webGL transform feedback object
  57766. * @param value defines the webGL transform feedback object to delete
  57767. */
  57768. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57769. /**
  57770. * Bind a webGL transform feedback object to the webgl context
  57771. * @param value defines the webGL transform feedback object to bind
  57772. */
  57773. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57774. /**
  57775. * Begins a transform feedback operation
  57776. * @param usePoints defines if points or triangles must be used
  57777. */
  57778. beginTransformFeedback(usePoints: boolean): void;
  57779. /**
  57780. * Ends a transform feedback operation
  57781. */
  57782. endTransformFeedback(): void;
  57783. /**
  57784. * Specify the varyings to use with transform feedback
  57785. * @param program defines the associated webGL program
  57786. * @param value defines the list of strings representing the varying names
  57787. */
  57788. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57789. /**
  57790. * Bind a webGL buffer for a transform feedback operation
  57791. * @param value defines the webGL buffer to bind
  57792. */
  57793. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57794. }
  57795. }
  57796. }
  57797. declare module "babylonjs/Engines/Extensions/engine.views" {
  57798. import { Camera } from "babylonjs/Cameras/camera";
  57799. import { Nullable } from "babylonjs/types";
  57800. /**
  57801. * Class used to define an additional view for the engine
  57802. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57803. */
  57804. export class EngineView {
  57805. /** Defines the canvas where to render the view */
  57806. target: HTMLCanvasElement;
  57807. /** Defines an optional camera used to render the view (will use active camera else) */
  57808. camera?: Camera;
  57809. }
  57810. module "babylonjs/Engines/engine" {
  57811. interface Engine {
  57812. /**
  57813. * Gets or sets the HTML element to use for attaching events
  57814. */
  57815. inputElement: Nullable<HTMLElement>;
  57816. /**
  57817. * Gets the current engine view
  57818. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57819. */
  57820. activeView: Nullable<EngineView>;
  57821. /** Gets or sets the list of views */
  57822. views: EngineView[];
  57823. /**
  57824. * Register a new child canvas
  57825. * @param canvas defines the canvas to register
  57826. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57827. * @returns the associated view
  57828. */
  57829. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57830. /**
  57831. * Remove a registered child canvas
  57832. * @param canvas defines the canvas to remove
  57833. * @returns the current engine
  57834. */
  57835. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57836. }
  57837. }
  57838. }
  57839. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57840. import { Nullable } from "babylonjs/types";
  57841. module "babylonjs/Engines/engine" {
  57842. interface Engine {
  57843. /** @hidden */
  57844. _excludedCompressedTextures: string[];
  57845. /** @hidden */
  57846. _textureFormatInUse: string;
  57847. /**
  57848. * Gets the list of texture formats supported
  57849. */
  57850. readonly texturesSupported: Array<string>;
  57851. /**
  57852. * Gets the texture format in use
  57853. */
  57854. readonly textureFormatInUse: Nullable<string>;
  57855. /**
  57856. * Set the compressed texture extensions or file names to skip.
  57857. *
  57858. * @param skippedFiles defines the list of those texture files you want to skip
  57859. * Example: [".dds", ".env", "myfile.png"]
  57860. */
  57861. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57862. /**
  57863. * Set the compressed texture format to use, based on the formats you have, and the formats
  57864. * supported by the hardware / browser.
  57865. *
  57866. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57867. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57868. * to API arguments needed to compressed textures. This puts the burden on the container
  57869. * generator to house the arcane code for determining these for current & future formats.
  57870. *
  57871. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57872. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57873. *
  57874. * Note: The result of this call is not taken into account when a texture is base64.
  57875. *
  57876. * @param formatsAvailable defines the list of those format families you have created
  57877. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57878. *
  57879. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57880. * @returns The extension selected.
  57881. */
  57882. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57883. }
  57884. }
  57885. }
  57886. declare module "babylonjs/Engines/Extensions/index" {
  57887. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57888. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57889. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57890. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57891. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57892. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57893. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57894. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57895. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57896. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57897. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57898. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57899. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57900. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57901. export * from "babylonjs/Engines/Extensions/engine.views";
  57902. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57903. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57904. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57905. }
  57906. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57907. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57908. /** @hidden */
  57909. export var rgbdEncodePixelShader: {
  57910. name: string;
  57911. shader: string;
  57912. };
  57913. }
  57914. declare module "babylonjs/Misc/environmentTextureTools" {
  57915. import { Nullable } from "babylonjs/types";
  57916. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57917. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57919. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57920. import "babylonjs/Engines/Extensions/engine.readTexture";
  57921. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57922. import "babylonjs/Shaders/rgbdEncode.fragment";
  57923. import "babylonjs/Shaders/rgbdDecode.fragment";
  57924. /**
  57925. * Raw texture data and descriptor sufficient for WebGL texture upload
  57926. */
  57927. export interface EnvironmentTextureInfo {
  57928. /**
  57929. * Version of the environment map
  57930. */
  57931. version: number;
  57932. /**
  57933. * Width of image
  57934. */
  57935. width: number;
  57936. /**
  57937. * Irradiance information stored in the file.
  57938. */
  57939. irradiance: any;
  57940. /**
  57941. * Specular information stored in the file.
  57942. */
  57943. specular: any;
  57944. }
  57945. /**
  57946. * Defines One Image in the file. It requires only the position in the file
  57947. * as well as the length.
  57948. */
  57949. interface BufferImageData {
  57950. /**
  57951. * Length of the image data.
  57952. */
  57953. length: number;
  57954. /**
  57955. * Position of the data from the null terminator delimiting the end of the JSON.
  57956. */
  57957. position: number;
  57958. }
  57959. /**
  57960. * Defines the specular data enclosed in the file.
  57961. * This corresponds to the version 1 of the data.
  57962. */
  57963. export interface EnvironmentTextureSpecularInfoV1 {
  57964. /**
  57965. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57966. */
  57967. specularDataPosition?: number;
  57968. /**
  57969. * This contains all the images data needed to reconstruct the cubemap.
  57970. */
  57971. mipmaps: Array<BufferImageData>;
  57972. /**
  57973. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57974. */
  57975. lodGenerationScale: number;
  57976. }
  57977. /**
  57978. * Sets of helpers addressing the serialization and deserialization of environment texture
  57979. * stored in a BabylonJS env file.
  57980. * Those files are usually stored as .env files.
  57981. */
  57982. export class EnvironmentTextureTools {
  57983. /**
  57984. * Magic number identifying the env file.
  57985. */
  57986. private static _MagicBytes;
  57987. /**
  57988. * Gets the environment info from an env file.
  57989. * @param data The array buffer containing the .env bytes.
  57990. * @returns the environment file info (the json header) if successfully parsed.
  57991. */
  57992. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  57993. /**
  57994. * Creates an environment texture from a loaded cube texture.
  57995. * @param texture defines the cube texture to convert in env file
  57996. * @return a promise containing the environment data if succesfull.
  57997. */
  57998. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  57999. /**
  58000. * Creates a JSON representation of the spherical data.
  58001. * @param texture defines the texture containing the polynomials
  58002. * @return the JSON representation of the spherical info
  58003. */
  58004. private static _CreateEnvTextureIrradiance;
  58005. /**
  58006. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58007. * @param data the image data
  58008. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58009. * @return the views described by info providing access to the underlying buffer
  58010. */
  58011. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58012. /**
  58013. * Uploads the texture info contained in the env file to the GPU.
  58014. * @param texture defines the internal texture to upload to
  58015. * @param data defines the data to load
  58016. * @param info defines the texture info retrieved through the GetEnvInfo method
  58017. * @returns a promise
  58018. */
  58019. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58020. private static _OnImageReadyAsync;
  58021. /**
  58022. * Uploads the levels of image data to the GPU.
  58023. * @param texture defines the internal texture to upload to
  58024. * @param imageData defines the array buffer views of image data [mipmap][face]
  58025. * @returns a promise
  58026. */
  58027. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58028. /**
  58029. * Uploads spherical polynomials information to the texture.
  58030. * @param texture defines the texture we are trying to upload the information to
  58031. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58032. */
  58033. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58034. /** @hidden */
  58035. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58036. }
  58037. }
  58038. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58039. /**
  58040. * Class used to inline functions in shader code
  58041. */
  58042. export class ShaderCodeInliner {
  58043. private static readonly _RegexpFindFunctionNameAndType;
  58044. private _sourceCode;
  58045. private _functionDescr;
  58046. private _numMaxIterations;
  58047. /** Gets or sets the token used to mark the functions to inline */
  58048. inlineToken: string;
  58049. /** Gets or sets the debug mode */
  58050. debug: boolean;
  58051. /** Gets the code after the inlining process */
  58052. get code(): string;
  58053. /**
  58054. * Initializes the inliner
  58055. * @param sourceCode shader code source to inline
  58056. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58057. */
  58058. constructor(sourceCode: string, numMaxIterations?: number);
  58059. /**
  58060. * Start the processing of the shader code
  58061. */
  58062. processCode(): void;
  58063. private _collectFunctions;
  58064. private _processInlining;
  58065. private _extractBetweenMarkers;
  58066. private _skipWhitespaces;
  58067. private _removeComments;
  58068. private _replaceFunctionCallsByCode;
  58069. private _findBackward;
  58070. private _escapeRegExp;
  58071. private _replaceNames;
  58072. }
  58073. }
  58074. declare module "babylonjs/Engines/nativeEngine" {
  58075. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58076. import { Engine } from "babylonjs/Engines/engine";
  58077. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58078. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58080. import { Effect } from "babylonjs/Materials/effect";
  58081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58082. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58083. import { IColor4Like } from "babylonjs/Maths/math.like";
  58084. import { Scene } from "babylonjs/scene";
  58085. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58086. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58087. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58088. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58089. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58090. /**
  58091. * Container for accessors for natively-stored mesh data buffers.
  58092. */
  58093. class NativeDataBuffer extends DataBuffer {
  58094. /**
  58095. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58096. */
  58097. nativeIndexBuffer?: any;
  58098. /**
  58099. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58100. */
  58101. nativeVertexBuffer?: any;
  58102. }
  58103. /** @hidden */
  58104. class NativeTexture extends InternalTexture {
  58105. getInternalTexture(): InternalTexture;
  58106. getViewCount(): number;
  58107. }
  58108. /** @hidden */
  58109. export class NativeEngine extends Engine {
  58110. private readonly _native;
  58111. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58112. private readonly INVALID_HANDLE;
  58113. private _boundBuffersVertexArray;
  58114. private _currentDepthTest;
  58115. getHardwareScalingLevel(): number;
  58116. constructor();
  58117. dispose(): void;
  58118. /**
  58119. * Can be used to override the current requestAnimationFrame requester.
  58120. * @hidden
  58121. */
  58122. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58123. /**
  58124. * Override default engine behavior.
  58125. * @param color
  58126. * @param backBuffer
  58127. * @param depth
  58128. * @param stencil
  58129. */
  58130. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58131. /**
  58132. * Gets host document
  58133. * @returns the host document object
  58134. */
  58135. getHostDocument(): Nullable<Document>;
  58136. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58137. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58138. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58139. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58140. [key: string]: VertexBuffer;
  58141. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58142. bindBuffers(vertexBuffers: {
  58143. [key: string]: VertexBuffer;
  58144. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58145. recordVertexArrayObject(vertexBuffers: {
  58146. [key: string]: VertexBuffer;
  58147. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58148. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58149. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58150. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58151. /**
  58152. * Draw a list of indexed primitives
  58153. * @param fillMode defines the primitive to use
  58154. * @param indexStart defines the starting index
  58155. * @param indexCount defines the number of index to draw
  58156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58157. */
  58158. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58159. /**
  58160. * Draw a list of unindexed primitives
  58161. * @param fillMode defines the primitive to use
  58162. * @param verticesStart defines the index of first vertex to draw
  58163. * @param verticesCount defines the count of vertices to draw
  58164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58165. */
  58166. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58167. createPipelineContext(): IPipelineContext;
  58168. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58169. /** @hidden */
  58170. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58171. /** @hidden */
  58172. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58173. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58174. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58175. protected _setProgram(program: WebGLProgram): void;
  58176. _releaseEffect(effect: Effect): void;
  58177. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58178. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58179. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58180. bindSamplers(effect: Effect): void;
  58181. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58182. getRenderWidth(useScreen?: boolean): number;
  58183. getRenderHeight(useScreen?: boolean): number;
  58184. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58185. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58186. /**
  58187. * Set the z offset to apply to current rendering
  58188. * @param value defines the offset to apply
  58189. */
  58190. setZOffset(value: number): void;
  58191. /**
  58192. * Gets the current value of the zOffset
  58193. * @returns the current zOffset state
  58194. */
  58195. getZOffset(): number;
  58196. /**
  58197. * Enable or disable depth buffering
  58198. * @param enable defines the state to set
  58199. */
  58200. setDepthBuffer(enable: boolean): void;
  58201. /**
  58202. * Gets a boolean indicating if depth writing is enabled
  58203. * @returns the current depth writing state
  58204. */
  58205. getDepthWrite(): boolean;
  58206. setDepthFunctionToGreater(): void;
  58207. setDepthFunctionToGreaterOrEqual(): void;
  58208. setDepthFunctionToLess(): void;
  58209. setDepthFunctionToLessOrEqual(): void;
  58210. /**
  58211. * Enable or disable depth writing
  58212. * @param enable defines the state to set
  58213. */
  58214. setDepthWrite(enable: boolean): void;
  58215. /**
  58216. * Enable or disable color writing
  58217. * @param enable defines the state to set
  58218. */
  58219. setColorWrite(enable: boolean): void;
  58220. /**
  58221. * Gets a boolean indicating if color writing is enabled
  58222. * @returns the current color writing state
  58223. */
  58224. getColorWrite(): boolean;
  58225. /**
  58226. * Sets alpha constants used by some alpha blending modes
  58227. * @param r defines the red component
  58228. * @param g defines the green component
  58229. * @param b defines the blue component
  58230. * @param a defines the alpha component
  58231. */
  58232. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58233. /**
  58234. * Sets the current alpha mode
  58235. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58236. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58237. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58238. */
  58239. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58240. /**
  58241. * Gets the current alpha mode
  58242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58243. * @returns the current alpha mode
  58244. */
  58245. getAlphaMode(): number;
  58246. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58247. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58248. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58249. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58250. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58251. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58252. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58253. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58254. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58255. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58256. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58257. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58258. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58259. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58260. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58261. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58262. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58263. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58264. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58265. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58266. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58267. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58268. wipeCaches(bruteForce?: boolean): void;
  58269. _createTexture(): WebGLTexture;
  58270. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58271. /**
  58272. * Update the content of a dynamic texture
  58273. * @param texture defines the texture to update
  58274. * @param canvas defines the canvas containing the source
  58275. * @param invertY defines if data must be stored with Y axis inverted
  58276. * @param premulAlpha defines if alpha is stored as premultiplied
  58277. * @param format defines the format of the data
  58278. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58279. */
  58280. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58281. /**
  58282. * Usually called from Texture.ts.
  58283. * Passed information to create a WebGLTexture
  58284. * @param url defines a value which contains one of the following:
  58285. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58286. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58287. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58288. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58289. * @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)
  58290. * @param scene needed for loading to the correct scene
  58291. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58292. * @param onLoad optional callback to be called upon successful completion
  58293. * @param onError optional callback to be called upon failure
  58294. * @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
  58295. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58296. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58297. * @param forcedExtension defines the extension to use to pick the right loader
  58298. * @param mimeType defines an optional mime type
  58299. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58300. */
  58301. 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;
  58302. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58303. _releaseFramebufferObjects(texture: InternalTexture): void;
  58304. /**
  58305. * Creates a cube texture
  58306. * @param rootUrl defines the url where the files to load is located
  58307. * @param scene defines the current scene
  58308. * @param files defines the list of files to load (1 per face)
  58309. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58310. * @param onLoad defines an optional callback raised when the texture is loaded
  58311. * @param onError defines an optional callback raised if there is an issue to load the texture
  58312. * @param format defines the format of the data
  58313. * @param forcedExtension defines the extension to use to pick the right loader
  58314. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58315. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58316. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58317. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58318. * @returns the cube texture as an InternalTexture
  58319. */
  58320. 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;
  58321. createRenderTargetTexture(size: number | {
  58322. width: number;
  58323. height: number;
  58324. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58325. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58326. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58327. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58328. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58329. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58330. /**
  58331. * Updates a dynamic vertex buffer.
  58332. * @param vertexBuffer the vertex buffer to update
  58333. * @param data the data used to update the vertex buffer
  58334. * @param byteOffset the byte offset of the data (optional)
  58335. * @param byteLength the byte length of the data (optional)
  58336. */
  58337. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58338. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58339. private _updateAnisotropicLevel;
  58340. private _getAddressMode;
  58341. /** @hidden */
  58342. _bindTexture(channel: number, texture: InternalTexture): void;
  58343. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58344. releaseEffects(): void;
  58345. /** @hidden */
  58346. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58347. /** @hidden */
  58348. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58349. /** @hidden */
  58350. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58351. /** @hidden */
  58352. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58353. private _getNativeSamplingMode;
  58354. private _getNativeTextureFormat;
  58355. private _getNativeAlphaMode;
  58356. private _getNativeAttribType;
  58357. }
  58358. }
  58359. declare module "babylonjs/Engines/index" {
  58360. export * from "babylonjs/Engines/constants";
  58361. export * from "babylonjs/Engines/engineCapabilities";
  58362. export * from "babylonjs/Engines/instancingAttributeInfo";
  58363. export * from "babylonjs/Engines/thinEngine";
  58364. export * from "babylonjs/Engines/engine";
  58365. export * from "babylonjs/Engines/engineStore";
  58366. export * from "babylonjs/Engines/nullEngine";
  58367. export * from "babylonjs/Engines/Extensions/index";
  58368. export * from "babylonjs/Engines/IPipelineContext";
  58369. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58370. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58371. export * from "babylonjs/Engines/nativeEngine";
  58372. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58373. export * from "babylonjs/Engines/performanceConfigurator";
  58374. }
  58375. declare module "babylonjs/Events/clipboardEvents" {
  58376. /**
  58377. * Gather the list of clipboard event types as constants.
  58378. */
  58379. export class ClipboardEventTypes {
  58380. /**
  58381. * The clipboard event is fired when a copy command is active (pressed).
  58382. */
  58383. static readonly COPY: number;
  58384. /**
  58385. * The clipboard event is fired when a cut command is active (pressed).
  58386. */
  58387. static readonly CUT: number;
  58388. /**
  58389. * The clipboard event is fired when a paste command is active (pressed).
  58390. */
  58391. static readonly PASTE: number;
  58392. }
  58393. /**
  58394. * This class is used to store clipboard related info for the onClipboardObservable event.
  58395. */
  58396. export class ClipboardInfo {
  58397. /**
  58398. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58399. */
  58400. type: number;
  58401. /**
  58402. * Defines the related dom event
  58403. */
  58404. event: ClipboardEvent;
  58405. /**
  58406. *Creates an instance of ClipboardInfo.
  58407. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58408. * @param event Defines the related dom event
  58409. */
  58410. constructor(
  58411. /**
  58412. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58413. */
  58414. type: number,
  58415. /**
  58416. * Defines the related dom event
  58417. */
  58418. event: ClipboardEvent);
  58419. /**
  58420. * Get the clipboard event's type from the keycode.
  58421. * @param keyCode Defines the keyCode for the current keyboard event.
  58422. * @return {number}
  58423. */
  58424. static GetTypeFromCharacter(keyCode: number): number;
  58425. }
  58426. }
  58427. declare module "babylonjs/Events/index" {
  58428. export * from "babylonjs/Events/keyboardEvents";
  58429. export * from "babylonjs/Events/pointerEvents";
  58430. export * from "babylonjs/Events/clipboardEvents";
  58431. }
  58432. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58433. import { Scene } from "babylonjs/scene";
  58434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58435. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58436. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58437. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58438. /**
  58439. * Google Daydream controller
  58440. */
  58441. export class DaydreamController extends WebVRController {
  58442. /**
  58443. * Base Url for the controller model.
  58444. */
  58445. static MODEL_BASE_URL: string;
  58446. /**
  58447. * File name for the controller model.
  58448. */
  58449. static MODEL_FILENAME: string;
  58450. /**
  58451. * Gamepad Id prefix used to identify Daydream Controller.
  58452. */
  58453. static readonly GAMEPAD_ID_PREFIX: string;
  58454. /**
  58455. * Creates a new DaydreamController from a gamepad
  58456. * @param vrGamepad the gamepad that the controller should be created from
  58457. */
  58458. constructor(vrGamepad: any);
  58459. /**
  58460. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58461. * @param scene scene in which to add meshes
  58462. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58463. */
  58464. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58465. /**
  58466. * Called once for each button that changed state since the last frame
  58467. * @param buttonIdx Which button index changed
  58468. * @param state New state of the button
  58469. * @param changes Which properties on the state changed since last frame
  58470. */
  58471. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58472. }
  58473. }
  58474. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58475. import { Scene } from "babylonjs/scene";
  58476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58477. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58478. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58479. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58480. /**
  58481. * Gear VR Controller
  58482. */
  58483. export class GearVRController extends WebVRController {
  58484. /**
  58485. * Base Url for the controller model.
  58486. */
  58487. static MODEL_BASE_URL: string;
  58488. /**
  58489. * File name for the controller model.
  58490. */
  58491. static MODEL_FILENAME: string;
  58492. /**
  58493. * Gamepad Id prefix used to identify this controller.
  58494. */
  58495. static readonly GAMEPAD_ID_PREFIX: string;
  58496. private readonly _buttonIndexToObservableNameMap;
  58497. /**
  58498. * Creates a new GearVRController from a gamepad
  58499. * @param vrGamepad the gamepad that the controller should be created from
  58500. */
  58501. constructor(vrGamepad: any);
  58502. /**
  58503. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58504. * @param scene scene in which to add meshes
  58505. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58506. */
  58507. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58508. /**
  58509. * Called once for each button that changed state since the last frame
  58510. * @param buttonIdx Which button index changed
  58511. * @param state New state of the button
  58512. * @param changes Which properties on the state changed since last frame
  58513. */
  58514. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58515. }
  58516. }
  58517. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58518. import { Scene } from "babylonjs/scene";
  58519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58520. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58521. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58522. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58523. /**
  58524. * Generic Controller
  58525. */
  58526. export class GenericController extends WebVRController {
  58527. /**
  58528. * Base Url for the controller model.
  58529. */
  58530. static readonly MODEL_BASE_URL: string;
  58531. /**
  58532. * File name for the controller model.
  58533. */
  58534. static readonly MODEL_FILENAME: string;
  58535. /**
  58536. * Creates a new GenericController from a gamepad
  58537. * @param vrGamepad the gamepad that the controller should be created from
  58538. */
  58539. constructor(vrGamepad: any);
  58540. /**
  58541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58542. * @param scene scene in which to add meshes
  58543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58544. */
  58545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58546. /**
  58547. * Called once for each button that changed state since the last frame
  58548. * @param buttonIdx Which button index changed
  58549. * @param state New state of the button
  58550. * @param changes Which properties on the state changed since last frame
  58551. */
  58552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58553. }
  58554. }
  58555. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58556. import { Observable } from "babylonjs/Misc/observable";
  58557. import { Scene } from "babylonjs/scene";
  58558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58559. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58560. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58561. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58562. /**
  58563. * Oculus Touch Controller
  58564. */
  58565. export class OculusTouchController extends WebVRController {
  58566. /**
  58567. * Base Url for the controller model.
  58568. */
  58569. static MODEL_BASE_URL: string;
  58570. /**
  58571. * File name for the left controller model.
  58572. */
  58573. static MODEL_LEFT_FILENAME: string;
  58574. /**
  58575. * File name for the right controller model.
  58576. */
  58577. static MODEL_RIGHT_FILENAME: string;
  58578. /**
  58579. * Base Url for the Quest controller model.
  58580. */
  58581. static QUEST_MODEL_BASE_URL: string;
  58582. /**
  58583. * @hidden
  58584. * If the controllers are running on a device that needs the updated Quest controller models
  58585. */
  58586. static _IsQuest: boolean;
  58587. /**
  58588. * Fired when the secondary trigger on this controller is modified
  58589. */
  58590. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58591. /**
  58592. * Fired when the thumb rest on this controller is modified
  58593. */
  58594. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58595. /**
  58596. * Creates a new OculusTouchController from a gamepad
  58597. * @param vrGamepad the gamepad that the controller should be created from
  58598. */
  58599. constructor(vrGamepad: any);
  58600. /**
  58601. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58602. * @param scene scene in which to add meshes
  58603. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58604. */
  58605. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58606. /**
  58607. * Fired when the A button on this controller is modified
  58608. */
  58609. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58610. /**
  58611. * Fired when the B button on this controller is modified
  58612. */
  58613. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58614. /**
  58615. * Fired when the X button on this controller is modified
  58616. */
  58617. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58618. /**
  58619. * Fired when the Y button on this controller is modified
  58620. */
  58621. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58622. /**
  58623. * Called once for each button that changed state since the last frame
  58624. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58625. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58626. * 2) secondary trigger (same)
  58627. * 3) A (right) X (left), touch, pressed = value
  58628. * 4) B / Y
  58629. * 5) thumb rest
  58630. * @param buttonIdx Which button index changed
  58631. * @param state New state of the button
  58632. * @param changes Which properties on the state changed since last frame
  58633. */
  58634. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58635. }
  58636. }
  58637. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58638. import { Scene } from "babylonjs/scene";
  58639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58640. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58641. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58642. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58643. import { Observable } from "babylonjs/Misc/observable";
  58644. /**
  58645. * Vive Controller
  58646. */
  58647. export class ViveController extends WebVRController {
  58648. /**
  58649. * Base Url for the controller model.
  58650. */
  58651. static MODEL_BASE_URL: string;
  58652. /**
  58653. * File name for the controller model.
  58654. */
  58655. static MODEL_FILENAME: string;
  58656. /**
  58657. * Creates a new ViveController from a gamepad
  58658. * @param vrGamepad the gamepad that the controller should be created from
  58659. */
  58660. constructor(vrGamepad: any);
  58661. /**
  58662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58663. * @param scene scene in which to add meshes
  58664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58665. */
  58666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58667. /**
  58668. * Fired when the left button on this controller is modified
  58669. */
  58670. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58671. /**
  58672. * Fired when the right button on this controller is modified
  58673. */
  58674. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58675. /**
  58676. * Fired when the menu button on this controller is modified
  58677. */
  58678. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58679. /**
  58680. * Called once for each button that changed state since the last frame
  58681. * Vive mapping:
  58682. * 0: touchpad
  58683. * 1: trigger
  58684. * 2: left AND right buttons
  58685. * 3: menu button
  58686. * @param buttonIdx Which button index changed
  58687. * @param state New state of the button
  58688. * @param changes Which properties on the state changed since last frame
  58689. */
  58690. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58691. }
  58692. }
  58693. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58694. import { Observable } from "babylonjs/Misc/observable";
  58695. import { Scene } from "babylonjs/scene";
  58696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58697. import { Ray } from "babylonjs/Culling/ray";
  58698. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58699. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58700. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58701. /**
  58702. * Defines the WindowsMotionController object that the state of the windows motion controller
  58703. */
  58704. export class WindowsMotionController extends WebVRController {
  58705. /**
  58706. * The base url used to load the left and right controller models
  58707. */
  58708. static MODEL_BASE_URL: string;
  58709. /**
  58710. * The name of the left controller model file
  58711. */
  58712. static MODEL_LEFT_FILENAME: string;
  58713. /**
  58714. * The name of the right controller model file
  58715. */
  58716. static MODEL_RIGHT_FILENAME: string;
  58717. /**
  58718. * The controller name prefix for this controller type
  58719. */
  58720. static readonly GAMEPAD_ID_PREFIX: string;
  58721. /**
  58722. * The controller id pattern for this controller type
  58723. */
  58724. private static readonly GAMEPAD_ID_PATTERN;
  58725. private _loadedMeshInfo;
  58726. protected readonly _mapping: {
  58727. buttons: string[];
  58728. buttonMeshNames: {
  58729. trigger: string;
  58730. menu: string;
  58731. grip: string;
  58732. thumbstick: string;
  58733. trackpad: string;
  58734. };
  58735. buttonObservableNames: {
  58736. trigger: string;
  58737. menu: string;
  58738. grip: string;
  58739. thumbstick: string;
  58740. trackpad: string;
  58741. };
  58742. axisMeshNames: string[];
  58743. pointingPoseMeshName: string;
  58744. };
  58745. /**
  58746. * Fired when the trackpad on this controller is clicked
  58747. */
  58748. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58749. /**
  58750. * Fired when the trackpad on this controller is modified
  58751. */
  58752. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58753. /**
  58754. * The current x and y values of this controller's trackpad
  58755. */
  58756. trackpad: StickValues;
  58757. /**
  58758. * Creates a new WindowsMotionController from a gamepad
  58759. * @param vrGamepad the gamepad that the controller should be created from
  58760. */
  58761. constructor(vrGamepad: any);
  58762. /**
  58763. * Fired when the trigger on this controller is modified
  58764. */
  58765. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58766. /**
  58767. * Fired when the menu button on this controller is modified
  58768. */
  58769. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58770. /**
  58771. * Fired when the grip button on this controller is modified
  58772. */
  58773. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58774. /**
  58775. * Fired when the thumbstick button on this controller is modified
  58776. */
  58777. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58778. /**
  58779. * Fired when the touchpad button on this controller is modified
  58780. */
  58781. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58782. /**
  58783. * Fired when the touchpad values on this controller are modified
  58784. */
  58785. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58786. protected _updateTrackpad(): void;
  58787. /**
  58788. * Called once per frame by the engine.
  58789. */
  58790. update(): void;
  58791. /**
  58792. * Called once for each button that changed state since the last frame
  58793. * @param buttonIdx Which button index changed
  58794. * @param state New state of the button
  58795. * @param changes Which properties on the state changed since last frame
  58796. */
  58797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58798. /**
  58799. * Moves the buttons on the controller mesh based on their current state
  58800. * @param buttonName the name of the button to move
  58801. * @param buttonValue the value of the button which determines the buttons new position
  58802. */
  58803. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58804. /**
  58805. * Moves the axis on the controller mesh based on its current state
  58806. * @param axis the index of the axis
  58807. * @param axisValue the value of the axis which determines the meshes new position
  58808. * @hidden
  58809. */
  58810. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58811. /**
  58812. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58813. * @param scene scene in which to add meshes
  58814. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58815. */
  58816. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58817. /**
  58818. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58819. * can be transformed by button presses and axes values, based on this._mapping.
  58820. *
  58821. * @param scene scene in which the meshes exist
  58822. * @param meshes list of meshes that make up the controller model to process
  58823. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58824. */
  58825. private processModel;
  58826. private createMeshInfo;
  58827. /**
  58828. * Gets the ray of the controller in the direction the controller is pointing
  58829. * @param length the length the resulting ray should be
  58830. * @returns a ray in the direction the controller is pointing
  58831. */
  58832. getForwardRay(length?: number): Ray;
  58833. /**
  58834. * Disposes of the controller
  58835. */
  58836. dispose(): void;
  58837. }
  58838. /**
  58839. * This class represents a new windows motion controller in XR.
  58840. */
  58841. export class XRWindowsMotionController extends WindowsMotionController {
  58842. /**
  58843. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58844. */
  58845. protected readonly _mapping: {
  58846. buttons: string[];
  58847. buttonMeshNames: {
  58848. trigger: string;
  58849. menu: string;
  58850. grip: string;
  58851. thumbstick: string;
  58852. trackpad: string;
  58853. };
  58854. buttonObservableNames: {
  58855. trigger: string;
  58856. menu: string;
  58857. grip: string;
  58858. thumbstick: string;
  58859. trackpad: string;
  58860. };
  58861. axisMeshNames: string[];
  58862. pointingPoseMeshName: string;
  58863. };
  58864. /**
  58865. * Construct a new XR-Based windows motion controller
  58866. *
  58867. * @param gamepadInfo the gamepad object from the browser
  58868. */
  58869. constructor(gamepadInfo: any);
  58870. /**
  58871. * holds the thumbstick values (X,Y)
  58872. */
  58873. thumbstickValues: StickValues;
  58874. /**
  58875. * Fired when the thumbstick on this controller is clicked
  58876. */
  58877. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58878. /**
  58879. * Fired when the thumbstick on this controller is modified
  58880. */
  58881. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58882. /**
  58883. * Fired when the touchpad button on this controller is modified
  58884. */
  58885. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58886. /**
  58887. * Fired when the touchpad values on this controller are modified
  58888. */
  58889. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58890. /**
  58891. * Fired when the thumbstick button on this controller is modified
  58892. * here to prevent breaking changes
  58893. */
  58894. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58895. /**
  58896. * updating the thumbstick(!) and not the trackpad.
  58897. * This is named this way due to the difference between WebVR and XR and to avoid
  58898. * changing the parent class.
  58899. */
  58900. protected _updateTrackpad(): void;
  58901. /**
  58902. * Disposes the class with joy
  58903. */
  58904. dispose(): void;
  58905. }
  58906. }
  58907. declare module "babylonjs/Gamepads/Controllers/index" {
  58908. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58909. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58910. export * from "babylonjs/Gamepads/Controllers/genericController";
  58911. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58912. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58913. export * from "babylonjs/Gamepads/Controllers/viveController";
  58914. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58915. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58916. }
  58917. declare module "babylonjs/Gamepads/index" {
  58918. export * from "babylonjs/Gamepads/Controllers/index";
  58919. export * from "babylonjs/Gamepads/gamepad";
  58920. export * from "babylonjs/Gamepads/gamepadManager";
  58921. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58922. export * from "babylonjs/Gamepads/xboxGamepad";
  58923. export * from "babylonjs/Gamepads/dualShockGamepad";
  58924. }
  58925. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58926. import { Scene } from "babylonjs/scene";
  58927. import { Vector4 } from "babylonjs/Maths/math.vector";
  58928. import { Color4 } from "babylonjs/Maths/math.color";
  58929. import { Mesh } from "babylonjs/Meshes/mesh";
  58930. import { Nullable } from "babylonjs/types";
  58931. /**
  58932. * Class containing static functions to help procedurally build meshes
  58933. */
  58934. export class PolyhedronBuilder {
  58935. /**
  58936. * Creates a polyhedron mesh
  58937. * * 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
  58938. * * The parameter `size` (positive float, default 1) sets the polygon size
  58939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58940. * * 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`
  58941. * * 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
  58942. * * 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)`)
  58943. * * 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
  58944. * * 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
  58945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58948. * @param name defines the name of the mesh
  58949. * @param options defines the options used to create the mesh
  58950. * @param scene defines the hosting scene
  58951. * @returns the polyhedron mesh
  58952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58953. */
  58954. static CreatePolyhedron(name: string, options: {
  58955. type?: number;
  58956. size?: number;
  58957. sizeX?: number;
  58958. sizeY?: number;
  58959. sizeZ?: number;
  58960. custom?: any;
  58961. faceUV?: Vector4[];
  58962. faceColors?: Color4[];
  58963. flat?: boolean;
  58964. updatable?: boolean;
  58965. sideOrientation?: number;
  58966. frontUVs?: Vector4;
  58967. backUVs?: Vector4;
  58968. }, scene?: Nullable<Scene>): Mesh;
  58969. }
  58970. }
  58971. declare module "babylonjs/Gizmos/scaleGizmo" {
  58972. import { Observable } from "babylonjs/Misc/observable";
  58973. import { Nullable } from "babylonjs/types";
  58974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58975. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58976. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58977. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58978. import { Node } from "babylonjs/node";
  58979. /**
  58980. * Gizmo that enables scaling a mesh along 3 axis
  58981. */
  58982. export class ScaleGizmo extends Gizmo {
  58983. /**
  58984. * Internal gizmo used for interactions on the x axis
  58985. */
  58986. xGizmo: AxisScaleGizmo;
  58987. /**
  58988. * Internal gizmo used for interactions on the y axis
  58989. */
  58990. yGizmo: AxisScaleGizmo;
  58991. /**
  58992. * Internal gizmo used for interactions on the z axis
  58993. */
  58994. zGizmo: AxisScaleGizmo;
  58995. /**
  58996. * Internal gizmo used to scale all axis equally
  58997. */
  58998. uniformScaleGizmo: AxisScaleGizmo;
  58999. private _meshAttached;
  59000. private _nodeAttached;
  59001. private _snapDistance;
  59002. private _uniformScalingMesh;
  59003. private _octahedron;
  59004. private _sensitivity;
  59005. /** Fires an event when any of it's sub gizmos are dragged */
  59006. onDragStartObservable: Observable<unknown>;
  59007. /** Fires an event when any of it's sub gizmos are released from dragging */
  59008. onDragEndObservable: Observable<unknown>;
  59009. get attachedMesh(): Nullable<AbstractMesh>;
  59010. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59011. get attachedNode(): Nullable<Node>;
  59012. set attachedNode(node: Nullable<Node>);
  59013. /**
  59014. * True when the mouse pointer is hovering a gizmo mesh
  59015. */
  59016. get isHovered(): boolean;
  59017. /**
  59018. * Creates a ScaleGizmo
  59019. * @param gizmoLayer The utility layer the gizmo will be added to
  59020. * @param thickness display gizmo axis thickness
  59021. */
  59022. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59023. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59024. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59025. /**
  59026. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59027. */
  59028. set snapDistance(value: number);
  59029. get snapDistance(): number;
  59030. /**
  59031. * Ratio for the scale of the gizmo (Default: 1)
  59032. */
  59033. set scaleRatio(value: number);
  59034. get scaleRatio(): number;
  59035. /**
  59036. * Sensitivity factor for dragging (Default: 1)
  59037. */
  59038. set sensitivity(value: number);
  59039. get sensitivity(): number;
  59040. /**
  59041. * Disposes of the gizmo
  59042. */
  59043. dispose(): void;
  59044. }
  59045. }
  59046. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59047. import { Observable } from "babylonjs/Misc/observable";
  59048. import { Nullable } from "babylonjs/types";
  59049. import { Vector3 } from "babylonjs/Maths/math.vector";
  59050. import { Node } from "babylonjs/node";
  59051. import { Mesh } from "babylonjs/Meshes/mesh";
  59052. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59053. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59054. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59055. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59056. import { Color3 } from "babylonjs/Maths/math.color";
  59057. /**
  59058. * Single axis scale gizmo
  59059. */
  59060. export class AxisScaleGizmo extends Gizmo {
  59061. /**
  59062. * Drag behavior responsible for the gizmos dragging interactions
  59063. */
  59064. dragBehavior: PointerDragBehavior;
  59065. private _pointerObserver;
  59066. /**
  59067. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59068. */
  59069. snapDistance: number;
  59070. /**
  59071. * Event that fires each time the gizmo snaps to a new location.
  59072. * * snapDistance is the the change in distance
  59073. */
  59074. onSnapObservable: Observable<{
  59075. snapDistance: number;
  59076. }>;
  59077. /**
  59078. * If the scaling operation should be done on all axis (default: false)
  59079. */
  59080. uniformScaling: boolean;
  59081. /**
  59082. * Custom sensitivity value for the drag strength
  59083. */
  59084. sensitivity: number;
  59085. private _isEnabled;
  59086. private _parent;
  59087. private _arrow;
  59088. private _coloredMaterial;
  59089. private _hoverMaterial;
  59090. /**
  59091. * Creates an AxisScaleGizmo
  59092. * @param gizmoLayer The utility layer the gizmo will be added to
  59093. * @param dragAxis The axis which the gizmo will be able to scale on
  59094. * @param color The color of the gizmo
  59095. * @param thickness display gizmo axis thickness
  59096. */
  59097. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59098. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59099. /**
  59100. * If the gizmo is enabled
  59101. */
  59102. set isEnabled(value: boolean);
  59103. get isEnabled(): boolean;
  59104. /**
  59105. * Disposes of the gizmo
  59106. */
  59107. dispose(): void;
  59108. /**
  59109. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59110. * @param mesh The mesh to replace the default mesh of the gizmo
  59111. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59112. */
  59113. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59114. }
  59115. }
  59116. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59117. import { Observable } from "babylonjs/Misc/observable";
  59118. import { Nullable } from "babylonjs/types";
  59119. import { Vector3 } from "babylonjs/Maths/math.vector";
  59120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59121. import { Mesh } from "babylonjs/Meshes/mesh";
  59122. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59123. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59124. import { Color3 } from "babylonjs/Maths/math.color";
  59125. import "babylonjs/Meshes/Builders/boxBuilder";
  59126. /**
  59127. * Bounding box gizmo
  59128. */
  59129. export class BoundingBoxGizmo extends Gizmo {
  59130. private _lineBoundingBox;
  59131. private _rotateSpheresParent;
  59132. private _scaleBoxesParent;
  59133. private _boundingDimensions;
  59134. private _renderObserver;
  59135. private _pointerObserver;
  59136. private _scaleDragSpeed;
  59137. private _tmpQuaternion;
  59138. private _tmpVector;
  59139. private _tmpRotationMatrix;
  59140. /**
  59141. * 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)
  59142. */
  59143. ignoreChildren: boolean;
  59144. /**
  59145. * 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)
  59146. */
  59147. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59148. /**
  59149. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59150. */
  59151. rotationSphereSize: number;
  59152. /**
  59153. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59154. */
  59155. scaleBoxSize: number;
  59156. /**
  59157. * 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)
  59158. */
  59159. fixedDragMeshScreenSize: boolean;
  59160. /**
  59161. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59162. */
  59163. fixedDragMeshScreenSizeDistanceFactor: number;
  59164. /**
  59165. * Fired when a rotation sphere or scale box is dragged
  59166. */
  59167. onDragStartObservable: Observable<{}>;
  59168. /**
  59169. * Fired when a scale box is dragged
  59170. */
  59171. onScaleBoxDragObservable: Observable<{}>;
  59172. /**
  59173. * Fired when a scale box drag is ended
  59174. */
  59175. onScaleBoxDragEndObservable: Observable<{}>;
  59176. /**
  59177. * Fired when a rotation sphere is dragged
  59178. */
  59179. onRotationSphereDragObservable: Observable<{}>;
  59180. /**
  59181. * Fired when a rotation sphere drag is ended
  59182. */
  59183. onRotationSphereDragEndObservable: Observable<{}>;
  59184. /**
  59185. * 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)
  59186. */
  59187. scalePivot: Nullable<Vector3>;
  59188. /**
  59189. * Mesh used as a pivot to rotate the attached node
  59190. */
  59191. private _anchorMesh;
  59192. private _existingMeshScale;
  59193. private _dragMesh;
  59194. private pointerDragBehavior;
  59195. private coloredMaterial;
  59196. private hoverColoredMaterial;
  59197. /**
  59198. * Sets the color of the bounding box gizmo
  59199. * @param color the color to set
  59200. */
  59201. setColor(color: Color3): void;
  59202. /**
  59203. * Creates an BoundingBoxGizmo
  59204. * @param gizmoLayer The utility layer the gizmo will be added to
  59205. * @param color The color of the gizmo
  59206. */
  59207. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59208. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59209. private _selectNode;
  59210. /**
  59211. * Updates the bounding box information for the Gizmo
  59212. */
  59213. updateBoundingBox(): void;
  59214. private _updateRotationSpheres;
  59215. private _updateScaleBoxes;
  59216. /**
  59217. * Enables rotation on the specified axis and disables rotation on the others
  59218. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59219. */
  59220. setEnabledRotationAxis(axis: string): void;
  59221. /**
  59222. * Enables/disables scaling
  59223. * @param enable if scaling should be enabled
  59224. * @param homogeneousScaling defines if scaling should only be homogeneous
  59225. */
  59226. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59227. private _updateDummy;
  59228. /**
  59229. * Enables a pointer drag behavior on the bounding box of the gizmo
  59230. */
  59231. enableDragBehavior(): void;
  59232. /**
  59233. * Disposes of the gizmo
  59234. */
  59235. dispose(): void;
  59236. /**
  59237. * 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)
  59238. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59239. * @returns the bounding box mesh with the passed in mesh as a child
  59240. */
  59241. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59242. /**
  59243. * CustomMeshes are not supported by this gizmo
  59244. * @param mesh The mesh to replace the default mesh of the gizmo
  59245. */
  59246. setCustomMesh(mesh: Mesh): void;
  59247. }
  59248. }
  59249. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59250. import { Observable } from "babylonjs/Misc/observable";
  59251. import { Nullable } from "babylonjs/types";
  59252. import { Vector3 } from "babylonjs/Maths/math.vector";
  59253. import { Color3 } from "babylonjs/Maths/math.color";
  59254. import { Node } from "babylonjs/node";
  59255. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59256. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59257. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59258. import "babylonjs/Meshes/Builders/linesBuilder";
  59259. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59260. /**
  59261. * Single plane rotation gizmo
  59262. */
  59263. export class PlaneRotationGizmo extends Gizmo {
  59264. /**
  59265. * Drag behavior responsible for the gizmos dragging interactions
  59266. */
  59267. dragBehavior: PointerDragBehavior;
  59268. private _pointerObserver;
  59269. /**
  59270. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59271. */
  59272. snapDistance: number;
  59273. /**
  59274. * Event that fires each time the gizmo snaps to a new location.
  59275. * * snapDistance is the the change in distance
  59276. */
  59277. onSnapObservable: Observable<{
  59278. snapDistance: number;
  59279. }>;
  59280. private _isEnabled;
  59281. private _parent;
  59282. /**
  59283. * Creates a PlaneRotationGizmo
  59284. * @param gizmoLayer The utility layer the gizmo will be added to
  59285. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59286. * @param color The color of the gizmo
  59287. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59288. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59289. * @param thickness display gizmo axis thickness
  59290. */
  59291. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59292. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59293. /**
  59294. * If the gizmo is enabled
  59295. */
  59296. set isEnabled(value: boolean);
  59297. get isEnabled(): boolean;
  59298. /**
  59299. * Disposes of the gizmo
  59300. */
  59301. dispose(): void;
  59302. }
  59303. }
  59304. declare module "babylonjs/Gizmos/rotationGizmo" {
  59305. import { Observable } from "babylonjs/Misc/observable";
  59306. import { Nullable } from "babylonjs/types";
  59307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59308. import { Mesh } from "babylonjs/Meshes/mesh";
  59309. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59310. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59311. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59312. import { Node } from "babylonjs/node";
  59313. /**
  59314. * Gizmo that enables rotating a mesh along 3 axis
  59315. */
  59316. export class RotationGizmo extends Gizmo {
  59317. /**
  59318. * Internal gizmo used for interactions on the x axis
  59319. */
  59320. xGizmo: PlaneRotationGizmo;
  59321. /**
  59322. * Internal gizmo used for interactions on the y axis
  59323. */
  59324. yGizmo: PlaneRotationGizmo;
  59325. /**
  59326. * Internal gizmo used for interactions on the z axis
  59327. */
  59328. zGizmo: PlaneRotationGizmo;
  59329. /** Fires an event when any of it's sub gizmos are dragged */
  59330. onDragStartObservable: Observable<unknown>;
  59331. /** Fires an event when any of it's sub gizmos are released from dragging */
  59332. onDragEndObservable: Observable<unknown>;
  59333. private _meshAttached;
  59334. private _nodeAttached;
  59335. get attachedMesh(): Nullable<AbstractMesh>;
  59336. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59337. get attachedNode(): Nullable<Node>;
  59338. set attachedNode(node: Nullable<Node>);
  59339. protected _checkBillboardTransform(): void;
  59340. /**
  59341. * True when the mouse pointer is hovering a gizmo mesh
  59342. */
  59343. get isHovered(): boolean;
  59344. /**
  59345. * Creates a RotationGizmo
  59346. * @param gizmoLayer The utility layer the gizmo will be added to
  59347. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59348. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59349. * @param thickness display gizmo axis thickness
  59350. */
  59351. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59352. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59353. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59354. /**
  59355. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59356. */
  59357. set snapDistance(value: number);
  59358. get snapDistance(): number;
  59359. /**
  59360. * Ratio for the scale of the gizmo (Default: 1)
  59361. */
  59362. set scaleRatio(value: number);
  59363. get scaleRatio(): number;
  59364. /**
  59365. * Disposes of the gizmo
  59366. */
  59367. dispose(): void;
  59368. /**
  59369. * CustomMeshes are not supported by this gizmo
  59370. * @param mesh The mesh to replace the default mesh of the gizmo
  59371. */
  59372. setCustomMesh(mesh: Mesh): void;
  59373. }
  59374. }
  59375. declare module "babylonjs/Gizmos/gizmoManager" {
  59376. import { Observable } from "babylonjs/Misc/observable";
  59377. import { Nullable } from "babylonjs/types";
  59378. import { Scene, IDisposable } from "babylonjs/scene";
  59379. import { Node } from "babylonjs/node";
  59380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59381. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59382. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59383. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59384. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59385. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59386. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59387. /**
  59388. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59389. */
  59390. export class GizmoManager implements IDisposable {
  59391. private scene;
  59392. /**
  59393. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59394. */
  59395. gizmos: {
  59396. positionGizmo: Nullable<PositionGizmo>;
  59397. rotationGizmo: Nullable<RotationGizmo>;
  59398. scaleGizmo: Nullable<ScaleGizmo>;
  59399. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59400. };
  59401. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59402. clearGizmoOnEmptyPointerEvent: boolean;
  59403. /** Fires an event when the manager is attached to a mesh */
  59404. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59405. /** Fires an event when the manager is attached to a node */
  59406. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59407. private _gizmosEnabled;
  59408. private _pointerObserver;
  59409. private _attachedMesh;
  59410. private _attachedNode;
  59411. private _boundingBoxColor;
  59412. private _defaultUtilityLayer;
  59413. private _defaultKeepDepthUtilityLayer;
  59414. private _thickness;
  59415. /**
  59416. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59417. */
  59418. boundingBoxDragBehavior: SixDofDragBehavior;
  59419. /**
  59420. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59421. */
  59422. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59423. /**
  59424. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59425. */
  59426. attachableNodes: Nullable<Array<Node>>;
  59427. /**
  59428. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59429. */
  59430. usePointerToAttachGizmos: boolean;
  59431. /**
  59432. * Utility layer that the bounding box gizmo belongs to
  59433. */
  59434. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59435. /**
  59436. * Utility layer that all gizmos besides bounding box belong to
  59437. */
  59438. get utilityLayer(): UtilityLayerRenderer;
  59439. /**
  59440. * True when the mouse pointer is hovering a gizmo mesh
  59441. */
  59442. get isHovered(): boolean;
  59443. /**
  59444. * Instatiates a gizmo manager
  59445. * @param scene the scene to overlay the gizmos on top of
  59446. * @param thickness display gizmo axis thickness
  59447. */
  59448. constructor(scene: Scene, thickness?: number);
  59449. /**
  59450. * Attaches a set of gizmos to the specified mesh
  59451. * @param mesh The mesh the gizmo's should be attached to
  59452. */
  59453. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59454. /**
  59455. * Attaches a set of gizmos to the specified node
  59456. * @param node The node the gizmo's should be attached to
  59457. */
  59458. attachToNode(node: Nullable<Node>): void;
  59459. /**
  59460. * If the position gizmo is enabled
  59461. */
  59462. set positionGizmoEnabled(value: boolean);
  59463. get positionGizmoEnabled(): boolean;
  59464. /**
  59465. * If the rotation gizmo is enabled
  59466. */
  59467. set rotationGizmoEnabled(value: boolean);
  59468. get rotationGizmoEnabled(): boolean;
  59469. /**
  59470. * If the scale gizmo is enabled
  59471. */
  59472. set scaleGizmoEnabled(value: boolean);
  59473. get scaleGizmoEnabled(): boolean;
  59474. /**
  59475. * If the boundingBox gizmo is enabled
  59476. */
  59477. set boundingBoxGizmoEnabled(value: boolean);
  59478. get boundingBoxGizmoEnabled(): boolean;
  59479. /**
  59480. * Disposes of the gizmo manager
  59481. */
  59482. dispose(): void;
  59483. }
  59484. }
  59485. declare module "babylonjs/Lights/directionalLight" {
  59486. import { Camera } from "babylonjs/Cameras/camera";
  59487. import { Scene } from "babylonjs/scene";
  59488. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59490. import { Light } from "babylonjs/Lights/light";
  59491. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59492. import { Effect } from "babylonjs/Materials/effect";
  59493. /**
  59494. * A directional light is defined by a direction (what a surprise!).
  59495. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59496. * 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.
  59497. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59498. */
  59499. export class DirectionalLight extends ShadowLight {
  59500. private _shadowFrustumSize;
  59501. /**
  59502. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59503. */
  59504. get shadowFrustumSize(): number;
  59505. /**
  59506. * Specifies a fix frustum size for the shadow generation.
  59507. */
  59508. set shadowFrustumSize(value: number);
  59509. private _shadowOrthoScale;
  59510. /**
  59511. * Gets the shadow projection scale against the optimal computed one.
  59512. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59513. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59514. */
  59515. get shadowOrthoScale(): number;
  59516. /**
  59517. * Sets the shadow projection scale against the optimal computed one.
  59518. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59519. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59520. */
  59521. set shadowOrthoScale(value: number);
  59522. /**
  59523. * Automatically compute the projection matrix to best fit (including all the casters)
  59524. * on each frame.
  59525. */
  59526. autoUpdateExtends: boolean;
  59527. /**
  59528. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59529. * on each frame. autoUpdateExtends must be set to true for this to work
  59530. */
  59531. autoCalcShadowZBounds: boolean;
  59532. private _orthoLeft;
  59533. private _orthoRight;
  59534. private _orthoTop;
  59535. private _orthoBottom;
  59536. /**
  59537. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59538. * The directional light is emitted from everywhere in the given direction.
  59539. * It can cast shadows.
  59540. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59541. * @param name The friendly name of the light
  59542. * @param direction The direction of the light
  59543. * @param scene The scene the light belongs to
  59544. */
  59545. constructor(name: string, direction: Vector3, scene: Scene);
  59546. /**
  59547. * Returns the string "DirectionalLight".
  59548. * @return The class name
  59549. */
  59550. getClassName(): string;
  59551. /**
  59552. * Returns the integer 1.
  59553. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59554. */
  59555. getTypeID(): number;
  59556. /**
  59557. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59558. * Returns the DirectionalLight Shadow projection matrix.
  59559. */
  59560. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59561. /**
  59562. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59563. * Returns the DirectionalLight Shadow projection matrix.
  59564. */
  59565. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59566. /**
  59567. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59568. * Returns the DirectionalLight Shadow projection matrix.
  59569. */
  59570. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59571. protected _buildUniformLayout(): void;
  59572. /**
  59573. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59574. * @param effect The effect to update
  59575. * @param lightIndex The index of the light in the effect to update
  59576. * @returns The directional light
  59577. */
  59578. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59580. /**
  59581. * Gets the minZ used for shadow according to both the scene and the light.
  59582. *
  59583. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59584. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59585. * @param activeCamera The camera we are returning the min for
  59586. * @returns the depth min z
  59587. */
  59588. getDepthMinZ(activeCamera: Camera): number;
  59589. /**
  59590. * Gets the maxZ used for shadow according to both the scene and the light.
  59591. *
  59592. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59593. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59594. * @param activeCamera The camera we are returning the max for
  59595. * @returns the depth max z
  59596. */
  59597. getDepthMaxZ(activeCamera: Camera): number;
  59598. /**
  59599. * Prepares the list of defines specific to the light type.
  59600. * @param defines the list of defines
  59601. * @param lightIndex defines the index of the light for the effect
  59602. */
  59603. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59604. }
  59605. }
  59606. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59607. import { Mesh } from "babylonjs/Meshes/mesh";
  59608. /**
  59609. * Class containing static functions to help procedurally build meshes
  59610. */
  59611. export class HemisphereBuilder {
  59612. /**
  59613. * Creates a hemisphere mesh
  59614. * @param name defines the name of the mesh
  59615. * @param options defines the options used to create the mesh
  59616. * @param scene defines the hosting scene
  59617. * @returns the hemisphere mesh
  59618. */
  59619. static CreateHemisphere(name: string, options: {
  59620. segments?: number;
  59621. diameter?: number;
  59622. sideOrientation?: number;
  59623. }, scene: any): Mesh;
  59624. }
  59625. }
  59626. declare module "babylonjs/Lights/spotLight" {
  59627. import { Nullable } from "babylonjs/types";
  59628. import { Scene } from "babylonjs/scene";
  59629. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59631. import { Effect } from "babylonjs/Materials/effect";
  59632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59633. import { Light } from "babylonjs/Lights/light";
  59634. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59635. /**
  59636. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59637. * These values define a cone of light starting from the position, emitting toward the direction.
  59638. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59639. * and the exponent defines the speed of the decay of the light with distance (reach).
  59640. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59641. */
  59642. export class SpotLight extends ShadowLight {
  59643. private _angle;
  59644. private _innerAngle;
  59645. private _cosHalfAngle;
  59646. private _lightAngleScale;
  59647. private _lightAngleOffset;
  59648. /**
  59649. * Gets the cone angle of the spot light in Radians.
  59650. */
  59651. get angle(): number;
  59652. /**
  59653. * Sets the cone angle of the spot light in Radians.
  59654. */
  59655. set angle(value: number);
  59656. /**
  59657. * Only used in gltf falloff mode, this defines the angle where
  59658. * the directional falloff will start before cutting at angle which could be seen
  59659. * as outer angle.
  59660. */
  59661. get innerAngle(): number;
  59662. /**
  59663. * Only used in gltf falloff mode, this defines the angle where
  59664. * the directional falloff will start before cutting at angle which could be seen
  59665. * as outer angle.
  59666. */
  59667. set innerAngle(value: number);
  59668. private _shadowAngleScale;
  59669. /**
  59670. * Allows scaling the angle of the light for shadow generation only.
  59671. */
  59672. get shadowAngleScale(): number;
  59673. /**
  59674. * Allows scaling the angle of the light for shadow generation only.
  59675. */
  59676. set shadowAngleScale(value: number);
  59677. /**
  59678. * The light decay speed with the distance from the emission spot.
  59679. */
  59680. exponent: number;
  59681. private _projectionTextureMatrix;
  59682. /**
  59683. * Allows reading the projecton texture
  59684. */
  59685. get projectionTextureMatrix(): Matrix;
  59686. protected _projectionTextureLightNear: number;
  59687. /**
  59688. * Gets the near clip of the Spotlight for texture projection.
  59689. */
  59690. get projectionTextureLightNear(): number;
  59691. /**
  59692. * Sets the near clip of the Spotlight for texture projection.
  59693. */
  59694. set projectionTextureLightNear(value: number);
  59695. protected _projectionTextureLightFar: number;
  59696. /**
  59697. * Gets the far clip of the Spotlight for texture projection.
  59698. */
  59699. get projectionTextureLightFar(): number;
  59700. /**
  59701. * Sets the far clip of the Spotlight for texture projection.
  59702. */
  59703. set projectionTextureLightFar(value: number);
  59704. protected _projectionTextureUpDirection: Vector3;
  59705. /**
  59706. * Gets the Up vector of the Spotlight for texture projection.
  59707. */
  59708. get projectionTextureUpDirection(): Vector3;
  59709. /**
  59710. * Sets the Up vector of the Spotlight for texture projection.
  59711. */
  59712. set projectionTextureUpDirection(value: Vector3);
  59713. private _projectionTexture;
  59714. /**
  59715. * Gets the projection texture of the light.
  59716. */
  59717. get projectionTexture(): Nullable<BaseTexture>;
  59718. /**
  59719. * Sets the projection texture of the light.
  59720. */
  59721. set projectionTexture(value: Nullable<BaseTexture>);
  59722. private _projectionTextureViewLightDirty;
  59723. private _projectionTextureProjectionLightDirty;
  59724. private _projectionTextureDirty;
  59725. private _projectionTextureViewTargetVector;
  59726. private _projectionTextureViewLightMatrix;
  59727. private _projectionTextureProjectionLightMatrix;
  59728. private _projectionTextureScalingMatrix;
  59729. /**
  59730. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59731. * It can cast shadows.
  59732. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59733. * @param name The light friendly name
  59734. * @param position The position of the spot light in the scene
  59735. * @param direction The direction of the light in the scene
  59736. * @param angle The cone angle of the light in Radians
  59737. * @param exponent The light decay speed with the distance from the emission spot
  59738. * @param scene The scene the lights belongs to
  59739. */
  59740. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59741. /**
  59742. * Returns the string "SpotLight".
  59743. * @returns the class name
  59744. */
  59745. getClassName(): string;
  59746. /**
  59747. * Returns the integer 2.
  59748. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59749. */
  59750. getTypeID(): number;
  59751. /**
  59752. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59753. */
  59754. protected _setDirection(value: Vector3): void;
  59755. /**
  59756. * Overrides the position setter to recompute the projection texture view light Matrix.
  59757. */
  59758. protected _setPosition(value: Vector3): void;
  59759. /**
  59760. * 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.
  59761. * Returns the SpotLight.
  59762. */
  59763. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59764. protected _computeProjectionTextureViewLightMatrix(): void;
  59765. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59766. /**
  59767. * Main function for light texture projection matrix computing.
  59768. */
  59769. protected _computeProjectionTextureMatrix(): void;
  59770. protected _buildUniformLayout(): void;
  59771. private _computeAngleValues;
  59772. /**
  59773. * Sets the passed Effect "effect" with the Light textures.
  59774. * @param effect The effect to update
  59775. * @param lightIndex The index of the light in the effect to update
  59776. * @returns The light
  59777. */
  59778. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59779. /**
  59780. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59781. * @param effect The effect to update
  59782. * @param lightIndex The index of the light in the effect to update
  59783. * @returns The spot light
  59784. */
  59785. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59786. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59787. /**
  59788. * Disposes the light and the associated resources.
  59789. */
  59790. dispose(): void;
  59791. /**
  59792. * Prepares the list of defines specific to the light type.
  59793. * @param defines the list of defines
  59794. * @param lightIndex defines the index of the light for the effect
  59795. */
  59796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59797. }
  59798. }
  59799. declare module "babylonjs/Gizmos/lightGizmo" {
  59800. import { Nullable } from "babylonjs/types";
  59801. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59802. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59803. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59804. import { Light } from "babylonjs/Lights/light";
  59805. import { Observable } from "babylonjs/Misc/observable";
  59806. /**
  59807. * Gizmo that enables viewing a light
  59808. */
  59809. export class LightGizmo extends Gizmo {
  59810. private _lightMesh;
  59811. private _material;
  59812. private _cachedPosition;
  59813. private _cachedForward;
  59814. private _attachedMeshParent;
  59815. private _pointerObserver;
  59816. /**
  59817. * Event that fires each time the gizmo is clicked
  59818. */
  59819. onClickedObservable: Observable<Light>;
  59820. /**
  59821. * Creates a LightGizmo
  59822. * @param gizmoLayer The utility layer the gizmo will be added to
  59823. */
  59824. constructor(gizmoLayer?: UtilityLayerRenderer);
  59825. private _light;
  59826. /**
  59827. * The light that the gizmo is attached to
  59828. */
  59829. set light(light: Nullable<Light>);
  59830. get light(): Nullable<Light>;
  59831. /**
  59832. * Gets the material used to render the light gizmo
  59833. */
  59834. get material(): StandardMaterial;
  59835. /**
  59836. * @hidden
  59837. * Updates the gizmo to match the attached mesh's position/rotation
  59838. */
  59839. protected _update(): void;
  59840. private static _Scale;
  59841. /**
  59842. * Creates the lines for a light mesh
  59843. */
  59844. private static _CreateLightLines;
  59845. /**
  59846. * Disposes of the light gizmo
  59847. */
  59848. dispose(): void;
  59849. private static _CreateHemisphericLightMesh;
  59850. private static _CreatePointLightMesh;
  59851. private static _CreateSpotLightMesh;
  59852. private static _CreateDirectionalLightMesh;
  59853. }
  59854. }
  59855. declare module "babylonjs/Gizmos/cameraGizmo" {
  59856. import { Nullable } from "babylonjs/types";
  59857. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59858. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59859. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59860. import { Camera } from "babylonjs/Cameras/camera";
  59861. import { Observable } from "babylonjs/Misc/observable";
  59862. /**
  59863. * Gizmo that enables viewing a camera
  59864. */
  59865. export class CameraGizmo extends Gizmo {
  59866. private _cameraMesh;
  59867. private _cameraLinesMesh;
  59868. private _material;
  59869. private _pointerObserver;
  59870. /**
  59871. * Event that fires each time the gizmo is clicked
  59872. */
  59873. onClickedObservable: Observable<Camera>;
  59874. /**
  59875. * Creates a CameraGizmo
  59876. * @param gizmoLayer The utility layer the gizmo will be added to
  59877. */
  59878. constructor(gizmoLayer?: UtilityLayerRenderer);
  59879. private _camera;
  59880. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59881. get displayFrustum(): boolean;
  59882. set displayFrustum(value: boolean);
  59883. /**
  59884. * The camera that the gizmo is attached to
  59885. */
  59886. set camera(camera: Nullable<Camera>);
  59887. get camera(): Nullable<Camera>;
  59888. /**
  59889. * Gets the material used to render the camera gizmo
  59890. */
  59891. get material(): StandardMaterial;
  59892. /**
  59893. * @hidden
  59894. * Updates the gizmo to match the attached mesh's position/rotation
  59895. */
  59896. protected _update(): void;
  59897. private static _Scale;
  59898. private _invProjection;
  59899. /**
  59900. * Disposes of the camera gizmo
  59901. */
  59902. dispose(): void;
  59903. private static _CreateCameraMesh;
  59904. private static _CreateCameraFrustum;
  59905. }
  59906. }
  59907. declare module "babylonjs/Gizmos/index" {
  59908. export * from "babylonjs/Gizmos/axisDragGizmo";
  59909. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59910. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59911. export * from "babylonjs/Gizmos/gizmo";
  59912. export * from "babylonjs/Gizmos/gizmoManager";
  59913. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59914. export * from "babylonjs/Gizmos/positionGizmo";
  59915. export * from "babylonjs/Gizmos/rotationGizmo";
  59916. export * from "babylonjs/Gizmos/scaleGizmo";
  59917. export * from "babylonjs/Gizmos/lightGizmo";
  59918. export * from "babylonjs/Gizmos/cameraGizmo";
  59919. export * from "babylonjs/Gizmos/planeDragGizmo";
  59920. }
  59921. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59922. /** @hidden */
  59923. export var backgroundFragmentDeclaration: {
  59924. name: string;
  59925. shader: string;
  59926. };
  59927. }
  59928. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59929. /** @hidden */
  59930. export var backgroundUboDeclaration: {
  59931. name: string;
  59932. shader: string;
  59933. };
  59934. }
  59935. declare module "babylonjs/Shaders/background.fragment" {
  59936. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59937. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59938. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59939. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59940. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59941. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59942. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59943. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59944. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59945. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59946. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59947. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59948. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59949. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59950. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59951. /** @hidden */
  59952. export var backgroundPixelShader: {
  59953. name: string;
  59954. shader: string;
  59955. };
  59956. }
  59957. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59958. /** @hidden */
  59959. export var backgroundVertexDeclaration: {
  59960. name: string;
  59961. shader: string;
  59962. };
  59963. }
  59964. declare module "babylonjs/Shaders/background.vertex" {
  59965. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59966. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59967. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59968. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59969. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59970. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59971. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59972. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59973. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59974. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59975. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59976. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59977. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59978. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59979. /** @hidden */
  59980. export var backgroundVertexShader: {
  59981. name: string;
  59982. shader: string;
  59983. };
  59984. }
  59985. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59986. import { Nullable, int, float } from "babylonjs/types";
  59987. import { Scene } from "babylonjs/scene";
  59988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59989. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59991. import { Mesh } from "babylonjs/Meshes/mesh";
  59992. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59993. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59994. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59996. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  59997. import { Color3 } from "babylonjs/Maths/math.color";
  59998. import "babylonjs/Shaders/background.fragment";
  59999. import "babylonjs/Shaders/background.vertex";
  60000. /**
  60001. * Background material used to create an efficient environement around your scene.
  60002. */
  60003. export class BackgroundMaterial extends PushMaterial {
  60004. /**
  60005. * Standard reflectance value at parallel view angle.
  60006. */
  60007. static StandardReflectance0: number;
  60008. /**
  60009. * Standard reflectance value at grazing angle.
  60010. */
  60011. static StandardReflectance90: number;
  60012. protected _primaryColor: Color3;
  60013. /**
  60014. * Key light Color (multiply against the environement texture)
  60015. */
  60016. primaryColor: Color3;
  60017. protected __perceptualColor: Nullable<Color3>;
  60018. /**
  60019. * Experimental Internal Use Only.
  60020. *
  60021. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60022. * This acts as a helper to set the primary color to a more "human friendly" value.
  60023. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60024. * output color as close as possible from the chosen value.
  60025. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60026. * part of lighting setup.)
  60027. */
  60028. get _perceptualColor(): Nullable<Color3>;
  60029. set _perceptualColor(value: Nullable<Color3>);
  60030. protected _primaryColorShadowLevel: float;
  60031. /**
  60032. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60033. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60034. */
  60035. get primaryColorShadowLevel(): float;
  60036. set primaryColorShadowLevel(value: float);
  60037. protected _primaryColorHighlightLevel: float;
  60038. /**
  60039. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60040. * The primary color is used at the level chosen to define what the white area would look.
  60041. */
  60042. get primaryColorHighlightLevel(): float;
  60043. set primaryColorHighlightLevel(value: float);
  60044. protected _reflectionTexture: Nullable<BaseTexture>;
  60045. /**
  60046. * Reflection Texture used in the material.
  60047. * Should be author in a specific way for the best result (refer to the documentation).
  60048. */
  60049. reflectionTexture: Nullable<BaseTexture>;
  60050. protected _reflectionBlur: float;
  60051. /**
  60052. * Reflection Texture level of blur.
  60053. *
  60054. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60055. * texture twice.
  60056. */
  60057. reflectionBlur: float;
  60058. protected _diffuseTexture: Nullable<BaseTexture>;
  60059. /**
  60060. * Diffuse Texture used in the material.
  60061. * Should be author in a specific way for the best result (refer to the documentation).
  60062. */
  60063. diffuseTexture: Nullable<BaseTexture>;
  60064. protected _shadowLights: Nullable<IShadowLight[]>;
  60065. /**
  60066. * Specify the list of lights casting shadow on the material.
  60067. * All scene shadow lights will be included if null.
  60068. */
  60069. shadowLights: Nullable<IShadowLight[]>;
  60070. protected _shadowLevel: float;
  60071. /**
  60072. * Helps adjusting the shadow to a softer level if required.
  60073. * 0 means black shadows and 1 means no shadows.
  60074. */
  60075. shadowLevel: float;
  60076. protected _sceneCenter: Vector3;
  60077. /**
  60078. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60079. * It is usually zero but might be interesting to modify according to your setup.
  60080. */
  60081. sceneCenter: Vector3;
  60082. protected _opacityFresnel: boolean;
  60083. /**
  60084. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60085. * This helps ensuring a nice transition when the camera goes under the ground.
  60086. */
  60087. opacityFresnel: boolean;
  60088. protected _reflectionFresnel: boolean;
  60089. /**
  60090. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60091. * This helps adding a mirror texture on the ground.
  60092. */
  60093. reflectionFresnel: boolean;
  60094. protected _reflectionFalloffDistance: number;
  60095. /**
  60096. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60097. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60098. */
  60099. reflectionFalloffDistance: number;
  60100. protected _reflectionAmount: number;
  60101. /**
  60102. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60103. */
  60104. reflectionAmount: number;
  60105. protected _reflectionReflectance0: number;
  60106. /**
  60107. * This specifies the weight of the reflection at grazing angle.
  60108. */
  60109. reflectionReflectance0: number;
  60110. protected _reflectionReflectance90: number;
  60111. /**
  60112. * This specifies the weight of the reflection at a perpendicular point of view.
  60113. */
  60114. reflectionReflectance90: number;
  60115. /**
  60116. * Sets the reflection reflectance fresnel values according to the default standard
  60117. * empirically know to work well :-)
  60118. */
  60119. set reflectionStandardFresnelWeight(value: number);
  60120. protected _useRGBColor: boolean;
  60121. /**
  60122. * Helps to directly use the maps channels instead of their level.
  60123. */
  60124. useRGBColor: boolean;
  60125. protected _enableNoise: boolean;
  60126. /**
  60127. * This helps reducing the banding effect that could occur on the background.
  60128. */
  60129. enableNoise: boolean;
  60130. /**
  60131. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60132. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60133. * Recommended to be keep at 1.0 except for special cases.
  60134. */
  60135. get fovMultiplier(): number;
  60136. set fovMultiplier(value: number);
  60137. private _fovMultiplier;
  60138. /**
  60139. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60140. */
  60141. useEquirectangularFOV: boolean;
  60142. private _maxSimultaneousLights;
  60143. /**
  60144. * Number of Simultaneous lights allowed on the material.
  60145. */
  60146. maxSimultaneousLights: int;
  60147. private _shadowOnly;
  60148. /**
  60149. * Make the material only render shadows
  60150. */
  60151. shadowOnly: boolean;
  60152. /**
  60153. * Default configuration related to image processing available in the Background Material.
  60154. */
  60155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60156. /**
  60157. * Keep track of the image processing observer to allow dispose and replace.
  60158. */
  60159. private _imageProcessingObserver;
  60160. /**
  60161. * Attaches a new image processing configuration to the PBR Material.
  60162. * @param configuration (if null the scene configuration will be use)
  60163. */
  60164. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60165. /**
  60166. * Gets the image processing configuration used either in this material.
  60167. */
  60168. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60169. /**
  60170. * Sets the Default image processing configuration used either in the this material.
  60171. *
  60172. * If sets to null, the scene one is in use.
  60173. */
  60174. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60175. /**
  60176. * Gets wether the color curves effect is enabled.
  60177. */
  60178. get cameraColorCurvesEnabled(): boolean;
  60179. /**
  60180. * Sets wether the color curves effect is enabled.
  60181. */
  60182. set cameraColorCurvesEnabled(value: boolean);
  60183. /**
  60184. * Gets wether the color grading effect is enabled.
  60185. */
  60186. get cameraColorGradingEnabled(): boolean;
  60187. /**
  60188. * Gets wether the color grading effect is enabled.
  60189. */
  60190. set cameraColorGradingEnabled(value: boolean);
  60191. /**
  60192. * Gets wether tonemapping is enabled or not.
  60193. */
  60194. get cameraToneMappingEnabled(): boolean;
  60195. /**
  60196. * Sets wether tonemapping is enabled or not
  60197. */
  60198. set cameraToneMappingEnabled(value: boolean);
  60199. /**
  60200. * The camera exposure used on this material.
  60201. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60202. * This corresponds to a photographic exposure.
  60203. */
  60204. get cameraExposure(): float;
  60205. /**
  60206. * The camera exposure used on this material.
  60207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60208. * This corresponds to a photographic exposure.
  60209. */
  60210. set cameraExposure(value: float);
  60211. /**
  60212. * Gets The camera contrast used on this material.
  60213. */
  60214. get cameraContrast(): float;
  60215. /**
  60216. * Sets The camera contrast used on this material.
  60217. */
  60218. set cameraContrast(value: float);
  60219. /**
  60220. * Gets the Color Grading 2D Lookup Texture.
  60221. */
  60222. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60223. /**
  60224. * Sets the Color Grading 2D Lookup Texture.
  60225. */
  60226. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60227. /**
  60228. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60229. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60230. * 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;
  60231. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60232. */
  60233. get cameraColorCurves(): Nullable<ColorCurves>;
  60234. /**
  60235. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60236. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60237. * 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;
  60238. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60239. */
  60240. set cameraColorCurves(value: Nullable<ColorCurves>);
  60241. /**
  60242. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60243. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60244. */
  60245. switchToBGR: boolean;
  60246. private _renderTargets;
  60247. private _reflectionControls;
  60248. private _white;
  60249. private _primaryShadowColor;
  60250. private _primaryHighlightColor;
  60251. /**
  60252. * Instantiates a Background Material in the given scene
  60253. * @param name The friendly name of the material
  60254. * @param scene The scene to add the material to
  60255. */
  60256. constructor(name: string, scene: Scene);
  60257. /**
  60258. * Gets a boolean indicating that current material needs to register RTT
  60259. */
  60260. get hasRenderTargetTextures(): boolean;
  60261. /**
  60262. * The entire material has been created in order to prevent overdraw.
  60263. * @returns false
  60264. */
  60265. needAlphaTesting(): boolean;
  60266. /**
  60267. * The entire material has been created in order to prevent overdraw.
  60268. * @returns true if blending is enable
  60269. */
  60270. needAlphaBlending(): boolean;
  60271. /**
  60272. * Checks wether the material is ready to be rendered for a given mesh.
  60273. * @param mesh The mesh to render
  60274. * @param subMesh The submesh to check against
  60275. * @param useInstances Specify wether or not the material is used with instances
  60276. * @returns true if all the dependencies are ready (Textures, Effects...)
  60277. */
  60278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60279. /**
  60280. * Compute the primary color according to the chosen perceptual color.
  60281. */
  60282. private _computePrimaryColorFromPerceptualColor;
  60283. /**
  60284. * Compute the highlights and shadow colors according to their chosen levels.
  60285. */
  60286. private _computePrimaryColors;
  60287. /**
  60288. * Build the uniform buffer used in the material.
  60289. */
  60290. buildUniformLayout(): void;
  60291. /**
  60292. * Unbind the material.
  60293. */
  60294. unbind(): void;
  60295. /**
  60296. * Bind only the world matrix to the material.
  60297. * @param world The world matrix to bind.
  60298. */
  60299. bindOnlyWorldMatrix(world: Matrix): void;
  60300. /**
  60301. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60302. * @param world The world matrix to bind.
  60303. * @param subMesh The submesh to bind for.
  60304. */
  60305. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60306. /**
  60307. * Checks to see if a texture is used in the material.
  60308. * @param texture - Base texture to use.
  60309. * @returns - Boolean specifying if a texture is used in the material.
  60310. */
  60311. hasTexture(texture: BaseTexture): boolean;
  60312. /**
  60313. * Dispose the material.
  60314. * @param forceDisposeEffect Force disposal of the associated effect.
  60315. * @param forceDisposeTextures Force disposal of the associated textures.
  60316. */
  60317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60318. /**
  60319. * Clones the material.
  60320. * @param name The cloned name.
  60321. * @returns The cloned material.
  60322. */
  60323. clone(name: string): BackgroundMaterial;
  60324. /**
  60325. * Serializes the current material to its JSON representation.
  60326. * @returns The JSON representation.
  60327. */
  60328. serialize(): any;
  60329. /**
  60330. * Gets the class name of the material
  60331. * @returns "BackgroundMaterial"
  60332. */
  60333. getClassName(): string;
  60334. /**
  60335. * Parse a JSON input to create back a background material.
  60336. * @param source The JSON data to parse
  60337. * @param scene The scene to create the parsed material in
  60338. * @param rootUrl The root url of the assets the material depends upon
  60339. * @returns the instantiated BackgroundMaterial.
  60340. */
  60341. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60342. }
  60343. }
  60344. declare module "babylonjs/Helpers/environmentHelper" {
  60345. import { Observable } from "babylonjs/Misc/observable";
  60346. import { Nullable } from "babylonjs/types";
  60347. import { Scene } from "babylonjs/scene";
  60348. import { Vector3 } from "babylonjs/Maths/math.vector";
  60349. import { Color3 } from "babylonjs/Maths/math.color";
  60350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60351. import { Mesh } from "babylonjs/Meshes/mesh";
  60352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60353. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60354. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60355. import "babylonjs/Meshes/Builders/planeBuilder";
  60356. import "babylonjs/Meshes/Builders/boxBuilder";
  60357. /**
  60358. * Represents the different options available during the creation of
  60359. * a Environment helper.
  60360. *
  60361. * This can control the default ground, skybox and image processing setup of your scene.
  60362. */
  60363. export interface IEnvironmentHelperOptions {
  60364. /**
  60365. * Specifies whether or not to create a ground.
  60366. * True by default.
  60367. */
  60368. createGround: boolean;
  60369. /**
  60370. * Specifies the ground size.
  60371. * 15 by default.
  60372. */
  60373. groundSize: number;
  60374. /**
  60375. * The texture used on the ground for the main color.
  60376. * Comes from the BabylonJS CDN by default.
  60377. *
  60378. * Remarks: Can be either a texture or a url.
  60379. */
  60380. groundTexture: string | BaseTexture;
  60381. /**
  60382. * The color mixed in the ground texture by default.
  60383. * BabylonJS clearColor by default.
  60384. */
  60385. groundColor: Color3;
  60386. /**
  60387. * Specifies the ground opacity.
  60388. * 1 by default.
  60389. */
  60390. groundOpacity: number;
  60391. /**
  60392. * Enables the ground to receive shadows.
  60393. * True by default.
  60394. */
  60395. enableGroundShadow: boolean;
  60396. /**
  60397. * Helps preventing the shadow to be fully black on the ground.
  60398. * 0.5 by default.
  60399. */
  60400. groundShadowLevel: number;
  60401. /**
  60402. * Creates a mirror texture attach to the ground.
  60403. * false by default.
  60404. */
  60405. enableGroundMirror: boolean;
  60406. /**
  60407. * Specifies the ground mirror size ratio.
  60408. * 0.3 by default as the default kernel is 64.
  60409. */
  60410. groundMirrorSizeRatio: number;
  60411. /**
  60412. * Specifies the ground mirror blur kernel size.
  60413. * 64 by default.
  60414. */
  60415. groundMirrorBlurKernel: number;
  60416. /**
  60417. * Specifies the ground mirror visibility amount.
  60418. * 1 by default
  60419. */
  60420. groundMirrorAmount: number;
  60421. /**
  60422. * Specifies the ground mirror reflectance weight.
  60423. * This uses the standard weight of the background material to setup the fresnel effect
  60424. * of the mirror.
  60425. * 1 by default.
  60426. */
  60427. groundMirrorFresnelWeight: number;
  60428. /**
  60429. * Specifies the ground mirror Falloff distance.
  60430. * This can helps reducing the size of the reflection.
  60431. * 0 by Default.
  60432. */
  60433. groundMirrorFallOffDistance: number;
  60434. /**
  60435. * Specifies the ground mirror texture type.
  60436. * Unsigned Int by Default.
  60437. */
  60438. groundMirrorTextureType: number;
  60439. /**
  60440. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60441. * the shown objects.
  60442. */
  60443. groundYBias: number;
  60444. /**
  60445. * Specifies whether or not to create a skybox.
  60446. * True by default.
  60447. */
  60448. createSkybox: boolean;
  60449. /**
  60450. * Specifies the skybox size.
  60451. * 20 by default.
  60452. */
  60453. skyboxSize: number;
  60454. /**
  60455. * The texture used on the skybox for the main color.
  60456. * Comes from the BabylonJS CDN by default.
  60457. *
  60458. * Remarks: Can be either a texture or a url.
  60459. */
  60460. skyboxTexture: string | BaseTexture;
  60461. /**
  60462. * The color mixed in the skybox texture by default.
  60463. * BabylonJS clearColor by default.
  60464. */
  60465. skyboxColor: Color3;
  60466. /**
  60467. * The background rotation around the Y axis of the scene.
  60468. * This helps aligning the key lights of your scene with the background.
  60469. * 0 by default.
  60470. */
  60471. backgroundYRotation: number;
  60472. /**
  60473. * Compute automatically the size of the elements to best fit with the scene.
  60474. */
  60475. sizeAuto: boolean;
  60476. /**
  60477. * Default position of the rootMesh if autoSize is not true.
  60478. */
  60479. rootPosition: Vector3;
  60480. /**
  60481. * Sets up the image processing in the scene.
  60482. * true by default.
  60483. */
  60484. setupImageProcessing: boolean;
  60485. /**
  60486. * The texture used as your environment texture in the scene.
  60487. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60488. *
  60489. * Remarks: Can be either a texture or a url.
  60490. */
  60491. environmentTexture: string | BaseTexture;
  60492. /**
  60493. * The value of the exposure to apply to the scene.
  60494. * 0.6 by default if setupImageProcessing is true.
  60495. */
  60496. cameraExposure: number;
  60497. /**
  60498. * The value of the contrast to apply to the scene.
  60499. * 1.6 by default if setupImageProcessing is true.
  60500. */
  60501. cameraContrast: number;
  60502. /**
  60503. * Specifies whether or not tonemapping should be enabled in the scene.
  60504. * true by default if setupImageProcessing is true.
  60505. */
  60506. toneMappingEnabled: boolean;
  60507. }
  60508. /**
  60509. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60510. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60511. * It also helps with the default setup of your imageProcessing configuration.
  60512. */
  60513. export class EnvironmentHelper {
  60514. /**
  60515. * Default ground texture URL.
  60516. */
  60517. private static _groundTextureCDNUrl;
  60518. /**
  60519. * Default skybox texture URL.
  60520. */
  60521. private static _skyboxTextureCDNUrl;
  60522. /**
  60523. * Default environment texture URL.
  60524. */
  60525. private static _environmentTextureCDNUrl;
  60526. /**
  60527. * Creates the default options for the helper.
  60528. */
  60529. private static _getDefaultOptions;
  60530. private _rootMesh;
  60531. /**
  60532. * Gets the root mesh created by the helper.
  60533. */
  60534. get rootMesh(): Mesh;
  60535. private _skybox;
  60536. /**
  60537. * Gets the skybox created by the helper.
  60538. */
  60539. get skybox(): Nullable<Mesh>;
  60540. private _skyboxTexture;
  60541. /**
  60542. * Gets the skybox texture created by the helper.
  60543. */
  60544. get skyboxTexture(): Nullable<BaseTexture>;
  60545. private _skyboxMaterial;
  60546. /**
  60547. * Gets the skybox material created by the helper.
  60548. */
  60549. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60550. private _ground;
  60551. /**
  60552. * Gets the ground mesh created by the helper.
  60553. */
  60554. get ground(): Nullable<Mesh>;
  60555. private _groundTexture;
  60556. /**
  60557. * Gets the ground texture created by the helper.
  60558. */
  60559. get groundTexture(): Nullable<BaseTexture>;
  60560. private _groundMirror;
  60561. /**
  60562. * Gets the ground mirror created by the helper.
  60563. */
  60564. get groundMirror(): Nullable<MirrorTexture>;
  60565. /**
  60566. * Gets the ground mirror render list to helps pushing the meshes
  60567. * you wish in the ground reflection.
  60568. */
  60569. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60570. private _groundMaterial;
  60571. /**
  60572. * Gets the ground material created by the helper.
  60573. */
  60574. get groundMaterial(): Nullable<BackgroundMaterial>;
  60575. /**
  60576. * Stores the creation options.
  60577. */
  60578. private readonly _scene;
  60579. private _options;
  60580. /**
  60581. * This observable will be notified with any error during the creation of the environment,
  60582. * mainly texture creation errors.
  60583. */
  60584. onErrorObservable: Observable<{
  60585. message?: string;
  60586. exception?: any;
  60587. }>;
  60588. /**
  60589. * constructor
  60590. * @param options Defines the options we want to customize the helper
  60591. * @param scene The scene to add the material to
  60592. */
  60593. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60594. /**
  60595. * Updates the background according to the new options
  60596. * @param options
  60597. */
  60598. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60599. /**
  60600. * Sets the primary color of all the available elements.
  60601. * @param color the main color to affect to the ground and the background
  60602. */
  60603. setMainColor(color: Color3): void;
  60604. /**
  60605. * Setup the image processing according to the specified options.
  60606. */
  60607. private _setupImageProcessing;
  60608. /**
  60609. * Setup the environment texture according to the specified options.
  60610. */
  60611. private _setupEnvironmentTexture;
  60612. /**
  60613. * Setup the background according to the specified options.
  60614. */
  60615. private _setupBackground;
  60616. /**
  60617. * Get the scene sizes according to the setup.
  60618. */
  60619. private _getSceneSize;
  60620. /**
  60621. * Setup the ground according to the specified options.
  60622. */
  60623. private _setupGround;
  60624. /**
  60625. * Setup the ground material according to the specified options.
  60626. */
  60627. private _setupGroundMaterial;
  60628. /**
  60629. * Setup the ground diffuse texture according to the specified options.
  60630. */
  60631. private _setupGroundDiffuseTexture;
  60632. /**
  60633. * Setup the ground mirror texture according to the specified options.
  60634. */
  60635. private _setupGroundMirrorTexture;
  60636. /**
  60637. * Setup the ground to receive the mirror texture.
  60638. */
  60639. private _setupMirrorInGroundMaterial;
  60640. /**
  60641. * Setup the skybox according to the specified options.
  60642. */
  60643. private _setupSkybox;
  60644. /**
  60645. * Setup the skybox material according to the specified options.
  60646. */
  60647. private _setupSkyboxMaterial;
  60648. /**
  60649. * Setup the skybox reflection texture according to the specified options.
  60650. */
  60651. private _setupSkyboxReflectionTexture;
  60652. private _errorHandler;
  60653. /**
  60654. * Dispose all the elements created by the Helper.
  60655. */
  60656. dispose(): void;
  60657. }
  60658. }
  60659. declare module "babylonjs/Helpers/textureDome" {
  60660. import { Scene } from "babylonjs/scene";
  60661. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60662. import { Mesh } from "babylonjs/Meshes/mesh";
  60663. import { Texture } from "babylonjs/Materials/Textures/texture";
  60664. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60665. import "babylonjs/Meshes/Builders/sphereBuilder";
  60666. import { Nullable } from "babylonjs/types";
  60667. import { Observable } from "babylonjs/Misc/observable";
  60668. /**
  60669. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60670. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60671. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60672. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60673. */
  60674. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60675. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60676. /**
  60677. * Define the source as a Monoscopic panoramic 360/180.
  60678. */
  60679. static readonly MODE_MONOSCOPIC: number;
  60680. /**
  60681. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60682. */
  60683. static readonly MODE_TOPBOTTOM: number;
  60684. /**
  60685. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60686. */
  60687. static readonly MODE_SIDEBYSIDE: number;
  60688. private _halfDome;
  60689. private _crossEye;
  60690. protected _useDirectMapping: boolean;
  60691. /**
  60692. * The texture being displayed on the sphere
  60693. */
  60694. protected _texture: T;
  60695. /**
  60696. * Gets the texture being displayed on the sphere
  60697. */
  60698. get texture(): T;
  60699. /**
  60700. * Sets the texture being displayed on the sphere
  60701. */
  60702. set texture(newTexture: T);
  60703. /**
  60704. * The skybox material
  60705. */
  60706. protected _material: BackgroundMaterial;
  60707. /**
  60708. * The surface used for the dome
  60709. */
  60710. protected _mesh: Mesh;
  60711. /**
  60712. * Gets the mesh used for the dome.
  60713. */
  60714. get mesh(): Mesh;
  60715. /**
  60716. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60717. */
  60718. private _halfDomeMask;
  60719. /**
  60720. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60721. * Also see the options.resolution property.
  60722. */
  60723. get fovMultiplier(): number;
  60724. set fovMultiplier(value: number);
  60725. protected _textureMode: number;
  60726. /**
  60727. * Gets or set the current texture mode for the texture. It can be:
  60728. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60729. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60730. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60731. */
  60732. get textureMode(): number;
  60733. /**
  60734. * Sets the current texture mode for the texture. It can be:
  60735. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60736. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60737. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60738. */
  60739. set textureMode(value: number);
  60740. /**
  60741. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60742. */
  60743. get halfDome(): boolean;
  60744. /**
  60745. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60746. */
  60747. set halfDome(enabled: boolean);
  60748. /**
  60749. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60750. */
  60751. set crossEye(enabled: boolean);
  60752. /**
  60753. * Is it a cross-eye texture?
  60754. */
  60755. get crossEye(): boolean;
  60756. /**
  60757. * The background material of this dome.
  60758. */
  60759. get material(): BackgroundMaterial;
  60760. /**
  60761. * Oberserver used in Stereoscopic VR Mode.
  60762. */
  60763. private _onBeforeCameraRenderObserver;
  60764. /**
  60765. * Observable raised when an error occured while loading the 360 image
  60766. */
  60767. onLoadErrorObservable: Observable<string>;
  60768. /**
  60769. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60770. * @param name Element's name, child elements will append suffixes for their own names.
  60771. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60772. * @param options An object containing optional or exposed sub element properties
  60773. */
  60774. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60775. resolution?: number;
  60776. clickToPlay?: boolean;
  60777. autoPlay?: boolean;
  60778. loop?: boolean;
  60779. size?: number;
  60780. poster?: string;
  60781. faceForward?: boolean;
  60782. useDirectMapping?: boolean;
  60783. halfDomeMode?: boolean;
  60784. crossEyeMode?: boolean;
  60785. generateMipMaps?: boolean;
  60786. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60787. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60788. protected _changeTextureMode(value: number): void;
  60789. /**
  60790. * Releases resources associated with this node.
  60791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60793. */
  60794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60795. }
  60796. }
  60797. declare module "babylonjs/Helpers/photoDome" {
  60798. import { Scene } from "babylonjs/scene";
  60799. import { Texture } from "babylonjs/Materials/Textures/texture";
  60800. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60801. /**
  60802. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60803. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60804. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60805. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60806. */
  60807. export class PhotoDome extends TextureDome<Texture> {
  60808. /**
  60809. * Define the image as a Monoscopic panoramic 360 image.
  60810. */
  60811. static readonly MODE_MONOSCOPIC: number;
  60812. /**
  60813. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60814. */
  60815. static readonly MODE_TOPBOTTOM: number;
  60816. /**
  60817. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60818. */
  60819. static readonly MODE_SIDEBYSIDE: number;
  60820. /**
  60821. * Gets or sets the texture being displayed on the sphere
  60822. */
  60823. get photoTexture(): Texture;
  60824. /**
  60825. * sets the texture being displayed on the sphere
  60826. */
  60827. set photoTexture(value: Texture);
  60828. /**
  60829. * Gets the current video mode for the video. It can be:
  60830. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60831. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60832. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60833. */
  60834. get imageMode(): number;
  60835. /**
  60836. * Sets the current video mode for the video. It can be:
  60837. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60838. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60839. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60840. */
  60841. set imageMode(value: number);
  60842. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60843. }
  60844. }
  60845. declare module "babylonjs/Misc/dds" {
  60846. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60847. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60848. import { Nullable } from "babylonjs/types";
  60849. import { Scene } from "babylonjs/scene";
  60850. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60851. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60852. /**
  60853. * Direct draw surface info
  60854. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60855. */
  60856. export interface DDSInfo {
  60857. /**
  60858. * Width of the texture
  60859. */
  60860. width: number;
  60861. /**
  60862. * Width of the texture
  60863. */
  60864. height: number;
  60865. /**
  60866. * Number of Mipmaps for the texture
  60867. * @see https://en.wikipedia.org/wiki/Mipmap
  60868. */
  60869. mipmapCount: number;
  60870. /**
  60871. * If the textures format is a known fourCC format
  60872. * @see https://www.fourcc.org/
  60873. */
  60874. isFourCC: boolean;
  60875. /**
  60876. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60877. */
  60878. isRGB: boolean;
  60879. /**
  60880. * If the texture is a lumincance format
  60881. */
  60882. isLuminance: boolean;
  60883. /**
  60884. * If this is a cube texture
  60885. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60886. */
  60887. isCube: boolean;
  60888. /**
  60889. * If the texture is a compressed format eg. FOURCC_DXT1
  60890. */
  60891. isCompressed: boolean;
  60892. /**
  60893. * The dxgiFormat of the texture
  60894. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60895. */
  60896. dxgiFormat: number;
  60897. /**
  60898. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60899. */
  60900. textureType: number;
  60901. /**
  60902. * Sphericle polynomial created for the dds texture
  60903. */
  60904. sphericalPolynomial?: SphericalPolynomial;
  60905. }
  60906. /**
  60907. * Class used to provide DDS decompression tools
  60908. */
  60909. export class DDSTools {
  60910. /**
  60911. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60912. */
  60913. static StoreLODInAlphaChannel: boolean;
  60914. /**
  60915. * Gets DDS information from an array buffer
  60916. * @param data defines the array buffer view to read data from
  60917. * @returns the DDS information
  60918. */
  60919. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60920. private static _FloatView;
  60921. private static _Int32View;
  60922. private static _ToHalfFloat;
  60923. private static _FromHalfFloat;
  60924. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60925. private static _GetHalfFloatRGBAArrayBuffer;
  60926. private static _GetFloatRGBAArrayBuffer;
  60927. private static _GetFloatAsUIntRGBAArrayBuffer;
  60928. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60929. private static _GetRGBAArrayBuffer;
  60930. private static _ExtractLongWordOrder;
  60931. private static _GetRGBArrayBuffer;
  60932. private static _GetLuminanceArrayBuffer;
  60933. /**
  60934. * Uploads DDS Levels to a Babylon Texture
  60935. * @hidden
  60936. */
  60937. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60938. }
  60939. module "babylonjs/Engines/thinEngine" {
  60940. interface ThinEngine {
  60941. /**
  60942. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60943. * @param rootUrl defines the url where the file to load is located
  60944. * @param scene defines the current scene
  60945. * @param lodScale defines scale to apply to the mip map selection
  60946. * @param lodOffset defines offset to apply to the mip map selection
  60947. * @param onLoad defines an optional callback raised when the texture is loaded
  60948. * @param onError defines an optional callback raised if there is an issue to load the texture
  60949. * @param format defines the format of the data
  60950. * @param forcedExtension defines the extension to use to pick the right loader
  60951. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60952. * @returns the cube texture as an InternalTexture
  60953. */
  60954. 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;
  60955. }
  60956. }
  60957. }
  60958. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60959. import { Nullable } from "babylonjs/types";
  60960. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60961. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60962. /**
  60963. * Implementation of the DDS Texture Loader.
  60964. * @hidden
  60965. */
  60966. export class _DDSTextureLoader implements IInternalTextureLoader {
  60967. /**
  60968. * Defines wether the loader supports cascade loading the different faces.
  60969. */
  60970. readonly supportCascades: boolean;
  60971. /**
  60972. * This returns if the loader support the current file information.
  60973. * @param extension defines the file extension of the file being loaded
  60974. * @returns true if the loader can load the specified file
  60975. */
  60976. canLoad(extension: string): boolean;
  60977. /**
  60978. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60979. * @param data contains the texture data
  60980. * @param texture defines the BabylonJS internal texture
  60981. * @param createPolynomials will be true if polynomials have been requested
  60982. * @param onLoad defines the callback to trigger once the texture is ready
  60983. * @param onError defines the callback to trigger in case of error
  60984. */
  60985. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60986. /**
  60987. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60988. * @param data contains the texture data
  60989. * @param texture defines the BabylonJS internal texture
  60990. * @param callback defines the method to call once ready to upload
  60991. */
  60992. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60993. }
  60994. }
  60995. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60996. import { Nullable } from "babylonjs/types";
  60997. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60998. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60999. /**
  61000. * Implementation of the ENV Texture Loader.
  61001. * @hidden
  61002. */
  61003. export class _ENVTextureLoader implements IInternalTextureLoader {
  61004. /**
  61005. * Defines wether the loader supports cascade loading the different faces.
  61006. */
  61007. readonly supportCascades: boolean;
  61008. /**
  61009. * This returns if the loader support the current file information.
  61010. * @param extension defines the file extension of the file being loaded
  61011. * @returns true if the loader can load the specified file
  61012. */
  61013. canLoad(extension: string): boolean;
  61014. /**
  61015. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61016. * @param data contains the texture data
  61017. * @param texture defines the BabylonJS internal texture
  61018. * @param createPolynomials will be true if polynomials have been requested
  61019. * @param onLoad defines the callback to trigger once the texture is ready
  61020. * @param onError defines the callback to trigger in case of error
  61021. */
  61022. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61023. /**
  61024. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61025. * @param data contains the texture data
  61026. * @param texture defines the BabylonJS internal texture
  61027. * @param callback defines the method to call once ready to upload
  61028. */
  61029. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61030. }
  61031. }
  61032. declare module "babylonjs/Misc/khronosTextureContainer" {
  61033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61034. /**
  61035. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61036. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61037. */
  61038. export class KhronosTextureContainer {
  61039. /** contents of the KTX container file */
  61040. data: ArrayBufferView;
  61041. private static HEADER_LEN;
  61042. private static COMPRESSED_2D;
  61043. private static COMPRESSED_3D;
  61044. private static TEX_2D;
  61045. private static TEX_3D;
  61046. /**
  61047. * Gets the openGL type
  61048. */
  61049. glType: number;
  61050. /**
  61051. * Gets the openGL type size
  61052. */
  61053. glTypeSize: number;
  61054. /**
  61055. * Gets the openGL format
  61056. */
  61057. glFormat: number;
  61058. /**
  61059. * Gets the openGL internal format
  61060. */
  61061. glInternalFormat: number;
  61062. /**
  61063. * Gets the base internal format
  61064. */
  61065. glBaseInternalFormat: number;
  61066. /**
  61067. * Gets image width in pixel
  61068. */
  61069. pixelWidth: number;
  61070. /**
  61071. * Gets image height in pixel
  61072. */
  61073. pixelHeight: number;
  61074. /**
  61075. * Gets image depth in pixels
  61076. */
  61077. pixelDepth: number;
  61078. /**
  61079. * Gets the number of array elements
  61080. */
  61081. numberOfArrayElements: number;
  61082. /**
  61083. * Gets the number of faces
  61084. */
  61085. numberOfFaces: number;
  61086. /**
  61087. * Gets the number of mipmap levels
  61088. */
  61089. numberOfMipmapLevels: number;
  61090. /**
  61091. * Gets the bytes of key value data
  61092. */
  61093. bytesOfKeyValueData: number;
  61094. /**
  61095. * Gets the load type
  61096. */
  61097. loadType: number;
  61098. /**
  61099. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61100. */
  61101. isInvalid: boolean;
  61102. /**
  61103. * Creates a new KhronosTextureContainer
  61104. * @param data contents of the KTX container file
  61105. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61106. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61107. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61108. */
  61109. constructor(
  61110. /** contents of the KTX container file */
  61111. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61112. /**
  61113. * Uploads KTX content to a Babylon Texture.
  61114. * It is assumed that the texture has already been created & is currently bound
  61115. * @hidden
  61116. */
  61117. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61118. private _upload2DCompressedLevels;
  61119. /**
  61120. * Checks if the given data starts with a KTX file identifier.
  61121. * @param data the data to check
  61122. * @returns true if the data is a KTX file or false otherwise
  61123. */
  61124. static IsValid(data: ArrayBufferView): boolean;
  61125. }
  61126. }
  61127. declare module "babylonjs/Misc/workerPool" {
  61128. import { IDisposable } from "babylonjs/scene";
  61129. /**
  61130. * Helper class to push actions to a pool of workers.
  61131. */
  61132. export class WorkerPool implements IDisposable {
  61133. private _workerInfos;
  61134. private _pendingActions;
  61135. /**
  61136. * Constructor
  61137. * @param workers Array of workers to use for actions
  61138. */
  61139. constructor(workers: Array<Worker>);
  61140. /**
  61141. * Terminates all workers and clears any pending actions.
  61142. */
  61143. dispose(): void;
  61144. /**
  61145. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61146. * pended until a worker has completed its action.
  61147. * @param action The action to perform. Call onComplete when the action is complete.
  61148. */
  61149. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61150. private _execute;
  61151. }
  61152. }
  61153. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61154. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61155. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61156. /**
  61157. * Class for loading KTX2 files
  61158. */
  61159. export class KhronosTextureContainer2 {
  61160. private static _WorkerPoolPromise?;
  61161. private static _Initialized;
  61162. private static _Ktx2Decoder;
  61163. /**
  61164. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61165. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61166. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61167. * Urls you can change:
  61168. * URLConfig.jsDecoderModule
  61169. * URLConfig.wasmUASTCToASTC
  61170. * URLConfig.wasmUASTCToBC7
  61171. * URLConfig.jsMSCTranscoder
  61172. * URLConfig.wasmMSCTranscoder
  61173. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61174. */
  61175. static URLConfig: {
  61176. jsDecoderModule: string;
  61177. wasmUASTCToASTC: null;
  61178. wasmUASTCToBC7: null;
  61179. jsMSCTranscoder: null;
  61180. wasmMSCTranscoder: null;
  61181. };
  61182. /**
  61183. * Default number of workers used to handle data decoding
  61184. */
  61185. static DefaultNumWorkers: number;
  61186. private static GetDefaultNumWorkers;
  61187. private _engine;
  61188. private static _CreateWorkerPool;
  61189. /**
  61190. * Constructor
  61191. * @param engine The engine to use
  61192. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61193. */
  61194. constructor(engine: ThinEngine, numWorkers?: number);
  61195. /** @hidden */
  61196. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  61197. /**
  61198. * Stop all async operations and release resources.
  61199. */
  61200. dispose(): void;
  61201. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61202. /**
  61203. * Checks if the given data starts with a KTX2 file identifier.
  61204. * @param data the data to check
  61205. * @returns true if the data is a KTX2 file or false otherwise
  61206. */
  61207. static IsValid(data: ArrayBufferView): boolean;
  61208. }
  61209. }
  61210. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61211. import { Nullable } from "babylonjs/types";
  61212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61213. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61214. /**
  61215. * Implementation of the KTX Texture Loader.
  61216. * @hidden
  61217. */
  61218. export class _KTXTextureLoader implements IInternalTextureLoader {
  61219. /**
  61220. * Defines wether the loader supports cascade loading the different faces.
  61221. */
  61222. readonly supportCascades: boolean;
  61223. /**
  61224. * This returns if the loader support the current file information.
  61225. * @param extension defines the file extension of the file being loaded
  61226. * @param mimeType defines the optional mime type of the file being loaded
  61227. * @returns true if the loader can load the specified file
  61228. */
  61229. canLoad(extension: string, mimeType?: string): boolean;
  61230. /**
  61231. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61232. * @param data contains the texture data
  61233. * @param texture defines the BabylonJS internal texture
  61234. * @param createPolynomials will be true if polynomials have been requested
  61235. * @param onLoad defines the callback to trigger once the texture is ready
  61236. * @param onError defines the callback to trigger in case of error
  61237. */
  61238. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61239. /**
  61240. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61241. * @param data contains the texture data
  61242. * @param texture defines the BabylonJS internal texture
  61243. * @param callback defines the method to call once ready to upload
  61244. */
  61245. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  61246. }
  61247. }
  61248. declare module "babylonjs/Helpers/sceneHelpers" {
  61249. import { Nullable } from "babylonjs/types";
  61250. import { Mesh } from "babylonjs/Meshes/mesh";
  61251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61252. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61253. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61254. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61255. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61256. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61257. import "babylonjs/Meshes/Builders/boxBuilder";
  61258. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61259. /** @hidden */
  61260. export var _forceSceneHelpersToBundle: boolean;
  61261. module "babylonjs/scene" {
  61262. interface Scene {
  61263. /**
  61264. * Creates a default light for the scene.
  61265. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61266. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61267. */
  61268. createDefaultLight(replace?: boolean): void;
  61269. /**
  61270. * Creates a default camera for the scene.
  61271. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61272. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61273. * @param replace has default false, when true replaces the active camera in the scene
  61274. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61275. */
  61276. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61277. /**
  61278. * Creates a default camera and a default light.
  61279. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61280. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61281. * @param replace has the default false, when true replaces the active camera/light in the scene
  61282. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61283. */
  61284. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61285. /**
  61286. * Creates a new sky box
  61287. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61288. * @param environmentTexture defines the texture to use as environment texture
  61289. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61290. * @param scale defines the overall scale of the skybox
  61291. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61292. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61293. * @returns a new mesh holding the sky box
  61294. */
  61295. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61296. /**
  61297. * Creates a new environment
  61298. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61299. * @param options defines the options you can use to configure the environment
  61300. * @returns the new EnvironmentHelper
  61301. */
  61302. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61303. /**
  61304. * Creates a new VREXperienceHelper
  61305. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61306. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61307. * @returns a new VREXperienceHelper
  61308. */
  61309. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61310. /**
  61311. * Creates a new WebXRDefaultExperience
  61312. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61313. * @param options experience options
  61314. * @returns a promise for a new WebXRDefaultExperience
  61315. */
  61316. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61317. }
  61318. }
  61319. }
  61320. declare module "babylonjs/Helpers/videoDome" {
  61321. import { Scene } from "babylonjs/scene";
  61322. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61323. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61324. /**
  61325. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61326. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61327. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61328. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61329. */
  61330. export class VideoDome extends TextureDome<VideoTexture> {
  61331. /**
  61332. * Define the video source as a Monoscopic panoramic 360 video.
  61333. */
  61334. static readonly MODE_MONOSCOPIC: number;
  61335. /**
  61336. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61337. */
  61338. static readonly MODE_TOPBOTTOM: number;
  61339. /**
  61340. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61341. */
  61342. static readonly MODE_SIDEBYSIDE: number;
  61343. /**
  61344. * Get the video texture associated with this video dome
  61345. */
  61346. get videoTexture(): VideoTexture;
  61347. /**
  61348. * Get the video mode of this dome
  61349. */
  61350. get videoMode(): number;
  61351. /**
  61352. * Set the video mode of this dome.
  61353. * @see textureMode
  61354. */
  61355. set videoMode(value: number);
  61356. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61357. }
  61358. }
  61359. declare module "babylonjs/Helpers/index" {
  61360. export * from "babylonjs/Helpers/environmentHelper";
  61361. export * from "babylonjs/Helpers/photoDome";
  61362. export * from "babylonjs/Helpers/sceneHelpers";
  61363. export * from "babylonjs/Helpers/videoDome";
  61364. }
  61365. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61366. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61367. import { IDisposable } from "babylonjs/scene";
  61368. import { Engine } from "babylonjs/Engines/engine";
  61369. /**
  61370. * This class can be used to get instrumentation data from a Babylon engine
  61371. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61372. */
  61373. export class EngineInstrumentation implements IDisposable {
  61374. /**
  61375. * Define the instrumented engine.
  61376. */
  61377. engine: Engine;
  61378. private _captureGPUFrameTime;
  61379. private _gpuFrameTimeToken;
  61380. private _gpuFrameTime;
  61381. private _captureShaderCompilationTime;
  61382. private _shaderCompilationTime;
  61383. private _onBeginFrameObserver;
  61384. private _onEndFrameObserver;
  61385. private _onBeforeShaderCompilationObserver;
  61386. private _onAfterShaderCompilationObserver;
  61387. /**
  61388. * Gets the perf counter used for GPU frame time
  61389. */
  61390. get gpuFrameTimeCounter(): PerfCounter;
  61391. /**
  61392. * Gets the GPU frame time capture status
  61393. */
  61394. get captureGPUFrameTime(): boolean;
  61395. /**
  61396. * Enable or disable the GPU frame time capture
  61397. */
  61398. set captureGPUFrameTime(value: boolean);
  61399. /**
  61400. * Gets the perf counter used for shader compilation time
  61401. */
  61402. get shaderCompilationTimeCounter(): PerfCounter;
  61403. /**
  61404. * Gets the shader compilation time capture status
  61405. */
  61406. get captureShaderCompilationTime(): boolean;
  61407. /**
  61408. * Enable or disable the shader compilation time capture
  61409. */
  61410. set captureShaderCompilationTime(value: boolean);
  61411. /**
  61412. * Instantiates a new engine instrumentation.
  61413. * This class can be used to get instrumentation data from a Babylon engine
  61414. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61415. * @param engine Defines the engine to instrument
  61416. */
  61417. constructor(
  61418. /**
  61419. * Define the instrumented engine.
  61420. */
  61421. engine: Engine);
  61422. /**
  61423. * Dispose and release associated resources.
  61424. */
  61425. dispose(): void;
  61426. }
  61427. }
  61428. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61429. import { Scene, IDisposable } from "babylonjs/scene";
  61430. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61431. /**
  61432. * This class can be used to get instrumentation data from a Babylon engine
  61433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61434. */
  61435. export class SceneInstrumentation implements IDisposable {
  61436. /**
  61437. * Defines the scene to instrument
  61438. */
  61439. scene: Scene;
  61440. private _captureActiveMeshesEvaluationTime;
  61441. private _activeMeshesEvaluationTime;
  61442. private _captureRenderTargetsRenderTime;
  61443. private _renderTargetsRenderTime;
  61444. private _captureFrameTime;
  61445. private _frameTime;
  61446. private _captureRenderTime;
  61447. private _renderTime;
  61448. private _captureInterFrameTime;
  61449. private _interFrameTime;
  61450. private _captureParticlesRenderTime;
  61451. private _particlesRenderTime;
  61452. private _captureSpritesRenderTime;
  61453. private _spritesRenderTime;
  61454. private _capturePhysicsTime;
  61455. private _physicsTime;
  61456. private _captureAnimationsTime;
  61457. private _animationsTime;
  61458. private _captureCameraRenderTime;
  61459. private _cameraRenderTime;
  61460. private _onBeforeActiveMeshesEvaluationObserver;
  61461. private _onAfterActiveMeshesEvaluationObserver;
  61462. private _onBeforeRenderTargetsRenderObserver;
  61463. private _onAfterRenderTargetsRenderObserver;
  61464. private _onAfterRenderObserver;
  61465. private _onBeforeDrawPhaseObserver;
  61466. private _onAfterDrawPhaseObserver;
  61467. private _onBeforeAnimationsObserver;
  61468. private _onBeforeParticlesRenderingObserver;
  61469. private _onAfterParticlesRenderingObserver;
  61470. private _onBeforeSpritesRenderingObserver;
  61471. private _onAfterSpritesRenderingObserver;
  61472. private _onBeforePhysicsObserver;
  61473. private _onAfterPhysicsObserver;
  61474. private _onAfterAnimationsObserver;
  61475. private _onBeforeCameraRenderObserver;
  61476. private _onAfterCameraRenderObserver;
  61477. /**
  61478. * Gets the perf counter used for active meshes evaluation time
  61479. */
  61480. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61481. /**
  61482. * Gets the active meshes evaluation time capture status
  61483. */
  61484. get captureActiveMeshesEvaluationTime(): boolean;
  61485. /**
  61486. * Enable or disable the active meshes evaluation time capture
  61487. */
  61488. set captureActiveMeshesEvaluationTime(value: boolean);
  61489. /**
  61490. * Gets the perf counter used for render targets render time
  61491. */
  61492. get renderTargetsRenderTimeCounter(): PerfCounter;
  61493. /**
  61494. * Gets the render targets render time capture status
  61495. */
  61496. get captureRenderTargetsRenderTime(): boolean;
  61497. /**
  61498. * Enable or disable the render targets render time capture
  61499. */
  61500. set captureRenderTargetsRenderTime(value: boolean);
  61501. /**
  61502. * Gets the perf counter used for particles render time
  61503. */
  61504. get particlesRenderTimeCounter(): PerfCounter;
  61505. /**
  61506. * Gets the particles render time capture status
  61507. */
  61508. get captureParticlesRenderTime(): boolean;
  61509. /**
  61510. * Enable or disable the particles render time capture
  61511. */
  61512. set captureParticlesRenderTime(value: boolean);
  61513. /**
  61514. * Gets the perf counter used for sprites render time
  61515. */
  61516. get spritesRenderTimeCounter(): PerfCounter;
  61517. /**
  61518. * Gets the sprites render time capture status
  61519. */
  61520. get captureSpritesRenderTime(): boolean;
  61521. /**
  61522. * Enable or disable the sprites render time capture
  61523. */
  61524. set captureSpritesRenderTime(value: boolean);
  61525. /**
  61526. * Gets the perf counter used for physics time
  61527. */
  61528. get physicsTimeCounter(): PerfCounter;
  61529. /**
  61530. * Gets the physics time capture status
  61531. */
  61532. get capturePhysicsTime(): boolean;
  61533. /**
  61534. * Enable or disable the physics time capture
  61535. */
  61536. set capturePhysicsTime(value: boolean);
  61537. /**
  61538. * Gets the perf counter used for animations time
  61539. */
  61540. get animationsTimeCounter(): PerfCounter;
  61541. /**
  61542. * Gets the animations time capture status
  61543. */
  61544. get captureAnimationsTime(): boolean;
  61545. /**
  61546. * Enable or disable the animations time capture
  61547. */
  61548. set captureAnimationsTime(value: boolean);
  61549. /**
  61550. * Gets the perf counter used for frame time capture
  61551. */
  61552. get frameTimeCounter(): PerfCounter;
  61553. /**
  61554. * Gets the frame time capture status
  61555. */
  61556. get captureFrameTime(): boolean;
  61557. /**
  61558. * Enable or disable the frame time capture
  61559. */
  61560. set captureFrameTime(value: boolean);
  61561. /**
  61562. * Gets the perf counter used for inter-frames time capture
  61563. */
  61564. get interFrameTimeCounter(): PerfCounter;
  61565. /**
  61566. * Gets the inter-frames time capture status
  61567. */
  61568. get captureInterFrameTime(): boolean;
  61569. /**
  61570. * Enable or disable the inter-frames time capture
  61571. */
  61572. set captureInterFrameTime(value: boolean);
  61573. /**
  61574. * Gets the perf counter used for render time capture
  61575. */
  61576. get renderTimeCounter(): PerfCounter;
  61577. /**
  61578. * Gets the render time capture status
  61579. */
  61580. get captureRenderTime(): boolean;
  61581. /**
  61582. * Enable or disable the render time capture
  61583. */
  61584. set captureRenderTime(value: boolean);
  61585. /**
  61586. * Gets the perf counter used for camera render time capture
  61587. */
  61588. get cameraRenderTimeCounter(): PerfCounter;
  61589. /**
  61590. * Gets the camera render time capture status
  61591. */
  61592. get captureCameraRenderTime(): boolean;
  61593. /**
  61594. * Enable or disable the camera render time capture
  61595. */
  61596. set captureCameraRenderTime(value: boolean);
  61597. /**
  61598. * Gets the perf counter used for draw calls
  61599. */
  61600. get drawCallsCounter(): PerfCounter;
  61601. /**
  61602. * Instantiates a new scene instrumentation.
  61603. * This class can be used to get instrumentation data from a Babylon engine
  61604. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61605. * @param scene Defines the scene to instrument
  61606. */
  61607. constructor(
  61608. /**
  61609. * Defines the scene to instrument
  61610. */
  61611. scene: Scene);
  61612. /**
  61613. * Dispose and release associated resources.
  61614. */
  61615. dispose(): void;
  61616. }
  61617. }
  61618. declare module "babylonjs/Instrumentation/index" {
  61619. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61620. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61621. export * from "babylonjs/Instrumentation/timeToken";
  61622. }
  61623. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61624. /** @hidden */
  61625. export var glowMapGenerationPixelShader: {
  61626. name: string;
  61627. shader: string;
  61628. };
  61629. }
  61630. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61631. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61634. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61635. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61636. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61637. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61638. /** @hidden */
  61639. export var glowMapGenerationVertexShader: {
  61640. name: string;
  61641. shader: string;
  61642. };
  61643. }
  61644. declare module "babylonjs/Layers/effectLayer" {
  61645. import { Observable } from "babylonjs/Misc/observable";
  61646. import { Nullable } from "babylonjs/types";
  61647. import { Camera } from "babylonjs/Cameras/camera";
  61648. import { Scene } from "babylonjs/scene";
  61649. import { ISize } from "babylonjs/Maths/math.size";
  61650. import { Color4 } from "babylonjs/Maths/math.color";
  61651. import { Engine } from "babylonjs/Engines/engine";
  61652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61654. import { Mesh } from "babylonjs/Meshes/mesh";
  61655. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61658. import { Effect } from "babylonjs/Materials/effect";
  61659. import { Material } from "babylonjs/Materials/material";
  61660. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61661. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61662. /**
  61663. * Effect layer options. This helps customizing the behaviour
  61664. * of the effect layer.
  61665. */
  61666. export interface IEffectLayerOptions {
  61667. /**
  61668. * Multiplication factor apply to the canvas size to compute the render target size
  61669. * used to generated the objects (the smaller the faster).
  61670. */
  61671. mainTextureRatio: number;
  61672. /**
  61673. * Enforces a fixed size texture to ensure effect stability across devices.
  61674. */
  61675. mainTextureFixedSize?: number;
  61676. /**
  61677. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61678. */
  61679. alphaBlendingMode: number;
  61680. /**
  61681. * The camera attached to the layer.
  61682. */
  61683. camera: Nullable<Camera>;
  61684. /**
  61685. * The rendering group to draw the layer in.
  61686. */
  61687. renderingGroupId: number;
  61688. }
  61689. /**
  61690. * The effect layer Helps adding post process effect blended with the main pass.
  61691. *
  61692. * This can be for instance use to generate glow or higlight effects on the scene.
  61693. *
  61694. * The effect layer class can not be used directly and is intented to inherited from to be
  61695. * customized per effects.
  61696. */
  61697. export abstract class EffectLayer {
  61698. private _vertexBuffers;
  61699. private _indexBuffer;
  61700. private _cachedDefines;
  61701. private _effectLayerMapGenerationEffect;
  61702. private _effectLayerOptions;
  61703. private _mergeEffect;
  61704. protected _scene: Scene;
  61705. protected _engine: Engine;
  61706. protected _maxSize: number;
  61707. protected _mainTextureDesiredSize: ISize;
  61708. protected _mainTexture: RenderTargetTexture;
  61709. protected _shouldRender: boolean;
  61710. protected _postProcesses: PostProcess[];
  61711. protected _textures: BaseTexture[];
  61712. protected _emissiveTextureAndColor: {
  61713. texture: Nullable<BaseTexture>;
  61714. color: Color4;
  61715. };
  61716. /**
  61717. * The name of the layer
  61718. */
  61719. name: string;
  61720. /**
  61721. * The clear color of the texture used to generate the glow map.
  61722. */
  61723. neutralColor: Color4;
  61724. /**
  61725. * Specifies whether the highlight layer is enabled or not.
  61726. */
  61727. isEnabled: boolean;
  61728. /**
  61729. * Gets the camera attached to the layer.
  61730. */
  61731. get camera(): Nullable<Camera>;
  61732. /**
  61733. * Gets the rendering group id the layer should render in.
  61734. */
  61735. get renderingGroupId(): number;
  61736. set renderingGroupId(renderingGroupId: number);
  61737. /**
  61738. * An event triggered when the effect layer has been disposed.
  61739. */
  61740. onDisposeObservable: Observable<EffectLayer>;
  61741. /**
  61742. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61743. */
  61744. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61745. /**
  61746. * An event triggered when the generated texture is being merged in the scene.
  61747. */
  61748. onBeforeComposeObservable: Observable<EffectLayer>;
  61749. /**
  61750. * An event triggered when the mesh is rendered into the effect render target.
  61751. */
  61752. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61753. /**
  61754. * An event triggered after the mesh has been rendered into the effect render target.
  61755. */
  61756. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61757. /**
  61758. * An event triggered when the generated texture has been merged in the scene.
  61759. */
  61760. onAfterComposeObservable: Observable<EffectLayer>;
  61761. /**
  61762. * An event triggered when the efffect layer changes its size.
  61763. */
  61764. onSizeChangedObservable: Observable<EffectLayer>;
  61765. /** @hidden */
  61766. static _SceneComponentInitialization: (scene: Scene) => void;
  61767. /**
  61768. * Instantiates a new effect Layer and references it in the scene.
  61769. * @param name The name of the layer
  61770. * @param scene The scene to use the layer in
  61771. */
  61772. constructor(
  61773. /** The Friendly of the effect in the scene */
  61774. name: string, scene: Scene);
  61775. /**
  61776. * Get the effect name of the layer.
  61777. * @return The effect name
  61778. */
  61779. abstract getEffectName(): string;
  61780. /**
  61781. * Checks for the readiness of the element composing the layer.
  61782. * @param subMesh the mesh to check for
  61783. * @param useInstances specify whether or not to use instances to render the mesh
  61784. * @return true if ready otherwise, false
  61785. */
  61786. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61787. /**
  61788. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61789. * @returns true if the effect requires stencil during the main canvas render pass.
  61790. */
  61791. abstract needStencil(): boolean;
  61792. /**
  61793. * Create the merge effect. This is the shader use to blit the information back
  61794. * to the main canvas at the end of the scene rendering.
  61795. * @returns The effect containing the shader used to merge the effect on the main canvas
  61796. */
  61797. protected abstract _createMergeEffect(): Effect;
  61798. /**
  61799. * Creates the render target textures and post processes used in the effect layer.
  61800. */
  61801. protected abstract _createTextureAndPostProcesses(): void;
  61802. /**
  61803. * Implementation specific of rendering the generating effect on the main canvas.
  61804. * @param effect The effect used to render through
  61805. */
  61806. protected abstract _internalRender(effect: Effect): void;
  61807. /**
  61808. * Sets the required values for both the emissive texture and and the main color.
  61809. */
  61810. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61811. /**
  61812. * Free any resources and references associated to a mesh.
  61813. * Internal use
  61814. * @param mesh The mesh to free.
  61815. */
  61816. abstract _disposeMesh(mesh: Mesh): void;
  61817. /**
  61818. * Serializes this layer (Glow or Highlight for example)
  61819. * @returns a serialized layer object
  61820. */
  61821. abstract serialize?(): any;
  61822. /**
  61823. * Initializes the effect layer with the required options.
  61824. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61825. */
  61826. protected _init(options: Partial<IEffectLayerOptions>): void;
  61827. /**
  61828. * Generates the index buffer of the full screen quad blending to the main canvas.
  61829. */
  61830. private _generateIndexBuffer;
  61831. /**
  61832. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61833. */
  61834. private _generateVertexBuffer;
  61835. /**
  61836. * Sets the main texture desired size which is the closest power of two
  61837. * of the engine canvas size.
  61838. */
  61839. private _setMainTextureSize;
  61840. /**
  61841. * Creates the main texture for the effect layer.
  61842. */
  61843. protected _createMainTexture(): void;
  61844. /**
  61845. * Adds specific effects defines.
  61846. * @param defines The defines to add specifics to.
  61847. */
  61848. protected _addCustomEffectDefines(defines: string[]): void;
  61849. /**
  61850. * Checks for the readiness of the element composing the layer.
  61851. * @param subMesh the mesh to check for
  61852. * @param useInstances specify whether or not to use instances to render the mesh
  61853. * @param emissiveTexture the associated emissive texture used to generate the glow
  61854. * @return true if ready otherwise, false
  61855. */
  61856. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61857. /**
  61858. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61859. */
  61860. render(): void;
  61861. /**
  61862. * Determine if a given mesh will be used in the current effect.
  61863. * @param mesh mesh to test
  61864. * @returns true if the mesh will be used
  61865. */
  61866. hasMesh(mesh: AbstractMesh): boolean;
  61867. /**
  61868. * Returns true if the layer contains information to display, otherwise false.
  61869. * @returns true if the glow layer should be rendered
  61870. */
  61871. shouldRender(): boolean;
  61872. /**
  61873. * Returns true if the mesh should render, otherwise false.
  61874. * @param mesh The mesh to render
  61875. * @returns true if it should render otherwise false
  61876. */
  61877. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61878. /**
  61879. * Returns true if the mesh can be rendered, otherwise false.
  61880. * @param mesh The mesh to render
  61881. * @param material The material used on the mesh
  61882. * @returns true if it can be rendered otherwise false
  61883. */
  61884. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61885. /**
  61886. * Returns true if the mesh should render, otherwise false.
  61887. * @param mesh The mesh to render
  61888. * @returns true if it should render otherwise false
  61889. */
  61890. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61891. /**
  61892. * Renders the submesh passed in parameter to the generation map.
  61893. */
  61894. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61895. /**
  61896. * Defines whether the current material of the mesh should be use to render the effect.
  61897. * @param mesh defines the current mesh to render
  61898. */
  61899. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61900. /**
  61901. * Rebuild the required buffers.
  61902. * @hidden Internal use only.
  61903. */
  61904. _rebuild(): void;
  61905. /**
  61906. * Dispose only the render target textures and post process.
  61907. */
  61908. private _disposeTextureAndPostProcesses;
  61909. /**
  61910. * Dispose the highlight layer and free resources.
  61911. */
  61912. dispose(): void;
  61913. /**
  61914. * Gets the class name of the effect layer
  61915. * @returns the string with the class name of the effect layer
  61916. */
  61917. getClassName(): string;
  61918. /**
  61919. * Creates an effect layer from parsed effect layer data
  61920. * @param parsedEffectLayer defines effect layer data
  61921. * @param scene defines the current scene
  61922. * @param rootUrl defines the root URL containing the effect layer information
  61923. * @returns a parsed effect Layer
  61924. */
  61925. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61926. }
  61927. }
  61928. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61929. import { Scene } from "babylonjs/scene";
  61930. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61931. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61932. import { AbstractScene } from "babylonjs/abstractScene";
  61933. module "babylonjs/abstractScene" {
  61934. interface AbstractScene {
  61935. /**
  61936. * The list of effect layers (highlights/glow) added to the scene
  61937. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61938. * @see https://doc.babylonjs.com/how_to/glow_layer
  61939. */
  61940. effectLayers: Array<EffectLayer>;
  61941. /**
  61942. * Removes the given effect layer from this scene.
  61943. * @param toRemove defines the effect layer to remove
  61944. * @returns the index of the removed effect layer
  61945. */
  61946. removeEffectLayer(toRemove: EffectLayer): number;
  61947. /**
  61948. * Adds the given effect layer to this scene
  61949. * @param newEffectLayer defines the effect layer to add
  61950. */
  61951. addEffectLayer(newEffectLayer: EffectLayer): void;
  61952. }
  61953. }
  61954. /**
  61955. * Defines the layer scene component responsible to manage any effect layers
  61956. * in a given scene.
  61957. */
  61958. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61959. /**
  61960. * The component name helpfull to identify the component in the list of scene components.
  61961. */
  61962. readonly name: string;
  61963. /**
  61964. * The scene the component belongs to.
  61965. */
  61966. scene: Scene;
  61967. private _engine;
  61968. private _renderEffects;
  61969. private _needStencil;
  61970. private _previousStencilState;
  61971. /**
  61972. * Creates a new instance of the component for the given scene
  61973. * @param scene Defines the scene to register the component in
  61974. */
  61975. constructor(scene: Scene);
  61976. /**
  61977. * Registers the component in a given scene
  61978. */
  61979. register(): void;
  61980. /**
  61981. * Rebuilds the elements related to this component in case of
  61982. * context lost for instance.
  61983. */
  61984. rebuild(): void;
  61985. /**
  61986. * Serializes the component data to the specified json object
  61987. * @param serializationObject The object to serialize to
  61988. */
  61989. serialize(serializationObject: any): void;
  61990. /**
  61991. * Adds all the elements from the container to the scene
  61992. * @param container the container holding the elements
  61993. */
  61994. addFromContainer(container: AbstractScene): void;
  61995. /**
  61996. * Removes all the elements in the container from the scene
  61997. * @param container contains the elements to remove
  61998. * @param dispose if the removed element should be disposed (default: false)
  61999. */
  62000. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62001. /**
  62002. * Disposes the component and the associated ressources.
  62003. */
  62004. dispose(): void;
  62005. private _isReadyForMesh;
  62006. private _renderMainTexture;
  62007. private _setStencil;
  62008. private _setStencilBack;
  62009. private _draw;
  62010. private _drawCamera;
  62011. private _drawRenderingGroup;
  62012. }
  62013. }
  62014. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62015. /** @hidden */
  62016. export var glowMapMergePixelShader: {
  62017. name: string;
  62018. shader: string;
  62019. };
  62020. }
  62021. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62022. /** @hidden */
  62023. export var glowMapMergeVertexShader: {
  62024. name: string;
  62025. shader: string;
  62026. };
  62027. }
  62028. declare module "babylonjs/Layers/glowLayer" {
  62029. import { Nullable } from "babylonjs/types";
  62030. import { Camera } from "babylonjs/Cameras/camera";
  62031. import { Scene } from "babylonjs/scene";
  62032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62034. import { Mesh } from "babylonjs/Meshes/mesh";
  62035. import { Texture } from "babylonjs/Materials/Textures/texture";
  62036. import { Effect } from "babylonjs/Materials/effect";
  62037. import { Material } from "babylonjs/Materials/material";
  62038. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62039. import { Color4 } from "babylonjs/Maths/math.color";
  62040. import "babylonjs/Shaders/glowMapMerge.fragment";
  62041. import "babylonjs/Shaders/glowMapMerge.vertex";
  62042. import "babylonjs/Layers/effectLayerSceneComponent";
  62043. module "babylonjs/abstractScene" {
  62044. interface AbstractScene {
  62045. /**
  62046. * Return a the first highlight layer of the scene with a given name.
  62047. * @param name The name of the highlight layer to look for.
  62048. * @return The highlight layer if found otherwise null.
  62049. */
  62050. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62051. }
  62052. }
  62053. /**
  62054. * Glow layer options. This helps customizing the behaviour
  62055. * of the glow layer.
  62056. */
  62057. export interface IGlowLayerOptions {
  62058. /**
  62059. * Multiplication factor apply to the canvas size to compute the render target size
  62060. * used to generated the glowing objects (the smaller the faster).
  62061. */
  62062. mainTextureRatio: number;
  62063. /**
  62064. * Enforces a fixed size texture to ensure resize independant blur.
  62065. */
  62066. mainTextureFixedSize?: number;
  62067. /**
  62068. * How big is the kernel of the blur texture.
  62069. */
  62070. blurKernelSize: number;
  62071. /**
  62072. * The camera attached to the layer.
  62073. */
  62074. camera: Nullable<Camera>;
  62075. /**
  62076. * Enable MSAA by chosing the number of samples.
  62077. */
  62078. mainTextureSamples?: number;
  62079. /**
  62080. * The rendering group to draw the layer in.
  62081. */
  62082. renderingGroupId: number;
  62083. }
  62084. /**
  62085. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62086. *
  62087. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62088. *
  62089. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62090. */
  62091. export class GlowLayer extends EffectLayer {
  62092. /**
  62093. * Effect Name of the layer.
  62094. */
  62095. static readonly EffectName: string;
  62096. /**
  62097. * The default blur kernel size used for the glow.
  62098. */
  62099. static DefaultBlurKernelSize: number;
  62100. /**
  62101. * The default texture size ratio used for the glow.
  62102. */
  62103. static DefaultTextureRatio: number;
  62104. /**
  62105. * Sets the kernel size of the blur.
  62106. */
  62107. set blurKernelSize(value: number);
  62108. /**
  62109. * Gets the kernel size of the blur.
  62110. */
  62111. get blurKernelSize(): number;
  62112. /**
  62113. * Sets the glow intensity.
  62114. */
  62115. set intensity(value: number);
  62116. /**
  62117. * Gets the glow intensity.
  62118. */
  62119. get intensity(): number;
  62120. private _options;
  62121. private _intensity;
  62122. private _horizontalBlurPostprocess1;
  62123. private _verticalBlurPostprocess1;
  62124. private _horizontalBlurPostprocess2;
  62125. private _verticalBlurPostprocess2;
  62126. private _blurTexture1;
  62127. private _blurTexture2;
  62128. private _postProcesses1;
  62129. private _postProcesses2;
  62130. private _includedOnlyMeshes;
  62131. private _excludedMeshes;
  62132. private _meshesUsingTheirOwnMaterials;
  62133. /**
  62134. * Callback used to let the user override the color selection on a per mesh basis
  62135. */
  62136. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62137. /**
  62138. * Callback used to let the user override the texture selection on a per mesh basis
  62139. */
  62140. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62141. /**
  62142. * Instantiates a new glow Layer and references it to the scene.
  62143. * @param name The name of the layer
  62144. * @param scene The scene to use the layer in
  62145. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62146. */
  62147. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62148. /**
  62149. * Get the effect name of the layer.
  62150. * @return The effect name
  62151. */
  62152. getEffectName(): string;
  62153. /**
  62154. * Create the merge effect. This is the shader use to blit the information back
  62155. * to the main canvas at the end of the scene rendering.
  62156. */
  62157. protected _createMergeEffect(): Effect;
  62158. /**
  62159. * Creates the render target textures and post processes used in the glow layer.
  62160. */
  62161. protected _createTextureAndPostProcesses(): void;
  62162. /**
  62163. * Checks for the readiness of the element composing the layer.
  62164. * @param subMesh the mesh to check for
  62165. * @param useInstances specify wether or not to use instances to render the mesh
  62166. * @param emissiveTexture the associated emissive texture used to generate the glow
  62167. * @return true if ready otherwise, false
  62168. */
  62169. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62170. /**
  62171. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62172. */
  62173. needStencil(): boolean;
  62174. /**
  62175. * Returns true if the mesh can be rendered, otherwise false.
  62176. * @param mesh The mesh to render
  62177. * @param material The material used on the mesh
  62178. * @returns true if it can be rendered otherwise false
  62179. */
  62180. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62181. /**
  62182. * Implementation specific of rendering the generating effect on the main canvas.
  62183. * @param effect The effect used to render through
  62184. */
  62185. protected _internalRender(effect: Effect): void;
  62186. /**
  62187. * Sets the required values for both the emissive texture and and the main color.
  62188. */
  62189. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62190. /**
  62191. * Returns true if the mesh should render, otherwise false.
  62192. * @param mesh The mesh to render
  62193. * @returns true if it should render otherwise false
  62194. */
  62195. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62196. /**
  62197. * Adds specific effects defines.
  62198. * @param defines The defines to add specifics to.
  62199. */
  62200. protected _addCustomEffectDefines(defines: string[]): void;
  62201. /**
  62202. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62203. * @param mesh The mesh to exclude from the glow layer
  62204. */
  62205. addExcludedMesh(mesh: Mesh): void;
  62206. /**
  62207. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62208. * @param mesh The mesh to remove
  62209. */
  62210. removeExcludedMesh(mesh: Mesh): void;
  62211. /**
  62212. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62213. * @param mesh The mesh to include in the glow layer
  62214. */
  62215. addIncludedOnlyMesh(mesh: Mesh): void;
  62216. /**
  62217. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62218. * @param mesh The mesh to remove
  62219. */
  62220. removeIncludedOnlyMesh(mesh: Mesh): void;
  62221. /**
  62222. * Determine if a given mesh will be used in the glow layer
  62223. * @param mesh The mesh to test
  62224. * @returns true if the mesh will be highlighted by the current glow layer
  62225. */
  62226. hasMesh(mesh: AbstractMesh): boolean;
  62227. /**
  62228. * Defines whether the current material of the mesh should be use to render the effect.
  62229. * @param mesh defines the current mesh to render
  62230. */
  62231. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62232. /**
  62233. * Add a mesh to be rendered through its own material and not with emissive only.
  62234. * @param mesh The mesh for which we need to use its material
  62235. */
  62236. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62237. /**
  62238. * Remove a mesh from being rendered through its own material and not with emissive only.
  62239. * @param mesh The mesh for which we need to not use its material
  62240. */
  62241. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62242. /**
  62243. * Free any resources and references associated to a mesh.
  62244. * Internal use
  62245. * @param mesh The mesh to free.
  62246. * @hidden
  62247. */
  62248. _disposeMesh(mesh: Mesh): void;
  62249. /**
  62250. * Gets the class name of the effect layer
  62251. * @returns the string with the class name of the effect layer
  62252. */
  62253. getClassName(): string;
  62254. /**
  62255. * Serializes this glow layer
  62256. * @returns a serialized glow layer object
  62257. */
  62258. serialize(): any;
  62259. /**
  62260. * Creates a Glow Layer from parsed glow layer data
  62261. * @param parsedGlowLayer defines glow layer data
  62262. * @param scene defines the current scene
  62263. * @param rootUrl defines the root URL containing the glow layer information
  62264. * @returns a parsed Glow Layer
  62265. */
  62266. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62267. }
  62268. }
  62269. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62270. /** @hidden */
  62271. export var glowBlurPostProcessPixelShader: {
  62272. name: string;
  62273. shader: string;
  62274. };
  62275. }
  62276. declare module "babylonjs/Layers/highlightLayer" {
  62277. import { Observable } from "babylonjs/Misc/observable";
  62278. import { Nullable } from "babylonjs/types";
  62279. import { Camera } from "babylonjs/Cameras/camera";
  62280. import { Scene } from "babylonjs/scene";
  62281. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62283. import { Mesh } from "babylonjs/Meshes/mesh";
  62284. import { Effect } from "babylonjs/Materials/effect";
  62285. import { Material } from "babylonjs/Materials/material";
  62286. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62287. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62288. import "babylonjs/Shaders/glowMapMerge.fragment";
  62289. import "babylonjs/Shaders/glowMapMerge.vertex";
  62290. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62291. module "babylonjs/abstractScene" {
  62292. interface AbstractScene {
  62293. /**
  62294. * Return a the first highlight layer of the scene with a given name.
  62295. * @param name The name of the highlight layer to look for.
  62296. * @return The highlight layer if found otherwise null.
  62297. */
  62298. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62299. }
  62300. }
  62301. /**
  62302. * Highlight layer options. This helps customizing the behaviour
  62303. * of the highlight layer.
  62304. */
  62305. export interface IHighlightLayerOptions {
  62306. /**
  62307. * Multiplication factor apply to the canvas size to compute the render target size
  62308. * used to generated the glowing objects (the smaller the faster).
  62309. */
  62310. mainTextureRatio: number;
  62311. /**
  62312. * Enforces a fixed size texture to ensure resize independant blur.
  62313. */
  62314. mainTextureFixedSize?: number;
  62315. /**
  62316. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62317. * of the picture to blur (the smaller the faster).
  62318. */
  62319. blurTextureSizeRatio: number;
  62320. /**
  62321. * How big in texel of the blur texture is the vertical blur.
  62322. */
  62323. blurVerticalSize: number;
  62324. /**
  62325. * How big in texel of the blur texture is the horizontal blur.
  62326. */
  62327. blurHorizontalSize: number;
  62328. /**
  62329. * Alpha blending mode used to apply the blur. Default is combine.
  62330. */
  62331. alphaBlendingMode: number;
  62332. /**
  62333. * The camera attached to the layer.
  62334. */
  62335. camera: Nullable<Camera>;
  62336. /**
  62337. * Should we display highlight as a solid stroke?
  62338. */
  62339. isStroke?: boolean;
  62340. /**
  62341. * The rendering group to draw the layer in.
  62342. */
  62343. renderingGroupId: number;
  62344. }
  62345. /**
  62346. * The highlight layer Helps adding a glow effect around a mesh.
  62347. *
  62348. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62349. * glowy meshes to your scene.
  62350. *
  62351. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62352. */
  62353. export class HighlightLayer extends EffectLayer {
  62354. name: string;
  62355. /**
  62356. * Effect Name of the highlight layer.
  62357. */
  62358. static readonly EffectName: string;
  62359. /**
  62360. * The neutral color used during the preparation of the glow effect.
  62361. * This is black by default as the blend operation is a blend operation.
  62362. */
  62363. static NeutralColor: Color4;
  62364. /**
  62365. * Stencil value used for glowing meshes.
  62366. */
  62367. static GlowingMeshStencilReference: number;
  62368. /**
  62369. * Stencil value used for the other meshes in the scene.
  62370. */
  62371. static NormalMeshStencilReference: number;
  62372. /**
  62373. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62374. */
  62375. innerGlow: boolean;
  62376. /**
  62377. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62378. */
  62379. outerGlow: boolean;
  62380. /**
  62381. * Specifies the horizontal size of the blur.
  62382. */
  62383. set blurHorizontalSize(value: number);
  62384. /**
  62385. * Specifies the vertical size of the blur.
  62386. */
  62387. set blurVerticalSize(value: number);
  62388. /**
  62389. * Gets the horizontal size of the blur.
  62390. */
  62391. get blurHorizontalSize(): number;
  62392. /**
  62393. * Gets the vertical size of the blur.
  62394. */
  62395. get blurVerticalSize(): number;
  62396. /**
  62397. * An event triggered when the highlight layer is being blurred.
  62398. */
  62399. onBeforeBlurObservable: Observable<HighlightLayer>;
  62400. /**
  62401. * An event triggered when the highlight layer has been blurred.
  62402. */
  62403. onAfterBlurObservable: Observable<HighlightLayer>;
  62404. private _instanceGlowingMeshStencilReference;
  62405. private _options;
  62406. private _downSamplePostprocess;
  62407. private _horizontalBlurPostprocess;
  62408. private _verticalBlurPostprocess;
  62409. private _blurTexture;
  62410. private _meshes;
  62411. private _excludedMeshes;
  62412. /**
  62413. * Instantiates a new highlight Layer and references it to the scene..
  62414. * @param name The name of the layer
  62415. * @param scene The scene to use the layer in
  62416. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62417. */
  62418. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62419. /**
  62420. * Get the effect name of the layer.
  62421. * @return The effect name
  62422. */
  62423. getEffectName(): string;
  62424. /**
  62425. * Create the merge effect. This is the shader use to blit the information back
  62426. * to the main canvas at the end of the scene rendering.
  62427. */
  62428. protected _createMergeEffect(): Effect;
  62429. /**
  62430. * Creates the render target textures and post processes used in the highlight layer.
  62431. */
  62432. protected _createTextureAndPostProcesses(): void;
  62433. /**
  62434. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62435. */
  62436. needStencil(): boolean;
  62437. /**
  62438. * Checks for the readiness of the element composing the layer.
  62439. * @param subMesh the mesh to check for
  62440. * @param useInstances specify wether or not to use instances to render the mesh
  62441. * @param emissiveTexture the associated emissive texture used to generate the glow
  62442. * @return true if ready otherwise, false
  62443. */
  62444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62445. /**
  62446. * Implementation specific of rendering the generating effect on the main canvas.
  62447. * @param effect The effect used to render through
  62448. */
  62449. protected _internalRender(effect: Effect): void;
  62450. /**
  62451. * Returns true if the layer contains information to display, otherwise false.
  62452. */
  62453. shouldRender(): boolean;
  62454. /**
  62455. * Returns true if the mesh should render, otherwise false.
  62456. * @param mesh The mesh to render
  62457. * @returns true if it should render otherwise false
  62458. */
  62459. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62460. /**
  62461. * Returns true if the mesh can be rendered, otherwise false.
  62462. * @param mesh The mesh to render
  62463. * @param material The material used on the mesh
  62464. * @returns true if it can be rendered otherwise false
  62465. */
  62466. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62467. /**
  62468. * Adds specific effects defines.
  62469. * @param defines The defines to add specifics to.
  62470. */
  62471. protected _addCustomEffectDefines(defines: string[]): void;
  62472. /**
  62473. * Sets the required values for both the emissive texture and and the main color.
  62474. */
  62475. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62476. /**
  62477. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62478. * @param mesh The mesh to exclude from the highlight layer
  62479. */
  62480. addExcludedMesh(mesh: Mesh): void;
  62481. /**
  62482. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62483. * @param mesh The mesh to highlight
  62484. */
  62485. removeExcludedMesh(mesh: Mesh): void;
  62486. /**
  62487. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62488. * @param mesh mesh to test
  62489. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62490. */
  62491. hasMesh(mesh: AbstractMesh): boolean;
  62492. /**
  62493. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62494. * @param mesh The mesh to highlight
  62495. * @param color The color of the highlight
  62496. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62497. */
  62498. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62499. /**
  62500. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62501. * @param mesh The mesh to highlight
  62502. */
  62503. removeMesh(mesh: Mesh): void;
  62504. /**
  62505. * Remove all the meshes currently referenced in the highlight layer
  62506. */
  62507. removeAllMeshes(): void;
  62508. /**
  62509. * Force the stencil to the normal expected value for none glowing parts
  62510. */
  62511. private _defaultStencilReference;
  62512. /**
  62513. * Free any resources and references associated to a mesh.
  62514. * Internal use
  62515. * @param mesh The mesh to free.
  62516. * @hidden
  62517. */
  62518. _disposeMesh(mesh: Mesh): void;
  62519. /**
  62520. * Dispose the highlight layer and free resources.
  62521. */
  62522. dispose(): void;
  62523. /**
  62524. * Gets the class name of the effect layer
  62525. * @returns the string with the class name of the effect layer
  62526. */
  62527. getClassName(): string;
  62528. /**
  62529. * Serializes this Highlight layer
  62530. * @returns a serialized Highlight layer object
  62531. */
  62532. serialize(): any;
  62533. /**
  62534. * Creates a Highlight layer from parsed Highlight layer data
  62535. * @param parsedHightlightLayer defines the Highlight layer data
  62536. * @param scene defines the current scene
  62537. * @param rootUrl defines the root URL containing the Highlight layer information
  62538. * @returns a parsed Highlight layer
  62539. */
  62540. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62541. }
  62542. }
  62543. declare module "babylonjs/Layers/layerSceneComponent" {
  62544. import { Scene } from "babylonjs/scene";
  62545. import { ISceneComponent } from "babylonjs/sceneComponent";
  62546. import { Layer } from "babylonjs/Layers/layer";
  62547. import { AbstractScene } from "babylonjs/abstractScene";
  62548. module "babylonjs/abstractScene" {
  62549. interface AbstractScene {
  62550. /**
  62551. * The list of layers (background and foreground) of the scene
  62552. */
  62553. layers: Array<Layer>;
  62554. }
  62555. }
  62556. /**
  62557. * Defines the layer scene component responsible to manage any layers
  62558. * in a given scene.
  62559. */
  62560. export class LayerSceneComponent implements ISceneComponent {
  62561. /**
  62562. * The component name helpfull to identify the component in the list of scene components.
  62563. */
  62564. readonly name: string;
  62565. /**
  62566. * The scene the component belongs to.
  62567. */
  62568. scene: Scene;
  62569. private _engine;
  62570. /**
  62571. * Creates a new instance of the component for the given scene
  62572. * @param scene Defines the scene to register the component in
  62573. */
  62574. constructor(scene: Scene);
  62575. /**
  62576. * Registers the component in a given scene
  62577. */
  62578. register(): void;
  62579. /**
  62580. * Rebuilds the elements related to this component in case of
  62581. * context lost for instance.
  62582. */
  62583. rebuild(): void;
  62584. /**
  62585. * Disposes the component and the associated ressources.
  62586. */
  62587. dispose(): void;
  62588. private _draw;
  62589. private _drawCameraPredicate;
  62590. private _drawCameraBackground;
  62591. private _drawCameraForeground;
  62592. private _drawRenderTargetPredicate;
  62593. private _drawRenderTargetBackground;
  62594. private _drawRenderTargetForeground;
  62595. /**
  62596. * Adds all the elements from the container to the scene
  62597. * @param container the container holding the elements
  62598. */
  62599. addFromContainer(container: AbstractScene): void;
  62600. /**
  62601. * Removes all the elements in the container from the scene
  62602. * @param container contains the elements to remove
  62603. * @param dispose if the removed element should be disposed (default: false)
  62604. */
  62605. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62606. }
  62607. }
  62608. declare module "babylonjs/Shaders/layer.fragment" {
  62609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62610. /** @hidden */
  62611. export var layerPixelShader: {
  62612. name: string;
  62613. shader: string;
  62614. };
  62615. }
  62616. declare module "babylonjs/Shaders/layer.vertex" {
  62617. /** @hidden */
  62618. export var layerVertexShader: {
  62619. name: string;
  62620. shader: string;
  62621. };
  62622. }
  62623. declare module "babylonjs/Layers/layer" {
  62624. import { Observable } from "babylonjs/Misc/observable";
  62625. import { Nullable } from "babylonjs/types";
  62626. import { Scene } from "babylonjs/scene";
  62627. import { Vector2 } from "babylonjs/Maths/math.vector";
  62628. import { Color4 } from "babylonjs/Maths/math.color";
  62629. import { Texture } from "babylonjs/Materials/Textures/texture";
  62630. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62631. import "babylonjs/Shaders/layer.fragment";
  62632. import "babylonjs/Shaders/layer.vertex";
  62633. /**
  62634. * This represents a full screen 2d layer.
  62635. * This can be useful to display a picture in the background of your scene for instance.
  62636. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62637. */
  62638. export class Layer {
  62639. /**
  62640. * Define the name of the layer.
  62641. */
  62642. name: string;
  62643. /**
  62644. * Define the texture the layer should display.
  62645. */
  62646. texture: Nullable<Texture>;
  62647. /**
  62648. * Is the layer in background or foreground.
  62649. */
  62650. isBackground: boolean;
  62651. /**
  62652. * Define the color of the layer (instead of texture).
  62653. */
  62654. color: Color4;
  62655. /**
  62656. * Define the scale of the layer in order to zoom in out of the texture.
  62657. */
  62658. scale: Vector2;
  62659. /**
  62660. * Define an offset for the layer in order to shift the texture.
  62661. */
  62662. offset: Vector2;
  62663. /**
  62664. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62665. */
  62666. alphaBlendingMode: number;
  62667. /**
  62668. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62669. * Alpha test will not mix with the background color in case of transparency.
  62670. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62671. */
  62672. alphaTest: boolean;
  62673. /**
  62674. * Define a mask to restrict the layer to only some of the scene cameras.
  62675. */
  62676. layerMask: number;
  62677. /**
  62678. * Define the list of render target the layer is visible into.
  62679. */
  62680. renderTargetTextures: RenderTargetTexture[];
  62681. /**
  62682. * Define if the layer is only used in renderTarget or if it also
  62683. * renders in the main frame buffer of the canvas.
  62684. */
  62685. renderOnlyInRenderTargetTextures: boolean;
  62686. private _scene;
  62687. private _vertexBuffers;
  62688. private _indexBuffer;
  62689. private _effect;
  62690. private _previousDefines;
  62691. /**
  62692. * An event triggered when the layer is disposed.
  62693. */
  62694. onDisposeObservable: Observable<Layer>;
  62695. private _onDisposeObserver;
  62696. /**
  62697. * Back compatibility with callback before the onDisposeObservable existed.
  62698. * The set callback will be triggered when the layer has been disposed.
  62699. */
  62700. set onDispose(callback: () => void);
  62701. /**
  62702. * An event triggered before rendering the scene
  62703. */
  62704. onBeforeRenderObservable: Observable<Layer>;
  62705. private _onBeforeRenderObserver;
  62706. /**
  62707. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62708. * The set callback will be triggered just before rendering the layer.
  62709. */
  62710. set onBeforeRender(callback: () => void);
  62711. /**
  62712. * An event triggered after rendering the scene
  62713. */
  62714. onAfterRenderObservable: Observable<Layer>;
  62715. private _onAfterRenderObserver;
  62716. /**
  62717. * Back compatibility with callback before the onAfterRenderObservable existed.
  62718. * The set callback will be triggered just after rendering the layer.
  62719. */
  62720. set onAfterRender(callback: () => void);
  62721. /**
  62722. * Instantiates a new layer.
  62723. * This represents a full screen 2d layer.
  62724. * This can be useful to display a picture in the background of your scene for instance.
  62725. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62726. * @param name Define the name of the layer in the scene
  62727. * @param imgUrl Define the url of the texture to display in the layer
  62728. * @param scene Define the scene the layer belongs to
  62729. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62730. * @param color Defines a color for the layer
  62731. */
  62732. constructor(
  62733. /**
  62734. * Define the name of the layer.
  62735. */
  62736. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62737. private _createIndexBuffer;
  62738. /** @hidden */
  62739. _rebuild(): void;
  62740. /**
  62741. * Renders the layer in the scene.
  62742. */
  62743. render(): void;
  62744. /**
  62745. * Disposes and releases the associated ressources.
  62746. */
  62747. dispose(): void;
  62748. }
  62749. }
  62750. declare module "babylonjs/Layers/index" {
  62751. export * from "babylonjs/Layers/effectLayer";
  62752. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62753. export * from "babylonjs/Layers/glowLayer";
  62754. export * from "babylonjs/Layers/highlightLayer";
  62755. export * from "babylonjs/Layers/layer";
  62756. export * from "babylonjs/Layers/layerSceneComponent";
  62757. }
  62758. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62759. /** @hidden */
  62760. export var lensFlarePixelShader: {
  62761. name: string;
  62762. shader: string;
  62763. };
  62764. }
  62765. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62766. /** @hidden */
  62767. export var lensFlareVertexShader: {
  62768. name: string;
  62769. shader: string;
  62770. };
  62771. }
  62772. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62773. import { Scene } from "babylonjs/scene";
  62774. import { Vector3 } from "babylonjs/Maths/math.vector";
  62775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62776. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62777. import "babylonjs/Shaders/lensFlare.fragment";
  62778. import "babylonjs/Shaders/lensFlare.vertex";
  62779. import { Viewport } from "babylonjs/Maths/math.viewport";
  62780. /**
  62781. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62782. * It is usually composed of several `lensFlare`.
  62783. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62784. */
  62785. export class LensFlareSystem {
  62786. /**
  62787. * Define the name of the lens flare system
  62788. */
  62789. name: string;
  62790. /**
  62791. * List of lens flares used in this system.
  62792. */
  62793. lensFlares: LensFlare[];
  62794. /**
  62795. * Define a limit from the border the lens flare can be visible.
  62796. */
  62797. borderLimit: number;
  62798. /**
  62799. * Define a viewport border we do not want to see the lens flare in.
  62800. */
  62801. viewportBorder: number;
  62802. /**
  62803. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62804. */
  62805. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62806. /**
  62807. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62808. */
  62809. layerMask: number;
  62810. /**
  62811. * Define the id of the lens flare system in the scene.
  62812. * (equal to name by default)
  62813. */
  62814. id: string;
  62815. private _scene;
  62816. private _emitter;
  62817. private _vertexBuffers;
  62818. private _indexBuffer;
  62819. private _effect;
  62820. private _positionX;
  62821. private _positionY;
  62822. private _isEnabled;
  62823. /** @hidden */
  62824. static _SceneComponentInitialization: (scene: Scene) => void;
  62825. /**
  62826. * Instantiates a lens flare system.
  62827. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62828. * It is usually composed of several `lensFlare`.
  62829. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62830. * @param name Define the name of the lens flare system in the scene
  62831. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62832. * @param scene Define the scene the lens flare system belongs to
  62833. */
  62834. constructor(
  62835. /**
  62836. * Define the name of the lens flare system
  62837. */
  62838. name: string, emitter: any, scene: Scene);
  62839. /**
  62840. * Define if the lens flare system is enabled.
  62841. */
  62842. get isEnabled(): boolean;
  62843. set isEnabled(value: boolean);
  62844. /**
  62845. * Get the scene the effects belongs to.
  62846. * @returns the scene holding the lens flare system
  62847. */
  62848. getScene(): Scene;
  62849. /**
  62850. * Get the emitter of the lens flare system.
  62851. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62852. * @returns the emitter of the lens flare system
  62853. */
  62854. getEmitter(): any;
  62855. /**
  62856. * Set the emitter of the lens flare system.
  62857. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62858. * @param newEmitter Define the new emitter of the system
  62859. */
  62860. setEmitter(newEmitter: any): void;
  62861. /**
  62862. * Get the lens flare system emitter position.
  62863. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62864. * @returns the position
  62865. */
  62866. getEmitterPosition(): Vector3;
  62867. /**
  62868. * @hidden
  62869. */
  62870. computeEffectivePosition(globalViewport: Viewport): boolean;
  62871. /** @hidden */
  62872. _isVisible(): boolean;
  62873. /**
  62874. * @hidden
  62875. */
  62876. render(): boolean;
  62877. /**
  62878. * Dispose and release the lens flare with its associated resources.
  62879. */
  62880. dispose(): void;
  62881. /**
  62882. * Parse a lens flare system from a JSON repressentation
  62883. * @param parsedLensFlareSystem Define the JSON to parse
  62884. * @param scene Define the scene the parsed system should be instantiated in
  62885. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62886. * @returns the parsed system
  62887. */
  62888. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62889. /**
  62890. * Serialize the current Lens Flare System into a JSON representation.
  62891. * @returns the serialized JSON
  62892. */
  62893. serialize(): any;
  62894. }
  62895. }
  62896. declare module "babylonjs/LensFlares/lensFlare" {
  62897. import { Nullable } from "babylonjs/types";
  62898. import { Color3 } from "babylonjs/Maths/math.color";
  62899. import { Texture } from "babylonjs/Materials/Textures/texture";
  62900. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62901. /**
  62902. * This represents one of the lens effect in a `lensFlareSystem`.
  62903. * It controls one of the indiviual texture used in the effect.
  62904. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62905. */
  62906. export class LensFlare {
  62907. /**
  62908. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62909. */
  62910. size: number;
  62911. /**
  62912. * 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.
  62913. */
  62914. position: number;
  62915. /**
  62916. * Define the lens color.
  62917. */
  62918. color: Color3;
  62919. /**
  62920. * Define the lens texture.
  62921. */
  62922. texture: Nullable<Texture>;
  62923. /**
  62924. * Define the alpha mode to render this particular lens.
  62925. */
  62926. alphaMode: number;
  62927. private _system;
  62928. /**
  62929. * Creates a new Lens Flare.
  62930. * This represents one of the lens effect in a `lensFlareSystem`.
  62931. * It controls one of the indiviual texture used in the effect.
  62932. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62933. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62934. * @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.
  62935. * @param color Define the lens color
  62936. * @param imgUrl Define the lens texture url
  62937. * @param system Define the `lensFlareSystem` this flare is part of
  62938. * @returns The newly created Lens Flare
  62939. */
  62940. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62941. /**
  62942. * Instantiates a new Lens Flare.
  62943. * This represents one of the lens effect in a `lensFlareSystem`.
  62944. * It controls one of the indiviual texture used in the effect.
  62945. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62946. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62947. * @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.
  62948. * @param color Define the lens color
  62949. * @param imgUrl Define the lens texture url
  62950. * @param system Define the `lensFlareSystem` this flare is part of
  62951. */
  62952. constructor(
  62953. /**
  62954. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62955. */
  62956. size: number,
  62957. /**
  62958. * 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.
  62959. */
  62960. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62961. /**
  62962. * Dispose and release the lens flare with its associated resources.
  62963. */
  62964. dispose(): void;
  62965. }
  62966. }
  62967. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62968. import { Nullable } from "babylonjs/types";
  62969. import { Scene } from "babylonjs/scene";
  62970. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62971. import { AbstractScene } from "babylonjs/abstractScene";
  62972. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62973. module "babylonjs/abstractScene" {
  62974. interface AbstractScene {
  62975. /**
  62976. * The list of lens flare system added to the scene
  62977. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62978. */
  62979. lensFlareSystems: Array<LensFlareSystem>;
  62980. /**
  62981. * Removes the given lens flare system from this scene.
  62982. * @param toRemove The lens flare system to remove
  62983. * @returns The index of the removed lens flare system
  62984. */
  62985. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62986. /**
  62987. * Adds the given lens flare system to this scene
  62988. * @param newLensFlareSystem The lens flare system to add
  62989. */
  62990. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62991. /**
  62992. * Gets a lens flare system using its name
  62993. * @param name defines the name to look for
  62994. * @returns the lens flare system or null if not found
  62995. */
  62996. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62997. /**
  62998. * Gets a lens flare system using its id
  62999. * @param id defines the id to look for
  63000. * @returns the lens flare system or null if not found
  63001. */
  63002. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63003. }
  63004. }
  63005. /**
  63006. * Defines the lens flare scene component responsible to manage any lens flares
  63007. * in a given scene.
  63008. */
  63009. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63010. /**
  63011. * The component name helpfull to identify the component in the list of scene components.
  63012. */
  63013. readonly name: string;
  63014. /**
  63015. * The scene the component belongs to.
  63016. */
  63017. scene: Scene;
  63018. /**
  63019. * Creates a new instance of the component for the given scene
  63020. * @param scene Defines the scene to register the component in
  63021. */
  63022. constructor(scene: Scene);
  63023. /**
  63024. * Registers the component in a given scene
  63025. */
  63026. register(): void;
  63027. /**
  63028. * Rebuilds the elements related to this component in case of
  63029. * context lost for instance.
  63030. */
  63031. rebuild(): void;
  63032. /**
  63033. * Adds all the elements from the container to the scene
  63034. * @param container the container holding the elements
  63035. */
  63036. addFromContainer(container: AbstractScene): void;
  63037. /**
  63038. * Removes all the elements in the container from the scene
  63039. * @param container contains the elements to remove
  63040. * @param dispose if the removed element should be disposed (default: false)
  63041. */
  63042. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63043. /**
  63044. * Serializes the component data to the specified json object
  63045. * @param serializationObject The object to serialize to
  63046. */
  63047. serialize(serializationObject: any): void;
  63048. /**
  63049. * Disposes the component and the associated ressources.
  63050. */
  63051. dispose(): void;
  63052. private _draw;
  63053. }
  63054. }
  63055. declare module "babylonjs/LensFlares/index" {
  63056. export * from "babylonjs/LensFlares/lensFlare";
  63057. export * from "babylonjs/LensFlares/lensFlareSystem";
  63058. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63059. }
  63060. declare module "babylonjs/Shaders/depth.fragment" {
  63061. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63062. /** @hidden */
  63063. export var depthPixelShader: {
  63064. name: string;
  63065. shader: string;
  63066. };
  63067. }
  63068. declare module "babylonjs/Shaders/depth.vertex" {
  63069. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63070. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63072. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63073. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63074. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63075. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63076. /** @hidden */
  63077. export var depthVertexShader: {
  63078. name: string;
  63079. shader: string;
  63080. };
  63081. }
  63082. declare module "babylonjs/Rendering/depthRenderer" {
  63083. import { Nullable } from "babylonjs/types";
  63084. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63085. import { Scene } from "babylonjs/scene";
  63086. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63087. import { Camera } from "babylonjs/Cameras/camera";
  63088. import "babylonjs/Shaders/depth.fragment";
  63089. import "babylonjs/Shaders/depth.vertex";
  63090. /**
  63091. * This represents a depth renderer in Babylon.
  63092. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63093. */
  63094. export class DepthRenderer {
  63095. private _scene;
  63096. private _depthMap;
  63097. private _effect;
  63098. private readonly _storeNonLinearDepth;
  63099. private readonly _clearColor;
  63100. /** Get if the depth renderer is using packed depth or not */
  63101. readonly isPacked: boolean;
  63102. private _cachedDefines;
  63103. private _camera;
  63104. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63105. enabled: boolean;
  63106. /**
  63107. * Specifiess that the depth renderer will only be used within
  63108. * the camera it is created for.
  63109. * This can help forcing its rendering during the camera processing.
  63110. */
  63111. useOnlyInActiveCamera: boolean;
  63112. /** @hidden */
  63113. static _SceneComponentInitialization: (scene: Scene) => void;
  63114. /**
  63115. * Instantiates a depth renderer
  63116. * @param scene The scene the renderer belongs to
  63117. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63118. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63119. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63120. */
  63121. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63122. /**
  63123. * Creates the depth rendering effect and checks if the effect is ready.
  63124. * @param subMesh The submesh to be used to render the depth map of
  63125. * @param useInstances If multiple world instances should be used
  63126. * @returns if the depth renderer is ready to render the depth map
  63127. */
  63128. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63129. /**
  63130. * Gets the texture which the depth map will be written to.
  63131. * @returns The depth map texture
  63132. */
  63133. getDepthMap(): RenderTargetTexture;
  63134. /**
  63135. * Disposes of the depth renderer.
  63136. */
  63137. dispose(): void;
  63138. }
  63139. }
  63140. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63141. /** @hidden */
  63142. export var minmaxReduxPixelShader: {
  63143. name: string;
  63144. shader: string;
  63145. };
  63146. }
  63147. declare module "babylonjs/Misc/minMaxReducer" {
  63148. import { Nullable } from "babylonjs/types";
  63149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63150. import { Camera } from "babylonjs/Cameras/camera";
  63151. import { Observer } from "babylonjs/Misc/observable";
  63152. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63153. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63154. import { Observable } from "babylonjs/Misc/observable";
  63155. import "babylonjs/Shaders/minmaxRedux.fragment";
  63156. /**
  63157. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63158. * and maximum values from all values of the texture.
  63159. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63160. * The source values are read from the red channel of the texture.
  63161. */
  63162. export class MinMaxReducer {
  63163. /**
  63164. * Observable triggered when the computation has been performed
  63165. */
  63166. onAfterReductionPerformed: Observable<{
  63167. min: number;
  63168. max: number;
  63169. }>;
  63170. protected _camera: Camera;
  63171. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63172. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63173. protected _postProcessManager: PostProcessManager;
  63174. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63175. protected _forceFullscreenViewport: boolean;
  63176. /**
  63177. * Creates a min/max reducer
  63178. * @param camera The camera to use for the post processes
  63179. */
  63180. constructor(camera: Camera);
  63181. /**
  63182. * Gets the texture used to read the values from.
  63183. */
  63184. get sourceTexture(): Nullable<RenderTargetTexture>;
  63185. /**
  63186. * Sets the source texture to read the values from.
  63187. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63188. * because in such textures '1' value must not be taken into account to compute the maximum
  63189. * as this value is used to clear the texture.
  63190. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63191. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63192. * @param depthRedux Indicates if the texture is a depth texture or not
  63193. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63194. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63195. */
  63196. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63197. /**
  63198. * Defines the refresh rate of the computation.
  63199. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63200. */
  63201. get refreshRate(): number;
  63202. set refreshRate(value: number);
  63203. protected _activated: boolean;
  63204. /**
  63205. * Gets the activation status of the reducer
  63206. */
  63207. get activated(): boolean;
  63208. /**
  63209. * Activates the reduction computation.
  63210. * When activated, the observers registered in onAfterReductionPerformed are
  63211. * called after the compuation is performed
  63212. */
  63213. activate(): void;
  63214. /**
  63215. * Deactivates the reduction computation.
  63216. */
  63217. deactivate(): void;
  63218. /**
  63219. * Disposes the min/max reducer
  63220. * @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.
  63221. */
  63222. dispose(disposeAll?: boolean): void;
  63223. }
  63224. }
  63225. declare module "babylonjs/Misc/depthReducer" {
  63226. import { Nullable } from "babylonjs/types";
  63227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63228. import { Camera } from "babylonjs/Cameras/camera";
  63229. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63230. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63231. /**
  63232. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63233. */
  63234. export class DepthReducer extends MinMaxReducer {
  63235. private _depthRenderer;
  63236. private _depthRendererId;
  63237. /**
  63238. * Gets the depth renderer used for the computation.
  63239. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63240. */
  63241. get depthRenderer(): Nullable<DepthRenderer>;
  63242. /**
  63243. * Creates a depth reducer
  63244. * @param camera The camera used to render the depth texture
  63245. */
  63246. constructor(camera: Camera);
  63247. /**
  63248. * Sets the depth renderer to use to generate the depth map
  63249. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63250. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63251. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63252. */
  63253. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63254. /** @hidden */
  63255. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63256. /**
  63257. * Activates the reduction computation.
  63258. * When activated, the observers registered in onAfterReductionPerformed are
  63259. * called after the compuation is performed
  63260. */
  63261. activate(): void;
  63262. /**
  63263. * Deactivates the reduction computation.
  63264. */
  63265. deactivate(): void;
  63266. /**
  63267. * Disposes the depth reducer
  63268. * @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.
  63269. */
  63270. dispose(disposeAll?: boolean): void;
  63271. }
  63272. }
  63273. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63274. import { Nullable } from "babylonjs/types";
  63275. import { Scene } from "babylonjs/scene";
  63276. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63277. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63279. import { Effect } from "babylonjs/Materials/effect";
  63280. import "babylonjs/Shaders/shadowMap.fragment";
  63281. import "babylonjs/Shaders/shadowMap.vertex";
  63282. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63283. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63284. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63285. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63286. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63287. /**
  63288. * A CSM implementation allowing casting shadows on large scenes.
  63289. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63290. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63291. */
  63292. export class CascadedShadowGenerator extends ShadowGenerator {
  63293. private static readonly frustumCornersNDCSpace;
  63294. /**
  63295. * Name of the CSM class
  63296. */
  63297. static CLASSNAME: string;
  63298. /**
  63299. * Defines the default number of cascades used by the CSM.
  63300. */
  63301. static readonly DEFAULT_CASCADES_COUNT: number;
  63302. /**
  63303. * Defines the minimum number of cascades used by the CSM.
  63304. */
  63305. static readonly MIN_CASCADES_COUNT: number;
  63306. /**
  63307. * Defines the maximum number of cascades used by the CSM.
  63308. */
  63309. static readonly MAX_CASCADES_COUNT: number;
  63310. protected _validateFilter(filter: number): number;
  63311. /**
  63312. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63313. */
  63314. penumbraDarkness: number;
  63315. private _numCascades;
  63316. /**
  63317. * Gets or set the number of cascades used by the CSM.
  63318. */
  63319. get numCascades(): number;
  63320. set numCascades(value: number);
  63321. /**
  63322. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63323. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63324. */
  63325. stabilizeCascades: boolean;
  63326. private _freezeShadowCastersBoundingInfo;
  63327. private _freezeShadowCastersBoundingInfoObservable;
  63328. /**
  63329. * Enables or disables the shadow casters bounding info computation.
  63330. * If your shadow casters don't move, you can disable this feature.
  63331. * If it is enabled, the bounding box computation is done every frame.
  63332. */
  63333. get freezeShadowCastersBoundingInfo(): boolean;
  63334. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63335. private _scbiMin;
  63336. private _scbiMax;
  63337. protected _computeShadowCastersBoundingInfo(): void;
  63338. protected _shadowCastersBoundingInfo: BoundingInfo;
  63339. /**
  63340. * Gets or sets the shadow casters bounding info.
  63341. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63342. * so that the system won't overwrite the bounds you provide
  63343. */
  63344. get shadowCastersBoundingInfo(): BoundingInfo;
  63345. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63346. protected _breaksAreDirty: boolean;
  63347. protected _minDistance: number;
  63348. protected _maxDistance: number;
  63349. /**
  63350. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63351. *
  63352. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63353. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63354. * @param min minimal distance for the breaks (default to 0.)
  63355. * @param max maximal distance for the breaks (default to 1.)
  63356. */
  63357. setMinMaxDistance(min: number, max: number): void;
  63358. /** Gets the minimal distance used in the cascade break computation */
  63359. get minDistance(): number;
  63360. /** Gets the maximal distance used in the cascade break computation */
  63361. get maxDistance(): number;
  63362. /**
  63363. * Gets the class name of that object
  63364. * @returns "CascadedShadowGenerator"
  63365. */
  63366. getClassName(): string;
  63367. private _cascadeMinExtents;
  63368. private _cascadeMaxExtents;
  63369. /**
  63370. * Gets a cascade minimum extents
  63371. * @param cascadeIndex index of the cascade
  63372. * @returns the minimum cascade extents
  63373. */
  63374. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63375. /**
  63376. * Gets a cascade maximum extents
  63377. * @param cascadeIndex index of the cascade
  63378. * @returns the maximum cascade extents
  63379. */
  63380. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63381. private _cascades;
  63382. private _currentLayer;
  63383. private _viewSpaceFrustumsZ;
  63384. private _viewMatrices;
  63385. private _projectionMatrices;
  63386. private _transformMatrices;
  63387. private _transformMatricesAsArray;
  63388. private _frustumLengths;
  63389. private _lightSizeUVCorrection;
  63390. private _depthCorrection;
  63391. private _frustumCornersWorldSpace;
  63392. private _frustumCenter;
  63393. private _shadowCameraPos;
  63394. private _shadowMaxZ;
  63395. /**
  63396. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63397. * It defaults to camera.maxZ
  63398. */
  63399. get shadowMaxZ(): number;
  63400. /**
  63401. * Sets the shadow max z distance.
  63402. */
  63403. set shadowMaxZ(value: number);
  63404. protected _debug: boolean;
  63405. /**
  63406. * Gets or sets the debug flag.
  63407. * When enabled, the cascades are materialized by different colors on the screen.
  63408. */
  63409. get debug(): boolean;
  63410. set debug(dbg: boolean);
  63411. private _depthClamp;
  63412. /**
  63413. * Gets or sets the depth clamping value.
  63414. *
  63415. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63416. * to account for the shadow casters far away.
  63417. *
  63418. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63419. */
  63420. get depthClamp(): boolean;
  63421. set depthClamp(value: boolean);
  63422. private _cascadeBlendPercentage;
  63423. /**
  63424. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63425. * It defaults to 0.1 (10% blending).
  63426. */
  63427. get cascadeBlendPercentage(): number;
  63428. set cascadeBlendPercentage(value: number);
  63429. private _lambda;
  63430. /**
  63431. * Gets or set the lambda parameter.
  63432. * This parameter is used to split the camera frustum and create the cascades.
  63433. * 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.
  63434. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63435. */
  63436. get lambda(): number;
  63437. set lambda(value: number);
  63438. /**
  63439. * Gets the view matrix corresponding to a given cascade
  63440. * @param cascadeNum cascade to retrieve the view matrix from
  63441. * @returns the cascade view matrix
  63442. */
  63443. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63444. /**
  63445. * Gets the projection matrix corresponding to a given cascade
  63446. * @param cascadeNum cascade to retrieve the projection matrix from
  63447. * @returns the cascade projection matrix
  63448. */
  63449. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63450. /**
  63451. * Gets the transformation matrix corresponding to a given cascade
  63452. * @param cascadeNum cascade to retrieve the transformation matrix from
  63453. * @returns the cascade transformation matrix
  63454. */
  63455. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63456. private _depthRenderer;
  63457. /**
  63458. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63459. *
  63460. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63461. *
  63462. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63463. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63464. * @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
  63465. */
  63466. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63467. private _depthReducer;
  63468. private _autoCalcDepthBounds;
  63469. /**
  63470. * Gets or sets the autoCalcDepthBounds property.
  63471. *
  63472. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63473. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63474. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63475. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63476. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63477. */
  63478. get autoCalcDepthBounds(): boolean;
  63479. set autoCalcDepthBounds(value: boolean);
  63480. /**
  63481. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63482. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63483. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63484. * for setting the refresh rate on the renderer yourself!
  63485. */
  63486. get autoCalcDepthBoundsRefreshRate(): number;
  63487. set autoCalcDepthBoundsRefreshRate(value: number);
  63488. /**
  63489. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63490. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63491. * you change the camera near/far planes!
  63492. */
  63493. splitFrustum(): void;
  63494. private _splitFrustum;
  63495. private _computeMatrices;
  63496. private _computeFrustumInWorldSpace;
  63497. private _computeCascadeFrustum;
  63498. /**
  63499. * Support test.
  63500. */
  63501. static get IsSupported(): boolean;
  63502. /** @hidden */
  63503. static _SceneComponentInitialization: (scene: Scene) => void;
  63504. /**
  63505. * Creates a Cascaded Shadow Generator object.
  63506. * A ShadowGenerator is the required tool to use the shadows.
  63507. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63508. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63509. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63510. * @param light The directional light object generating the shadows.
  63511. * @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.
  63512. */
  63513. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63514. protected _initializeGenerator(): void;
  63515. protected _createTargetRenderTexture(): void;
  63516. protected _initializeShadowMap(): void;
  63517. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63518. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63519. /**
  63520. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63521. * @param defines Defines of the material we want to update
  63522. * @param lightIndex Index of the light in the enabled light list of the material
  63523. */
  63524. prepareDefines(defines: any, lightIndex: number): void;
  63525. /**
  63526. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63527. * defined in the generator but impacting the effect).
  63528. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63529. * @param effect The effect we are binfing the information for
  63530. */
  63531. bindShadowLight(lightIndex: string, effect: Effect): void;
  63532. /**
  63533. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63534. * (eq to view projection * shadow projection matrices)
  63535. * @returns The transform matrix used to create the shadow map
  63536. */
  63537. getTransformMatrix(): Matrix;
  63538. /**
  63539. * Disposes the ShadowGenerator.
  63540. * Returns nothing.
  63541. */
  63542. dispose(): void;
  63543. /**
  63544. * Serializes the shadow generator setup to a json object.
  63545. * @returns The serialized JSON object
  63546. */
  63547. serialize(): any;
  63548. /**
  63549. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63550. * @param parsedShadowGenerator The JSON object to parse
  63551. * @param scene The scene to create the shadow map for
  63552. * @returns The parsed shadow generator
  63553. */
  63554. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63555. }
  63556. }
  63557. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63558. import { Scene } from "babylonjs/scene";
  63559. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63560. import { AbstractScene } from "babylonjs/abstractScene";
  63561. /**
  63562. * Defines the shadow generator component responsible to manage any shadow generators
  63563. * in a given scene.
  63564. */
  63565. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63566. /**
  63567. * The component name helpfull to identify the component in the list of scene components.
  63568. */
  63569. readonly name: string;
  63570. /**
  63571. * The scene the component belongs to.
  63572. */
  63573. scene: Scene;
  63574. /**
  63575. * Creates a new instance of the component for the given scene
  63576. * @param scene Defines the scene to register the component in
  63577. */
  63578. constructor(scene: Scene);
  63579. /**
  63580. * Registers the component in a given scene
  63581. */
  63582. register(): void;
  63583. /**
  63584. * Rebuilds the elements related to this component in case of
  63585. * context lost for instance.
  63586. */
  63587. rebuild(): void;
  63588. /**
  63589. * Serializes the component data to the specified json object
  63590. * @param serializationObject The object to serialize to
  63591. */
  63592. serialize(serializationObject: any): void;
  63593. /**
  63594. * Adds all the elements from the container to the scene
  63595. * @param container the container holding the elements
  63596. */
  63597. addFromContainer(container: AbstractScene): void;
  63598. /**
  63599. * Removes all the elements in the container from the scene
  63600. * @param container contains the elements to remove
  63601. * @param dispose if the removed element should be disposed (default: false)
  63602. */
  63603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63604. /**
  63605. * Rebuilds the elements related to this component in case of
  63606. * context lost for instance.
  63607. */
  63608. dispose(): void;
  63609. private _gatherRenderTargets;
  63610. }
  63611. }
  63612. declare module "babylonjs/Lights/Shadows/index" {
  63613. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63614. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63615. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63616. }
  63617. declare module "babylonjs/Lights/pointLight" {
  63618. import { Scene } from "babylonjs/scene";
  63619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63621. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63622. import { Effect } from "babylonjs/Materials/effect";
  63623. /**
  63624. * A point light is a light defined by an unique point in world space.
  63625. * The light is emitted in every direction from this point.
  63626. * A good example of a point light is a standard light bulb.
  63627. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63628. */
  63629. export class PointLight extends ShadowLight {
  63630. private _shadowAngle;
  63631. /**
  63632. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63633. * This specifies what angle the shadow will use to be created.
  63634. *
  63635. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63636. */
  63637. get shadowAngle(): number;
  63638. /**
  63639. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63640. * This specifies what angle the shadow will use to be created.
  63641. *
  63642. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63643. */
  63644. set shadowAngle(value: number);
  63645. /**
  63646. * Gets the direction if it has been set.
  63647. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63648. */
  63649. get direction(): Vector3;
  63650. /**
  63651. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63652. */
  63653. set direction(value: Vector3);
  63654. /**
  63655. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63656. * A PointLight emits the light in every direction.
  63657. * It can cast shadows.
  63658. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63659. * ```javascript
  63660. * var pointLight = new PointLight("pl", camera.position, scene);
  63661. * ```
  63662. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63663. * @param name The light friendly name
  63664. * @param position The position of the point light in the scene
  63665. * @param scene The scene the lights belongs to
  63666. */
  63667. constructor(name: string, position: Vector3, scene: Scene);
  63668. /**
  63669. * Returns the string "PointLight"
  63670. * @returns the class name
  63671. */
  63672. getClassName(): string;
  63673. /**
  63674. * Returns the integer 0.
  63675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63676. */
  63677. getTypeID(): number;
  63678. /**
  63679. * Specifies wether or not the shadowmap should be a cube texture.
  63680. * @returns true if the shadowmap needs to be a cube texture.
  63681. */
  63682. needCube(): boolean;
  63683. /**
  63684. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63685. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63686. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63687. */
  63688. getShadowDirection(faceIndex?: number): Vector3;
  63689. /**
  63690. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63691. * - fov = PI / 2
  63692. * - aspect ratio : 1.0
  63693. * - z-near and far equal to the active camera minZ and maxZ.
  63694. * Returns the PointLight.
  63695. */
  63696. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63697. protected _buildUniformLayout(): void;
  63698. /**
  63699. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63700. * @param effect The effect to update
  63701. * @param lightIndex The index of the light in the effect to update
  63702. * @returns The point light
  63703. */
  63704. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63705. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63706. /**
  63707. * Prepares the list of defines specific to the light type.
  63708. * @param defines the list of defines
  63709. * @param lightIndex defines the index of the light for the effect
  63710. */
  63711. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63712. }
  63713. }
  63714. declare module "babylonjs/Lights/index" {
  63715. export * from "babylonjs/Lights/light";
  63716. export * from "babylonjs/Lights/shadowLight";
  63717. export * from "babylonjs/Lights/Shadows/index";
  63718. export * from "babylonjs/Lights/directionalLight";
  63719. export * from "babylonjs/Lights/hemisphericLight";
  63720. export * from "babylonjs/Lights/pointLight";
  63721. export * from "babylonjs/Lights/spotLight";
  63722. }
  63723. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63724. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63725. /**
  63726. * Header information of HDR texture files.
  63727. */
  63728. export interface HDRInfo {
  63729. /**
  63730. * The height of the texture in pixels.
  63731. */
  63732. height: number;
  63733. /**
  63734. * The width of the texture in pixels.
  63735. */
  63736. width: number;
  63737. /**
  63738. * The index of the beginning of the data in the binary file.
  63739. */
  63740. dataPosition: number;
  63741. }
  63742. /**
  63743. * This groups tools to convert HDR texture to native colors array.
  63744. */
  63745. export class HDRTools {
  63746. private static Ldexp;
  63747. private static Rgbe2float;
  63748. private static readStringLine;
  63749. /**
  63750. * Reads header information from an RGBE texture stored in a native array.
  63751. * More information on this format are available here:
  63752. * https://en.wikipedia.org/wiki/RGBE_image_format
  63753. *
  63754. * @param uint8array The binary file stored in native array.
  63755. * @return The header information.
  63756. */
  63757. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63758. /**
  63759. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63760. * This RGBE texture needs to store the information as a panorama.
  63761. *
  63762. * More information on this format are available here:
  63763. * https://en.wikipedia.org/wiki/RGBE_image_format
  63764. *
  63765. * @param buffer The binary file stored in an array buffer.
  63766. * @param size The expected size of the extracted cubemap.
  63767. * @return The Cube Map information.
  63768. */
  63769. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63770. /**
  63771. * Returns the pixels data extracted from an RGBE texture.
  63772. * This pixels will be stored left to right up to down in the R G B order in one array.
  63773. *
  63774. * More information on this format are available here:
  63775. * https://en.wikipedia.org/wiki/RGBE_image_format
  63776. *
  63777. * @param uint8array The binary file stored in an array buffer.
  63778. * @param hdrInfo The header information of the file.
  63779. * @return The pixels data in RGB right to left up to down order.
  63780. */
  63781. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63782. private static RGBE_ReadPixels_RLE;
  63783. private static RGBE_ReadPixels_NOT_RLE;
  63784. }
  63785. }
  63786. declare module "babylonjs/Materials/effectRenderer" {
  63787. import { Nullable } from "babylonjs/types";
  63788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63790. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63791. import { Viewport } from "babylonjs/Maths/math.viewport";
  63792. import { Observable } from "babylonjs/Misc/observable";
  63793. import { Effect } from "babylonjs/Materials/effect";
  63794. import "babylonjs/Shaders/postprocess.vertex";
  63795. /**
  63796. * Effect Render Options
  63797. */
  63798. export interface IEffectRendererOptions {
  63799. /**
  63800. * Defines the vertices positions.
  63801. */
  63802. positions?: number[];
  63803. /**
  63804. * Defines the indices.
  63805. */
  63806. indices?: number[];
  63807. }
  63808. /**
  63809. * Helper class to render one or more effects.
  63810. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63811. */
  63812. export class EffectRenderer {
  63813. private engine;
  63814. private static _DefaultOptions;
  63815. private _vertexBuffers;
  63816. private _indexBuffer;
  63817. private _fullscreenViewport;
  63818. /**
  63819. * Creates an effect renderer
  63820. * @param engine the engine to use for rendering
  63821. * @param options defines the options of the effect renderer
  63822. */
  63823. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63824. /**
  63825. * Sets the current viewport in normalized coordinates 0-1
  63826. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63827. */
  63828. setViewport(viewport?: Viewport): void;
  63829. /**
  63830. * Binds the embedded attributes buffer to the effect.
  63831. * @param effect Defines the effect to bind the attributes for
  63832. */
  63833. bindBuffers(effect: Effect): void;
  63834. /**
  63835. * Sets the current effect wrapper to use during draw.
  63836. * The effect needs to be ready before calling this api.
  63837. * This also sets the default full screen position attribute.
  63838. * @param effectWrapper Defines the effect to draw with
  63839. */
  63840. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63841. /**
  63842. * Restores engine states
  63843. */
  63844. restoreStates(): void;
  63845. /**
  63846. * Draws a full screen quad.
  63847. */
  63848. draw(): void;
  63849. private isRenderTargetTexture;
  63850. /**
  63851. * renders one or more effects to a specified texture
  63852. * @param effectWrapper the effect to renderer
  63853. * @param outputTexture texture to draw to, if null it will render to the screen.
  63854. */
  63855. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63856. /**
  63857. * Disposes of the effect renderer
  63858. */
  63859. dispose(): void;
  63860. }
  63861. /**
  63862. * Options to create an EffectWrapper
  63863. */
  63864. interface EffectWrapperCreationOptions {
  63865. /**
  63866. * Engine to use to create the effect
  63867. */
  63868. engine: ThinEngine;
  63869. /**
  63870. * Fragment shader for the effect
  63871. */
  63872. fragmentShader: string;
  63873. /**
  63874. * Use the shader store instead of direct source code
  63875. */
  63876. useShaderStore?: boolean;
  63877. /**
  63878. * Vertex shader for the effect
  63879. */
  63880. vertexShader?: string;
  63881. /**
  63882. * Attributes to use in the shader
  63883. */
  63884. attributeNames?: Array<string>;
  63885. /**
  63886. * Uniforms to use in the shader
  63887. */
  63888. uniformNames?: Array<string>;
  63889. /**
  63890. * Texture sampler names to use in the shader
  63891. */
  63892. samplerNames?: Array<string>;
  63893. /**
  63894. * Defines to use in the shader
  63895. */
  63896. defines?: Array<string>;
  63897. /**
  63898. * Callback when effect is compiled
  63899. */
  63900. onCompiled?: Nullable<(effect: Effect) => void>;
  63901. /**
  63902. * The friendly name of the effect displayed in Spector.
  63903. */
  63904. name?: string;
  63905. }
  63906. /**
  63907. * Wraps an effect to be used for rendering
  63908. */
  63909. export class EffectWrapper {
  63910. /**
  63911. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63912. */
  63913. onApplyObservable: Observable<{}>;
  63914. /**
  63915. * The underlying effect
  63916. */
  63917. effect: Effect;
  63918. /**
  63919. * Creates an effect to be renderer
  63920. * @param creationOptions options to create the effect
  63921. */
  63922. constructor(creationOptions: EffectWrapperCreationOptions);
  63923. /**
  63924. * Disposes of the effect wrapper
  63925. */
  63926. dispose(): void;
  63927. }
  63928. }
  63929. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63930. /** @hidden */
  63931. export var hdrFilteringVertexShader: {
  63932. name: string;
  63933. shader: string;
  63934. };
  63935. }
  63936. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63937. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63938. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63939. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63940. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63941. /** @hidden */
  63942. export var hdrFilteringPixelShader: {
  63943. name: string;
  63944. shader: string;
  63945. };
  63946. }
  63947. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63949. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63950. import { Nullable } from "babylonjs/types";
  63951. import "babylonjs/Shaders/hdrFiltering.vertex";
  63952. import "babylonjs/Shaders/hdrFiltering.fragment";
  63953. /**
  63954. * Options for texture filtering
  63955. */
  63956. interface IHDRFilteringOptions {
  63957. /**
  63958. * Scales pixel intensity for the input HDR map.
  63959. */
  63960. hdrScale?: number;
  63961. /**
  63962. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63963. */
  63964. quality?: number;
  63965. }
  63966. /**
  63967. * Filters HDR maps to get correct renderings of PBR reflections
  63968. */
  63969. export class HDRFiltering {
  63970. private _engine;
  63971. private _effectRenderer;
  63972. private _effectWrapper;
  63973. private _lodGenerationOffset;
  63974. private _lodGenerationScale;
  63975. /**
  63976. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63977. * you care about baking speed.
  63978. */
  63979. quality: number;
  63980. /**
  63981. * Scales pixel intensity for the input HDR map.
  63982. */
  63983. hdrScale: number;
  63984. /**
  63985. * Instantiates HDR filter for reflection maps
  63986. *
  63987. * @param engine Thin engine
  63988. * @param options Options
  63989. */
  63990. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63991. private _createRenderTarget;
  63992. private _prefilterInternal;
  63993. private _createEffect;
  63994. /**
  63995. * Get a value indicating if the filter is ready to be used
  63996. * @param texture Texture to filter
  63997. * @returns true if the filter is ready
  63998. */
  63999. isReady(texture: BaseTexture): boolean;
  64000. /**
  64001. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64002. * Prefiltering will be invoked at the end of next rendering pass.
  64003. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64004. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64005. * @param texture Texture to filter
  64006. * @param onFinished Callback when filtering is done
  64007. * @return Promise called when prefiltering is done
  64008. */
  64009. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64010. }
  64011. }
  64012. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64013. import { Nullable } from "babylonjs/types";
  64014. import { Scene } from "babylonjs/scene";
  64015. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64017. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64018. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64019. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64020. /**
  64021. * This represents a texture coming from an HDR input.
  64022. *
  64023. * The only supported format is currently panorama picture stored in RGBE format.
  64024. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64025. */
  64026. export class HDRCubeTexture extends BaseTexture {
  64027. private static _facesMapping;
  64028. private _generateHarmonics;
  64029. private _noMipmap;
  64030. private _prefilterOnLoad;
  64031. private _textureMatrix;
  64032. private _size;
  64033. private _onLoad;
  64034. private _onError;
  64035. /**
  64036. * The texture URL.
  64037. */
  64038. url: string;
  64039. protected _isBlocking: boolean;
  64040. /**
  64041. * Sets wether or not the texture is blocking during loading.
  64042. */
  64043. set isBlocking(value: boolean);
  64044. /**
  64045. * Gets wether or not the texture is blocking during loading.
  64046. */
  64047. get isBlocking(): boolean;
  64048. protected _rotationY: number;
  64049. /**
  64050. * Sets texture matrix rotation angle around Y axis in radians.
  64051. */
  64052. set rotationY(value: number);
  64053. /**
  64054. * Gets texture matrix rotation angle around Y axis radians.
  64055. */
  64056. get rotationY(): number;
  64057. /**
  64058. * Gets or sets the center of the bounding box associated with the cube texture
  64059. * It must define where the camera used to render the texture was set
  64060. */
  64061. boundingBoxPosition: Vector3;
  64062. private _boundingBoxSize;
  64063. /**
  64064. * Gets or sets the size of the bounding box associated with the cube texture
  64065. * When defined, the cubemap will switch to local mode
  64066. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64067. * @example https://www.babylonjs-playground.com/#RNASML
  64068. */
  64069. set boundingBoxSize(value: Vector3);
  64070. get boundingBoxSize(): Vector3;
  64071. /**
  64072. * Instantiates an HDRTexture from the following parameters.
  64073. *
  64074. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64075. * @param sceneOrEngine The scene or engine the texture will be used in
  64076. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64077. * @param noMipmap Forces to not generate the mipmap if true
  64078. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64079. * @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)
  64080. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64081. */
  64082. 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>);
  64083. /**
  64084. * Get the current class name of the texture useful for serialization or dynamic coding.
  64085. * @returns "HDRCubeTexture"
  64086. */
  64087. getClassName(): string;
  64088. /**
  64089. * Occurs when the file is raw .hdr file.
  64090. */
  64091. private loadTexture;
  64092. clone(): HDRCubeTexture;
  64093. delayLoad(): void;
  64094. /**
  64095. * Get the texture reflection matrix used to rotate/transform the reflection.
  64096. * @returns the reflection matrix
  64097. */
  64098. getReflectionTextureMatrix(): Matrix;
  64099. /**
  64100. * Set the texture reflection matrix used to rotate/transform the reflection.
  64101. * @param value Define the reflection matrix to set
  64102. */
  64103. setReflectionTextureMatrix(value: Matrix): void;
  64104. /**
  64105. * Parses a JSON representation of an HDR Texture in order to create the texture
  64106. * @param parsedTexture Define the JSON representation
  64107. * @param scene Define the scene the texture should be created in
  64108. * @param rootUrl Define the root url in case we need to load relative dependencies
  64109. * @returns the newly created texture after parsing
  64110. */
  64111. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64112. serialize(): any;
  64113. }
  64114. }
  64115. declare module "babylonjs/Physics/physicsEngine" {
  64116. import { Nullable } from "babylonjs/types";
  64117. import { Vector3 } from "babylonjs/Maths/math.vector";
  64118. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64119. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64120. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64121. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64122. /**
  64123. * Class used to control physics engine
  64124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64125. */
  64126. export class PhysicsEngine implements IPhysicsEngine {
  64127. private _physicsPlugin;
  64128. /**
  64129. * Global value used to control the smallest number supported by the simulation
  64130. */
  64131. static Epsilon: number;
  64132. private _impostors;
  64133. private _joints;
  64134. private _subTimeStep;
  64135. /**
  64136. * Gets the gravity vector used by the simulation
  64137. */
  64138. gravity: Vector3;
  64139. /**
  64140. * Factory used to create the default physics plugin.
  64141. * @returns The default physics plugin
  64142. */
  64143. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64144. /**
  64145. * Creates a new Physics Engine
  64146. * @param gravity defines the gravity vector used by the simulation
  64147. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64148. */
  64149. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64150. /**
  64151. * Sets the gravity vector used by the simulation
  64152. * @param gravity defines the gravity vector to use
  64153. */
  64154. setGravity(gravity: Vector3): void;
  64155. /**
  64156. * Set the time step of the physics engine.
  64157. * Default is 1/60.
  64158. * To slow it down, enter 1/600 for example.
  64159. * To speed it up, 1/30
  64160. * @param newTimeStep defines the new timestep to apply to this world.
  64161. */
  64162. setTimeStep(newTimeStep?: number): void;
  64163. /**
  64164. * Get the time step of the physics engine.
  64165. * @returns the current time step
  64166. */
  64167. getTimeStep(): number;
  64168. /**
  64169. * Set the sub time step of the physics engine.
  64170. * Default is 0 meaning there is no sub steps
  64171. * To increase physics resolution precision, set a small value (like 1 ms)
  64172. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64173. */
  64174. setSubTimeStep(subTimeStep?: number): void;
  64175. /**
  64176. * Get the sub time step of the physics engine.
  64177. * @returns the current sub time step
  64178. */
  64179. getSubTimeStep(): number;
  64180. /**
  64181. * Release all resources
  64182. */
  64183. dispose(): void;
  64184. /**
  64185. * Gets the name of the current physics plugin
  64186. * @returns the name of the plugin
  64187. */
  64188. getPhysicsPluginName(): string;
  64189. /**
  64190. * Adding a new impostor for the impostor tracking.
  64191. * This will be done by the impostor itself.
  64192. * @param impostor the impostor to add
  64193. */
  64194. addImpostor(impostor: PhysicsImpostor): void;
  64195. /**
  64196. * Remove an impostor from the engine.
  64197. * This impostor and its mesh will not longer be updated by the physics engine.
  64198. * @param impostor the impostor to remove
  64199. */
  64200. removeImpostor(impostor: PhysicsImpostor): void;
  64201. /**
  64202. * Add a joint to the physics engine
  64203. * @param mainImpostor defines the main impostor to which the joint is added.
  64204. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64205. * @param joint defines the joint that will connect both impostors.
  64206. */
  64207. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64208. /**
  64209. * Removes a joint from the simulation
  64210. * @param mainImpostor defines the impostor used with the joint
  64211. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64212. * @param joint defines the joint to remove
  64213. */
  64214. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64215. /**
  64216. * Called by the scene. No need to call it.
  64217. * @param delta defines the timespam between frames
  64218. */
  64219. _step(delta: number): void;
  64220. /**
  64221. * Gets the current plugin used to run the simulation
  64222. * @returns current plugin
  64223. */
  64224. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64225. /**
  64226. * Gets the list of physic impostors
  64227. * @returns an array of PhysicsImpostor
  64228. */
  64229. getImpostors(): Array<PhysicsImpostor>;
  64230. /**
  64231. * Gets the impostor for a physics enabled object
  64232. * @param object defines the object impersonated by the impostor
  64233. * @returns the PhysicsImpostor or null if not found
  64234. */
  64235. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64236. /**
  64237. * Gets the impostor for a physics body object
  64238. * @param body defines physics body used by the impostor
  64239. * @returns the PhysicsImpostor or null if not found
  64240. */
  64241. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64242. /**
  64243. * Does a raycast in the physics world
  64244. * @param from when should the ray start?
  64245. * @param to when should the ray end?
  64246. * @returns PhysicsRaycastResult
  64247. */
  64248. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64249. }
  64250. }
  64251. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64252. import { Nullable } from "babylonjs/types";
  64253. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64255. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64256. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64257. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64258. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64259. /** @hidden */
  64260. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64261. private _useDeltaForWorldStep;
  64262. world: any;
  64263. name: string;
  64264. private _physicsMaterials;
  64265. private _fixedTimeStep;
  64266. private _cannonRaycastResult;
  64267. private _raycastResult;
  64268. private _physicsBodysToRemoveAfterStep;
  64269. private _firstFrame;
  64270. BJSCANNON: any;
  64271. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64272. setGravity(gravity: Vector3): void;
  64273. setTimeStep(timeStep: number): void;
  64274. getTimeStep(): number;
  64275. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64276. private _removeMarkedPhysicsBodiesFromWorld;
  64277. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64278. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64279. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64280. private _processChildMeshes;
  64281. removePhysicsBody(impostor: PhysicsImpostor): void;
  64282. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64283. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64284. private _addMaterial;
  64285. private _checkWithEpsilon;
  64286. private _createShape;
  64287. private _createHeightmap;
  64288. private _minus90X;
  64289. private _plus90X;
  64290. private _tmpPosition;
  64291. private _tmpDeltaPosition;
  64292. private _tmpUnityRotation;
  64293. private _updatePhysicsBodyTransformation;
  64294. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64296. isSupported(): boolean;
  64297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64299. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64302. getBodyMass(impostor: PhysicsImpostor): number;
  64303. getBodyFriction(impostor: PhysicsImpostor): number;
  64304. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64305. getBodyRestitution(impostor: PhysicsImpostor): number;
  64306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64307. sleepBody(impostor: PhysicsImpostor): void;
  64308. wakeUpBody(impostor: PhysicsImpostor): void;
  64309. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64310. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64312. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64313. getRadius(impostor: PhysicsImpostor): number;
  64314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64315. dispose(): void;
  64316. private _extendNamespace;
  64317. /**
  64318. * Does a raycast in the physics world
  64319. * @param from when should the ray start?
  64320. * @param to when should the ray end?
  64321. * @returns PhysicsRaycastResult
  64322. */
  64323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64324. }
  64325. }
  64326. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64327. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64328. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64329. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64331. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64332. import { Nullable } from "babylonjs/types";
  64333. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64334. /** @hidden */
  64335. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64336. private _useDeltaForWorldStep;
  64337. world: any;
  64338. name: string;
  64339. BJSOIMO: any;
  64340. private _raycastResult;
  64341. private _fixedTimeStep;
  64342. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64343. setGravity(gravity: Vector3): void;
  64344. setTimeStep(timeStep: number): void;
  64345. getTimeStep(): number;
  64346. private _tmpImpostorsArray;
  64347. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64348. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64349. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64351. private _tmpPositionVector;
  64352. removePhysicsBody(impostor: PhysicsImpostor): void;
  64353. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64354. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64355. isSupported(): boolean;
  64356. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64357. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64358. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64359. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64360. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64361. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64362. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64363. getBodyMass(impostor: PhysicsImpostor): number;
  64364. getBodyFriction(impostor: PhysicsImpostor): number;
  64365. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64366. getBodyRestitution(impostor: PhysicsImpostor): number;
  64367. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64368. sleepBody(impostor: PhysicsImpostor): void;
  64369. wakeUpBody(impostor: PhysicsImpostor): void;
  64370. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64371. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64372. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64373. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64374. getRadius(impostor: PhysicsImpostor): number;
  64375. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64376. dispose(): void;
  64377. /**
  64378. * Does a raycast in the physics world
  64379. * @param from when should the ray start?
  64380. * @param to when should the ray end?
  64381. * @returns PhysicsRaycastResult
  64382. */
  64383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64384. }
  64385. }
  64386. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64387. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64388. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64389. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64390. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64391. import { Nullable } from "babylonjs/types";
  64392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64393. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64394. /**
  64395. * AmmoJS Physics plugin
  64396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64397. * @see https://github.com/kripken/ammo.js/
  64398. */
  64399. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64400. private _useDeltaForWorldStep;
  64401. /**
  64402. * Reference to the Ammo library
  64403. */
  64404. bjsAMMO: any;
  64405. /**
  64406. * Created ammoJS world which physics bodies are added to
  64407. */
  64408. world: any;
  64409. /**
  64410. * Name of the plugin
  64411. */
  64412. name: string;
  64413. private _timeStep;
  64414. private _fixedTimeStep;
  64415. private _maxSteps;
  64416. private _tmpQuaternion;
  64417. private _tmpAmmoTransform;
  64418. private _tmpAmmoQuaternion;
  64419. private _tmpAmmoConcreteContactResultCallback;
  64420. private _collisionConfiguration;
  64421. private _dispatcher;
  64422. private _overlappingPairCache;
  64423. private _solver;
  64424. private _softBodySolver;
  64425. private _tmpAmmoVectorA;
  64426. private _tmpAmmoVectorB;
  64427. private _tmpAmmoVectorC;
  64428. private _tmpAmmoVectorD;
  64429. private _tmpContactCallbackResult;
  64430. private _tmpAmmoVectorRCA;
  64431. private _tmpAmmoVectorRCB;
  64432. private _raycastResult;
  64433. private _tmpContactPoint;
  64434. private static readonly DISABLE_COLLISION_FLAG;
  64435. private static readonly KINEMATIC_FLAG;
  64436. private static readonly DISABLE_DEACTIVATION_FLAG;
  64437. /**
  64438. * Initializes the ammoJS plugin
  64439. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64440. * @param ammoInjection can be used to inject your own ammo reference
  64441. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64442. */
  64443. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64444. /**
  64445. * Sets the gravity of the physics world (m/(s^2))
  64446. * @param gravity Gravity to set
  64447. */
  64448. setGravity(gravity: Vector3): void;
  64449. /**
  64450. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64451. * @param timeStep timestep to use in seconds
  64452. */
  64453. setTimeStep(timeStep: number): void;
  64454. /**
  64455. * 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)
  64456. * @param fixedTimeStep fixedTimeStep to use in seconds
  64457. */
  64458. setFixedTimeStep(fixedTimeStep: number): void;
  64459. /**
  64460. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64461. * @param maxSteps the maximum number of steps by the physics engine per frame
  64462. */
  64463. setMaxSteps(maxSteps: number): void;
  64464. /**
  64465. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64466. * @returns the current timestep in seconds
  64467. */
  64468. getTimeStep(): number;
  64469. /**
  64470. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64471. */
  64472. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64473. private _isImpostorInContact;
  64474. private _isImpostorPairInContact;
  64475. private _stepSimulation;
  64476. /**
  64477. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64478. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64479. * After the step the babylon meshes are set to the position of the physics imposters
  64480. * @param delta amount of time to step forward
  64481. * @param impostors array of imposters to update before/after the step
  64482. */
  64483. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64484. /**
  64485. * Update babylon mesh to match physics world object
  64486. * @param impostor imposter to match
  64487. */
  64488. private _afterSoftStep;
  64489. /**
  64490. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64491. * @param impostor imposter to match
  64492. */
  64493. private _ropeStep;
  64494. /**
  64495. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64496. * @param impostor imposter to match
  64497. */
  64498. private _softbodyOrClothStep;
  64499. private _tmpMatrix;
  64500. /**
  64501. * Applies an impulse on the imposter
  64502. * @param impostor imposter to apply impulse to
  64503. * @param force amount of force to be applied to the imposter
  64504. * @param contactPoint the location to apply the impulse on the imposter
  64505. */
  64506. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64507. /**
  64508. * Applies a force on the imposter
  64509. * @param impostor imposter to apply force
  64510. * @param force amount of force to be applied to the imposter
  64511. * @param contactPoint the location to apply the force on the imposter
  64512. */
  64513. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64514. /**
  64515. * Creates a physics body using the plugin
  64516. * @param impostor the imposter to create the physics body on
  64517. */
  64518. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64519. /**
  64520. * Removes the physics body from the imposter and disposes of the body's memory
  64521. * @param impostor imposter to remove the physics body from
  64522. */
  64523. removePhysicsBody(impostor: PhysicsImpostor): void;
  64524. /**
  64525. * Generates a joint
  64526. * @param impostorJoint the imposter joint to create the joint with
  64527. */
  64528. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64529. /**
  64530. * Removes a joint
  64531. * @param impostorJoint the imposter joint to remove the joint from
  64532. */
  64533. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64534. private _addMeshVerts;
  64535. /**
  64536. * Initialise the soft body vertices to match its object's (mesh) vertices
  64537. * Softbody vertices (nodes) are in world space and to match this
  64538. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64539. * @param impostor to create the softbody for
  64540. */
  64541. private _softVertexData;
  64542. /**
  64543. * Create an impostor's soft body
  64544. * @param impostor to create the softbody for
  64545. */
  64546. private _createSoftbody;
  64547. /**
  64548. * Create cloth for an impostor
  64549. * @param impostor to create the softbody for
  64550. */
  64551. private _createCloth;
  64552. /**
  64553. * Create rope for an impostor
  64554. * @param impostor to create the softbody for
  64555. */
  64556. private _createRope;
  64557. /**
  64558. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64559. * @param impostor to create the custom physics shape for
  64560. */
  64561. private _createCustom;
  64562. private _addHullVerts;
  64563. private _createShape;
  64564. /**
  64565. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64566. * @param impostor imposter containing the physics body and babylon object
  64567. */
  64568. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64569. /**
  64570. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64571. * @param impostor imposter containing the physics body and babylon object
  64572. * @param newPosition new position
  64573. * @param newRotation new rotation
  64574. */
  64575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64576. /**
  64577. * If this plugin is supported
  64578. * @returns true if its supported
  64579. */
  64580. isSupported(): boolean;
  64581. /**
  64582. * Sets the linear velocity of the physics body
  64583. * @param impostor imposter to set the velocity on
  64584. * @param velocity velocity to set
  64585. */
  64586. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64587. /**
  64588. * Sets the angular velocity of the physics body
  64589. * @param impostor imposter to set the velocity on
  64590. * @param velocity velocity to set
  64591. */
  64592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64593. /**
  64594. * gets the linear velocity
  64595. * @param impostor imposter to get linear velocity from
  64596. * @returns linear velocity
  64597. */
  64598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64599. /**
  64600. * gets the angular velocity
  64601. * @param impostor imposter to get angular velocity from
  64602. * @returns angular velocity
  64603. */
  64604. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64605. /**
  64606. * Sets the mass of physics body
  64607. * @param impostor imposter to set the mass on
  64608. * @param mass mass to set
  64609. */
  64610. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64611. /**
  64612. * Gets the mass of the physics body
  64613. * @param impostor imposter to get the mass from
  64614. * @returns mass
  64615. */
  64616. getBodyMass(impostor: PhysicsImpostor): number;
  64617. /**
  64618. * Gets friction of the impostor
  64619. * @param impostor impostor to get friction from
  64620. * @returns friction value
  64621. */
  64622. getBodyFriction(impostor: PhysicsImpostor): number;
  64623. /**
  64624. * Sets friction of the impostor
  64625. * @param impostor impostor to set friction on
  64626. * @param friction friction value
  64627. */
  64628. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64629. /**
  64630. * Gets restitution of the impostor
  64631. * @param impostor impostor to get restitution from
  64632. * @returns restitution value
  64633. */
  64634. getBodyRestitution(impostor: PhysicsImpostor): number;
  64635. /**
  64636. * Sets resitution of the impostor
  64637. * @param impostor impostor to set resitution on
  64638. * @param restitution resitution value
  64639. */
  64640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64641. /**
  64642. * Gets pressure inside the impostor
  64643. * @param impostor impostor to get pressure from
  64644. * @returns pressure value
  64645. */
  64646. getBodyPressure(impostor: PhysicsImpostor): number;
  64647. /**
  64648. * Sets pressure inside a soft body impostor
  64649. * Cloth and rope must remain 0 pressure
  64650. * @param impostor impostor to set pressure on
  64651. * @param pressure pressure value
  64652. */
  64653. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64654. /**
  64655. * Gets stiffness of the impostor
  64656. * @param impostor impostor to get stiffness from
  64657. * @returns pressure value
  64658. */
  64659. getBodyStiffness(impostor: PhysicsImpostor): number;
  64660. /**
  64661. * Sets stiffness of the impostor
  64662. * @param impostor impostor to set stiffness on
  64663. * @param stiffness stiffness value from 0 to 1
  64664. */
  64665. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64666. /**
  64667. * Gets velocityIterations of the impostor
  64668. * @param impostor impostor to get velocity iterations from
  64669. * @returns velocityIterations value
  64670. */
  64671. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64672. /**
  64673. * Sets velocityIterations of the impostor
  64674. * @param impostor impostor to set velocity iterations on
  64675. * @param velocityIterations velocityIterations value
  64676. */
  64677. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64678. /**
  64679. * Gets positionIterations of the impostor
  64680. * @param impostor impostor to get position iterations from
  64681. * @returns positionIterations value
  64682. */
  64683. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64684. /**
  64685. * Sets positionIterations of the impostor
  64686. * @param impostor impostor to set position on
  64687. * @param positionIterations positionIterations value
  64688. */
  64689. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64690. /**
  64691. * Append an anchor to a cloth object
  64692. * @param impostor is the cloth impostor to add anchor to
  64693. * @param otherImpostor is the rigid impostor to anchor to
  64694. * @param width ratio across width from 0 to 1
  64695. * @param height ratio up height from 0 to 1
  64696. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64697. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64698. */
  64699. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64700. /**
  64701. * Append an hook to a rope object
  64702. * @param impostor is the rope impostor to add hook to
  64703. * @param otherImpostor is the rigid impostor to hook to
  64704. * @param length ratio along the rope from 0 to 1
  64705. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64706. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64707. */
  64708. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64709. /**
  64710. * Sleeps the physics body and stops it from being active
  64711. * @param impostor impostor to sleep
  64712. */
  64713. sleepBody(impostor: PhysicsImpostor): void;
  64714. /**
  64715. * Activates the physics body
  64716. * @param impostor impostor to activate
  64717. */
  64718. wakeUpBody(impostor: PhysicsImpostor): void;
  64719. /**
  64720. * Updates the distance parameters of the joint
  64721. * @param joint joint to update
  64722. * @param maxDistance maximum distance of the joint
  64723. * @param minDistance minimum distance of the joint
  64724. */
  64725. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64726. /**
  64727. * Sets a motor on the joint
  64728. * @param joint joint to set motor on
  64729. * @param speed speed of the motor
  64730. * @param maxForce maximum force of the motor
  64731. * @param motorIndex index of the motor
  64732. */
  64733. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64734. /**
  64735. * Sets the motors limit
  64736. * @param joint joint to set limit on
  64737. * @param upperLimit upper limit
  64738. * @param lowerLimit lower limit
  64739. */
  64740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64741. /**
  64742. * Syncs the position and rotation of a mesh with the impostor
  64743. * @param mesh mesh to sync
  64744. * @param impostor impostor to update the mesh with
  64745. */
  64746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64747. /**
  64748. * Gets the radius of the impostor
  64749. * @param impostor impostor to get radius from
  64750. * @returns the radius
  64751. */
  64752. getRadius(impostor: PhysicsImpostor): number;
  64753. /**
  64754. * Gets the box size of the impostor
  64755. * @param impostor impostor to get box size from
  64756. * @param result the resulting box size
  64757. */
  64758. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64759. /**
  64760. * Disposes of the impostor
  64761. */
  64762. dispose(): void;
  64763. /**
  64764. * Does a raycast in the physics world
  64765. * @param from when should the ray start?
  64766. * @param to when should the ray end?
  64767. * @returns PhysicsRaycastResult
  64768. */
  64769. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64770. }
  64771. }
  64772. declare module "babylonjs/Probes/reflectionProbe" {
  64773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64774. import { Vector3 } from "babylonjs/Maths/math.vector";
  64775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64776. import { Nullable } from "babylonjs/types";
  64777. import { Scene } from "babylonjs/scene";
  64778. module "babylonjs/abstractScene" {
  64779. interface AbstractScene {
  64780. /**
  64781. * The list of reflection probes added to the scene
  64782. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64783. */
  64784. reflectionProbes: Array<ReflectionProbe>;
  64785. /**
  64786. * Removes the given reflection probe from this scene.
  64787. * @param toRemove The reflection probe to remove
  64788. * @returns The index of the removed reflection probe
  64789. */
  64790. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64791. /**
  64792. * Adds the given reflection probe to this scene.
  64793. * @param newReflectionProbe The reflection probe to add
  64794. */
  64795. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64796. }
  64797. }
  64798. /**
  64799. * Class used to generate realtime reflection / refraction cube textures
  64800. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64801. */
  64802. export class ReflectionProbe {
  64803. /** defines the name of the probe */
  64804. name: string;
  64805. private _scene;
  64806. private _renderTargetTexture;
  64807. private _projectionMatrix;
  64808. private _viewMatrix;
  64809. private _target;
  64810. private _add;
  64811. private _attachedMesh;
  64812. private _invertYAxis;
  64813. /** Gets or sets probe position (center of the cube map) */
  64814. position: Vector3;
  64815. /**
  64816. * Creates a new reflection probe
  64817. * @param name defines the name of the probe
  64818. * @param size defines the texture resolution (for each face)
  64819. * @param scene defines the hosting scene
  64820. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64821. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64822. */
  64823. constructor(
  64824. /** defines the name of the probe */
  64825. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64826. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64827. get samples(): number;
  64828. set samples(value: number);
  64829. /** Gets or sets the refresh rate to use (on every frame by default) */
  64830. get refreshRate(): number;
  64831. set refreshRate(value: number);
  64832. /**
  64833. * Gets the hosting scene
  64834. * @returns a Scene
  64835. */
  64836. getScene(): Scene;
  64837. /** Gets the internal CubeTexture used to render to */
  64838. get cubeTexture(): RenderTargetTexture;
  64839. /** Gets the list of meshes to render */
  64840. get renderList(): Nullable<AbstractMesh[]>;
  64841. /**
  64842. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64843. * @param mesh defines the mesh to attach to
  64844. */
  64845. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64846. /**
  64847. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64848. * @param renderingGroupId The rendering group id corresponding to its index
  64849. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64850. */
  64851. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64852. /**
  64853. * Clean all associated resources
  64854. */
  64855. dispose(): void;
  64856. /**
  64857. * Converts the reflection probe information to a readable string for debug purpose.
  64858. * @param fullDetails Supports for multiple levels of logging within scene loading
  64859. * @returns the human readable reflection probe info
  64860. */
  64861. toString(fullDetails?: boolean): string;
  64862. /**
  64863. * Get the class name of the relfection probe.
  64864. * @returns "ReflectionProbe"
  64865. */
  64866. getClassName(): string;
  64867. /**
  64868. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64869. * @returns The JSON representation of the texture
  64870. */
  64871. serialize(): any;
  64872. /**
  64873. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64874. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64875. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64876. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64877. * @returns The parsed reflection probe if successful
  64878. */
  64879. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64880. }
  64881. }
  64882. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64883. /** @hidden */
  64884. export var _BabylonLoaderRegistered: boolean;
  64885. /**
  64886. * Helps setting up some configuration for the babylon file loader.
  64887. */
  64888. export class BabylonFileLoaderConfiguration {
  64889. /**
  64890. * The loader does not allow injecting custom physix engine into the plugins.
  64891. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64892. * So you could set this variable to your engine import to make it work.
  64893. */
  64894. static LoaderInjectedPhysicsEngine: any;
  64895. }
  64896. }
  64897. declare module "babylonjs/Loading/Plugins/index" {
  64898. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64899. }
  64900. declare module "babylonjs/Loading/index" {
  64901. export * from "babylonjs/Loading/loadingScreen";
  64902. export * from "babylonjs/Loading/Plugins/index";
  64903. export * from "babylonjs/Loading/sceneLoader";
  64904. export * from "babylonjs/Loading/sceneLoaderFlags";
  64905. }
  64906. declare module "babylonjs/Materials/Background/index" {
  64907. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64908. }
  64909. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64910. import { Scene } from "babylonjs/scene";
  64911. import { Color3 } from "babylonjs/Maths/math.color";
  64912. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64914. /**
  64915. * The Physically based simple base material of BJS.
  64916. *
  64917. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64918. * It is used as the base class for both the specGloss and metalRough conventions.
  64919. */
  64920. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64921. /**
  64922. * Number of Simultaneous lights allowed on the material.
  64923. */
  64924. maxSimultaneousLights: number;
  64925. /**
  64926. * If sets to true, disables all the lights affecting the material.
  64927. */
  64928. disableLighting: boolean;
  64929. /**
  64930. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64931. */
  64932. environmentTexture: BaseTexture;
  64933. /**
  64934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64935. */
  64936. invertNormalMapX: boolean;
  64937. /**
  64938. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64939. */
  64940. invertNormalMapY: boolean;
  64941. /**
  64942. * Normal map used in the model.
  64943. */
  64944. normalTexture: BaseTexture;
  64945. /**
  64946. * Emissivie color used to self-illuminate the model.
  64947. */
  64948. emissiveColor: Color3;
  64949. /**
  64950. * Emissivie texture used to self-illuminate the model.
  64951. */
  64952. emissiveTexture: BaseTexture;
  64953. /**
  64954. * Occlusion Channel Strenght.
  64955. */
  64956. occlusionStrength: number;
  64957. /**
  64958. * Occlusion Texture of the material (adding extra occlusion effects).
  64959. */
  64960. occlusionTexture: BaseTexture;
  64961. /**
  64962. * Defines the alpha limits in alpha test mode.
  64963. */
  64964. alphaCutOff: number;
  64965. /**
  64966. * Gets the current double sided mode.
  64967. */
  64968. get doubleSided(): boolean;
  64969. /**
  64970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64971. */
  64972. set doubleSided(value: boolean);
  64973. /**
  64974. * Stores the pre-calculated light information of a mesh in a texture.
  64975. */
  64976. lightmapTexture: BaseTexture;
  64977. /**
  64978. * If true, the light map contains occlusion information instead of lighting info.
  64979. */
  64980. useLightmapAsShadowmap: boolean;
  64981. /**
  64982. * Instantiates a new PBRMaterial instance.
  64983. *
  64984. * @param name The material name
  64985. * @param scene The scene the material will be use in.
  64986. */
  64987. constructor(name: string, scene: Scene);
  64988. getClassName(): string;
  64989. }
  64990. }
  64991. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64992. import { Scene } from "babylonjs/scene";
  64993. import { Color3 } from "babylonjs/Maths/math.color";
  64994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64995. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64996. /**
  64997. * The PBR material of BJS following the metal roughness convention.
  64998. *
  64999. * This fits to the PBR convention in the GLTF definition:
  65000. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65001. */
  65002. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65003. /**
  65004. * The base color has two different interpretations depending on the value of metalness.
  65005. * When the material is a metal, the base color is the specific measured reflectance value
  65006. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65007. * of the material.
  65008. */
  65009. baseColor: Color3;
  65010. /**
  65011. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65012. * well as opacity information in the alpha channel.
  65013. */
  65014. baseTexture: BaseTexture;
  65015. /**
  65016. * Specifies the metallic scalar value of the material.
  65017. * Can also be used to scale the metalness values of the metallic texture.
  65018. */
  65019. metallic: number;
  65020. /**
  65021. * Specifies the roughness scalar value of the material.
  65022. * Can also be used to scale the roughness values of the metallic texture.
  65023. */
  65024. roughness: number;
  65025. /**
  65026. * Texture containing both the metallic value in the B channel and the
  65027. * roughness value in the G channel to keep better precision.
  65028. */
  65029. metallicRoughnessTexture: BaseTexture;
  65030. /**
  65031. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65032. *
  65033. * @param name The material name
  65034. * @param scene The scene the material will be use in.
  65035. */
  65036. constructor(name: string, scene: Scene);
  65037. /**
  65038. * Return the currrent class name of the material.
  65039. */
  65040. getClassName(): string;
  65041. /**
  65042. * Makes a duplicate of the current material.
  65043. * @param name - name to use for the new material.
  65044. */
  65045. clone(name: string): PBRMetallicRoughnessMaterial;
  65046. /**
  65047. * Serialize the material to a parsable JSON object.
  65048. */
  65049. serialize(): any;
  65050. /**
  65051. * Parses a JSON object correponding to the serialize function.
  65052. */
  65053. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65054. }
  65055. }
  65056. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65057. import { Scene } from "babylonjs/scene";
  65058. import { Color3 } from "babylonjs/Maths/math.color";
  65059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65060. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65061. /**
  65062. * The PBR material of BJS following the specular glossiness convention.
  65063. *
  65064. * This fits to the PBR convention in the GLTF definition:
  65065. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65066. */
  65067. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65068. /**
  65069. * Specifies the diffuse color of the material.
  65070. */
  65071. diffuseColor: Color3;
  65072. /**
  65073. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65074. * channel.
  65075. */
  65076. diffuseTexture: BaseTexture;
  65077. /**
  65078. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65079. */
  65080. specularColor: Color3;
  65081. /**
  65082. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65083. */
  65084. glossiness: number;
  65085. /**
  65086. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65087. */
  65088. specularGlossinessTexture: BaseTexture;
  65089. /**
  65090. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65091. *
  65092. * @param name The material name
  65093. * @param scene The scene the material will be use in.
  65094. */
  65095. constructor(name: string, scene: Scene);
  65096. /**
  65097. * Return the currrent class name of the material.
  65098. */
  65099. getClassName(): string;
  65100. /**
  65101. * Makes a duplicate of the current material.
  65102. * @param name - name to use for the new material.
  65103. */
  65104. clone(name: string): PBRSpecularGlossinessMaterial;
  65105. /**
  65106. * Serialize the material to a parsable JSON object.
  65107. */
  65108. serialize(): any;
  65109. /**
  65110. * Parses a JSON object correponding to the serialize function.
  65111. */
  65112. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65113. }
  65114. }
  65115. declare module "babylonjs/Materials/PBR/index" {
  65116. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65117. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65118. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65119. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65120. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65121. }
  65122. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65123. import { Nullable } from "babylonjs/types";
  65124. import { Scene } from "babylonjs/scene";
  65125. import { Matrix } from "babylonjs/Maths/math.vector";
  65126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65127. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65128. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65129. /**
  65130. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65131. * It can help converting any input color in a desired output one. This can then be used to create effects
  65132. * from sepia, black and white to sixties or futuristic rendering...
  65133. *
  65134. * The only supported format is currently 3dl.
  65135. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65136. */
  65137. export class ColorGradingTexture extends BaseTexture {
  65138. /**
  65139. * The texture URL.
  65140. */
  65141. url: string;
  65142. /**
  65143. * Empty line regex stored for GC.
  65144. */
  65145. private static _noneEmptyLineRegex;
  65146. private _textureMatrix;
  65147. private _onLoad;
  65148. /**
  65149. * Instantiates a ColorGradingTexture from the following parameters.
  65150. *
  65151. * @param url The location of the color gradind data (currently only supporting 3dl)
  65152. * @param sceneOrEngine The scene or engine the texture will be used in
  65153. * @param onLoad defines a callback triggered when the texture has been loaded
  65154. */
  65155. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65156. /**
  65157. * Fires the onload event from the constructor if requested.
  65158. */
  65159. private _triggerOnLoad;
  65160. /**
  65161. * Returns the texture matrix used in most of the material.
  65162. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65163. */
  65164. getTextureMatrix(): Matrix;
  65165. /**
  65166. * Occurs when the file being loaded is a .3dl LUT file.
  65167. */
  65168. private load3dlTexture;
  65169. /**
  65170. * Starts the loading process of the texture.
  65171. */
  65172. private loadTexture;
  65173. /**
  65174. * Clones the color gradind texture.
  65175. */
  65176. clone(): ColorGradingTexture;
  65177. /**
  65178. * Called during delayed load for textures.
  65179. */
  65180. delayLoad(): void;
  65181. /**
  65182. * Parses a color grading texture serialized by Babylon.
  65183. * @param parsedTexture The texture information being parsedTexture
  65184. * @param scene The scene to load the texture in
  65185. * @param rootUrl The root url of the data assets to load
  65186. * @return A color gradind texture
  65187. */
  65188. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65189. /**
  65190. * Serializes the LUT texture to json format.
  65191. */
  65192. serialize(): any;
  65193. }
  65194. }
  65195. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65197. import { Scene } from "babylonjs/scene";
  65198. import { Nullable } from "babylonjs/types";
  65199. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65200. /**
  65201. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65202. */
  65203. export class EquiRectangularCubeTexture extends BaseTexture {
  65204. /** The six faces of the cube. */
  65205. private static _FacesMapping;
  65206. private _noMipmap;
  65207. private _onLoad;
  65208. private _onError;
  65209. /** The size of the cubemap. */
  65210. private _size;
  65211. /** The buffer of the image. */
  65212. private _buffer;
  65213. /** The width of the input image. */
  65214. private _width;
  65215. /** The height of the input image. */
  65216. private _height;
  65217. /** The URL to the image. */
  65218. url: string;
  65219. /**
  65220. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65221. * @param url The location of the image
  65222. * @param scene The scene the texture will be used in
  65223. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65224. * @param noMipmap Forces to not generate the mipmap if true
  65225. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65226. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65227. * @param onLoad — defines a callback called when texture is loaded
  65228. * @param onError — defines a callback called if there is an error
  65229. */
  65230. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65231. /**
  65232. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65233. */
  65234. private loadImage;
  65235. /**
  65236. * Convert the image buffer into a cubemap and create a CubeTexture.
  65237. */
  65238. private loadTexture;
  65239. /**
  65240. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65241. * @param buffer The ArrayBuffer that should be converted.
  65242. * @returns The buffer as Float32Array.
  65243. */
  65244. private getFloat32ArrayFromArrayBuffer;
  65245. /**
  65246. * Get the current class name of the texture useful for serialization or dynamic coding.
  65247. * @returns "EquiRectangularCubeTexture"
  65248. */
  65249. getClassName(): string;
  65250. /**
  65251. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65252. * @returns A clone of the current EquiRectangularCubeTexture.
  65253. */
  65254. clone(): EquiRectangularCubeTexture;
  65255. }
  65256. }
  65257. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65258. import { Nullable } from "babylonjs/types";
  65259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65260. import { Matrix } from "babylonjs/Maths/math.vector";
  65261. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65262. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65263. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65264. import { Scene } from "babylonjs/scene";
  65265. /**
  65266. * Defines the options related to the creation of an HtmlElementTexture
  65267. */
  65268. export interface IHtmlElementTextureOptions {
  65269. /**
  65270. * Defines wether mip maps should be created or not.
  65271. */
  65272. generateMipMaps?: boolean;
  65273. /**
  65274. * Defines the sampling mode of the texture.
  65275. */
  65276. samplingMode?: number;
  65277. /**
  65278. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65279. */
  65280. engine: Nullable<ThinEngine>;
  65281. /**
  65282. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65283. */
  65284. scene: Nullable<Scene>;
  65285. }
  65286. /**
  65287. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65288. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65289. * is automatically managed.
  65290. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65291. * in your application.
  65292. *
  65293. * As the update is not automatic, you need to call them manually.
  65294. */
  65295. export class HtmlElementTexture extends BaseTexture {
  65296. /**
  65297. * The texture URL.
  65298. */
  65299. element: HTMLVideoElement | HTMLCanvasElement;
  65300. private static readonly DefaultOptions;
  65301. private _textureMatrix;
  65302. private _isVideo;
  65303. private _generateMipMaps;
  65304. private _samplingMode;
  65305. /**
  65306. * Instantiates a HtmlElementTexture from the following parameters.
  65307. *
  65308. * @param name Defines the name of the texture
  65309. * @param element Defines the video or canvas the texture is filled with
  65310. * @param options Defines the other none mandatory texture creation options
  65311. */
  65312. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65313. private _createInternalTexture;
  65314. /**
  65315. * Returns the texture matrix used in most of the material.
  65316. */
  65317. getTextureMatrix(): Matrix;
  65318. /**
  65319. * Updates the content of the texture.
  65320. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65321. */
  65322. update(invertY?: Nullable<boolean>): void;
  65323. }
  65324. }
  65325. declare module "babylonjs/Misc/tga" {
  65326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65327. /**
  65328. * Based on jsTGALoader - Javascript loader for TGA file
  65329. * By Vincent Thibault
  65330. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65331. */
  65332. export class TGATools {
  65333. private static _TYPE_INDEXED;
  65334. private static _TYPE_RGB;
  65335. private static _TYPE_GREY;
  65336. private static _TYPE_RLE_INDEXED;
  65337. private static _TYPE_RLE_RGB;
  65338. private static _TYPE_RLE_GREY;
  65339. private static _ORIGIN_MASK;
  65340. private static _ORIGIN_SHIFT;
  65341. private static _ORIGIN_BL;
  65342. private static _ORIGIN_BR;
  65343. private static _ORIGIN_UL;
  65344. private static _ORIGIN_UR;
  65345. /**
  65346. * Gets the header of a TGA file
  65347. * @param data defines the TGA data
  65348. * @returns the header
  65349. */
  65350. static GetTGAHeader(data: Uint8Array): any;
  65351. /**
  65352. * Uploads TGA content to a Babylon Texture
  65353. * @hidden
  65354. */
  65355. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65356. /** @hidden */
  65357. 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;
  65358. /** @hidden */
  65359. 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;
  65360. /** @hidden */
  65361. 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;
  65362. /** @hidden */
  65363. 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;
  65364. /** @hidden */
  65365. 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;
  65366. /** @hidden */
  65367. 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;
  65368. }
  65369. }
  65370. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65371. import { Nullable } from "babylonjs/types";
  65372. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65373. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65374. /**
  65375. * Implementation of the TGA Texture Loader.
  65376. * @hidden
  65377. */
  65378. export class _TGATextureLoader implements IInternalTextureLoader {
  65379. /**
  65380. * Defines wether the loader supports cascade loading the different faces.
  65381. */
  65382. readonly supportCascades: boolean;
  65383. /**
  65384. * This returns if the loader support the current file information.
  65385. * @param extension defines the file extension of the file being loaded
  65386. * @returns true if the loader can load the specified file
  65387. */
  65388. canLoad(extension: string): boolean;
  65389. /**
  65390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65391. * @param data contains the texture data
  65392. * @param texture defines the BabylonJS internal texture
  65393. * @param createPolynomials will be true if polynomials have been requested
  65394. * @param onLoad defines the callback to trigger once the texture is ready
  65395. * @param onError defines the callback to trigger in case of error
  65396. */
  65397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65398. /**
  65399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65400. * @param data contains the texture data
  65401. * @param texture defines the BabylonJS internal texture
  65402. * @param callback defines the method to call once ready to upload
  65403. */
  65404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65405. }
  65406. }
  65407. declare module "babylonjs/Misc/basis" {
  65408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65409. /**
  65410. * Info about the .basis files
  65411. */
  65412. class BasisFileInfo {
  65413. /**
  65414. * If the file has alpha
  65415. */
  65416. hasAlpha: boolean;
  65417. /**
  65418. * Info about each image of the basis file
  65419. */
  65420. images: Array<{
  65421. levels: Array<{
  65422. width: number;
  65423. height: number;
  65424. transcodedPixels: ArrayBufferView;
  65425. }>;
  65426. }>;
  65427. }
  65428. /**
  65429. * Result of transcoding a basis file
  65430. */
  65431. class TranscodeResult {
  65432. /**
  65433. * Info about the .basis file
  65434. */
  65435. fileInfo: BasisFileInfo;
  65436. /**
  65437. * Format to use when loading the file
  65438. */
  65439. format: number;
  65440. }
  65441. /**
  65442. * Configuration options for the Basis transcoder
  65443. */
  65444. export class BasisTranscodeConfiguration {
  65445. /**
  65446. * Supported compression formats used to determine the supported output format of the transcoder
  65447. */
  65448. supportedCompressionFormats?: {
  65449. /**
  65450. * etc1 compression format
  65451. */
  65452. etc1?: boolean;
  65453. /**
  65454. * s3tc compression format
  65455. */
  65456. s3tc?: boolean;
  65457. /**
  65458. * pvrtc compression format
  65459. */
  65460. pvrtc?: boolean;
  65461. /**
  65462. * etc2 compression format
  65463. */
  65464. etc2?: boolean;
  65465. };
  65466. /**
  65467. * If mipmap levels should be loaded for transcoded images (Default: true)
  65468. */
  65469. loadMipmapLevels?: boolean;
  65470. /**
  65471. * Index of a single image to load (Default: all images)
  65472. */
  65473. loadSingleImage?: number;
  65474. }
  65475. /**
  65476. * Used to load .Basis files
  65477. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65478. */
  65479. export class BasisTools {
  65480. private static _IgnoreSupportedFormats;
  65481. /**
  65482. * URL to use when loading the basis transcoder
  65483. */
  65484. static JSModuleURL: string;
  65485. /**
  65486. * URL to use when loading the wasm module for the transcoder
  65487. */
  65488. static WasmModuleURL: string;
  65489. /**
  65490. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65491. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65492. * @returns internal format corresponding to the Basis format
  65493. */
  65494. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65495. private static _WorkerPromise;
  65496. private static _Worker;
  65497. private static _actionId;
  65498. private static _CreateWorkerAsync;
  65499. /**
  65500. * Transcodes a loaded image file to compressed pixel data
  65501. * @param data image data to transcode
  65502. * @param config configuration options for the transcoding
  65503. * @returns a promise resulting in the transcoded image
  65504. */
  65505. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65506. /**
  65507. * Loads a texture from the transcode result
  65508. * @param texture texture load to
  65509. * @param transcodeResult the result of transcoding the basis file to load from
  65510. */
  65511. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65512. }
  65513. }
  65514. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65515. import { Nullable } from "babylonjs/types";
  65516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65517. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65518. /**
  65519. * Loader for .basis file format
  65520. */
  65521. export class _BasisTextureLoader implements IInternalTextureLoader {
  65522. /**
  65523. * Defines whether the loader supports cascade loading the different faces.
  65524. */
  65525. readonly supportCascades: boolean;
  65526. /**
  65527. * This returns if the loader support the current file information.
  65528. * @param extension defines the file extension of the file being loaded
  65529. * @returns true if the loader can load the specified file
  65530. */
  65531. canLoad(extension: string): boolean;
  65532. /**
  65533. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65534. * @param data contains the texture data
  65535. * @param texture defines the BabylonJS internal texture
  65536. * @param createPolynomials will be true if polynomials have been requested
  65537. * @param onLoad defines the callback to trigger once the texture is ready
  65538. * @param onError defines the callback to trigger in case of error
  65539. */
  65540. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65541. /**
  65542. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65543. * @param data contains the texture data
  65544. * @param texture defines the BabylonJS internal texture
  65545. * @param callback defines the method to call once ready to upload
  65546. */
  65547. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65548. }
  65549. }
  65550. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65551. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65552. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65553. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65554. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65555. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65556. }
  65557. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65558. import { Vector2 } from "babylonjs/Maths/math.vector";
  65559. /**
  65560. * Defines the basic options interface of a TexturePacker Frame
  65561. */
  65562. export interface ITexturePackerFrame {
  65563. /**
  65564. * The frame ID
  65565. */
  65566. id: number;
  65567. /**
  65568. * The frames Scale
  65569. */
  65570. scale: Vector2;
  65571. /**
  65572. * The Frames offset
  65573. */
  65574. offset: Vector2;
  65575. }
  65576. /**
  65577. * This is a support class for frame Data on texture packer sets.
  65578. */
  65579. export class TexturePackerFrame implements ITexturePackerFrame {
  65580. /**
  65581. * The frame ID
  65582. */
  65583. id: number;
  65584. /**
  65585. * The frames Scale
  65586. */
  65587. scale: Vector2;
  65588. /**
  65589. * The Frames offset
  65590. */
  65591. offset: Vector2;
  65592. /**
  65593. * Initializes a texture package frame.
  65594. * @param id The numerical frame identifier
  65595. * @param scale Scalar Vector2 for UV frame
  65596. * @param offset Vector2 for the frame position in UV units.
  65597. * @returns TexturePackerFrame
  65598. */
  65599. constructor(id: number, scale: Vector2, offset: Vector2);
  65600. }
  65601. }
  65602. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65604. import { Scene } from "babylonjs/scene";
  65605. import { Nullable } from "babylonjs/types";
  65606. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65607. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65608. /**
  65609. * Defines the basic options interface of a TexturePacker
  65610. */
  65611. export interface ITexturePackerOptions {
  65612. /**
  65613. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65614. */
  65615. map?: string[];
  65616. /**
  65617. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65618. */
  65619. uvsIn?: string;
  65620. /**
  65621. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65622. */
  65623. uvsOut?: string;
  65624. /**
  65625. * number representing the layout style. Defaults to LAYOUT_STRIP
  65626. */
  65627. layout?: number;
  65628. /**
  65629. * number of columns if using custom column count layout(2). This defaults to 4.
  65630. */
  65631. colnum?: number;
  65632. /**
  65633. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65634. */
  65635. updateInputMeshes?: boolean;
  65636. /**
  65637. * boolean flag to dispose all the source textures. Defaults to true.
  65638. */
  65639. disposeSources?: boolean;
  65640. /**
  65641. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65642. */
  65643. fillBlanks?: boolean;
  65644. /**
  65645. * string value representing the context fill style color. Defaults to 'black'.
  65646. */
  65647. customFillColor?: string;
  65648. /**
  65649. * Width and Height Value of each Frame in the TexturePacker Sets
  65650. */
  65651. frameSize?: number;
  65652. /**
  65653. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65654. */
  65655. paddingRatio?: number;
  65656. /**
  65657. * Number that declares the fill method for the padding gutter.
  65658. */
  65659. paddingMode?: number;
  65660. /**
  65661. * If in SUBUV_COLOR padding mode what color to use.
  65662. */
  65663. paddingColor?: Color3 | Color4;
  65664. }
  65665. /**
  65666. * Defines the basic interface of a TexturePacker JSON File
  65667. */
  65668. export interface ITexturePackerJSON {
  65669. /**
  65670. * The frame ID
  65671. */
  65672. name: string;
  65673. /**
  65674. * The base64 channel data
  65675. */
  65676. sets: any;
  65677. /**
  65678. * The options of the Packer
  65679. */
  65680. options: ITexturePackerOptions;
  65681. /**
  65682. * The frame data of the Packer
  65683. */
  65684. frames: Array<number>;
  65685. }
  65686. /**
  65687. * This is a support class that generates a series of packed texture sets.
  65688. * @see https://doc.babylonjs.com/babylon101/materials
  65689. */
  65690. export class TexturePacker {
  65691. /** Packer Layout Constant 0 */
  65692. static readonly LAYOUT_STRIP: number;
  65693. /** Packer Layout Constant 1 */
  65694. static readonly LAYOUT_POWER2: number;
  65695. /** Packer Layout Constant 2 */
  65696. static readonly LAYOUT_COLNUM: number;
  65697. /** Packer Layout Constant 0 */
  65698. static readonly SUBUV_WRAP: number;
  65699. /** Packer Layout Constant 1 */
  65700. static readonly SUBUV_EXTEND: number;
  65701. /** Packer Layout Constant 2 */
  65702. static readonly SUBUV_COLOR: number;
  65703. /** The Name of the Texture Package */
  65704. name: string;
  65705. /** The scene scope of the TexturePacker */
  65706. scene: Scene;
  65707. /** The Meshes to target */
  65708. meshes: AbstractMesh[];
  65709. /** Arguments passed with the Constructor */
  65710. options: ITexturePackerOptions;
  65711. /** The promise that is started upon initialization */
  65712. promise: Nullable<Promise<TexturePacker | string>>;
  65713. /** The Container object for the channel sets that are generated */
  65714. sets: object;
  65715. /** The Container array for the frames that are generated */
  65716. frames: TexturePackerFrame[];
  65717. /** The expected number of textures the system is parsing. */
  65718. private _expecting;
  65719. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65720. private _paddingValue;
  65721. /**
  65722. * Initializes a texture package series from an array of meshes or a single mesh.
  65723. * @param name The name of the package
  65724. * @param meshes The target meshes to compose the package from
  65725. * @param options The arguments that texture packer should follow while building.
  65726. * @param scene The scene which the textures are scoped to.
  65727. * @returns TexturePacker
  65728. */
  65729. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65730. /**
  65731. * Starts the package process
  65732. * @param resolve The promises resolution function
  65733. * @returns TexturePacker
  65734. */
  65735. private _createFrames;
  65736. /**
  65737. * Calculates the Size of the Channel Sets
  65738. * @returns Vector2
  65739. */
  65740. private _calculateSize;
  65741. /**
  65742. * Calculates the UV data for the frames.
  65743. * @param baseSize the base frameSize
  65744. * @param padding the base frame padding
  65745. * @param dtSize size of the Dynamic Texture for that channel
  65746. * @param dtUnits is 1/dtSize
  65747. * @param update flag to update the input meshes
  65748. */
  65749. private _calculateMeshUVFrames;
  65750. /**
  65751. * Calculates the frames Offset.
  65752. * @param index of the frame
  65753. * @returns Vector2
  65754. */
  65755. private _getFrameOffset;
  65756. /**
  65757. * Updates a Mesh to the frame data
  65758. * @param mesh that is the target
  65759. * @param frameID or the frame index
  65760. */
  65761. private _updateMeshUV;
  65762. /**
  65763. * Updates a Meshes materials to use the texture packer channels
  65764. * @param m is the mesh to target
  65765. * @param force all channels on the packer to be set.
  65766. */
  65767. private _updateTextureReferences;
  65768. /**
  65769. * Public method to set a Mesh to a frame
  65770. * @param m that is the target
  65771. * @param frameID or the frame index
  65772. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65773. */
  65774. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65775. /**
  65776. * Starts the async promise to compile the texture packer.
  65777. * @returns Promise<void>
  65778. */
  65779. processAsync(): Promise<void>;
  65780. /**
  65781. * Disposes all textures associated with this packer
  65782. */
  65783. dispose(): void;
  65784. /**
  65785. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65786. * @param imageType is the image type to use.
  65787. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65788. */
  65789. download(imageType?: string, quality?: number): void;
  65790. /**
  65791. * Public method to load a texturePacker JSON file.
  65792. * @param data of the JSON file in string format.
  65793. */
  65794. updateFromJSON(data: string): void;
  65795. }
  65796. }
  65797. declare module "babylonjs/Materials/Textures/Packer/index" {
  65798. export * from "babylonjs/Materials/Textures/Packer/packer";
  65799. export * from "babylonjs/Materials/Textures/Packer/frame";
  65800. }
  65801. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65802. import { Scene } from "babylonjs/scene";
  65803. import { Texture } from "babylonjs/Materials/Textures/texture";
  65804. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65805. /**
  65806. * 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.
  65807. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65808. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65809. */
  65810. export class CustomProceduralTexture extends ProceduralTexture {
  65811. private _animate;
  65812. private _time;
  65813. private _config;
  65814. private _texturePath;
  65815. /**
  65816. * Instantiates a new Custom Procedural Texture.
  65817. * 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.
  65818. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65819. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65820. * @param name Define the name of the texture
  65821. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65822. * @param size Define the size of the texture to create
  65823. * @param scene Define the scene the texture belongs to
  65824. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65825. * @param generateMipMaps Define if the texture should creates mip maps or not
  65826. */
  65827. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65828. private _loadJson;
  65829. /**
  65830. * Is the texture ready to be used ? (rendered at least once)
  65831. * @returns true if ready, otherwise, false.
  65832. */
  65833. isReady(): boolean;
  65834. /**
  65835. * Render the texture to its associated render target.
  65836. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65837. */
  65838. render(useCameraPostProcess?: boolean): void;
  65839. /**
  65840. * Update the list of dependant textures samplers in the shader.
  65841. */
  65842. updateTextures(): void;
  65843. /**
  65844. * Update the uniform values of the procedural texture in the shader.
  65845. */
  65846. updateShaderUniforms(): void;
  65847. /**
  65848. * Define if the texture animates or not.
  65849. */
  65850. get animate(): boolean;
  65851. set animate(value: boolean);
  65852. }
  65853. }
  65854. declare module "babylonjs/Shaders/noise.fragment" {
  65855. /** @hidden */
  65856. export var noisePixelShader: {
  65857. name: string;
  65858. shader: string;
  65859. };
  65860. }
  65861. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65862. import { Nullable } from "babylonjs/types";
  65863. import { Scene } from "babylonjs/scene";
  65864. import { Texture } from "babylonjs/Materials/Textures/texture";
  65865. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65866. import "babylonjs/Shaders/noise.fragment";
  65867. /**
  65868. * Class used to generate noise procedural textures
  65869. */
  65870. export class NoiseProceduralTexture extends ProceduralTexture {
  65871. /** Gets or sets the start time (default is 0) */
  65872. time: number;
  65873. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65874. brightness: number;
  65875. /** Defines the number of octaves to process */
  65876. octaves: number;
  65877. /** Defines the level of persistence (0.8 by default) */
  65878. persistence: number;
  65879. /** Gets or sets animation speed factor (default is 1) */
  65880. animationSpeedFactor: number;
  65881. /**
  65882. * Creates a new NoiseProceduralTexture
  65883. * @param name defines the name fo the texture
  65884. * @param size defines the size of the texture (default is 256)
  65885. * @param scene defines the hosting scene
  65886. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65887. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65888. */
  65889. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65890. private _updateShaderUniforms;
  65891. protected _getDefines(): string;
  65892. /** Generate the current state of the procedural texture */
  65893. render(useCameraPostProcess?: boolean): void;
  65894. /**
  65895. * Serializes this noise procedural texture
  65896. * @returns a serialized noise procedural texture object
  65897. */
  65898. serialize(): any;
  65899. /**
  65900. * Clone the texture.
  65901. * @returns the cloned texture
  65902. */
  65903. clone(): NoiseProceduralTexture;
  65904. /**
  65905. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65906. * @param parsedTexture defines parsed texture data
  65907. * @param scene defines the current scene
  65908. * @param rootUrl defines the root URL containing noise procedural texture information
  65909. * @returns a parsed NoiseProceduralTexture
  65910. */
  65911. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65912. }
  65913. }
  65914. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65915. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65916. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65917. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65918. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65919. }
  65920. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65921. import { Nullable } from "babylonjs/types";
  65922. import { Scene } from "babylonjs/scene";
  65923. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65925. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65926. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65927. /**
  65928. * Raw cube texture where the raw buffers are passed in
  65929. */
  65930. export class RawCubeTexture extends CubeTexture {
  65931. /**
  65932. * Creates a cube texture where the raw buffers are passed in.
  65933. * @param scene defines the scene the texture is attached to
  65934. * @param data defines the array of data to use to create each face
  65935. * @param size defines the size of the textures
  65936. * @param format defines the format of the data
  65937. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65938. * @param generateMipMaps defines if the engine should generate the mip levels
  65939. * @param invertY defines if data must be stored with Y axis inverted
  65940. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65941. * @param compression defines the compression used (null by default)
  65942. */
  65943. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65944. /**
  65945. * Updates the raw cube texture.
  65946. * @param data defines the data to store
  65947. * @param format defines the data format
  65948. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65949. * @param invertY defines if data must be stored with Y axis inverted
  65950. * @param compression defines the compression used (null by default)
  65951. * @param level defines which level of the texture to update
  65952. */
  65953. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65954. /**
  65955. * Updates a raw cube texture with RGBD encoded data.
  65956. * @param data defines the array of data [mipmap][face] to use to create each face
  65957. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65958. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65959. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65960. * @returns a promsie that resolves when the operation is complete
  65961. */
  65962. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65963. /**
  65964. * Clones the raw cube texture.
  65965. * @return a new cube texture
  65966. */
  65967. clone(): CubeTexture;
  65968. /** @hidden */
  65969. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65970. }
  65971. }
  65972. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65973. import { Scene } from "babylonjs/scene";
  65974. import { Texture } from "babylonjs/Materials/Textures/texture";
  65975. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65976. /**
  65977. * Class used to store 2D array textures containing user data
  65978. */
  65979. export class RawTexture2DArray extends Texture {
  65980. /** Gets or sets the texture format to use */
  65981. format: number;
  65982. /**
  65983. * Create a new RawTexture2DArray
  65984. * @param data defines the data of the texture
  65985. * @param width defines the width of the texture
  65986. * @param height defines the height of the texture
  65987. * @param depth defines the number of layers of the texture
  65988. * @param format defines the texture format to use
  65989. * @param scene defines the hosting scene
  65990. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65991. * @param invertY defines if texture must be stored with Y axis inverted
  65992. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65993. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65994. */
  65995. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65996. /** Gets or sets the texture format to use */
  65997. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65998. /**
  65999. * Update the texture with new data
  66000. * @param data defines the data to store in the texture
  66001. */
  66002. update(data: ArrayBufferView): void;
  66003. }
  66004. }
  66005. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66006. import { Scene } from "babylonjs/scene";
  66007. import { Texture } from "babylonjs/Materials/Textures/texture";
  66008. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66009. /**
  66010. * Class used to store 3D textures containing user data
  66011. */
  66012. export class RawTexture3D extends Texture {
  66013. /** Gets or sets the texture format to use */
  66014. format: number;
  66015. /**
  66016. * Create a new RawTexture3D
  66017. * @param data defines the data of the texture
  66018. * @param width defines the width of the texture
  66019. * @param height defines the height of the texture
  66020. * @param depth defines the depth of the texture
  66021. * @param format defines the texture format to use
  66022. * @param scene defines the hosting scene
  66023. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66024. * @param invertY defines if texture must be stored with Y axis inverted
  66025. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66026. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66027. */
  66028. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66029. /** Gets or sets the texture format to use */
  66030. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66031. /**
  66032. * Update the texture with new data
  66033. * @param data defines the data to store in the texture
  66034. */
  66035. update(data: ArrayBufferView): void;
  66036. }
  66037. }
  66038. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66039. import { Scene } from "babylonjs/scene";
  66040. import { Plane } from "babylonjs/Maths/math.plane";
  66041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66042. /**
  66043. * Creates a refraction texture used by refraction channel of the standard material.
  66044. * It is like a mirror but to see through a material.
  66045. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66046. */
  66047. export class RefractionTexture extends RenderTargetTexture {
  66048. /**
  66049. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66050. * 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.
  66051. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66052. */
  66053. refractionPlane: Plane;
  66054. /**
  66055. * Define how deep under the surface we should see.
  66056. */
  66057. depth: number;
  66058. /**
  66059. * Creates a refraction texture used by refraction channel of the standard material.
  66060. * It is like a mirror but to see through a material.
  66061. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66062. * @param name Define the texture name
  66063. * @param size Define the size of the underlying texture
  66064. * @param scene Define the scene the refraction belongs to
  66065. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66066. */
  66067. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66068. /**
  66069. * Clone the refraction texture.
  66070. * @returns the cloned texture
  66071. */
  66072. clone(): RefractionTexture;
  66073. /**
  66074. * Serialize the texture to a JSON representation you could use in Parse later on
  66075. * @returns the serialized JSON representation
  66076. */
  66077. serialize(): any;
  66078. }
  66079. }
  66080. declare module "babylonjs/Materials/Textures/index" {
  66081. export * from "babylonjs/Materials/Textures/baseTexture";
  66082. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66083. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66084. export * from "babylonjs/Materials/Textures/cubeTexture";
  66085. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66086. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66087. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66088. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66089. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66090. export * from "babylonjs/Materials/Textures/internalTexture";
  66091. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66092. export * from "babylonjs/Materials/Textures/Loaders/index";
  66093. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66094. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66095. export * from "babylonjs/Materials/Textures/Packer/index";
  66096. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66097. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66098. export * from "babylonjs/Materials/Textures/rawTexture";
  66099. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66100. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66101. export * from "babylonjs/Materials/Textures/refractionTexture";
  66102. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66103. export * from "babylonjs/Materials/Textures/texture";
  66104. export * from "babylonjs/Materials/Textures/videoTexture";
  66105. }
  66106. declare module "babylonjs/Materials/Node/Enums/index" {
  66107. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66108. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66109. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66110. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66111. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66112. }
  66113. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66117. import { Mesh } from "babylonjs/Meshes/mesh";
  66118. import { Effect } from "babylonjs/Materials/effect";
  66119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66120. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66121. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66122. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66123. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66124. /**
  66125. * Block used to add support for vertex skinning (bones)
  66126. */
  66127. export class BonesBlock extends NodeMaterialBlock {
  66128. /**
  66129. * Creates a new BonesBlock
  66130. * @param name defines the block name
  66131. */
  66132. constructor(name: string);
  66133. /**
  66134. * Initialize the block and prepare the context for build
  66135. * @param state defines the state that will be used for the build
  66136. */
  66137. initialize(state: NodeMaterialBuildState): void;
  66138. /**
  66139. * Gets the current class name
  66140. * @returns the class name
  66141. */
  66142. getClassName(): string;
  66143. /**
  66144. * Gets the matrix indices input component
  66145. */
  66146. get matricesIndices(): NodeMaterialConnectionPoint;
  66147. /**
  66148. * Gets the matrix weights input component
  66149. */
  66150. get matricesWeights(): NodeMaterialConnectionPoint;
  66151. /**
  66152. * Gets the extra matrix indices input component
  66153. */
  66154. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66155. /**
  66156. * Gets the extra matrix weights input component
  66157. */
  66158. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the world input component
  66161. */
  66162. get world(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the output component
  66165. */
  66166. get output(): NodeMaterialConnectionPoint;
  66167. autoConfigure(material: NodeMaterial): void;
  66168. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66171. protected _buildBlock(state: NodeMaterialBuildState): this;
  66172. }
  66173. }
  66174. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66180. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66181. /**
  66182. * Block used to add support for instances
  66183. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66184. */
  66185. export class InstancesBlock extends NodeMaterialBlock {
  66186. /**
  66187. * Creates a new InstancesBlock
  66188. * @param name defines the block name
  66189. */
  66190. constructor(name: string);
  66191. /**
  66192. * Gets the current class name
  66193. * @returns the class name
  66194. */
  66195. getClassName(): string;
  66196. /**
  66197. * Gets the first world row input component
  66198. */
  66199. get world0(): NodeMaterialConnectionPoint;
  66200. /**
  66201. * Gets the second world row input component
  66202. */
  66203. get world1(): NodeMaterialConnectionPoint;
  66204. /**
  66205. * Gets the third world row input component
  66206. */
  66207. get world2(): NodeMaterialConnectionPoint;
  66208. /**
  66209. * Gets the forth world row input component
  66210. */
  66211. get world3(): NodeMaterialConnectionPoint;
  66212. /**
  66213. * Gets the world input component
  66214. */
  66215. get world(): NodeMaterialConnectionPoint;
  66216. /**
  66217. * Gets the output component
  66218. */
  66219. get output(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the isntanceID component
  66222. */
  66223. get instanceID(): NodeMaterialConnectionPoint;
  66224. autoConfigure(material: NodeMaterial): void;
  66225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66226. protected _buildBlock(state: NodeMaterialBuildState): this;
  66227. }
  66228. }
  66229. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66234. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66235. import { Effect } from "babylonjs/Materials/effect";
  66236. import { Mesh } from "babylonjs/Meshes/mesh";
  66237. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66238. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66239. /**
  66240. * Block used to add morph targets support to vertex shader
  66241. */
  66242. export class MorphTargetsBlock extends NodeMaterialBlock {
  66243. private _repeatableContentAnchor;
  66244. /**
  66245. * Create a new MorphTargetsBlock
  66246. * @param name defines the block name
  66247. */
  66248. constructor(name: string);
  66249. /**
  66250. * Gets the current class name
  66251. * @returns the class name
  66252. */
  66253. getClassName(): string;
  66254. /**
  66255. * Gets the position input component
  66256. */
  66257. get position(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the normal input component
  66260. */
  66261. get normal(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the tangent input component
  66264. */
  66265. get tangent(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the tangent input component
  66268. */
  66269. get uv(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the position output component
  66272. */
  66273. get positionOutput(): NodeMaterialConnectionPoint;
  66274. /**
  66275. * Gets the normal output component
  66276. */
  66277. get normalOutput(): NodeMaterialConnectionPoint;
  66278. /**
  66279. * Gets the tangent output component
  66280. */
  66281. get tangentOutput(): NodeMaterialConnectionPoint;
  66282. /**
  66283. * Gets the tangent output component
  66284. */
  66285. get uvOutput(): NodeMaterialConnectionPoint;
  66286. initialize(state: NodeMaterialBuildState): void;
  66287. autoConfigure(material: NodeMaterial): void;
  66288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66290. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66291. protected _buildBlock(state: NodeMaterialBuildState): this;
  66292. }
  66293. }
  66294. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66298. import { Nullable } from "babylonjs/types";
  66299. import { Scene } from "babylonjs/scene";
  66300. import { Effect } from "babylonjs/Materials/effect";
  66301. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66302. import { Mesh } from "babylonjs/Meshes/mesh";
  66303. import { Light } from "babylonjs/Lights/light";
  66304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66305. /**
  66306. * Block used to get data information from a light
  66307. */
  66308. export class LightInformationBlock extends NodeMaterialBlock {
  66309. private _lightDataUniformName;
  66310. private _lightColorUniformName;
  66311. private _lightTypeDefineName;
  66312. /**
  66313. * Gets or sets the light associated with this block
  66314. */
  66315. light: Nullable<Light>;
  66316. /**
  66317. * Creates a new LightInformationBlock
  66318. * @param name defines the block name
  66319. */
  66320. constructor(name: string);
  66321. /**
  66322. * Gets the current class name
  66323. * @returns the class name
  66324. */
  66325. getClassName(): string;
  66326. /**
  66327. * Gets the world position input component
  66328. */
  66329. get worldPosition(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the direction output component
  66332. */
  66333. get direction(): NodeMaterialConnectionPoint;
  66334. /**
  66335. * Gets the direction output component
  66336. */
  66337. get color(): NodeMaterialConnectionPoint;
  66338. /**
  66339. * Gets the direction output component
  66340. */
  66341. get intensity(): NodeMaterialConnectionPoint;
  66342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66344. protected _buildBlock(state: NodeMaterialBuildState): this;
  66345. serialize(): any;
  66346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66347. }
  66348. }
  66349. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66350. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66351. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66352. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66353. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66354. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66355. }
  66356. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66361. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66362. import { Effect } from "babylonjs/Materials/effect";
  66363. import { Mesh } from "babylonjs/Meshes/mesh";
  66364. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66365. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66366. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66367. /**
  66368. * Block used to add image processing support to fragment shader
  66369. */
  66370. export class ImageProcessingBlock extends NodeMaterialBlock {
  66371. /**
  66372. * Create a new ImageProcessingBlock
  66373. * @param name defines the block name
  66374. */
  66375. constructor(name: string);
  66376. /**
  66377. * Gets the current class name
  66378. * @returns the class name
  66379. */
  66380. getClassName(): string;
  66381. /**
  66382. * Gets the color input component
  66383. */
  66384. get color(): NodeMaterialConnectionPoint;
  66385. /**
  66386. * Gets the output component
  66387. */
  66388. get output(): NodeMaterialConnectionPoint;
  66389. /**
  66390. * Initialize the block and prepare the context for build
  66391. * @param state defines the state that will be used for the build
  66392. */
  66393. initialize(state: NodeMaterialBuildState): void;
  66394. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66397. protected _buildBlock(state: NodeMaterialBuildState): this;
  66398. }
  66399. }
  66400. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66404. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66406. import { Effect } from "babylonjs/Materials/effect";
  66407. import { Mesh } from "babylonjs/Meshes/mesh";
  66408. import { Scene } from "babylonjs/scene";
  66409. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66410. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66411. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66412. /**
  66413. * Block used to pertub normals based on a normal map
  66414. */
  66415. export class PerturbNormalBlock extends NodeMaterialBlock {
  66416. private _tangentSpaceParameterName;
  66417. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66418. invertX: boolean;
  66419. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66420. invertY: boolean;
  66421. /**
  66422. * Create a new PerturbNormalBlock
  66423. * @param name defines the block name
  66424. */
  66425. constructor(name: string);
  66426. /**
  66427. * Gets the current class name
  66428. * @returns the class name
  66429. */
  66430. getClassName(): string;
  66431. /**
  66432. * Gets the world position input component
  66433. */
  66434. get worldPosition(): NodeMaterialConnectionPoint;
  66435. /**
  66436. * Gets the world normal input component
  66437. */
  66438. get worldNormal(): NodeMaterialConnectionPoint;
  66439. /**
  66440. * Gets the world tangent input component
  66441. */
  66442. get worldTangent(): NodeMaterialConnectionPoint;
  66443. /**
  66444. * Gets the uv input component
  66445. */
  66446. get uv(): NodeMaterialConnectionPoint;
  66447. /**
  66448. * Gets the normal map color input component
  66449. */
  66450. get normalMapColor(): NodeMaterialConnectionPoint;
  66451. /**
  66452. * Gets the strength input component
  66453. */
  66454. get strength(): NodeMaterialConnectionPoint;
  66455. /**
  66456. * Gets the output component
  66457. */
  66458. get output(): NodeMaterialConnectionPoint;
  66459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66461. autoConfigure(material: NodeMaterial): void;
  66462. protected _buildBlock(state: NodeMaterialBuildState): this;
  66463. protected _dumpPropertiesCode(): string;
  66464. serialize(): any;
  66465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66466. }
  66467. }
  66468. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66472. /**
  66473. * Block used to discard a pixel if a value is smaller than a cutoff
  66474. */
  66475. export class DiscardBlock extends NodeMaterialBlock {
  66476. /**
  66477. * Create a new DiscardBlock
  66478. * @param name defines the block name
  66479. */
  66480. constructor(name: string);
  66481. /**
  66482. * Gets the current class name
  66483. * @returns the class name
  66484. */
  66485. getClassName(): string;
  66486. /**
  66487. * Gets the color input component
  66488. */
  66489. get value(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the cutoff input component
  66492. */
  66493. get cutoff(): NodeMaterialConnectionPoint;
  66494. protected _buildBlock(state: NodeMaterialBuildState): this;
  66495. }
  66496. }
  66497. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66501. /**
  66502. * Block used to test if the fragment shader is front facing
  66503. */
  66504. export class FrontFacingBlock extends NodeMaterialBlock {
  66505. /**
  66506. * Creates a new FrontFacingBlock
  66507. * @param name defines the block name
  66508. */
  66509. constructor(name: string);
  66510. /**
  66511. * Gets the current class name
  66512. * @returns the class name
  66513. */
  66514. getClassName(): string;
  66515. /**
  66516. * Gets the output component
  66517. */
  66518. get output(): NodeMaterialConnectionPoint;
  66519. protected _buildBlock(state: NodeMaterialBuildState): this;
  66520. }
  66521. }
  66522. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66526. /**
  66527. * Block used to get the derivative value on x and y of a given input
  66528. */
  66529. export class DerivativeBlock extends NodeMaterialBlock {
  66530. /**
  66531. * Create a new DerivativeBlock
  66532. * @param name defines the block name
  66533. */
  66534. constructor(name: string);
  66535. /**
  66536. * Gets the current class name
  66537. * @returns the class name
  66538. */
  66539. getClassName(): string;
  66540. /**
  66541. * Gets the input component
  66542. */
  66543. get input(): NodeMaterialConnectionPoint;
  66544. /**
  66545. * Gets the derivative output on x
  66546. */
  66547. get dx(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the derivative output on y
  66550. */
  66551. get dy(): NodeMaterialConnectionPoint;
  66552. protected _buildBlock(state: NodeMaterialBuildState): this;
  66553. }
  66554. }
  66555. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66559. /**
  66560. * Block used to make gl_FragCoord available
  66561. */
  66562. export class FragCoordBlock extends NodeMaterialBlock {
  66563. /**
  66564. * Creates a new FragCoordBlock
  66565. * @param name defines the block name
  66566. */
  66567. constructor(name: string);
  66568. /**
  66569. * Gets the current class name
  66570. * @returns the class name
  66571. */
  66572. getClassName(): string;
  66573. /**
  66574. * Gets the xy component
  66575. */
  66576. get xy(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the xyz component
  66579. */
  66580. get xyz(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the xyzw component
  66583. */
  66584. get xyzw(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the x component
  66587. */
  66588. get x(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the y component
  66591. */
  66592. get y(): NodeMaterialConnectionPoint;
  66593. /**
  66594. * Gets the z component
  66595. */
  66596. get z(): NodeMaterialConnectionPoint;
  66597. /**
  66598. * Gets the w component
  66599. */
  66600. get output(): NodeMaterialConnectionPoint;
  66601. protected writeOutputs(state: NodeMaterialBuildState): string;
  66602. protected _buildBlock(state: NodeMaterialBuildState): this;
  66603. }
  66604. }
  66605. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66609. import { Effect } from "babylonjs/Materials/effect";
  66610. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66611. import { Mesh } from "babylonjs/Meshes/mesh";
  66612. /**
  66613. * Block used to get the screen sizes
  66614. */
  66615. export class ScreenSizeBlock extends NodeMaterialBlock {
  66616. private _varName;
  66617. private _scene;
  66618. /**
  66619. * Creates a new ScreenSizeBlock
  66620. * @param name defines the block name
  66621. */
  66622. constructor(name: string);
  66623. /**
  66624. * Gets the current class name
  66625. * @returns the class name
  66626. */
  66627. getClassName(): string;
  66628. /**
  66629. * Gets the xy component
  66630. */
  66631. get xy(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the x component
  66634. */
  66635. get x(): NodeMaterialConnectionPoint;
  66636. /**
  66637. * Gets the y component
  66638. */
  66639. get y(): NodeMaterialConnectionPoint;
  66640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66641. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66642. protected _buildBlock(state: NodeMaterialBuildState): this;
  66643. }
  66644. }
  66645. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66646. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66647. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66648. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66649. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66650. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66651. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66652. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66653. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66654. }
  66655. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66658. import { Mesh } from "babylonjs/Meshes/mesh";
  66659. import { Effect } from "babylonjs/Materials/effect";
  66660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66662. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66663. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66664. /**
  66665. * Block used to add support for scene fog
  66666. */
  66667. export class FogBlock extends NodeMaterialBlock {
  66668. private _fogDistanceName;
  66669. private _fogParameters;
  66670. /**
  66671. * Create a new FogBlock
  66672. * @param name defines the block name
  66673. */
  66674. constructor(name: string);
  66675. /**
  66676. * Gets the current class name
  66677. * @returns the class name
  66678. */
  66679. getClassName(): string;
  66680. /**
  66681. * Gets the world position input component
  66682. */
  66683. get worldPosition(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the view input component
  66686. */
  66687. get view(): NodeMaterialConnectionPoint;
  66688. /**
  66689. * Gets the color input component
  66690. */
  66691. get input(): NodeMaterialConnectionPoint;
  66692. /**
  66693. * Gets the fog color input component
  66694. */
  66695. get fogColor(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the output component
  66698. */
  66699. get output(): NodeMaterialConnectionPoint;
  66700. autoConfigure(material: NodeMaterial): void;
  66701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66702. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66703. protected _buildBlock(state: NodeMaterialBuildState): this;
  66704. }
  66705. }
  66706. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66711. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66712. import { Effect } from "babylonjs/Materials/effect";
  66713. import { Mesh } from "babylonjs/Meshes/mesh";
  66714. import { Light } from "babylonjs/Lights/light";
  66715. import { Nullable } from "babylonjs/types";
  66716. import { Scene } from "babylonjs/scene";
  66717. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66718. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66719. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66720. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66721. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66722. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66723. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66724. /**
  66725. * Block used to add light in the fragment shader
  66726. */
  66727. export class LightBlock extends NodeMaterialBlock {
  66728. private _lightId;
  66729. /**
  66730. * Gets or sets the light associated with this block
  66731. */
  66732. light: Nullable<Light>;
  66733. /**
  66734. * Create a new LightBlock
  66735. * @param name defines the block name
  66736. */
  66737. constructor(name: string);
  66738. /**
  66739. * Gets the current class name
  66740. * @returns the class name
  66741. */
  66742. getClassName(): string;
  66743. /**
  66744. * Gets the world position input component
  66745. */
  66746. get worldPosition(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the world normal input component
  66749. */
  66750. get worldNormal(): NodeMaterialConnectionPoint;
  66751. /**
  66752. * Gets the camera (or eye) position component
  66753. */
  66754. get cameraPosition(): NodeMaterialConnectionPoint;
  66755. /**
  66756. * Gets the glossiness component
  66757. */
  66758. get glossiness(): NodeMaterialConnectionPoint;
  66759. /**
  66760. * Gets the glossinness power component
  66761. */
  66762. get glossPower(): NodeMaterialConnectionPoint;
  66763. /**
  66764. * Gets the diffuse color component
  66765. */
  66766. get diffuseColor(): NodeMaterialConnectionPoint;
  66767. /**
  66768. * Gets the specular color component
  66769. */
  66770. get specularColor(): NodeMaterialConnectionPoint;
  66771. /**
  66772. * Gets the diffuse output component
  66773. */
  66774. get diffuseOutput(): NodeMaterialConnectionPoint;
  66775. /**
  66776. * Gets the specular output component
  66777. */
  66778. get specularOutput(): NodeMaterialConnectionPoint;
  66779. /**
  66780. * Gets the shadow output component
  66781. */
  66782. get shadow(): NodeMaterialConnectionPoint;
  66783. autoConfigure(material: NodeMaterial): void;
  66784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66785. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66787. private _injectVertexCode;
  66788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66789. serialize(): any;
  66790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66791. }
  66792. }
  66793. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66796. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66797. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66798. /**
  66799. * Block used to read a reflection texture from a sampler
  66800. */
  66801. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66802. /**
  66803. * Create a new ReflectionTextureBlock
  66804. * @param name defines the block name
  66805. */
  66806. constructor(name: string);
  66807. /**
  66808. * Gets the current class name
  66809. * @returns the class name
  66810. */
  66811. getClassName(): string;
  66812. /**
  66813. * Gets the world position input component
  66814. */
  66815. get position(): NodeMaterialConnectionPoint;
  66816. /**
  66817. * Gets the world position input component
  66818. */
  66819. get worldPosition(): NodeMaterialConnectionPoint;
  66820. /**
  66821. * Gets the world normal input component
  66822. */
  66823. get worldNormal(): NodeMaterialConnectionPoint;
  66824. /**
  66825. * Gets the world input component
  66826. */
  66827. get world(): NodeMaterialConnectionPoint;
  66828. /**
  66829. * Gets the camera (or eye) position component
  66830. */
  66831. get cameraPosition(): NodeMaterialConnectionPoint;
  66832. /**
  66833. * Gets the view input component
  66834. */
  66835. get view(): NodeMaterialConnectionPoint;
  66836. /**
  66837. * Gets the rgb output component
  66838. */
  66839. get rgb(): NodeMaterialConnectionPoint;
  66840. /**
  66841. * Gets the rgba output component
  66842. */
  66843. get rgba(): NodeMaterialConnectionPoint;
  66844. /**
  66845. * Gets the r output component
  66846. */
  66847. get r(): NodeMaterialConnectionPoint;
  66848. /**
  66849. * Gets the g output component
  66850. */
  66851. get g(): NodeMaterialConnectionPoint;
  66852. /**
  66853. * Gets the b output component
  66854. */
  66855. get b(): NodeMaterialConnectionPoint;
  66856. /**
  66857. * Gets the a output component
  66858. */
  66859. get a(): NodeMaterialConnectionPoint;
  66860. autoConfigure(material: NodeMaterial): void;
  66861. protected _buildBlock(state: NodeMaterialBuildState): this;
  66862. }
  66863. }
  66864. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66865. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66866. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66867. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66868. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66869. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66870. }
  66871. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66872. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66873. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66874. }
  66875. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66879. /**
  66880. * Block used to add 2 vectors
  66881. */
  66882. export class AddBlock extends NodeMaterialBlock {
  66883. /**
  66884. * Creates a new AddBlock
  66885. * @param name defines the block name
  66886. */
  66887. constructor(name: string);
  66888. /**
  66889. * Gets the current class name
  66890. * @returns the class name
  66891. */
  66892. getClassName(): string;
  66893. /**
  66894. * Gets the left operand input component
  66895. */
  66896. get left(): NodeMaterialConnectionPoint;
  66897. /**
  66898. * Gets the right operand input component
  66899. */
  66900. get right(): 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/scaleBlock" {
  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. /**
  66913. * Block used to scale a vector by a float
  66914. */
  66915. export class ScaleBlock extends NodeMaterialBlock {
  66916. /**
  66917. * Creates a new ScaleBlock
  66918. * @param name defines the block name
  66919. */
  66920. constructor(name: string);
  66921. /**
  66922. * Gets the current class name
  66923. * @returns the class name
  66924. */
  66925. getClassName(): string;
  66926. /**
  66927. * Gets the input component
  66928. */
  66929. get input(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the factor input component
  66932. */
  66933. get factor(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the output component
  66936. */
  66937. get output(): NodeMaterialConnectionPoint;
  66938. protected _buildBlock(state: NodeMaterialBuildState): this;
  66939. }
  66940. }
  66941. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66945. import { Scene } from "babylonjs/scene";
  66946. /**
  66947. * Block used to clamp a float
  66948. */
  66949. export class ClampBlock extends NodeMaterialBlock {
  66950. /** Gets or sets the minimum range */
  66951. minimum: number;
  66952. /** Gets or sets the maximum range */
  66953. maximum: number;
  66954. /**
  66955. * Creates a new ClampBlock
  66956. * @param name defines the block name
  66957. */
  66958. constructor(name: string);
  66959. /**
  66960. * Gets the current class name
  66961. * @returns the class name
  66962. */
  66963. getClassName(): string;
  66964. /**
  66965. * Gets the value input component
  66966. */
  66967. get value(): NodeMaterialConnectionPoint;
  66968. /**
  66969. * Gets the output component
  66970. */
  66971. get output(): NodeMaterialConnectionPoint;
  66972. protected _buildBlock(state: NodeMaterialBuildState): this;
  66973. protected _dumpPropertiesCode(): string;
  66974. serialize(): any;
  66975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66976. }
  66977. }
  66978. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66982. /**
  66983. * Block used to apply a cross product between 2 vectors
  66984. */
  66985. export class CrossBlock extends NodeMaterialBlock {
  66986. /**
  66987. * Creates a new CrossBlock
  66988. * @param name defines the block name
  66989. */
  66990. constructor(name: string);
  66991. /**
  66992. * Gets the current class name
  66993. * @returns the class name
  66994. */
  66995. getClassName(): string;
  66996. /**
  66997. * Gets the left operand input component
  66998. */
  66999. get left(): NodeMaterialConnectionPoint;
  67000. /**
  67001. * Gets the right operand input component
  67002. */
  67003. get right(): NodeMaterialConnectionPoint;
  67004. /**
  67005. * Gets the output component
  67006. */
  67007. get output(): NodeMaterialConnectionPoint;
  67008. protected _buildBlock(state: NodeMaterialBuildState): this;
  67009. }
  67010. }
  67011. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67015. /**
  67016. * Block used to apply a dot product between 2 vectors
  67017. */
  67018. export class DotBlock extends NodeMaterialBlock {
  67019. /**
  67020. * Creates a new DotBlock
  67021. * @param name defines the block name
  67022. */
  67023. constructor(name: string);
  67024. /**
  67025. * Gets the current class name
  67026. * @returns the class name
  67027. */
  67028. getClassName(): string;
  67029. /**
  67030. * Gets the left operand input component
  67031. */
  67032. get left(): NodeMaterialConnectionPoint;
  67033. /**
  67034. * Gets the right operand input component
  67035. */
  67036. get right(): NodeMaterialConnectionPoint;
  67037. /**
  67038. * Gets the output component
  67039. */
  67040. get output(): NodeMaterialConnectionPoint;
  67041. protected _buildBlock(state: NodeMaterialBuildState): this;
  67042. }
  67043. }
  67044. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67048. /**
  67049. * Block used to normalize a vector
  67050. */
  67051. export class NormalizeBlock extends NodeMaterialBlock {
  67052. /**
  67053. * Creates a new NormalizeBlock
  67054. * @param name defines the block name
  67055. */
  67056. constructor(name: string);
  67057. /**
  67058. * Gets the current class name
  67059. * @returns the class name
  67060. */
  67061. getClassName(): string;
  67062. /**
  67063. * Gets the input component
  67064. */
  67065. get input(): NodeMaterialConnectionPoint;
  67066. /**
  67067. * Gets the output component
  67068. */
  67069. get output(): NodeMaterialConnectionPoint;
  67070. protected _buildBlock(state: NodeMaterialBuildState): this;
  67071. }
  67072. }
  67073. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67077. /**
  67078. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67079. */
  67080. export class ColorMergerBlock extends NodeMaterialBlock {
  67081. /**
  67082. * Create a new ColorMergerBlock
  67083. * @param name defines the block name
  67084. */
  67085. constructor(name: string);
  67086. /**
  67087. * Gets the current class name
  67088. * @returns the class name
  67089. */
  67090. getClassName(): string;
  67091. /**
  67092. * Gets the rgb component (input)
  67093. */
  67094. get rgbIn(): NodeMaterialConnectionPoint;
  67095. /**
  67096. * Gets the r component (input)
  67097. */
  67098. get r(): NodeMaterialConnectionPoint;
  67099. /**
  67100. * Gets the g component (input)
  67101. */
  67102. get g(): NodeMaterialConnectionPoint;
  67103. /**
  67104. * Gets the b component (input)
  67105. */
  67106. get b(): NodeMaterialConnectionPoint;
  67107. /**
  67108. * Gets the a component (input)
  67109. */
  67110. get a(): NodeMaterialConnectionPoint;
  67111. /**
  67112. * Gets the rgba component (output)
  67113. */
  67114. get rgba(): NodeMaterialConnectionPoint;
  67115. /**
  67116. * Gets the rgb component (output)
  67117. */
  67118. get rgbOut(): NodeMaterialConnectionPoint;
  67119. /**
  67120. * Gets the rgb component (output)
  67121. * @deprecated Please use rgbOut instead.
  67122. */
  67123. get rgb(): NodeMaterialConnectionPoint;
  67124. protected _buildBlock(state: NodeMaterialBuildState): this;
  67125. }
  67126. }
  67127. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67131. /**
  67132. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67133. */
  67134. export class VectorSplitterBlock extends NodeMaterialBlock {
  67135. /**
  67136. * Create a new VectorSplitterBlock
  67137. * @param name defines the block name
  67138. */
  67139. constructor(name: string);
  67140. /**
  67141. * Gets the current class name
  67142. * @returns the class name
  67143. */
  67144. getClassName(): string;
  67145. /**
  67146. * Gets the xyzw component (input)
  67147. */
  67148. get xyzw(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the xyz component (input)
  67151. */
  67152. get xyzIn(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the xy component (input)
  67155. */
  67156. get xyIn(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the xyz component (output)
  67159. */
  67160. get xyzOut(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the xy component (output)
  67163. */
  67164. get xyOut(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the x component (output)
  67167. */
  67168. get x(): NodeMaterialConnectionPoint;
  67169. /**
  67170. * Gets the y component (output)
  67171. */
  67172. get y(): NodeMaterialConnectionPoint;
  67173. /**
  67174. * Gets the z component (output)
  67175. */
  67176. get z(): NodeMaterialConnectionPoint;
  67177. /**
  67178. * Gets the w component (output)
  67179. */
  67180. get w(): NodeMaterialConnectionPoint;
  67181. protected _inputRename(name: string): string;
  67182. protected _outputRename(name: string): string;
  67183. protected _buildBlock(state: NodeMaterialBuildState): this;
  67184. }
  67185. }
  67186. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67190. /**
  67191. * Block used to lerp between 2 values
  67192. */
  67193. export class LerpBlock extends NodeMaterialBlock {
  67194. /**
  67195. * Creates a new LerpBlock
  67196. * @param name defines the block name
  67197. */
  67198. constructor(name: string);
  67199. /**
  67200. * Gets the current class name
  67201. * @returns the class name
  67202. */
  67203. getClassName(): string;
  67204. /**
  67205. * Gets the left operand input component
  67206. */
  67207. get left(): NodeMaterialConnectionPoint;
  67208. /**
  67209. * Gets the right operand input component
  67210. */
  67211. get right(): NodeMaterialConnectionPoint;
  67212. /**
  67213. * Gets the gradient operand input component
  67214. */
  67215. get gradient(): NodeMaterialConnectionPoint;
  67216. /**
  67217. * Gets the output component
  67218. */
  67219. get output(): NodeMaterialConnectionPoint;
  67220. protected _buildBlock(state: NodeMaterialBuildState): this;
  67221. }
  67222. }
  67223. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67227. /**
  67228. * Block used to divide 2 vectors
  67229. */
  67230. export class DivideBlock extends NodeMaterialBlock {
  67231. /**
  67232. * Creates a new DivideBlock
  67233. * @param name defines the block name
  67234. */
  67235. constructor(name: string);
  67236. /**
  67237. * Gets the current class name
  67238. * @returns the class name
  67239. */
  67240. getClassName(): string;
  67241. /**
  67242. * Gets the left operand input component
  67243. */
  67244. get left(): NodeMaterialConnectionPoint;
  67245. /**
  67246. * Gets the right operand input component
  67247. */
  67248. get right(): NodeMaterialConnectionPoint;
  67249. /**
  67250. * Gets the output component
  67251. */
  67252. get output(): NodeMaterialConnectionPoint;
  67253. protected _buildBlock(state: NodeMaterialBuildState): this;
  67254. }
  67255. }
  67256. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67260. /**
  67261. * Block used to subtract 2 vectors
  67262. */
  67263. export class SubtractBlock extends NodeMaterialBlock {
  67264. /**
  67265. * Creates a new SubtractBlock
  67266. * @param name defines the block name
  67267. */
  67268. constructor(name: string);
  67269. /**
  67270. * Gets the current class name
  67271. * @returns the class name
  67272. */
  67273. getClassName(): string;
  67274. /**
  67275. * Gets the left operand input component
  67276. */
  67277. get left(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the right operand input component
  67280. */
  67281. get right(): NodeMaterialConnectionPoint;
  67282. /**
  67283. * Gets the output component
  67284. */
  67285. get output(): NodeMaterialConnectionPoint;
  67286. protected _buildBlock(state: NodeMaterialBuildState): this;
  67287. }
  67288. }
  67289. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67293. /**
  67294. * Block used to step a value
  67295. */
  67296. export class StepBlock extends NodeMaterialBlock {
  67297. /**
  67298. * Creates a new StepBlock
  67299. * @param name defines the block name
  67300. */
  67301. constructor(name: string);
  67302. /**
  67303. * Gets the current class name
  67304. * @returns the class name
  67305. */
  67306. getClassName(): string;
  67307. /**
  67308. * Gets the value operand input component
  67309. */
  67310. get value(): NodeMaterialConnectionPoint;
  67311. /**
  67312. * Gets the edge operand input component
  67313. */
  67314. get edge(): NodeMaterialConnectionPoint;
  67315. /**
  67316. * Gets the output component
  67317. */
  67318. get output(): NodeMaterialConnectionPoint;
  67319. protected _buildBlock(state: NodeMaterialBuildState): this;
  67320. }
  67321. }
  67322. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67326. /**
  67327. * Block used to get the opposite (1 - x) of a value
  67328. */
  67329. export class OneMinusBlock extends NodeMaterialBlock {
  67330. /**
  67331. * Creates a new OneMinusBlock
  67332. * @param name defines the block name
  67333. */
  67334. constructor(name: string);
  67335. /**
  67336. * Gets the current class name
  67337. * @returns the class name
  67338. */
  67339. getClassName(): string;
  67340. /**
  67341. * Gets the input component
  67342. */
  67343. get input(): NodeMaterialConnectionPoint;
  67344. /**
  67345. * Gets the output component
  67346. */
  67347. get output(): NodeMaterialConnectionPoint;
  67348. protected _buildBlock(state: NodeMaterialBuildState): this;
  67349. }
  67350. }
  67351. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67355. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67356. /**
  67357. * Block used to get the view direction
  67358. */
  67359. export class ViewDirectionBlock extends NodeMaterialBlock {
  67360. /**
  67361. * Creates a new ViewDirectionBlock
  67362. * @param name defines the block name
  67363. */
  67364. constructor(name: string);
  67365. /**
  67366. * Gets the current class name
  67367. * @returns the class name
  67368. */
  67369. getClassName(): string;
  67370. /**
  67371. * Gets the world position component
  67372. */
  67373. get worldPosition(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the camera position component
  67376. */
  67377. get cameraPosition(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the output component
  67380. */
  67381. get output(): NodeMaterialConnectionPoint;
  67382. autoConfigure(material: NodeMaterial): void;
  67383. protected _buildBlock(state: NodeMaterialBuildState): this;
  67384. }
  67385. }
  67386. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67390. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67391. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67392. /**
  67393. * Block used to compute fresnel value
  67394. */
  67395. export class FresnelBlock extends NodeMaterialBlock {
  67396. /**
  67397. * Create a new FresnelBlock
  67398. * @param name defines the block name
  67399. */
  67400. constructor(name: string);
  67401. /**
  67402. * Gets the current class name
  67403. * @returns the class name
  67404. */
  67405. getClassName(): string;
  67406. /**
  67407. * Gets the world normal input component
  67408. */
  67409. get worldNormal(): NodeMaterialConnectionPoint;
  67410. /**
  67411. * Gets the view direction input component
  67412. */
  67413. get viewDirection(): NodeMaterialConnectionPoint;
  67414. /**
  67415. * Gets the bias input component
  67416. */
  67417. get bias(): NodeMaterialConnectionPoint;
  67418. /**
  67419. * Gets the camera (or eye) position component
  67420. */
  67421. get power(): NodeMaterialConnectionPoint;
  67422. /**
  67423. * Gets the fresnel output component
  67424. */
  67425. get fresnel(): NodeMaterialConnectionPoint;
  67426. autoConfigure(material: NodeMaterial): void;
  67427. protected _buildBlock(state: NodeMaterialBuildState): this;
  67428. }
  67429. }
  67430. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67433. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67434. /**
  67435. * Block used to get the max of 2 values
  67436. */
  67437. export class MaxBlock extends NodeMaterialBlock {
  67438. /**
  67439. * Creates a new MaxBlock
  67440. * @param name defines the block name
  67441. */
  67442. constructor(name: string);
  67443. /**
  67444. * Gets the current class name
  67445. * @returns the class name
  67446. */
  67447. getClassName(): string;
  67448. /**
  67449. * Gets the left operand input component
  67450. */
  67451. get left(): NodeMaterialConnectionPoint;
  67452. /**
  67453. * Gets the right operand input component
  67454. */
  67455. get right(): NodeMaterialConnectionPoint;
  67456. /**
  67457. * Gets the output component
  67458. */
  67459. get output(): NodeMaterialConnectionPoint;
  67460. protected _buildBlock(state: NodeMaterialBuildState): this;
  67461. }
  67462. }
  67463. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67467. /**
  67468. * Block used to get the min of 2 values
  67469. */
  67470. export class MinBlock extends NodeMaterialBlock {
  67471. /**
  67472. * Creates a new MinBlock
  67473. * @param name defines the block name
  67474. */
  67475. constructor(name: string);
  67476. /**
  67477. * Gets the current class name
  67478. * @returns the class name
  67479. */
  67480. getClassName(): string;
  67481. /**
  67482. * Gets the left operand input component
  67483. */
  67484. get left(): NodeMaterialConnectionPoint;
  67485. /**
  67486. * Gets the right operand input component
  67487. */
  67488. get right(): NodeMaterialConnectionPoint;
  67489. /**
  67490. * Gets the output component
  67491. */
  67492. get output(): NodeMaterialConnectionPoint;
  67493. protected _buildBlock(state: NodeMaterialBuildState): this;
  67494. }
  67495. }
  67496. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67500. /**
  67501. * Block used to get the distance between 2 values
  67502. */
  67503. export class DistanceBlock extends NodeMaterialBlock {
  67504. /**
  67505. * Creates a new DistanceBlock
  67506. * @param name defines the block name
  67507. */
  67508. constructor(name: string);
  67509. /**
  67510. * Gets the current class name
  67511. * @returns the class name
  67512. */
  67513. getClassName(): string;
  67514. /**
  67515. * Gets the left operand input component
  67516. */
  67517. get left(): NodeMaterialConnectionPoint;
  67518. /**
  67519. * Gets the right operand input component
  67520. */
  67521. get right(): NodeMaterialConnectionPoint;
  67522. /**
  67523. * Gets the output component
  67524. */
  67525. get output(): NodeMaterialConnectionPoint;
  67526. protected _buildBlock(state: NodeMaterialBuildState): this;
  67527. }
  67528. }
  67529. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67533. /**
  67534. * Block used to get the length of a vector
  67535. */
  67536. export class LengthBlock extends NodeMaterialBlock {
  67537. /**
  67538. * Creates a new LengthBlock
  67539. * @param name defines the block name
  67540. */
  67541. constructor(name: string);
  67542. /**
  67543. * Gets the current class name
  67544. * @returns the class name
  67545. */
  67546. getClassName(): string;
  67547. /**
  67548. * Gets the value input component
  67549. */
  67550. get value(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the output component
  67553. */
  67554. get output(): NodeMaterialConnectionPoint;
  67555. protected _buildBlock(state: NodeMaterialBuildState): this;
  67556. }
  67557. }
  67558. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67560. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67561. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67562. /**
  67563. * Block used to get negative version of a value (i.e. x * -1)
  67564. */
  67565. export class NegateBlock extends NodeMaterialBlock {
  67566. /**
  67567. * Creates a new NegateBlock
  67568. * @param name defines the block name
  67569. */
  67570. constructor(name: string);
  67571. /**
  67572. * Gets the current class name
  67573. * @returns the class name
  67574. */
  67575. getClassName(): string;
  67576. /**
  67577. * Gets the value input component
  67578. */
  67579. get value(): NodeMaterialConnectionPoint;
  67580. /**
  67581. * Gets the output component
  67582. */
  67583. get output(): NodeMaterialConnectionPoint;
  67584. protected _buildBlock(state: NodeMaterialBuildState): this;
  67585. }
  67586. }
  67587. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67591. /**
  67592. * Block used to get the value of the first parameter raised to the power of the second
  67593. */
  67594. export class PowBlock extends NodeMaterialBlock {
  67595. /**
  67596. * Creates a new PowBlock
  67597. * @param name defines the block name
  67598. */
  67599. constructor(name: string);
  67600. /**
  67601. * Gets the current class name
  67602. * @returns the class name
  67603. */
  67604. getClassName(): string;
  67605. /**
  67606. * Gets the value operand input component
  67607. */
  67608. get value(): NodeMaterialConnectionPoint;
  67609. /**
  67610. * Gets the power operand input component
  67611. */
  67612. get power(): NodeMaterialConnectionPoint;
  67613. /**
  67614. * Gets the output component
  67615. */
  67616. get output(): NodeMaterialConnectionPoint;
  67617. protected _buildBlock(state: NodeMaterialBuildState): this;
  67618. }
  67619. }
  67620. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67624. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67625. /**
  67626. * Block used to get a random number
  67627. */
  67628. export class RandomNumberBlock extends NodeMaterialBlock {
  67629. /**
  67630. * Creates a new RandomNumberBlock
  67631. * @param name defines the block name
  67632. */
  67633. constructor(name: string);
  67634. /**
  67635. * Gets the current class name
  67636. * @returns the class name
  67637. */
  67638. getClassName(): string;
  67639. /**
  67640. * Gets the seed input component
  67641. */
  67642. get seed(): NodeMaterialConnectionPoint;
  67643. /**
  67644. * Gets the output component
  67645. */
  67646. get output(): NodeMaterialConnectionPoint;
  67647. protected _buildBlock(state: NodeMaterialBuildState): this;
  67648. }
  67649. }
  67650. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67654. /**
  67655. * Block used to compute arc tangent of 2 values
  67656. */
  67657. export class ArcTan2Block extends NodeMaterialBlock {
  67658. /**
  67659. * Creates a new ArcTan2Block
  67660. * @param name defines the block name
  67661. */
  67662. constructor(name: string);
  67663. /**
  67664. * Gets the current class name
  67665. * @returns the class name
  67666. */
  67667. getClassName(): string;
  67668. /**
  67669. * Gets the x operand input component
  67670. */
  67671. get x(): NodeMaterialConnectionPoint;
  67672. /**
  67673. * Gets the y operand input component
  67674. */
  67675. get y(): NodeMaterialConnectionPoint;
  67676. /**
  67677. * Gets the output component
  67678. */
  67679. get output(): NodeMaterialConnectionPoint;
  67680. protected _buildBlock(state: NodeMaterialBuildState): this;
  67681. }
  67682. }
  67683. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  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 smooth step a value
  67689. */
  67690. export class SmoothStepBlock extends NodeMaterialBlock {
  67691. /**
  67692. * Creates a new SmoothStepBlock
  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 value operand input component
  67703. */
  67704. get value(): NodeMaterialConnectionPoint;
  67705. /**
  67706. * Gets the first edge operand input component
  67707. */
  67708. get edge0(): NodeMaterialConnectionPoint;
  67709. /**
  67710. * Gets the second edge operand input component
  67711. */
  67712. get edge1(): NodeMaterialConnectionPoint;
  67713. /**
  67714. * Gets the output component
  67715. */
  67716. get output(): NodeMaterialConnectionPoint;
  67717. protected _buildBlock(state: NodeMaterialBuildState): this;
  67718. }
  67719. }
  67720. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67724. /**
  67725. * Block used to get the reciprocal (1 / x) of a value
  67726. */
  67727. export class ReciprocalBlock extends NodeMaterialBlock {
  67728. /**
  67729. * Creates a new ReciprocalBlock
  67730. * @param name defines the block name
  67731. */
  67732. constructor(name: string);
  67733. /**
  67734. * Gets the current class name
  67735. * @returns the class name
  67736. */
  67737. getClassName(): string;
  67738. /**
  67739. * Gets the input component
  67740. */
  67741. get input(): NodeMaterialConnectionPoint;
  67742. /**
  67743. * Gets the output component
  67744. */
  67745. get output(): NodeMaterialConnectionPoint;
  67746. protected _buildBlock(state: NodeMaterialBuildState): this;
  67747. }
  67748. }
  67749. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67751. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67752. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67753. /**
  67754. * Block used to replace a color by another one
  67755. */
  67756. export class ReplaceColorBlock extends NodeMaterialBlock {
  67757. /**
  67758. * Creates a new ReplaceColorBlock
  67759. * @param name defines the block name
  67760. */
  67761. constructor(name: string);
  67762. /**
  67763. * Gets the current class name
  67764. * @returns the class name
  67765. */
  67766. getClassName(): string;
  67767. /**
  67768. * Gets the value input component
  67769. */
  67770. get value(): NodeMaterialConnectionPoint;
  67771. /**
  67772. * Gets the reference input component
  67773. */
  67774. get reference(): NodeMaterialConnectionPoint;
  67775. /**
  67776. * Gets the distance input component
  67777. */
  67778. get distance(): NodeMaterialConnectionPoint;
  67779. /**
  67780. * Gets the replacement input component
  67781. */
  67782. get replacement(): NodeMaterialConnectionPoint;
  67783. /**
  67784. * Gets the output component
  67785. */
  67786. get output(): NodeMaterialConnectionPoint;
  67787. protected _buildBlock(state: NodeMaterialBuildState): this;
  67788. }
  67789. }
  67790. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67794. /**
  67795. * Block used to posterize a value
  67796. * @see https://en.wikipedia.org/wiki/Posterization
  67797. */
  67798. export class PosterizeBlock extends NodeMaterialBlock {
  67799. /**
  67800. * Creates a new PosterizeBlock
  67801. * @param name defines the block name
  67802. */
  67803. constructor(name: string);
  67804. /**
  67805. * Gets the current class name
  67806. * @returns the class name
  67807. */
  67808. getClassName(): string;
  67809. /**
  67810. * Gets the value input component
  67811. */
  67812. get value(): NodeMaterialConnectionPoint;
  67813. /**
  67814. * Gets the steps input component
  67815. */
  67816. get steps(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the output component
  67819. */
  67820. get output(): NodeMaterialConnectionPoint;
  67821. protected _buildBlock(state: NodeMaterialBuildState): this;
  67822. }
  67823. }
  67824. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67828. import { Scene } from "babylonjs/scene";
  67829. /**
  67830. * Operations supported by the Wave block
  67831. */
  67832. export enum WaveBlockKind {
  67833. /** SawTooth */
  67834. SawTooth = 0,
  67835. /** Square */
  67836. Square = 1,
  67837. /** Triangle */
  67838. Triangle = 2
  67839. }
  67840. /**
  67841. * Block used to apply wave operation to floats
  67842. */
  67843. export class WaveBlock extends NodeMaterialBlock {
  67844. /**
  67845. * Gets or sets the kibnd of wave to be applied by the block
  67846. */
  67847. kind: WaveBlockKind;
  67848. /**
  67849. * Creates a new WaveBlock
  67850. * @param name defines the block name
  67851. */
  67852. constructor(name: string);
  67853. /**
  67854. * Gets the current class name
  67855. * @returns the class name
  67856. */
  67857. getClassName(): string;
  67858. /**
  67859. * Gets the input component
  67860. */
  67861. get input(): NodeMaterialConnectionPoint;
  67862. /**
  67863. * Gets the output component
  67864. */
  67865. get output(): NodeMaterialConnectionPoint;
  67866. protected _buildBlock(state: NodeMaterialBuildState): this;
  67867. serialize(): any;
  67868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67869. }
  67870. }
  67871. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67875. import { Color3 } from "babylonjs/Maths/math.color";
  67876. import { Scene } from "babylonjs/scene";
  67877. import { Observable } from "babylonjs/Misc/observable";
  67878. /**
  67879. * Class used to store a color step for the GradientBlock
  67880. */
  67881. export class GradientBlockColorStep {
  67882. private _step;
  67883. /**
  67884. * Gets value indicating which step this color is associated with (between 0 and 1)
  67885. */
  67886. get step(): number;
  67887. /**
  67888. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67889. */
  67890. set step(val: number);
  67891. private _color;
  67892. /**
  67893. * Gets the color associated with this step
  67894. */
  67895. get color(): Color3;
  67896. /**
  67897. * Sets the color associated with this step
  67898. */
  67899. set color(val: Color3);
  67900. /**
  67901. * Creates a new GradientBlockColorStep
  67902. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67903. * @param color defines the color associated with this step
  67904. */
  67905. constructor(step: number, color: Color3);
  67906. }
  67907. /**
  67908. * Block used to return a color from a gradient based on an input value between 0 and 1
  67909. */
  67910. export class GradientBlock extends NodeMaterialBlock {
  67911. /**
  67912. * Gets or sets the list of color steps
  67913. */
  67914. colorSteps: GradientBlockColorStep[];
  67915. /** Gets an observable raised when the value is changed */
  67916. onValueChangedObservable: Observable<GradientBlock>;
  67917. /** calls observable when the value is changed*/
  67918. colorStepsUpdated(): void;
  67919. /**
  67920. * Creates a new GradientBlock
  67921. * @param name defines the block name
  67922. */
  67923. constructor(name: string);
  67924. /**
  67925. * Gets the current class name
  67926. * @returns the class name
  67927. */
  67928. getClassName(): string;
  67929. /**
  67930. * Gets the gradient input component
  67931. */
  67932. get gradient(): NodeMaterialConnectionPoint;
  67933. /**
  67934. * Gets the output component
  67935. */
  67936. get output(): NodeMaterialConnectionPoint;
  67937. private _writeColorConstant;
  67938. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67939. serialize(): any;
  67940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67941. protected _dumpPropertiesCode(): string;
  67942. }
  67943. }
  67944. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67948. /**
  67949. * Block used to normalize lerp between 2 values
  67950. */
  67951. export class NLerpBlock extends NodeMaterialBlock {
  67952. /**
  67953. * Creates a new NLerpBlock
  67954. * @param name defines the block name
  67955. */
  67956. constructor(name: string);
  67957. /**
  67958. * Gets the current class name
  67959. * @returns the class name
  67960. */
  67961. getClassName(): string;
  67962. /**
  67963. * Gets the left operand input component
  67964. */
  67965. get left(): NodeMaterialConnectionPoint;
  67966. /**
  67967. * Gets the right operand input component
  67968. */
  67969. get right(): NodeMaterialConnectionPoint;
  67970. /**
  67971. * Gets the gradient operand input component
  67972. */
  67973. get gradient(): NodeMaterialConnectionPoint;
  67974. /**
  67975. * Gets the output component
  67976. */
  67977. get output(): NodeMaterialConnectionPoint;
  67978. protected _buildBlock(state: NodeMaterialBuildState): this;
  67979. }
  67980. }
  67981. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67985. import { Scene } from "babylonjs/scene";
  67986. /**
  67987. * block used to Generate a Worley Noise 3D Noise Pattern
  67988. */
  67989. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67990. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67991. manhattanDistance: boolean;
  67992. /**
  67993. * Creates a new WorleyNoise3DBlock
  67994. * @param name defines the block name
  67995. */
  67996. constructor(name: string);
  67997. /**
  67998. * Gets the current class name
  67999. * @returns the class name
  68000. */
  68001. getClassName(): string;
  68002. /**
  68003. * Gets the seed input component
  68004. */
  68005. get seed(): NodeMaterialConnectionPoint;
  68006. /**
  68007. * Gets the jitter input component
  68008. */
  68009. get jitter(): NodeMaterialConnectionPoint;
  68010. /**
  68011. * Gets the output component
  68012. */
  68013. get output(): NodeMaterialConnectionPoint;
  68014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68015. /**
  68016. * Exposes the properties to the UI?
  68017. */
  68018. protected _dumpPropertiesCode(): string;
  68019. /**
  68020. * Exposes the properties to the Seralize?
  68021. */
  68022. serialize(): any;
  68023. /**
  68024. * Exposes the properties to the deseralize?
  68025. */
  68026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68027. }
  68028. }
  68029. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68033. /**
  68034. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68035. */
  68036. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68037. /**
  68038. * Creates a new SimplexPerlin3DBlock
  68039. * @param name defines the block name
  68040. */
  68041. constructor(name: string);
  68042. /**
  68043. * Gets the current class name
  68044. * @returns the class name
  68045. */
  68046. getClassName(): string;
  68047. /**
  68048. * Gets the seed operand input component
  68049. */
  68050. get seed(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the output component
  68053. */
  68054. get output(): NodeMaterialConnectionPoint;
  68055. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68056. }
  68057. }
  68058. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68062. /**
  68063. * Block used to blend normals
  68064. */
  68065. export class NormalBlendBlock extends NodeMaterialBlock {
  68066. /**
  68067. * Creates a new NormalBlendBlock
  68068. * @param name defines the block name
  68069. */
  68070. constructor(name: string);
  68071. /**
  68072. * Gets the current class name
  68073. * @returns the class name
  68074. */
  68075. getClassName(): string;
  68076. /**
  68077. * Gets the first input component
  68078. */
  68079. get normalMap0(): NodeMaterialConnectionPoint;
  68080. /**
  68081. * Gets the second input component
  68082. */
  68083. get normalMap1(): NodeMaterialConnectionPoint;
  68084. /**
  68085. * Gets the output component
  68086. */
  68087. get output(): NodeMaterialConnectionPoint;
  68088. protected _buildBlock(state: NodeMaterialBuildState): this;
  68089. }
  68090. }
  68091. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68095. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68096. /**
  68097. * Block used to rotate a 2d vector by a given angle
  68098. */
  68099. export class Rotate2dBlock extends NodeMaterialBlock {
  68100. /**
  68101. * Creates a new Rotate2dBlock
  68102. * @param name defines the block name
  68103. */
  68104. constructor(name: string);
  68105. /**
  68106. * Gets the current class name
  68107. * @returns the class name
  68108. */
  68109. getClassName(): string;
  68110. /**
  68111. * Gets the input vector
  68112. */
  68113. get input(): NodeMaterialConnectionPoint;
  68114. /**
  68115. * Gets the input angle
  68116. */
  68117. get angle(): NodeMaterialConnectionPoint;
  68118. /**
  68119. * Gets the output component
  68120. */
  68121. get output(): NodeMaterialConnectionPoint;
  68122. autoConfigure(material: NodeMaterial): void;
  68123. protected _buildBlock(state: NodeMaterialBuildState): this;
  68124. }
  68125. }
  68126. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68130. /**
  68131. * Block used to get the reflected vector from a direction and a normal
  68132. */
  68133. export class ReflectBlock extends NodeMaterialBlock {
  68134. /**
  68135. * Creates a new ReflectBlock
  68136. * @param name defines the block name
  68137. */
  68138. constructor(name: string);
  68139. /**
  68140. * Gets the current class name
  68141. * @returns the class name
  68142. */
  68143. getClassName(): string;
  68144. /**
  68145. * Gets the incident component
  68146. */
  68147. get incident(): NodeMaterialConnectionPoint;
  68148. /**
  68149. * Gets the normal component
  68150. */
  68151. get normal(): NodeMaterialConnectionPoint;
  68152. /**
  68153. * Gets the output component
  68154. */
  68155. get output(): NodeMaterialConnectionPoint;
  68156. protected _buildBlock(state: NodeMaterialBuildState): this;
  68157. }
  68158. }
  68159. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68163. /**
  68164. * Block used to get the refracted vector from a direction and a normal
  68165. */
  68166. export class RefractBlock extends NodeMaterialBlock {
  68167. /**
  68168. * Creates a new RefractBlock
  68169. * @param name defines the block name
  68170. */
  68171. constructor(name: string);
  68172. /**
  68173. * Gets the current class name
  68174. * @returns the class name
  68175. */
  68176. getClassName(): string;
  68177. /**
  68178. * Gets the incident component
  68179. */
  68180. get incident(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the normal component
  68183. */
  68184. get normal(): NodeMaterialConnectionPoint;
  68185. /**
  68186. * Gets the index of refraction component
  68187. */
  68188. get ior(): NodeMaterialConnectionPoint;
  68189. /**
  68190. * Gets the output component
  68191. */
  68192. get output(): NodeMaterialConnectionPoint;
  68193. protected _buildBlock(state: NodeMaterialBuildState): this;
  68194. }
  68195. }
  68196. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68200. /**
  68201. * Block used to desaturate a color
  68202. */
  68203. export class DesaturateBlock extends NodeMaterialBlock {
  68204. /**
  68205. * Creates a new DesaturateBlock
  68206. * @param name defines the block name
  68207. */
  68208. constructor(name: string);
  68209. /**
  68210. * Gets the current class name
  68211. * @returns the class name
  68212. */
  68213. getClassName(): string;
  68214. /**
  68215. * Gets the color operand input component
  68216. */
  68217. get color(): NodeMaterialConnectionPoint;
  68218. /**
  68219. * Gets the level operand input component
  68220. */
  68221. get level(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the output component
  68224. */
  68225. get output(): NodeMaterialConnectionPoint;
  68226. protected _buildBlock(state: NodeMaterialBuildState): this;
  68227. }
  68228. }
  68229. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68233. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68234. import { Nullable } from "babylonjs/types";
  68235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68236. import { Scene } from "babylonjs/scene";
  68237. /**
  68238. * Block used to implement the ambient occlusion module of the PBR material
  68239. */
  68240. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68241. /**
  68242. * Create a new AmbientOcclusionBlock
  68243. * @param name defines the block name
  68244. */
  68245. constructor(name: string);
  68246. /**
  68247. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68248. */
  68249. useAmbientInGrayScale: boolean;
  68250. /**
  68251. * Initialize the block and prepare the context for build
  68252. * @param state defines the state that will be used for the build
  68253. */
  68254. initialize(state: NodeMaterialBuildState): void;
  68255. /**
  68256. * Gets the current class name
  68257. * @returns the class name
  68258. */
  68259. getClassName(): string;
  68260. /**
  68261. * Gets the texture input component
  68262. */
  68263. get texture(): NodeMaterialConnectionPoint;
  68264. /**
  68265. * Gets the texture intensity component
  68266. */
  68267. get intensity(): NodeMaterialConnectionPoint;
  68268. /**
  68269. * Gets the direct light intensity input component
  68270. */
  68271. get directLightIntensity(): NodeMaterialConnectionPoint;
  68272. /**
  68273. * Gets the ambient occlusion object output component
  68274. */
  68275. get ambientOcc(): NodeMaterialConnectionPoint;
  68276. /**
  68277. * Gets the main code of the block (fragment side)
  68278. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68279. * @returns the shader code
  68280. */
  68281. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68283. protected _buildBlock(state: NodeMaterialBuildState): this;
  68284. protected _dumpPropertiesCode(): string;
  68285. serialize(): any;
  68286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68287. }
  68288. }
  68289. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68292. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68293. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68295. import { Nullable } from "babylonjs/types";
  68296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68297. import { Mesh } from "babylonjs/Meshes/mesh";
  68298. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68299. import { Effect } from "babylonjs/Materials/effect";
  68300. import { Scene } from "babylonjs/scene";
  68301. /**
  68302. * Block used to implement the reflection module of the PBR material
  68303. */
  68304. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68305. /** @hidden */
  68306. _defineLODReflectionAlpha: string;
  68307. /** @hidden */
  68308. _defineLinearSpecularReflection: string;
  68309. private _vEnvironmentIrradianceName;
  68310. /** @hidden */
  68311. _vReflectionMicrosurfaceInfosName: string;
  68312. /** @hidden */
  68313. _vReflectionInfosName: string;
  68314. /** @hidden */
  68315. _vReflectionFilteringInfoName: string;
  68316. private _scene;
  68317. /**
  68318. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68319. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68320. * It's less burden on the user side in the editor part.
  68321. */
  68322. /** @hidden */
  68323. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68324. /** @hidden */
  68325. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68326. /** @hidden */
  68327. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68328. /**
  68329. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68330. * diffuse part of the IBL.
  68331. */
  68332. useSphericalHarmonics: boolean;
  68333. /**
  68334. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68335. */
  68336. forceIrradianceInFragment: boolean;
  68337. /**
  68338. * Create a new ReflectionBlock
  68339. * @param name defines the block name
  68340. */
  68341. constructor(name: string);
  68342. /**
  68343. * Gets the current class name
  68344. * @returns the class name
  68345. */
  68346. getClassName(): string;
  68347. /**
  68348. * Gets the position input component
  68349. */
  68350. get position(): NodeMaterialConnectionPoint;
  68351. /**
  68352. * Gets the world position input component
  68353. */
  68354. get worldPosition(): NodeMaterialConnectionPoint;
  68355. /**
  68356. * Gets the world normal input component
  68357. */
  68358. get worldNormal(): NodeMaterialConnectionPoint;
  68359. /**
  68360. * Gets the world input component
  68361. */
  68362. get world(): NodeMaterialConnectionPoint;
  68363. /**
  68364. * Gets the camera (or eye) position component
  68365. */
  68366. get cameraPosition(): NodeMaterialConnectionPoint;
  68367. /**
  68368. * Gets the view input component
  68369. */
  68370. get view(): NodeMaterialConnectionPoint;
  68371. /**
  68372. * Gets the color input component
  68373. */
  68374. get color(): NodeMaterialConnectionPoint;
  68375. /**
  68376. * Gets the reflection object output component
  68377. */
  68378. get reflection(): NodeMaterialConnectionPoint;
  68379. /**
  68380. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68381. */
  68382. get hasTexture(): boolean;
  68383. /**
  68384. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68385. */
  68386. get reflectionColor(): string;
  68387. protected _getTexture(): Nullable<BaseTexture>;
  68388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68390. /**
  68391. * Gets the code to inject in the vertex shader
  68392. * @param state current state of the node material building
  68393. * @returns the shader code
  68394. */
  68395. handleVertexSide(state: NodeMaterialBuildState): string;
  68396. /**
  68397. * Gets the main code of the block (fragment side)
  68398. * @param state current state of the node material building
  68399. * @param normalVarName name of the existing variable corresponding to the normal
  68400. * @returns the shader code
  68401. */
  68402. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68403. protected _buildBlock(state: NodeMaterialBuildState): this;
  68404. protected _dumpPropertiesCode(): string;
  68405. serialize(): any;
  68406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68407. }
  68408. }
  68409. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68413. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68415. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68416. import { Scene } from "babylonjs/scene";
  68417. import { Nullable } from "babylonjs/types";
  68418. /**
  68419. * Block used to implement the sheen module of the PBR material
  68420. */
  68421. export class SheenBlock extends NodeMaterialBlock {
  68422. /**
  68423. * Create a new SheenBlock
  68424. * @param name defines the block name
  68425. */
  68426. constructor(name: string);
  68427. /**
  68428. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68429. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68430. * making it easier to setup and tweak the effect
  68431. */
  68432. albedoScaling: boolean;
  68433. /**
  68434. * Defines if the sheen is linked to the sheen color.
  68435. */
  68436. linkSheenWithAlbedo: boolean;
  68437. /**
  68438. * Initialize the block and prepare the context for build
  68439. * @param state defines the state that will be used for the build
  68440. */
  68441. initialize(state: NodeMaterialBuildState): void;
  68442. /**
  68443. * Gets the current class name
  68444. * @returns the class name
  68445. */
  68446. getClassName(): string;
  68447. /**
  68448. * Gets the intensity input component
  68449. */
  68450. get intensity(): NodeMaterialConnectionPoint;
  68451. /**
  68452. * Gets the color input component
  68453. */
  68454. get color(): NodeMaterialConnectionPoint;
  68455. /**
  68456. * Gets the roughness input component
  68457. */
  68458. get roughness(): NodeMaterialConnectionPoint;
  68459. /**
  68460. * Gets the sheen object output component
  68461. */
  68462. get sheen(): NodeMaterialConnectionPoint;
  68463. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68464. /**
  68465. * Gets the main code of the block (fragment side)
  68466. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68467. * @returns the shader code
  68468. */
  68469. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68470. protected _buildBlock(state: NodeMaterialBuildState): this;
  68471. protected _dumpPropertiesCode(): string;
  68472. serialize(): any;
  68473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68474. }
  68475. }
  68476. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68477. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68482. import { Scene } from "babylonjs/scene";
  68483. import { Nullable } from "babylonjs/types";
  68484. import { Mesh } from "babylonjs/Meshes/mesh";
  68485. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68486. import { Effect } from "babylonjs/Materials/effect";
  68487. /**
  68488. * Block used to implement the reflectivity module of the PBR material
  68489. */
  68490. export class ReflectivityBlock extends NodeMaterialBlock {
  68491. private _metallicReflectanceColor;
  68492. private _metallicF0Factor;
  68493. /** @hidden */
  68494. _vMetallicReflectanceFactorsName: string;
  68495. /**
  68496. * The property below is set by the main PBR block prior to calling methods of this class.
  68497. */
  68498. /** @hidden */
  68499. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68500. /**
  68501. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68502. */
  68503. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68504. /**
  68505. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68506. */
  68507. useMetallnessFromMetallicTextureBlue: boolean;
  68508. /**
  68509. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68510. */
  68511. useRoughnessFromMetallicTextureAlpha: boolean;
  68512. /**
  68513. * Specifies if the metallic texture contains the roughness information in its green channel.
  68514. */
  68515. useRoughnessFromMetallicTextureGreen: boolean;
  68516. /**
  68517. * Create a new ReflectivityBlock
  68518. * @param name defines the block name
  68519. */
  68520. constructor(name: string);
  68521. /**
  68522. * Initialize the block and prepare the context for build
  68523. * @param state defines the state that will be used for the build
  68524. */
  68525. initialize(state: NodeMaterialBuildState): void;
  68526. /**
  68527. * Gets the current class name
  68528. * @returns the class name
  68529. */
  68530. getClassName(): string;
  68531. /**
  68532. * Gets the metallic input component
  68533. */
  68534. get metallic(): NodeMaterialConnectionPoint;
  68535. /**
  68536. * Gets the roughness input component
  68537. */
  68538. get roughness(): NodeMaterialConnectionPoint;
  68539. /**
  68540. * Gets the texture input component
  68541. */
  68542. get texture(): NodeMaterialConnectionPoint;
  68543. /**
  68544. * Gets the reflectivity object output component
  68545. */
  68546. get reflectivity(): NodeMaterialConnectionPoint;
  68547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68548. /**
  68549. * Gets the main code of the block (fragment side)
  68550. * @param state current state of the node material building
  68551. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68552. * @returns the shader code
  68553. */
  68554. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68556. protected _buildBlock(state: NodeMaterialBuildState): this;
  68557. protected _dumpPropertiesCode(): string;
  68558. serialize(): any;
  68559. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68560. }
  68561. }
  68562. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68563. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68568. /**
  68569. * Block used to implement the anisotropy module of the PBR material
  68570. */
  68571. export class AnisotropyBlock extends NodeMaterialBlock {
  68572. /**
  68573. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68574. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68575. * It's less burden on the user side in the editor part.
  68576. */
  68577. /** @hidden */
  68578. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68579. /** @hidden */
  68580. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68581. /**
  68582. * Create a new AnisotropyBlock
  68583. * @param name defines the block name
  68584. */
  68585. constructor(name: string);
  68586. /**
  68587. * Initialize the block and prepare the context for build
  68588. * @param state defines the state that will be used for the build
  68589. */
  68590. initialize(state: NodeMaterialBuildState): void;
  68591. /**
  68592. * Gets the current class name
  68593. * @returns the class name
  68594. */
  68595. getClassName(): string;
  68596. /**
  68597. * Gets the intensity input component
  68598. */
  68599. get intensity(): NodeMaterialConnectionPoint;
  68600. /**
  68601. * Gets the direction input component
  68602. */
  68603. get direction(): NodeMaterialConnectionPoint;
  68604. /**
  68605. * Gets the texture input component
  68606. */
  68607. get texture(): NodeMaterialConnectionPoint;
  68608. /**
  68609. * Gets the uv input component
  68610. */
  68611. get uv(): NodeMaterialConnectionPoint;
  68612. /**
  68613. * Gets the worldTangent input component
  68614. */
  68615. get worldTangent(): NodeMaterialConnectionPoint;
  68616. /**
  68617. * Gets the anisotropy object output component
  68618. */
  68619. get anisotropy(): NodeMaterialConnectionPoint;
  68620. private _generateTBNSpace;
  68621. /**
  68622. * Gets the main code of the block (fragment side)
  68623. * @param state current state of the node material building
  68624. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68625. * @returns the shader code
  68626. */
  68627. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68629. protected _buildBlock(state: NodeMaterialBuildState): this;
  68630. }
  68631. }
  68632. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68636. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68638. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68639. import { Nullable } from "babylonjs/types";
  68640. import { Mesh } from "babylonjs/Meshes/mesh";
  68641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68642. import { Effect } from "babylonjs/Materials/effect";
  68643. /**
  68644. * Block used to implement the clear coat module of the PBR material
  68645. */
  68646. export class ClearCoatBlock extends NodeMaterialBlock {
  68647. private _scene;
  68648. /**
  68649. * Create a new ClearCoatBlock
  68650. * @param name defines the block name
  68651. */
  68652. constructor(name: string);
  68653. /**
  68654. * Initialize the block and prepare the context for build
  68655. * @param state defines the state that will be used for the build
  68656. */
  68657. initialize(state: NodeMaterialBuildState): void;
  68658. /**
  68659. * Gets the current class name
  68660. * @returns the class name
  68661. */
  68662. getClassName(): string;
  68663. /**
  68664. * Gets the intensity input component
  68665. */
  68666. get intensity(): NodeMaterialConnectionPoint;
  68667. /**
  68668. * Gets the roughness input component
  68669. */
  68670. get roughness(): NodeMaterialConnectionPoint;
  68671. /**
  68672. * Gets the ior input component
  68673. */
  68674. get ior(): NodeMaterialConnectionPoint;
  68675. /**
  68676. * Gets the texture input component
  68677. */
  68678. get texture(): NodeMaterialConnectionPoint;
  68679. /**
  68680. * Gets the bump texture input component
  68681. */
  68682. get bumpTexture(): NodeMaterialConnectionPoint;
  68683. /**
  68684. * Gets the uv input component
  68685. */
  68686. get uv(): NodeMaterialConnectionPoint;
  68687. /**
  68688. * Gets the tint color input component
  68689. */
  68690. get tintColor(): NodeMaterialConnectionPoint;
  68691. /**
  68692. * Gets the tint "at distance" input component
  68693. */
  68694. get tintAtDistance(): NodeMaterialConnectionPoint;
  68695. /**
  68696. * Gets the tint thickness input component
  68697. */
  68698. get tintThickness(): NodeMaterialConnectionPoint;
  68699. /**
  68700. * Gets the world tangent input component
  68701. */
  68702. get worldTangent(): NodeMaterialConnectionPoint;
  68703. /**
  68704. * Gets the clear coat object output component
  68705. */
  68706. get clearcoat(): NodeMaterialConnectionPoint;
  68707. autoConfigure(material: NodeMaterial): void;
  68708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68710. private _generateTBNSpace;
  68711. /**
  68712. * Gets the main code of the block (fragment side)
  68713. * @param state current state of the node material building
  68714. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68715. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68716. * @param worldPosVarName name of the variable holding the world position
  68717. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68718. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68719. * @param worldNormalVarName name of the variable holding the world normal
  68720. * @returns the shader code
  68721. */
  68722. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68723. protected _buildBlock(state: NodeMaterialBuildState): this;
  68724. }
  68725. }
  68726. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68728. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68729. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68730. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68732. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68733. import { Nullable } from "babylonjs/types";
  68734. /**
  68735. * Block used to implement the sub surface module of the PBR material
  68736. */
  68737. export class SubSurfaceBlock extends NodeMaterialBlock {
  68738. /**
  68739. * Create a new SubSurfaceBlock
  68740. * @param name defines the block name
  68741. */
  68742. constructor(name: string);
  68743. /**
  68744. * Stores the intensity of the different subsurface effects in the thickness texture.
  68745. * * the green channel is the translucency intensity.
  68746. * * the blue channel is the scattering intensity.
  68747. * * the alpha channel is the refraction intensity.
  68748. */
  68749. useMaskFromThicknessTexture: boolean;
  68750. /**
  68751. * Initialize the block and prepare the context for build
  68752. * @param state defines the state that will be used for the build
  68753. */
  68754. initialize(state: NodeMaterialBuildState): void;
  68755. /**
  68756. * Gets the current class name
  68757. * @returns the class name
  68758. */
  68759. getClassName(): string;
  68760. /**
  68761. * Gets the min thickness input component
  68762. */
  68763. get minThickness(): NodeMaterialConnectionPoint;
  68764. /**
  68765. * Gets the max thickness input component
  68766. */
  68767. get maxThickness(): NodeMaterialConnectionPoint;
  68768. /**
  68769. * Gets the thickness texture component
  68770. */
  68771. get thicknessTexture(): NodeMaterialConnectionPoint;
  68772. /**
  68773. * Gets the tint color input component
  68774. */
  68775. get tintColor(): NodeMaterialConnectionPoint;
  68776. /**
  68777. * Gets the translucency intensity input component
  68778. */
  68779. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68780. /**
  68781. * Gets the translucency diffusion distance input component
  68782. */
  68783. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68784. /**
  68785. * Gets the refraction object parameters
  68786. */
  68787. get refraction(): NodeMaterialConnectionPoint;
  68788. /**
  68789. * Gets the sub surface object output component
  68790. */
  68791. get subsurface(): NodeMaterialConnectionPoint;
  68792. autoConfigure(material: NodeMaterial): void;
  68793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68794. /**
  68795. * Gets the main code of the block (fragment side)
  68796. * @param state current state of the node material building
  68797. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68798. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68799. * @param worldPosVarName name of the variable holding the world position
  68800. * @returns the shader code
  68801. */
  68802. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68803. protected _buildBlock(state: NodeMaterialBuildState): this;
  68804. }
  68805. }
  68806. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68810. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68811. import { Light } from "babylonjs/Lights/light";
  68812. import { Nullable } from "babylonjs/types";
  68813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68814. import { Effect } from "babylonjs/Materials/effect";
  68815. import { Mesh } from "babylonjs/Meshes/mesh";
  68816. import { Scene } from "babylonjs/scene";
  68817. /**
  68818. * Block used to implement the PBR metallic/roughness model
  68819. */
  68820. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68821. /**
  68822. * Gets or sets the light associated with this block
  68823. */
  68824. light: Nullable<Light>;
  68825. private _lightId;
  68826. private _scene;
  68827. private _environmentBRDFTexture;
  68828. private _environmentBrdfSamplerName;
  68829. private _vNormalWName;
  68830. private _invertNormalName;
  68831. /**
  68832. * Create a new ReflectionBlock
  68833. * @param name defines the block name
  68834. */
  68835. constructor(name: string);
  68836. /**
  68837. * Intensity of the direct lights e.g. the four lights available in your scene.
  68838. * This impacts both the direct diffuse and specular highlights.
  68839. */
  68840. directIntensity: number;
  68841. /**
  68842. * Intensity of the environment e.g. how much the environment will light the object
  68843. * either through harmonics for rough material or through the refelction for shiny ones.
  68844. */
  68845. environmentIntensity: number;
  68846. /**
  68847. * This is a special control allowing the reduction of the specular highlights coming from the
  68848. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68849. */
  68850. specularIntensity: number;
  68851. /**
  68852. * Defines the falloff type used in this material.
  68853. * It by default is Physical.
  68854. */
  68855. lightFalloff: number;
  68856. /**
  68857. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68858. */
  68859. useAlphaFromAlbedoTexture: boolean;
  68860. /**
  68861. * Specifies that alpha test should be used
  68862. */
  68863. useAlphaTest: boolean;
  68864. /**
  68865. * Defines the alpha limits in alpha test mode.
  68866. */
  68867. alphaTestCutoff: number;
  68868. /**
  68869. * Specifies that alpha blending should be used
  68870. */
  68871. useAlphaBlending: boolean;
  68872. /**
  68873. * Defines if the alpha value should be determined via the rgb values.
  68874. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68875. */
  68876. opacityRGB: boolean;
  68877. /**
  68878. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68879. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68880. */
  68881. useRadianceOverAlpha: boolean;
  68882. /**
  68883. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68884. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68885. */
  68886. useSpecularOverAlpha: boolean;
  68887. /**
  68888. * Enables specular anti aliasing in the PBR shader.
  68889. * It will both interacts on the Geometry for analytical and IBL lighting.
  68890. * It also prefilter the roughness map based on the bump values.
  68891. */
  68892. enableSpecularAntiAliasing: boolean;
  68893. /**
  68894. * Enables realtime filtering on the texture.
  68895. */
  68896. realTimeFiltering: boolean;
  68897. /**
  68898. * Quality switch for realtime filtering
  68899. */
  68900. realTimeFilteringQuality: number;
  68901. /**
  68902. * Defines if the material uses energy conservation.
  68903. */
  68904. useEnergyConservation: boolean;
  68905. /**
  68906. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68907. * too much the area relying on ambient texture to define their ambient occlusion.
  68908. */
  68909. useRadianceOcclusion: boolean;
  68910. /**
  68911. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68912. * makes the reflect vector face the model (under horizon).
  68913. */
  68914. useHorizonOcclusion: boolean;
  68915. /**
  68916. * If set to true, no lighting calculations will be applied.
  68917. */
  68918. unlit: boolean;
  68919. /**
  68920. * Force normal to face away from face.
  68921. */
  68922. forceNormalForward: boolean;
  68923. /**
  68924. * Defines the material debug mode.
  68925. * It helps seeing only some components of the material while troubleshooting.
  68926. */
  68927. debugMode: number;
  68928. /**
  68929. * Specify from where on screen the debug mode should start.
  68930. * The value goes from -1 (full screen) to 1 (not visible)
  68931. * It helps with side by side comparison against the final render
  68932. * This defaults to 0
  68933. */
  68934. debugLimit: number;
  68935. /**
  68936. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68937. * You can use the factor to better multiply the final value.
  68938. */
  68939. debugFactor: number;
  68940. /**
  68941. * Initialize the block and prepare the context for build
  68942. * @param state defines the state that will be used for the build
  68943. */
  68944. initialize(state: NodeMaterialBuildState): void;
  68945. /**
  68946. * Gets the current class name
  68947. * @returns the class name
  68948. */
  68949. getClassName(): string;
  68950. /**
  68951. * Gets the world position input component
  68952. */
  68953. get worldPosition(): NodeMaterialConnectionPoint;
  68954. /**
  68955. * Gets the world normal input component
  68956. */
  68957. get worldNormal(): NodeMaterialConnectionPoint;
  68958. /**
  68959. * Gets the perturbed normal input component
  68960. */
  68961. get perturbedNormal(): NodeMaterialConnectionPoint;
  68962. /**
  68963. * Gets the camera position input component
  68964. */
  68965. get cameraPosition(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the base color input component
  68968. */
  68969. get baseColor(): NodeMaterialConnectionPoint;
  68970. /**
  68971. * Gets the opacity texture input component
  68972. */
  68973. get opacityTexture(): NodeMaterialConnectionPoint;
  68974. /**
  68975. * Gets the ambient color input component
  68976. */
  68977. get ambientColor(): NodeMaterialConnectionPoint;
  68978. /**
  68979. * Gets the reflectivity object parameters
  68980. */
  68981. get reflectivity(): NodeMaterialConnectionPoint;
  68982. /**
  68983. * Gets the ambient occlusion object parameters
  68984. */
  68985. get ambientOcc(): NodeMaterialConnectionPoint;
  68986. /**
  68987. * Gets the reflection object parameters
  68988. */
  68989. get reflection(): NodeMaterialConnectionPoint;
  68990. /**
  68991. * Gets the sheen object parameters
  68992. */
  68993. get sheen(): NodeMaterialConnectionPoint;
  68994. /**
  68995. * Gets the clear coat object parameters
  68996. */
  68997. get clearcoat(): NodeMaterialConnectionPoint;
  68998. /**
  68999. * Gets the sub surface object parameters
  69000. */
  69001. get subsurface(): NodeMaterialConnectionPoint;
  69002. /**
  69003. * Gets the anisotropy object parameters
  69004. */
  69005. get anisotropy(): NodeMaterialConnectionPoint;
  69006. /**
  69007. * Gets the ambient output component
  69008. */
  69009. get ambient(): NodeMaterialConnectionPoint;
  69010. /**
  69011. * Gets the diffuse output component
  69012. */
  69013. get diffuse(): NodeMaterialConnectionPoint;
  69014. /**
  69015. * Gets the specular output component
  69016. */
  69017. get specular(): NodeMaterialConnectionPoint;
  69018. /**
  69019. * Gets the sheen output component
  69020. */
  69021. get sheenDir(): NodeMaterialConnectionPoint;
  69022. /**
  69023. * Gets the clear coat output component
  69024. */
  69025. get clearcoatDir(): NodeMaterialConnectionPoint;
  69026. /**
  69027. * Gets the indirect diffuse output component
  69028. */
  69029. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69030. /**
  69031. * Gets the indirect specular output component
  69032. */
  69033. get specularIndirect(): NodeMaterialConnectionPoint;
  69034. /**
  69035. * Gets the indirect sheen output component
  69036. */
  69037. get sheenIndirect(): NodeMaterialConnectionPoint;
  69038. /**
  69039. * Gets the indirect clear coat output component
  69040. */
  69041. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69042. /**
  69043. * Gets the refraction output component
  69044. */
  69045. get refraction(): NodeMaterialConnectionPoint;
  69046. /**
  69047. * Gets the global lighting output component
  69048. */
  69049. get lighting(): NodeMaterialConnectionPoint;
  69050. /**
  69051. * Gets the shadow output component
  69052. */
  69053. get shadow(): NodeMaterialConnectionPoint;
  69054. /**
  69055. * Gets the alpha output component
  69056. */
  69057. get alpha(): NodeMaterialConnectionPoint;
  69058. autoConfigure(material: NodeMaterial): void;
  69059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69060. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69061. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69062. private _injectVertexCode;
  69063. /**
  69064. * Gets the code corresponding to the albedo/opacity module
  69065. * @returns the shader code
  69066. */
  69067. getAlbedoOpacityCode(): string;
  69068. protected _buildBlock(state: NodeMaterialBuildState): this;
  69069. protected _dumpPropertiesCode(): string;
  69070. serialize(): any;
  69071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69072. }
  69073. }
  69074. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69075. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69076. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69077. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69078. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69079. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69080. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69081. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69082. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69083. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69084. }
  69085. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69086. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69087. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69088. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69089. }
  69090. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69094. /**
  69095. * Block used to compute value of one parameter modulo another
  69096. */
  69097. export class ModBlock extends NodeMaterialBlock {
  69098. /**
  69099. * Creates a new ModBlock
  69100. * @param name defines the block name
  69101. */
  69102. constructor(name: string);
  69103. /**
  69104. * Gets the current class name
  69105. * @returns the class name
  69106. */
  69107. getClassName(): string;
  69108. /**
  69109. * Gets the left operand input component
  69110. */
  69111. get left(): NodeMaterialConnectionPoint;
  69112. /**
  69113. * Gets the right operand input component
  69114. */
  69115. get right(): NodeMaterialConnectionPoint;
  69116. /**
  69117. * Gets the output component
  69118. */
  69119. get output(): NodeMaterialConnectionPoint;
  69120. protected _buildBlock(state: NodeMaterialBuildState): this;
  69121. }
  69122. }
  69123. declare module "babylonjs/Materials/Node/Blocks/index" {
  69124. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69125. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69126. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69127. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69128. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69129. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69130. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69131. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69132. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69133. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69134. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69135. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69136. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69137. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69138. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69139. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69140. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69141. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69142. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69143. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69144. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69145. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69146. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69147. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69148. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69149. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69150. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69151. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69152. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69153. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69154. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69155. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69156. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69157. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69158. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69159. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69160. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69161. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69162. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69163. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69164. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69165. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69166. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69167. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69168. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69169. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69170. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69171. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69172. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69173. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69174. }
  69175. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69176. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69177. }
  69178. declare module "babylonjs/Materials/Node/index" {
  69179. export * from "babylonjs/Materials/Node/Enums/index";
  69180. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69181. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69182. export * from "babylonjs/Materials/Node/nodeMaterial";
  69183. export * from "babylonjs/Materials/Node/Blocks/index";
  69184. export * from "babylonjs/Materials/Node/Optimizers/index";
  69185. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69186. }
  69187. declare module "babylonjs/Materials/index" {
  69188. export * from "babylonjs/Materials/Background/index";
  69189. export * from "babylonjs/Materials/colorCurves";
  69190. export * from "babylonjs/Materials/iEffectFallbacks";
  69191. export * from "babylonjs/Materials/effectFallbacks";
  69192. export * from "babylonjs/Materials/effect";
  69193. export * from "babylonjs/Materials/fresnelParameters";
  69194. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69195. export * from "babylonjs/Materials/material";
  69196. export * from "babylonjs/Materials/materialDefines";
  69197. export * from "babylonjs/Materials/thinMaterialHelper";
  69198. export * from "babylonjs/Materials/materialHelper";
  69199. export * from "babylonjs/Materials/multiMaterial";
  69200. export * from "babylonjs/Materials/PBR/index";
  69201. export * from "babylonjs/Materials/pushMaterial";
  69202. export * from "babylonjs/Materials/shaderMaterial";
  69203. export * from "babylonjs/Materials/standardMaterial";
  69204. export * from "babylonjs/Materials/Textures/index";
  69205. export * from "babylonjs/Materials/uniformBuffer";
  69206. export * from "babylonjs/Materials/materialFlags";
  69207. export * from "babylonjs/Materials/Node/index";
  69208. export * from "babylonjs/Materials/effectRenderer";
  69209. export * from "babylonjs/Materials/shadowDepthWrapper";
  69210. }
  69211. declare module "babylonjs/Maths/index" {
  69212. export * from "babylonjs/Maths/math.scalar";
  69213. export * from "babylonjs/Maths/math";
  69214. export * from "babylonjs/Maths/sphericalPolynomial";
  69215. }
  69216. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69217. import { IDisposable } from "babylonjs/scene";
  69218. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69219. /**
  69220. * Configuration for Draco compression
  69221. */
  69222. export interface IDracoCompressionConfiguration {
  69223. /**
  69224. * Configuration for the decoder.
  69225. */
  69226. decoder: {
  69227. /**
  69228. * The url to the WebAssembly module.
  69229. */
  69230. wasmUrl?: string;
  69231. /**
  69232. * The url to the WebAssembly binary.
  69233. */
  69234. wasmBinaryUrl?: string;
  69235. /**
  69236. * The url to the fallback JavaScript module.
  69237. */
  69238. fallbackUrl?: string;
  69239. };
  69240. }
  69241. /**
  69242. * Draco compression (https://google.github.io/draco/)
  69243. *
  69244. * This class wraps the Draco module.
  69245. *
  69246. * **Encoder**
  69247. *
  69248. * The encoder is not currently implemented.
  69249. *
  69250. * **Decoder**
  69251. *
  69252. * 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.
  69253. *
  69254. * To update the configuration, use the following code:
  69255. * ```javascript
  69256. * DracoCompression.Configuration = {
  69257. * decoder: {
  69258. * wasmUrl: "<url to the WebAssembly library>",
  69259. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69260. * fallbackUrl: "<url to the fallback JavaScript library>",
  69261. * }
  69262. * };
  69263. * ```
  69264. *
  69265. * 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.
  69266. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69267. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69268. *
  69269. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69270. * ```javascript
  69271. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69272. * ```
  69273. *
  69274. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69275. */
  69276. export class DracoCompression implements IDisposable {
  69277. private _workerPoolPromise?;
  69278. private _decoderModulePromise?;
  69279. /**
  69280. * The configuration. Defaults to the following urls:
  69281. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69282. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69283. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69284. */
  69285. static Configuration: IDracoCompressionConfiguration;
  69286. /**
  69287. * Returns true if the decoder configuration is available.
  69288. */
  69289. static get DecoderAvailable(): boolean;
  69290. /**
  69291. * Default number of workers to create when creating the draco compression object.
  69292. */
  69293. static DefaultNumWorkers: number;
  69294. private static GetDefaultNumWorkers;
  69295. private static _Default;
  69296. /**
  69297. * Default instance for the draco compression object.
  69298. */
  69299. static get Default(): DracoCompression;
  69300. /**
  69301. * Constructor
  69302. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69303. */
  69304. constructor(numWorkers?: number);
  69305. /**
  69306. * Stop all async operations and release resources.
  69307. */
  69308. dispose(): void;
  69309. /**
  69310. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69311. * @returns a promise that resolves when ready
  69312. */
  69313. whenReadyAsync(): Promise<void>;
  69314. /**
  69315. * Decode Draco compressed mesh data to vertex data.
  69316. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69317. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69318. * @returns A promise that resolves with the decoded vertex data
  69319. */
  69320. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69321. [kind: string]: number;
  69322. }): Promise<VertexData>;
  69323. }
  69324. }
  69325. declare module "babylonjs/Meshes/Compression/index" {
  69326. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69327. }
  69328. declare module "babylonjs/Meshes/csg" {
  69329. import { Nullable } from "babylonjs/types";
  69330. import { Scene } from "babylonjs/scene";
  69331. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69332. import { Mesh } from "babylonjs/Meshes/mesh";
  69333. import { Material } from "babylonjs/Materials/material";
  69334. /**
  69335. * Class for building Constructive Solid Geometry
  69336. */
  69337. export class CSG {
  69338. private polygons;
  69339. /**
  69340. * The world matrix
  69341. */
  69342. matrix: Matrix;
  69343. /**
  69344. * Stores the position
  69345. */
  69346. position: Vector3;
  69347. /**
  69348. * Stores the rotation
  69349. */
  69350. rotation: Vector3;
  69351. /**
  69352. * Stores the rotation quaternion
  69353. */
  69354. rotationQuaternion: Nullable<Quaternion>;
  69355. /**
  69356. * Stores the scaling vector
  69357. */
  69358. scaling: Vector3;
  69359. /**
  69360. * Convert the Mesh to CSG
  69361. * @param mesh The Mesh to convert to CSG
  69362. * @returns A new CSG from the Mesh
  69363. */
  69364. static FromMesh(mesh: Mesh): CSG;
  69365. /**
  69366. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69367. * @param polygons Polygons used to construct a CSG solid
  69368. */
  69369. private static FromPolygons;
  69370. /**
  69371. * Clones, or makes a deep copy, of the CSG
  69372. * @returns A new CSG
  69373. */
  69374. clone(): CSG;
  69375. /**
  69376. * Unions this CSG with another CSG
  69377. * @param csg The CSG to union against this CSG
  69378. * @returns The unioned CSG
  69379. */
  69380. union(csg: CSG): CSG;
  69381. /**
  69382. * Unions this CSG with another CSG in place
  69383. * @param csg The CSG to union against this CSG
  69384. */
  69385. unionInPlace(csg: CSG): void;
  69386. /**
  69387. * Subtracts this CSG with another CSG
  69388. * @param csg The CSG to subtract against this CSG
  69389. * @returns A new CSG
  69390. */
  69391. subtract(csg: CSG): CSG;
  69392. /**
  69393. * Subtracts this CSG with another CSG in place
  69394. * @param csg The CSG to subtact against this CSG
  69395. */
  69396. subtractInPlace(csg: CSG): void;
  69397. /**
  69398. * Intersect this CSG with another CSG
  69399. * @param csg The CSG to intersect against this CSG
  69400. * @returns A new CSG
  69401. */
  69402. intersect(csg: CSG): CSG;
  69403. /**
  69404. * Intersects this CSG with another CSG in place
  69405. * @param csg The CSG to intersect against this CSG
  69406. */
  69407. intersectInPlace(csg: CSG): void;
  69408. /**
  69409. * Return a new CSG solid with solid and empty space switched. This solid is
  69410. * not modified.
  69411. * @returns A new CSG solid with solid and empty space switched
  69412. */
  69413. inverse(): CSG;
  69414. /**
  69415. * Inverses the CSG in place
  69416. */
  69417. inverseInPlace(): void;
  69418. /**
  69419. * This is used to keep meshes transformations so they can be restored
  69420. * when we build back a Babylon Mesh
  69421. * NB : All CSG operations are performed in world coordinates
  69422. * @param csg The CSG to copy the transform attributes from
  69423. * @returns This CSG
  69424. */
  69425. copyTransformAttributes(csg: CSG): CSG;
  69426. /**
  69427. * Build Raw mesh from CSG
  69428. * Coordinates here are in world space
  69429. * @param name The name of the mesh geometry
  69430. * @param scene The Scene
  69431. * @param keepSubMeshes Specifies if the submeshes should be kept
  69432. * @returns A new Mesh
  69433. */
  69434. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69435. /**
  69436. * Build Mesh from CSG taking material and transforms into account
  69437. * @param name The name of the Mesh
  69438. * @param material The material of the Mesh
  69439. * @param scene The Scene
  69440. * @param keepSubMeshes Specifies if submeshes should be kept
  69441. * @returns The new Mesh
  69442. */
  69443. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69444. }
  69445. }
  69446. declare module "babylonjs/Meshes/trailMesh" {
  69447. import { Mesh } from "babylonjs/Meshes/mesh";
  69448. import { Scene } from "babylonjs/scene";
  69449. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69450. /**
  69451. * Class used to create a trail following a mesh
  69452. */
  69453. export class TrailMesh extends Mesh {
  69454. private _generator;
  69455. private _autoStart;
  69456. private _running;
  69457. private _diameter;
  69458. private _length;
  69459. private _sectionPolygonPointsCount;
  69460. private _sectionVectors;
  69461. private _sectionNormalVectors;
  69462. private _beforeRenderObserver;
  69463. /**
  69464. * @constructor
  69465. * @param name The value used by scene.getMeshByName() to do a lookup.
  69466. * @param generator The mesh or transform node to generate a trail.
  69467. * @param scene The scene to add this mesh to.
  69468. * @param diameter Diameter of trailing mesh. Default is 1.
  69469. * @param length Length of trailing mesh. Default is 60.
  69470. * @param autoStart Automatically start trailing mesh. Default true.
  69471. */
  69472. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69473. /**
  69474. * "TrailMesh"
  69475. * @returns "TrailMesh"
  69476. */
  69477. getClassName(): string;
  69478. private _createMesh;
  69479. /**
  69480. * Start trailing mesh.
  69481. */
  69482. start(): void;
  69483. /**
  69484. * Stop trailing mesh.
  69485. */
  69486. stop(): void;
  69487. /**
  69488. * Update trailing mesh geometry.
  69489. */
  69490. update(): void;
  69491. /**
  69492. * Returns a new TrailMesh object.
  69493. * @param name is a string, the name given to the new mesh
  69494. * @param newGenerator use new generator object for cloned trail mesh
  69495. * @returns a new mesh
  69496. */
  69497. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69498. /**
  69499. * Serializes this trail mesh
  69500. * @param serializationObject object to write serialization to
  69501. */
  69502. serialize(serializationObject: any): void;
  69503. /**
  69504. * Parses a serialized trail mesh
  69505. * @param parsedMesh the serialized mesh
  69506. * @param scene the scene to create the trail mesh in
  69507. * @returns the created trail mesh
  69508. */
  69509. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69510. }
  69511. }
  69512. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69513. import { Nullable } from "babylonjs/types";
  69514. import { Scene } from "babylonjs/scene";
  69515. import { Vector4 } from "babylonjs/Maths/math.vector";
  69516. import { Color4 } from "babylonjs/Maths/math.color";
  69517. import { Mesh } from "babylonjs/Meshes/mesh";
  69518. /**
  69519. * Class containing static functions to help procedurally build meshes
  69520. */
  69521. export class TiledBoxBuilder {
  69522. /**
  69523. * Creates a box mesh
  69524. * 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)
  69525. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69529. * @param name defines the name of the mesh
  69530. * @param options defines the options used to create the mesh
  69531. * @param scene defines the hosting scene
  69532. * @returns the box mesh
  69533. */
  69534. static CreateTiledBox(name: string, options: {
  69535. pattern?: number;
  69536. width?: number;
  69537. height?: number;
  69538. depth?: number;
  69539. tileSize?: number;
  69540. tileWidth?: number;
  69541. tileHeight?: number;
  69542. alignHorizontal?: number;
  69543. alignVertical?: number;
  69544. faceUV?: Vector4[];
  69545. faceColors?: Color4[];
  69546. sideOrientation?: number;
  69547. updatable?: boolean;
  69548. }, scene?: Nullable<Scene>): Mesh;
  69549. }
  69550. }
  69551. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69552. import { Vector4 } from "babylonjs/Maths/math.vector";
  69553. import { Mesh } from "babylonjs/Meshes/mesh";
  69554. /**
  69555. * Class containing static functions to help procedurally build meshes
  69556. */
  69557. export class TorusKnotBuilder {
  69558. /**
  69559. * Creates a torus knot mesh
  69560. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69561. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69562. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69563. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69567. * @param name defines the name of the mesh
  69568. * @param options defines the options used to create the mesh
  69569. * @param scene defines the hosting scene
  69570. * @returns the torus knot mesh
  69571. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69572. */
  69573. static CreateTorusKnot(name: string, options: {
  69574. radius?: number;
  69575. tube?: number;
  69576. radialSegments?: number;
  69577. tubularSegments?: number;
  69578. p?: number;
  69579. q?: number;
  69580. updatable?: boolean;
  69581. sideOrientation?: number;
  69582. frontUVs?: Vector4;
  69583. backUVs?: Vector4;
  69584. }, scene: any): Mesh;
  69585. }
  69586. }
  69587. declare module "babylonjs/Meshes/polygonMesh" {
  69588. import { Scene } from "babylonjs/scene";
  69589. import { Vector2 } from "babylonjs/Maths/math.vector";
  69590. import { Mesh } from "babylonjs/Meshes/mesh";
  69591. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69592. import { Path2 } from "babylonjs/Maths/math.path";
  69593. /**
  69594. * Polygon
  69595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69596. */
  69597. export class Polygon {
  69598. /**
  69599. * Creates a rectangle
  69600. * @param xmin bottom X coord
  69601. * @param ymin bottom Y coord
  69602. * @param xmax top X coord
  69603. * @param ymax top Y coord
  69604. * @returns points that make the resulting rectation
  69605. */
  69606. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69607. /**
  69608. * Creates a circle
  69609. * @param radius radius of circle
  69610. * @param cx scale in x
  69611. * @param cy scale in y
  69612. * @param numberOfSides number of sides that make up the circle
  69613. * @returns points that make the resulting circle
  69614. */
  69615. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69616. /**
  69617. * Creates a polygon from input string
  69618. * @param input Input polygon data
  69619. * @returns the parsed points
  69620. */
  69621. static Parse(input: string): Vector2[];
  69622. /**
  69623. * Starts building a polygon from x and y coordinates
  69624. * @param x x coordinate
  69625. * @param y y coordinate
  69626. * @returns the started path2
  69627. */
  69628. static StartingAt(x: number, y: number): Path2;
  69629. }
  69630. /**
  69631. * Builds a polygon
  69632. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69633. */
  69634. export class PolygonMeshBuilder {
  69635. private _points;
  69636. private _outlinepoints;
  69637. private _holes;
  69638. private _name;
  69639. private _scene;
  69640. private _epoints;
  69641. private _eholes;
  69642. private _addToepoint;
  69643. /**
  69644. * Babylon reference to the earcut plugin.
  69645. */
  69646. bjsEarcut: any;
  69647. /**
  69648. * Creates a PolygonMeshBuilder
  69649. * @param name name of the builder
  69650. * @param contours Path of the polygon
  69651. * @param scene scene to add to when creating the mesh
  69652. * @param earcutInjection can be used to inject your own earcut reference
  69653. */
  69654. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69655. /**
  69656. * Adds a whole within the polygon
  69657. * @param hole Array of points defining the hole
  69658. * @returns this
  69659. */
  69660. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69661. /**
  69662. * Creates the polygon
  69663. * @param updatable If the mesh should be updatable
  69664. * @param depth The depth of the mesh created
  69665. * @returns the created mesh
  69666. */
  69667. build(updatable?: boolean, depth?: number): Mesh;
  69668. /**
  69669. * Creates the polygon
  69670. * @param depth The depth of the mesh created
  69671. * @returns the created VertexData
  69672. */
  69673. buildVertexData(depth?: number): VertexData;
  69674. /**
  69675. * Adds a side to the polygon
  69676. * @param positions points that make the polygon
  69677. * @param normals normals of the polygon
  69678. * @param uvs uvs of the polygon
  69679. * @param indices indices of the polygon
  69680. * @param bounds bounds of the polygon
  69681. * @param points points of the polygon
  69682. * @param depth depth of the polygon
  69683. * @param flip flip of the polygon
  69684. */
  69685. private addSide;
  69686. }
  69687. }
  69688. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69689. import { Scene } from "babylonjs/scene";
  69690. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69691. import { Color4 } from "babylonjs/Maths/math.color";
  69692. import { Mesh } from "babylonjs/Meshes/mesh";
  69693. import { Nullable } from "babylonjs/types";
  69694. /**
  69695. * Class containing static functions to help procedurally build meshes
  69696. */
  69697. export class PolygonBuilder {
  69698. /**
  69699. * Creates a polygon mesh
  69700. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69701. * * 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
  69702. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69705. * * Remember you can only change the shape positions, not their number when updating a polygon
  69706. * @param name defines the name of the mesh
  69707. * @param options defines the options used to create the mesh
  69708. * @param scene defines the hosting scene
  69709. * @param earcutInjection can be used to inject your own earcut reference
  69710. * @returns the polygon mesh
  69711. */
  69712. static CreatePolygon(name: string, options: {
  69713. shape: Vector3[];
  69714. holes?: Vector3[][];
  69715. depth?: number;
  69716. faceUV?: Vector4[];
  69717. faceColors?: Color4[];
  69718. updatable?: boolean;
  69719. sideOrientation?: number;
  69720. frontUVs?: Vector4;
  69721. backUVs?: Vector4;
  69722. wrap?: boolean;
  69723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69724. /**
  69725. * Creates an extruded polygon mesh, with depth in the Y direction.
  69726. * * 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)
  69727. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69728. * @param name defines the name of the mesh
  69729. * @param options defines the options used to create the mesh
  69730. * @param scene defines the hosting scene
  69731. * @param earcutInjection can be used to inject your own earcut reference
  69732. * @returns the polygon mesh
  69733. */
  69734. static ExtrudePolygon(name: string, options: {
  69735. shape: Vector3[];
  69736. holes?: Vector3[][];
  69737. depth?: number;
  69738. faceUV?: Vector4[];
  69739. faceColors?: Color4[];
  69740. updatable?: boolean;
  69741. sideOrientation?: number;
  69742. frontUVs?: Vector4;
  69743. backUVs?: Vector4;
  69744. wrap?: boolean;
  69745. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69746. }
  69747. }
  69748. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69749. import { Scene } from "babylonjs/scene";
  69750. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69751. import { Mesh } from "babylonjs/Meshes/mesh";
  69752. import { Nullable } from "babylonjs/types";
  69753. /**
  69754. * Class containing static functions to help procedurally build meshes
  69755. */
  69756. export class LatheBuilder {
  69757. /**
  69758. * Creates lathe mesh.
  69759. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69760. * * 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
  69761. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69762. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69763. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69764. * * 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
  69765. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69766. * * 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
  69767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69771. * @param name defines the name of the mesh
  69772. * @param options defines the options used to create the mesh
  69773. * @param scene defines the hosting scene
  69774. * @returns the lathe mesh
  69775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69776. */
  69777. static CreateLathe(name: string, options: {
  69778. shape: Vector3[];
  69779. radius?: number;
  69780. tessellation?: number;
  69781. clip?: number;
  69782. arc?: number;
  69783. closed?: boolean;
  69784. updatable?: boolean;
  69785. sideOrientation?: number;
  69786. frontUVs?: Vector4;
  69787. backUVs?: Vector4;
  69788. cap?: number;
  69789. invertUV?: boolean;
  69790. }, scene?: Nullable<Scene>): Mesh;
  69791. }
  69792. }
  69793. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69794. import { Nullable } from "babylonjs/types";
  69795. import { Scene } from "babylonjs/scene";
  69796. import { Vector4 } from "babylonjs/Maths/math.vector";
  69797. import { Mesh } from "babylonjs/Meshes/mesh";
  69798. /**
  69799. * Class containing static functions to help procedurally build meshes
  69800. */
  69801. export class TiledPlaneBuilder {
  69802. /**
  69803. * Creates a tiled plane mesh
  69804. * * The parameter `pattern` will, depending on value, do nothing or
  69805. * * * flip (reflect about central vertical) alternate tiles across and up
  69806. * * * flip every tile on alternate rows
  69807. * * * rotate (180 degs) alternate tiles across and up
  69808. * * * rotate every tile on alternate rows
  69809. * * * flip and rotate alternate tiles across and up
  69810. * * * flip and rotate every tile on alternate rows
  69811. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69812. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69815. * * 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)
  69816. * * 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)
  69817. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69818. * @param name defines the name of the mesh
  69819. * @param options defines the options used to create the mesh
  69820. * @param scene defines the hosting scene
  69821. * @returns the box mesh
  69822. */
  69823. static CreateTiledPlane(name: string, options: {
  69824. pattern?: number;
  69825. tileSize?: number;
  69826. tileWidth?: number;
  69827. tileHeight?: number;
  69828. size?: number;
  69829. width?: number;
  69830. height?: number;
  69831. alignHorizontal?: number;
  69832. alignVertical?: number;
  69833. sideOrientation?: number;
  69834. frontUVs?: Vector4;
  69835. backUVs?: Vector4;
  69836. updatable?: boolean;
  69837. }, scene?: Nullable<Scene>): Mesh;
  69838. }
  69839. }
  69840. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69841. import { Nullable } from "babylonjs/types";
  69842. import { Scene } from "babylonjs/scene";
  69843. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69844. import { Mesh } from "babylonjs/Meshes/mesh";
  69845. /**
  69846. * Class containing static functions to help procedurally build meshes
  69847. */
  69848. export class TubeBuilder {
  69849. /**
  69850. * Creates a tube mesh.
  69851. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69852. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69853. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69854. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69855. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69856. * * 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)
  69857. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69858. * * 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
  69859. * * 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
  69860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69864. * @param name defines the name of the mesh
  69865. * @param options defines the options used to create the mesh
  69866. * @param scene defines the hosting scene
  69867. * @returns the tube mesh
  69868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69869. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69870. */
  69871. static CreateTube(name: string, options: {
  69872. path: Vector3[];
  69873. radius?: number;
  69874. tessellation?: number;
  69875. radiusFunction?: {
  69876. (i: number, distance: number): number;
  69877. };
  69878. cap?: number;
  69879. arc?: number;
  69880. updatable?: boolean;
  69881. sideOrientation?: number;
  69882. frontUVs?: Vector4;
  69883. backUVs?: Vector4;
  69884. instance?: Mesh;
  69885. invertUV?: boolean;
  69886. }, scene?: Nullable<Scene>): Mesh;
  69887. }
  69888. }
  69889. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69890. import { Scene } from "babylonjs/scene";
  69891. import { Vector4 } from "babylonjs/Maths/math.vector";
  69892. import { Mesh } from "babylonjs/Meshes/mesh";
  69893. import { Nullable } from "babylonjs/types";
  69894. /**
  69895. * Class containing static functions to help procedurally build meshes
  69896. */
  69897. export class IcoSphereBuilder {
  69898. /**
  69899. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69900. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69901. * * 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`)
  69902. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69903. * * 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
  69904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69907. * @param name defines the name of the mesh
  69908. * @param options defines the options used to create the mesh
  69909. * @param scene defines the hosting scene
  69910. * @returns the icosahedron mesh
  69911. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69912. */
  69913. static CreateIcoSphere(name: string, options: {
  69914. radius?: number;
  69915. radiusX?: number;
  69916. radiusY?: number;
  69917. radiusZ?: number;
  69918. flat?: boolean;
  69919. subdivisions?: number;
  69920. sideOrientation?: number;
  69921. frontUVs?: Vector4;
  69922. backUVs?: Vector4;
  69923. updatable?: boolean;
  69924. }, scene?: Nullable<Scene>): Mesh;
  69925. }
  69926. }
  69927. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69928. import { Vector3 } from "babylonjs/Maths/math.vector";
  69929. import { Mesh } from "babylonjs/Meshes/mesh";
  69930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69931. /**
  69932. * Class containing static functions to help procedurally build meshes
  69933. */
  69934. export class DecalBuilder {
  69935. /**
  69936. * Creates a decal mesh.
  69937. * 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
  69938. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69939. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69940. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69941. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69942. * @param name defines the name of the mesh
  69943. * @param sourceMesh defines the mesh where the decal must be applied
  69944. * @param options defines the options used to create the mesh
  69945. * @param scene defines the hosting scene
  69946. * @returns the decal mesh
  69947. * @see https://doc.babylonjs.com/how_to/decals
  69948. */
  69949. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69950. position?: Vector3;
  69951. normal?: Vector3;
  69952. size?: Vector3;
  69953. angle?: number;
  69954. }): Mesh;
  69955. }
  69956. }
  69957. declare module "babylonjs/Meshes/meshBuilder" {
  69958. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69959. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69960. import { Nullable } from "babylonjs/types";
  69961. import { Scene } from "babylonjs/scene";
  69962. import { Mesh } from "babylonjs/Meshes/mesh";
  69963. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69964. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69966. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69967. import { Plane } from "babylonjs/Maths/math.plane";
  69968. /**
  69969. * Class containing static functions to help procedurally build meshes
  69970. */
  69971. export class MeshBuilder {
  69972. /**
  69973. * Creates a box mesh
  69974. * * The parameter `size` sets the size (float) of each box side (default 1)
  69975. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69976. * * 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)
  69977. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69981. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  69986. */
  69987. static CreateBox(name: string, options: {
  69988. size?: number;
  69989. width?: number;
  69990. height?: number;
  69991. depth?: number;
  69992. faceUV?: Vector4[];
  69993. faceColors?: Color4[];
  69994. sideOrientation?: number;
  69995. frontUVs?: Vector4;
  69996. backUVs?: Vector4;
  69997. wrap?: boolean;
  69998. topBaseAt?: number;
  69999. bottomBaseAt?: number;
  70000. updatable?: boolean;
  70001. }, scene?: Nullable<Scene>): Mesh;
  70002. /**
  70003. * Creates a tiled box mesh
  70004. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70006. * @param name defines the name of the mesh
  70007. * @param options defines the options used to create the mesh
  70008. * @param scene defines the hosting scene
  70009. * @returns the tiled box mesh
  70010. */
  70011. static CreateTiledBox(name: string, options: {
  70012. pattern?: number;
  70013. size?: number;
  70014. width?: number;
  70015. height?: number;
  70016. depth: number;
  70017. tileSize?: number;
  70018. tileWidth?: number;
  70019. tileHeight?: number;
  70020. faceUV?: Vector4[];
  70021. faceColors?: Color4[];
  70022. alignHorizontal?: number;
  70023. alignVertical?: number;
  70024. sideOrientation?: number;
  70025. updatable?: boolean;
  70026. }, scene?: Nullable<Scene>): Mesh;
  70027. /**
  70028. * Creates a sphere mesh
  70029. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70030. * * 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`)
  70031. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70032. * * 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
  70033. * * 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)
  70034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70037. * @param name defines the name of the mesh
  70038. * @param options defines the options used to create the mesh
  70039. * @param scene defines the hosting scene
  70040. * @returns the sphere mesh
  70041. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70042. */
  70043. static CreateSphere(name: string, options: {
  70044. segments?: number;
  70045. diameter?: number;
  70046. diameterX?: number;
  70047. diameterY?: number;
  70048. diameterZ?: number;
  70049. arc?: number;
  70050. slice?: number;
  70051. sideOrientation?: number;
  70052. frontUVs?: Vector4;
  70053. backUVs?: Vector4;
  70054. updatable?: boolean;
  70055. }, scene?: Nullable<Scene>): Mesh;
  70056. /**
  70057. * Creates a plane polygonal mesh. By default, this is a disc
  70058. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70059. * * 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
  70060. * * 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
  70061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70064. * @param name defines the name of the mesh
  70065. * @param options defines the options used to create the mesh
  70066. * @param scene defines the hosting scene
  70067. * @returns the plane polygonal mesh
  70068. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70069. */
  70070. static CreateDisc(name: string, options: {
  70071. radius?: number;
  70072. tessellation?: number;
  70073. arc?: number;
  70074. updatable?: boolean;
  70075. sideOrientation?: number;
  70076. frontUVs?: Vector4;
  70077. backUVs?: Vector4;
  70078. }, scene?: Nullable<Scene>): Mesh;
  70079. /**
  70080. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70081. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70082. * * 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`)
  70083. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70084. * * 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
  70085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70088. * @param name defines the name of the mesh
  70089. * @param options defines the options used to create the mesh
  70090. * @param scene defines the hosting scene
  70091. * @returns the icosahedron mesh
  70092. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70093. */
  70094. static CreateIcoSphere(name: string, options: {
  70095. radius?: number;
  70096. radiusX?: number;
  70097. radiusY?: number;
  70098. radiusZ?: number;
  70099. flat?: boolean;
  70100. subdivisions?: number;
  70101. sideOrientation?: number;
  70102. frontUVs?: Vector4;
  70103. backUVs?: Vector4;
  70104. updatable?: boolean;
  70105. }, scene?: Nullable<Scene>): Mesh;
  70106. /**
  70107. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70108. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70109. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70110. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70111. * * 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
  70112. * * 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
  70113. * * 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
  70114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70117. * * 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
  70118. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70119. * * 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
  70120. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70122. * @param name defines the name of the mesh
  70123. * @param options defines the options used to create the mesh
  70124. * @param scene defines the hosting scene
  70125. * @returns the ribbon mesh
  70126. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70128. */
  70129. static CreateRibbon(name: string, options: {
  70130. pathArray: Vector3[][];
  70131. closeArray?: boolean;
  70132. closePath?: boolean;
  70133. offset?: number;
  70134. updatable?: boolean;
  70135. sideOrientation?: number;
  70136. frontUVs?: Vector4;
  70137. backUVs?: Vector4;
  70138. instance?: Mesh;
  70139. invertUV?: boolean;
  70140. uvs?: Vector2[];
  70141. colors?: Color4[];
  70142. }, scene?: Nullable<Scene>): Mesh;
  70143. /**
  70144. * Creates a cylinder or a cone mesh
  70145. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70146. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70147. * * 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.
  70148. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70149. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70150. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70151. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70152. * * 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).
  70153. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70154. * * 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).
  70155. * * 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
  70156. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70157. * * 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
  70158. * * 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.
  70159. * * If `enclose` is false, a ring surface is one element.
  70160. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70161. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70165. * @param name defines the name of the mesh
  70166. * @param options defines the options used to create the mesh
  70167. * @param scene defines the hosting scene
  70168. * @returns the cylinder mesh
  70169. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70170. */
  70171. static CreateCylinder(name: string, options: {
  70172. height?: number;
  70173. diameterTop?: number;
  70174. diameterBottom?: number;
  70175. diameter?: number;
  70176. tessellation?: number;
  70177. subdivisions?: number;
  70178. arc?: number;
  70179. faceColors?: Color4[];
  70180. faceUV?: Vector4[];
  70181. updatable?: boolean;
  70182. hasRings?: boolean;
  70183. enclose?: boolean;
  70184. cap?: number;
  70185. sideOrientation?: number;
  70186. frontUVs?: Vector4;
  70187. backUVs?: Vector4;
  70188. }, scene?: Nullable<Scene>): Mesh;
  70189. /**
  70190. * Creates a torus mesh
  70191. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70192. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70193. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70197. * @param name defines the name of the mesh
  70198. * @param options defines the options used to create the mesh
  70199. * @param scene defines the hosting scene
  70200. * @returns the torus mesh
  70201. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70202. */
  70203. static CreateTorus(name: string, options: {
  70204. diameter?: number;
  70205. thickness?: number;
  70206. tessellation?: number;
  70207. updatable?: boolean;
  70208. sideOrientation?: number;
  70209. frontUVs?: Vector4;
  70210. backUVs?: Vector4;
  70211. }, scene?: Nullable<Scene>): Mesh;
  70212. /**
  70213. * Creates a torus knot mesh
  70214. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70215. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70216. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70217. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70221. * @param name defines the name of the mesh
  70222. * @param options defines the options used to create the mesh
  70223. * @param scene defines the hosting scene
  70224. * @returns the torus knot mesh
  70225. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70226. */
  70227. static CreateTorusKnot(name: string, options: {
  70228. radius?: number;
  70229. tube?: number;
  70230. radialSegments?: number;
  70231. tubularSegments?: number;
  70232. p?: number;
  70233. q?: number;
  70234. updatable?: boolean;
  70235. sideOrientation?: number;
  70236. frontUVs?: Vector4;
  70237. backUVs?: Vector4;
  70238. }, scene?: Nullable<Scene>): Mesh;
  70239. /**
  70240. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70241. * * 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
  70242. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70243. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70244. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70245. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70246. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70247. * * 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
  70248. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70251. * @param name defines the name of the new line system
  70252. * @param options defines the options used to create the line system
  70253. * @param scene defines the hosting scene
  70254. * @returns a new line system mesh
  70255. */
  70256. static CreateLineSystem(name: string, options: {
  70257. lines: Vector3[][];
  70258. updatable?: boolean;
  70259. instance?: Nullable<LinesMesh>;
  70260. colors?: Nullable<Color4[][]>;
  70261. useVertexAlpha?: boolean;
  70262. }, scene: Nullable<Scene>): LinesMesh;
  70263. /**
  70264. * Creates a line mesh
  70265. * 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
  70266. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70267. * * The parameter `points` is an array successive Vector3
  70268. * * 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
  70269. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70270. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70271. * * When updating an instance, remember that only point positions can change, not the number of points
  70272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70274. * @param name defines the name of the new line system
  70275. * @param options defines the options used to create the line system
  70276. * @param scene defines the hosting scene
  70277. * @returns a new line mesh
  70278. */
  70279. static CreateLines(name: string, options: {
  70280. points: Vector3[];
  70281. updatable?: boolean;
  70282. instance?: Nullable<LinesMesh>;
  70283. colors?: Color4[];
  70284. useVertexAlpha?: boolean;
  70285. }, scene?: Nullable<Scene>): LinesMesh;
  70286. /**
  70287. * Creates a dashed line mesh
  70288. * * 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
  70289. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70290. * * The parameter `points` is an array successive Vector3
  70291. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70292. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70293. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70294. * * 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
  70295. * * When updating an instance, remember that only point positions can change, not the number of points
  70296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70297. * @param name defines the name of the mesh
  70298. * @param options defines the options used to create the mesh
  70299. * @param scene defines the hosting scene
  70300. * @returns the dashed line mesh
  70301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70302. */
  70303. static CreateDashedLines(name: string, options: {
  70304. points: Vector3[];
  70305. dashSize?: number;
  70306. gapSize?: number;
  70307. dashNb?: number;
  70308. updatable?: boolean;
  70309. instance?: LinesMesh;
  70310. }, scene?: Nullable<Scene>): LinesMesh;
  70311. /**
  70312. * 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.
  70313. * * 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.
  70314. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70315. * * 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.
  70316. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70317. * * 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
  70318. * * 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
  70319. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70322. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70324. * @param name defines the name of the mesh
  70325. * @param options defines the options used to create the mesh
  70326. * @param scene defines the hosting scene
  70327. * @returns the extruded shape mesh
  70328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70330. */
  70331. static ExtrudeShape(name: string, options: {
  70332. shape: Vector3[];
  70333. path: Vector3[];
  70334. scale?: number;
  70335. rotation?: number;
  70336. cap?: number;
  70337. updatable?: boolean;
  70338. sideOrientation?: number;
  70339. frontUVs?: Vector4;
  70340. backUVs?: Vector4;
  70341. instance?: Mesh;
  70342. invertUV?: boolean;
  70343. }, scene?: Nullable<Scene>): Mesh;
  70344. /**
  70345. * Creates an custom extruded shape mesh.
  70346. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70347. * * 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.
  70348. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70349. * * 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
  70350. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70351. * * 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
  70352. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70353. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70354. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70355. * * 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
  70356. * * 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
  70357. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70362. * @param name defines the name of the mesh
  70363. * @param options defines the options used to create the mesh
  70364. * @param scene defines the hosting scene
  70365. * @returns the custom extruded shape mesh
  70366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70369. */
  70370. static ExtrudeShapeCustom(name: string, options: {
  70371. shape: Vector3[];
  70372. path: Vector3[];
  70373. scaleFunction?: any;
  70374. rotationFunction?: any;
  70375. ribbonCloseArray?: boolean;
  70376. ribbonClosePath?: boolean;
  70377. cap?: number;
  70378. updatable?: boolean;
  70379. sideOrientation?: number;
  70380. frontUVs?: Vector4;
  70381. backUVs?: Vector4;
  70382. instance?: Mesh;
  70383. invertUV?: boolean;
  70384. }, scene?: Nullable<Scene>): Mesh;
  70385. /**
  70386. * Creates lathe mesh.
  70387. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70388. * * 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
  70389. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70390. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70391. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70392. * * 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
  70393. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70394. * * 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
  70395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70399. * @param name defines the name of the mesh
  70400. * @param options defines the options used to create the mesh
  70401. * @param scene defines the hosting scene
  70402. * @returns the lathe mesh
  70403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70404. */
  70405. static CreateLathe(name: string, options: {
  70406. shape: Vector3[];
  70407. radius?: number;
  70408. tessellation?: number;
  70409. clip?: number;
  70410. arc?: number;
  70411. closed?: boolean;
  70412. updatable?: boolean;
  70413. sideOrientation?: number;
  70414. frontUVs?: Vector4;
  70415. backUVs?: Vector4;
  70416. cap?: number;
  70417. invertUV?: boolean;
  70418. }, scene?: Nullable<Scene>): Mesh;
  70419. /**
  70420. * Creates a tiled plane mesh
  70421. * * You can set a limited pattern arrangement with the tiles
  70422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70425. * @param name defines the name of the mesh
  70426. * @param options defines the options used to create the mesh
  70427. * @param scene defines the hosting scene
  70428. * @returns the plane mesh
  70429. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70430. */
  70431. static CreateTiledPlane(name: string, options: {
  70432. pattern?: number;
  70433. tileSize?: number;
  70434. tileWidth?: number;
  70435. tileHeight?: number;
  70436. size?: number;
  70437. width?: number;
  70438. height?: number;
  70439. alignHorizontal?: number;
  70440. alignVertical?: number;
  70441. sideOrientation?: number;
  70442. frontUVs?: Vector4;
  70443. backUVs?: Vector4;
  70444. updatable?: boolean;
  70445. }, scene?: Nullable<Scene>): Mesh;
  70446. /**
  70447. * Creates a plane mesh
  70448. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70449. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70450. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70454. * @param name defines the name of the mesh
  70455. * @param options defines the options used to create the mesh
  70456. * @param scene defines the hosting scene
  70457. * @returns the plane mesh
  70458. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70459. */
  70460. static CreatePlane(name: string, options: {
  70461. size?: number;
  70462. width?: number;
  70463. height?: number;
  70464. sideOrientation?: number;
  70465. frontUVs?: Vector4;
  70466. backUVs?: Vector4;
  70467. updatable?: boolean;
  70468. sourcePlane?: Plane;
  70469. }, scene?: Nullable<Scene>): Mesh;
  70470. /**
  70471. * Creates a ground mesh
  70472. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70473. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70475. * @param name defines the name of the mesh
  70476. * @param options defines the options used to create the mesh
  70477. * @param scene defines the hosting scene
  70478. * @returns the ground mesh
  70479. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70480. */
  70481. static CreateGround(name: string, options: {
  70482. width?: number;
  70483. height?: number;
  70484. subdivisions?: number;
  70485. subdivisionsX?: number;
  70486. subdivisionsY?: number;
  70487. updatable?: boolean;
  70488. }, scene?: Nullable<Scene>): Mesh;
  70489. /**
  70490. * Creates a tiled ground mesh
  70491. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70492. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70493. * * 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
  70494. * * 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
  70495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70496. * @param name defines the name of the mesh
  70497. * @param options defines the options used to create the mesh
  70498. * @param scene defines the hosting scene
  70499. * @returns the tiled ground mesh
  70500. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70501. */
  70502. static CreateTiledGround(name: string, options: {
  70503. xmin: number;
  70504. zmin: number;
  70505. xmax: number;
  70506. zmax: number;
  70507. subdivisions?: {
  70508. w: number;
  70509. h: number;
  70510. };
  70511. precision?: {
  70512. w: number;
  70513. h: number;
  70514. };
  70515. updatable?: boolean;
  70516. }, scene?: Nullable<Scene>): Mesh;
  70517. /**
  70518. * Creates a ground mesh from a height map
  70519. * * The parameter `url` sets the URL of the height map image resource.
  70520. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70521. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70522. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70523. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70524. * * 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.
  70525. * * 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).
  70526. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70528. * @param name defines the name of the mesh
  70529. * @param url defines the url to the height map
  70530. * @param options defines the options used to create the mesh
  70531. * @param scene defines the hosting scene
  70532. * @returns the ground mesh
  70533. * @see https://doc.babylonjs.com/babylon101/height_map
  70534. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70535. */
  70536. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70537. width?: number;
  70538. height?: number;
  70539. subdivisions?: number;
  70540. minHeight?: number;
  70541. maxHeight?: number;
  70542. colorFilter?: Color3;
  70543. alphaFilter?: number;
  70544. updatable?: boolean;
  70545. onReady?: (mesh: GroundMesh) => void;
  70546. }, scene?: Nullable<Scene>): GroundMesh;
  70547. /**
  70548. * Creates a polygon mesh
  70549. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70550. * * 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
  70551. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70554. * * Remember you can only change the shape positions, not their number when updating a polygon
  70555. * @param name defines the name of the mesh
  70556. * @param options defines the options used to create the mesh
  70557. * @param scene defines the hosting scene
  70558. * @param earcutInjection can be used to inject your own earcut reference
  70559. * @returns the polygon mesh
  70560. */
  70561. static CreatePolygon(name: string, options: {
  70562. shape: Vector3[];
  70563. holes?: Vector3[][];
  70564. depth?: number;
  70565. faceUV?: Vector4[];
  70566. faceColors?: Color4[];
  70567. updatable?: boolean;
  70568. sideOrientation?: number;
  70569. frontUVs?: Vector4;
  70570. backUVs?: Vector4;
  70571. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70572. /**
  70573. * Creates an extruded polygon mesh, with depth in the Y direction.
  70574. * * 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)
  70575. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70576. * @param name defines the name of the mesh
  70577. * @param options defines the options used to create the mesh
  70578. * @param scene defines the hosting scene
  70579. * @param earcutInjection can be used to inject your own earcut reference
  70580. * @returns the polygon mesh
  70581. */
  70582. static ExtrudePolygon(name: string, options: {
  70583. shape: Vector3[];
  70584. holes?: Vector3[][];
  70585. depth?: number;
  70586. faceUV?: Vector4[];
  70587. faceColors?: Color4[];
  70588. updatable?: boolean;
  70589. sideOrientation?: number;
  70590. frontUVs?: Vector4;
  70591. backUVs?: Vector4;
  70592. wrap?: boolean;
  70593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70594. /**
  70595. * Creates a tube mesh.
  70596. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70597. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70598. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70599. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70600. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70601. * * 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)
  70602. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70603. * * 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
  70604. * * 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
  70605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70609. * @param name defines the name of the mesh
  70610. * @param options defines the options used to create the mesh
  70611. * @param scene defines the hosting scene
  70612. * @returns the tube mesh
  70613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70614. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70615. */
  70616. static CreateTube(name: string, options: {
  70617. path: Vector3[];
  70618. radius?: number;
  70619. tessellation?: number;
  70620. radiusFunction?: {
  70621. (i: number, distance: number): number;
  70622. };
  70623. cap?: number;
  70624. arc?: number;
  70625. updatable?: boolean;
  70626. sideOrientation?: number;
  70627. frontUVs?: Vector4;
  70628. backUVs?: Vector4;
  70629. instance?: Mesh;
  70630. invertUV?: boolean;
  70631. }, scene?: Nullable<Scene>): Mesh;
  70632. /**
  70633. * Creates a polyhedron mesh
  70634. * * 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
  70635. * * The parameter `size` (positive float, default 1) sets the polygon size
  70636. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70637. * * 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`
  70638. * * 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
  70639. * * 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)`)
  70640. * * 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
  70641. * * 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
  70642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70645. * @param name defines the name of the mesh
  70646. * @param options defines the options used to create the mesh
  70647. * @param scene defines the hosting scene
  70648. * @returns the polyhedron mesh
  70649. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70650. */
  70651. static CreatePolyhedron(name: string, options: {
  70652. type?: number;
  70653. size?: number;
  70654. sizeX?: number;
  70655. sizeY?: number;
  70656. sizeZ?: number;
  70657. custom?: any;
  70658. faceUV?: Vector4[];
  70659. faceColors?: Color4[];
  70660. flat?: boolean;
  70661. updatable?: boolean;
  70662. sideOrientation?: number;
  70663. frontUVs?: Vector4;
  70664. backUVs?: Vector4;
  70665. }, scene?: Nullable<Scene>): Mesh;
  70666. /**
  70667. * Creates a decal mesh.
  70668. * 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
  70669. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70670. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70671. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70672. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70673. * @param name defines the name of the mesh
  70674. * @param sourceMesh defines the mesh where the decal must be applied
  70675. * @param options defines the options used to create the mesh
  70676. * @param scene defines the hosting scene
  70677. * @returns the decal mesh
  70678. * @see https://doc.babylonjs.com/how_to/decals
  70679. */
  70680. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70681. position?: Vector3;
  70682. normal?: Vector3;
  70683. size?: Vector3;
  70684. angle?: number;
  70685. }): Mesh;
  70686. /**
  70687. * Creates a Capsule Mesh
  70688. * @param name defines the name of the mesh.
  70689. * @param options the constructors options used to shape the mesh.
  70690. * @param scene defines the scene the mesh is scoped to.
  70691. * @returns the capsule mesh
  70692. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70693. */
  70694. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70695. }
  70696. }
  70697. declare module "babylonjs/Meshes/meshSimplification" {
  70698. import { Mesh } from "babylonjs/Meshes/mesh";
  70699. /**
  70700. * A simplifier interface for future simplification implementations
  70701. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70702. */
  70703. export interface ISimplifier {
  70704. /**
  70705. * Simplification of a given mesh according to the given settings.
  70706. * Since this requires computation, it is assumed that the function runs async.
  70707. * @param settings The settings of the simplification, including quality and distance
  70708. * @param successCallback A callback that will be called after the mesh was simplified.
  70709. * @param errorCallback in case of an error, this callback will be called. optional.
  70710. */
  70711. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70712. }
  70713. /**
  70714. * Expected simplification settings.
  70715. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70716. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70717. */
  70718. export interface ISimplificationSettings {
  70719. /**
  70720. * Gets or sets the expected quality
  70721. */
  70722. quality: number;
  70723. /**
  70724. * Gets or sets the distance when this optimized version should be used
  70725. */
  70726. distance: number;
  70727. /**
  70728. * Gets an already optimized mesh
  70729. */
  70730. optimizeMesh?: boolean;
  70731. }
  70732. /**
  70733. * Class used to specify simplification options
  70734. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70735. */
  70736. export class SimplificationSettings implements ISimplificationSettings {
  70737. /** expected quality */
  70738. quality: number;
  70739. /** distance when this optimized version should be used */
  70740. distance: number;
  70741. /** already optimized mesh */
  70742. optimizeMesh?: boolean | undefined;
  70743. /**
  70744. * Creates a SimplificationSettings
  70745. * @param quality expected quality
  70746. * @param distance distance when this optimized version should be used
  70747. * @param optimizeMesh already optimized mesh
  70748. */
  70749. constructor(
  70750. /** expected quality */
  70751. quality: number,
  70752. /** distance when this optimized version should be used */
  70753. distance: number,
  70754. /** already optimized mesh */
  70755. optimizeMesh?: boolean | undefined);
  70756. }
  70757. /**
  70758. * Interface used to define a simplification task
  70759. */
  70760. export interface ISimplificationTask {
  70761. /**
  70762. * Array of settings
  70763. */
  70764. settings: Array<ISimplificationSettings>;
  70765. /**
  70766. * Simplification type
  70767. */
  70768. simplificationType: SimplificationType;
  70769. /**
  70770. * Mesh to simplify
  70771. */
  70772. mesh: Mesh;
  70773. /**
  70774. * Callback called on success
  70775. */
  70776. successCallback?: () => void;
  70777. /**
  70778. * Defines if parallel processing can be used
  70779. */
  70780. parallelProcessing: boolean;
  70781. }
  70782. /**
  70783. * Queue used to order the simplification tasks
  70784. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70785. */
  70786. export class SimplificationQueue {
  70787. private _simplificationArray;
  70788. /**
  70789. * Gets a boolean indicating that the process is still running
  70790. */
  70791. running: boolean;
  70792. /**
  70793. * Creates a new queue
  70794. */
  70795. constructor();
  70796. /**
  70797. * Adds a new simplification task
  70798. * @param task defines a task to add
  70799. */
  70800. addTask(task: ISimplificationTask): void;
  70801. /**
  70802. * Execute next task
  70803. */
  70804. executeNext(): void;
  70805. /**
  70806. * Execute a simplification task
  70807. * @param task defines the task to run
  70808. */
  70809. runSimplification(task: ISimplificationTask): void;
  70810. private getSimplifier;
  70811. }
  70812. /**
  70813. * The implemented types of simplification
  70814. * At the moment only Quadratic Error Decimation is implemented
  70815. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70816. */
  70817. export enum SimplificationType {
  70818. /** Quadratic error decimation */
  70819. QUADRATIC = 0
  70820. }
  70821. /**
  70822. * An implementation of the Quadratic Error simplification algorithm.
  70823. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70824. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70825. * @author RaananW
  70826. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70827. */
  70828. export class QuadraticErrorSimplification implements ISimplifier {
  70829. private _mesh;
  70830. private triangles;
  70831. private vertices;
  70832. private references;
  70833. private _reconstructedMesh;
  70834. /** Gets or sets the number pf sync interations */
  70835. syncIterations: number;
  70836. /** Gets or sets the aggressiveness of the simplifier */
  70837. aggressiveness: number;
  70838. /** Gets or sets the number of allowed iterations for decimation */
  70839. decimationIterations: number;
  70840. /** Gets or sets the espilon to use for bounding box computation */
  70841. boundingBoxEpsilon: number;
  70842. /**
  70843. * Creates a new QuadraticErrorSimplification
  70844. * @param _mesh defines the target mesh
  70845. */
  70846. constructor(_mesh: Mesh);
  70847. /**
  70848. * Simplification of a given mesh according to the given settings.
  70849. * Since this requires computation, it is assumed that the function runs async.
  70850. * @param settings The settings of the simplification, including quality and distance
  70851. * @param successCallback A callback that will be called after the mesh was simplified.
  70852. */
  70853. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70854. private runDecimation;
  70855. private initWithMesh;
  70856. private init;
  70857. private reconstructMesh;
  70858. private initDecimatedMesh;
  70859. private isFlipped;
  70860. private updateTriangles;
  70861. private identifyBorder;
  70862. private updateMesh;
  70863. private vertexError;
  70864. private calculateError;
  70865. }
  70866. }
  70867. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70868. import { Scene } from "babylonjs/scene";
  70869. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70870. import { ISceneComponent } from "babylonjs/sceneComponent";
  70871. module "babylonjs/scene" {
  70872. interface Scene {
  70873. /** @hidden (Backing field) */
  70874. _simplificationQueue: SimplificationQueue;
  70875. /**
  70876. * Gets or sets the simplification queue attached to the scene
  70877. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70878. */
  70879. simplificationQueue: SimplificationQueue;
  70880. }
  70881. }
  70882. module "babylonjs/Meshes/mesh" {
  70883. interface Mesh {
  70884. /**
  70885. * Simplify the mesh according to the given array of settings.
  70886. * Function will return immediately and will simplify async
  70887. * @param settings a collection of simplification settings
  70888. * @param parallelProcessing should all levels calculate parallel or one after the other
  70889. * @param simplificationType the type of simplification to run
  70890. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70891. * @returns the current mesh
  70892. */
  70893. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70894. }
  70895. }
  70896. /**
  70897. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70898. * created in a scene
  70899. */
  70900. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70901. /**
  70902. * The component name helpfull to identify the component in the list of scene components.
  70903. */
  70904. readonly name: string;
  70905. /**
  70906. * The scene the component belongs to.
  70907. */
  70908. scene: Scene;
  70909. /**
  70910. * Creates a new instance of the component for the given scene
  70911. * @param scene Defines the scene to register the component in
  70912. */
  70913. constructor(scene: Scene);
  70914. /**
  70915. * Registers the component in a given scene
  70916. */
  70917. register(): void;
  70918. /**
  70919. * Rebuilds the elements related to this component in case of
  70920. * context lost for instance.
  70921. */
  70922. rebuild(): void;
  70923. /**
  70924. * Disposes the component and the associated ressources
  70925. */
  70926. dispose(): void;
  70927. private _beforeCameraUpdate;
  70928. }
  70929. }
  70930. declare module "babylonjs/Meshes/Builders/index" {
  70931. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70932. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70933. export * from "babylonjs/Meshes/Builders/discBuilder";
  70934. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70935. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70936. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70937. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70938. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70939. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70940. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70941. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70942. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70943. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70944. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70945. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70946. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70947. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70948. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70949. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70950. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70951. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70952. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70953. }
  70954. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70955. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70956. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70957. import { Matrix } from "babylonjs/Maths/math.vector";
  70958. module "babylonjs/Meshes/mesh" {
  70959. interface Mesh {
  70960. /**
  70961. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70962. */
  70963. thinInstanceEnablePicking: boolean;
  70964. /**
  70965. * Creates a new thin instance
  70966. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70967. * @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
  70968. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70969. */
  70970. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70971. /**
  70972. * Adds the transformation (matrix) of the current mesh as a thin instance
  70973. * @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
  70974. * @returns the thin instance index number
  70975. */
  70976. thinInstanceAddSelf(refresh: boolean): number;
  70977. /**
  70978. * Registers a custom attribute to be used with thin instances
  70979. * @param kind name of the attribute
  70980. * @param stride size in floats of the attribute
  70981. */
  70982. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70983. /**
  70984. * Sets the matrix of a thin instance
  70985. * @param index index of the thin instance
  70986. * @param matrix matrix to set
  70987. * @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
  70988. */
  70989. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70990. /**
  70991. * Sets the value of a custom attribute for a thin instance
  70992. * @param kind name of the attribute
  70993. * @param index index of the thin instance
  70994. * @param value value to set
  70995. * @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
  70996. */
  70997. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70998. /**
  70999. * 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.
  71000. */
  71001. thinInstanceCount: number;
  71002. /**
  71003. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71004. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71005. * @param buffer buffer to set
  71006. * @param stride size in floats of each value of the buffer
  71007. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71008. */
  71009. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71010. /**
  71011. * Gets the list of world matrices
  71012. * @return an array containing all the world matrices from the thin instances
  71013. */
  71014. thinInstanceGetWorldMatrices(): Matrix[];
  71015. /**
  71016. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71017. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71018. */
  71019. thinInstanceBufferUpdated(kind: string): void;
  71020. /**
  71021. * Applies a partial update to a buffer directly on the GPU
  71022. * 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
  71023. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71024. * @param data the data to set in the GPU buffer
  71025. * @param offset the offset in the GPU buffer where to update the data
  71026. */
  71027. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71028. /**
  71029. * Refreshes the bounding info, taking into account all the thin instances defined
  71030. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71031. */
  71032. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71033. /** @hidden */
  71034. _thinInstanceInitializeUserStorage(): void;
  71035. /** @hidden */
  71036. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71037. /** @hidden */
  71038. _userThinInstanceBuffersStorage: {
  71039. data: {
  71040. [key: string]: Float32Array;
  71041. };
  71042. sizes: {
  71043. [key: string]: number;
  71044. };
  71045. vertexBuffers: {
  71046. [key: string]: Nullable<VertexBuffer>;
  71047. };
  71048. strides: {
  71049. [key: string]: number;
  71050. };
  71051. };
  71052. }
  71053. }
  71054. }
  71055. declare module "babylonjs/Meshes/index" {
  71056. export * from "babylonjs/Meshes/abstractMesh";
  71057. export * from "babylonjs/Meshes/buffer";
  71058. export * from "babylonjs/Meshes/Compression/index";
  71059. export * from "babylonjs/Meshes/csg";
  71060. export * from "babylonjs/Meshes/geometry";
  71061. export * from "babylonjs/Meshes/groundMesh";
  71062. export * from "babylonjs/Meshes/trailMesh";
  71063. export * from "babylonjs/Meshes/instancedMesh";
  71064. export * from "babylonjs/Meshes/linesMesh";
  71065. export * from "babylonjs/Meshes/mesh";
  71066. export * from "babylonjs/Meshes/mesh.vertexData";
  71067. export * from "babylonjs/Meshes/meshBuilder";
  71068. export * from "babylonjs/Meshes/meshSimplification";
  71069. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71070. export * from "babylonjs/Meshes/polygonMesh";
  71071. export * from "babylonjs/Meshes/subMesh";
  71072. export * from "babylonjs/Meshes/meshLODLevel";
  71073. export * from "babylonjs/Meshes/transformNode";
  71074. export * from "babylonjs/Meshes/Builders/index";
  71075. export * from "babylonjs/Meshes/dataBuffer";
  71076. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71077. import "babylonjs/Meshes/thinInstanceMesh";
  71078. export * from "babylonjs/Meshes/thinInstanceMesh";
  71079. }
  71080. declare module "babylonjs/Morph/index" {
  71081. export * from "babylonjs/Morph/morphTarget";
  71082. export * from "babylonjs/Morph/morphTargetManager";
  71083. }
  71084. declare module "babylonjs/Navigation/INavigationEngine" {
  71085. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71086. import { Vector3 } from "babylonjs/Maths/math";
  71087. import { Mesh } from "babylonjs/Meshes/mesh";
  71088. import { Scene } from "babylonjs/scene";
  71089. /**
  71090. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71091. */
  71092. export interface INavigationEnginePlugin {
  71093. /**
  71094. * plugin name
  71095. */
  71096. name: string;
  71097. /**
  71098. * Creates a navigation mesh
  71099. * @param meshes array of all the geometry used to compute the navigatio mesh
  71100. * @param parameters bunch of parameters used to filter geometry
  71101. */
  71102. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71103. /**
  71104. * Create a navigation mesh debug mesh
  71105. * @param scene is where the mesh will be added
  71106. * @returns debug display mesh
  71107. */
  71108. createDebugNavMesh(scene: Scene): Mesh;
  71109. /**
  71110. * Get a navigation mesh constrained position, closest to the parameter position
  71111. * @param position world position
  71112. * @returns the closest point to position constrained by the navigation mesh
  71113. */
  71114. getClosestPoint(position: Vector3): Vector3;
  71115. /**
  71116. * Get a navigation mesh constrained position, closest to the parameter position
  71117. * @param position world position
  71118. * @param result output the closest point to position constrained by the navigation mesh
  71119. */
  71120. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71121. /**
  71122. * Get a navigation mesh constrained position, within a particular radius
  71123. * @param position world position
  71124. * @param maxRadius the maximum distance to the constrained world position
  71125. * @returns the closest point to position constrained by the navigation mesh
  71126. */
  71127. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71128. /**
  71129. * Get a navigation mesh constrained position, within a particular radius
  71130. * @param position world position
  71131. * @param maxRadius the maximum distance to the constrained world position
  71132. * @param result output the closest point to position constrained by the navigation mesh
  71133. */
  71134. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71135. /**
  71136. * Compute the final position from a segment made of destination-position
  71137. * @param position world position
  71138. * @param destination world position
  71139. * @returns the resulting point along the navmesh
  71140. */
  71141. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71142. /**
  71143. * Compute the final position from a segment made of destination-position
  71144. * @param position world position
  71145. * @param destination world position
  71146. * @param result output the resulting point along the navmesh
  71147. */
  71148. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71149. /**
  71150. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71151. * @param start world position
  71152. * @param end world position
  71153. * @returns array containing world position composing the path
  71154. */
  71155. computePath(start: Vector3, end: Vector3): Vector3[];
  71156. /**
  71157. * If this plugin is supported
  71158. * @returns true if plugin is supported
  71159. */
  71160. isSupported(): boolean;
  71161. /**
  71162. * Create a new Crowd so you can add agents
  71163. * @param maxAgents the maximum agent count in the crowd
  71164. * @param maxAgentRadius the maximum radius an agent can have
  71165. * @param scene to attach the crowd to
  71166. * @returns the crowd you can add agents to
  71167. */
  71168. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71169. /**
  71170. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71171. * The queries will try to find a solution within those bounds
  71172. * default is (1,1,1)
  71173. * @param extent x,y,z value that define the extent around the queries point of reference
  71174. */
  71175. setDefaultQueryExtent(extent: Vector3): void;
  71176. /**
  71177. * Get the Bounding box extent specified by setDefaultQueryExtent
  71178. * @returns the box extent values
  71179. */
  71180. getDefaultQueryExtent(): Vector3;
  71181. /**
  71182. * build the navmesh from a previously saved state using getNavmeshData
  71183. * @param data the Uint8Array returned by getNavmeshData
  71184. */
  71185. buildFromNavmeshData(data: Uint8Array): void;
  71186. /**
  71187. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71188. * @returns data the Uint8Array that can be saved and reused
  71189. */
  71190. getNavmeshData(): Uint8Array;
  71191. /**
  71192. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71193. * @param result output the box extent values
  71194. */
  71195. getDefaultQueryExtentToRef(result: Vector3): void;
  71196. /**
  71197. * Release all resources
  71198. */
  71199. dispose(): void;
  71200. }
  71201. /**
  71202. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71203. */
  71204. export interface ICrowd {
  71205. /**
  71206. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71207. * You can attach anything to that node. The node position is updated in the scene update tick.
  71208. * @param pos world position that will be constrained by the navigation mesh
  71209. * @param parameters agent parameters
  71210. * @param transform hooked to the agent that will be update by the scene
  71211. * @returns agent index
  71212. */
  71213. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71214. /**
  71215. * Returns the agent position in world space
  71216. * @param index agent index returned by addAgent
  71217. * @returns world space position
  71218. */
  71219. getAgentPosition(index: number): Vector3;
  71220. /**
  71221. * Gets the agent position result in world space
  71222. * @param index agent index returned by addAgent
  71223. * @param result output world space position
  71224. */
  71225. getAgentPositionToRef(index: number, result: Vector3): void;
  71226. /**
  71227. * Gets the agent velocity in world space
  71228. * @param index agent index returned by addAgent
  71229. * @returns world space velocity
  71230. */
  71231. getAgentVelocity(index: number): Vector3;
  71232. /**
  71233. * Gets the agent velocity result in world space
  71234. * @param index agent index returned by addAgent
  71235. * @param result output world space velocity
  71236. */
  71237. getAgentVelocityToRef(index: number, result: Vector3): void;
  71238. /**
  71239. * remove a particular agent previously created
  71240. * @param index agent index returned by addAgent
  71241. */
  71242. removeAgent(index: number): void;
  71243. /**
  71244. * get the list of all agents attached to this crowd
  71245. * @returns list of agent indices
  71246. */
  71247. getAgents(): number[];
  71248. /**
  71249. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71250. * @param deltaTime in seconds
  71251. */
  71252. update(deltaTime: number): void;
  71253. /**
  71254. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71255. * @param index agent index returned by addAgent
  71256. * @param destination targeted world position
  71257. */
  71258. agentGoto(index: number, destination: Vector3): void;
  71259. /**
  71260. * Teleport the agent to a new position
  71261. * @param index agent index returned by addAgent
  71262. * @param destination targeted world position
  71263. */
  71264. agentTeleport(index: number, destination: Vector3): void;
  71265. /**
  71266. * Update agent parameters
  71267. * @param index agent index returned by addAgent
  71268. * @param parameters agent parameters
  71269. */
  71270. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71271. /**
  71272. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71273. * The queries will try to find a solution within those bounds
  71274. * default is (1,1,1)
  71275. * @param extent x,y,z value that define the extent around the queries point of reference
  71276. */
  71277. setDefaultQueryExtent(extent: Vector3): void;
  71278. /**
  71279. * Get the Bounding box extent specified by setDefaultQueryExtent
  71280. * @returns the box extent values
  71281. */
  71282. getDefaultQueryExtent(): Vector3;
  71283. /**
  71284. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71285. * @param result output the box extent values
  71286. */
  71287. getDefaultQueryExtentToRef(result: Vector3): void;
  71288. /**
  71289. * Release all resources
  71290. */
  71291. dispose(): void;
  71292. }
  71293. /**
  71294. * Configures an agent
  71295. */
  71296. export interface IAgentParameters {
  71297. /**
  71298. * Agent radius. [Limit: >= 0]
  71299. */
  71300. radius: number;
  71301. /**
  71302. * Agent height. [Limit: > 0]
  71303. */
  71304. height: number;
  71305. /**
  71306. * Maximum allowed acceleration. [Limit: >= 0]
  71307. */
  71308. maxAcceleration: number;
  71309. /**
  71310. * Maximum allowed speed. [Limit: >= 0]
  71311. */
  71312. maxSpeed: number;
  71313. /**
  71314. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71315. */
  71316. collisionQueryRange: number;
  71317. /**
  71318. * The path visibility optimization range. [Limit: > 0]
  71319. */
  71320. pathOptimizationRange: number;
  71321. /**
  71322. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71323. */
  71324. separationWeight: number;
  71325. }
  71326. /**
  71327. * Configures the navigation mesh creation
  71328. */
  71329. export interface INavMeshParameters {
  71330. /**
  71331. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71332. */
  71333. cs: number;
  71334. /**
  71335. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71336. */
  71337. ch: number;
  71338. /**
  71339. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71340. */
  71341. walkableSlopeAngle: number;
  71342. /**
  71343. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71344. * be considered walkable. [Limit: >= 3] [Units: vx]
  71345. */
  71346. walkableHeight: number;
  71347. /**
  71348. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71349. */
  71350. walkableClimb: number;
  71351. /**
  71352. * The distance to erode/shrink the walkable area of the heightfield away from
  71353. * obstructions. [Limit: >=0] [Units: vx]
  71354. */
  71355. walkableRadius: number;
  71356. /**
  71357. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71358. */
  71359. maxEdgeLen: number;
  71360. /**
  71361. * The maximum distance a simplfied contour's border edges should deviate
  71362. * the original raw contour. [Limit: >=0] [Units: vx]
  71363. */
  71364. maxSimplificationError: number;
  71365. /**
  71366. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71367. */
  71368. minRegionArea: number;
  71369. /**
  71370. * Any regions with a span count smaller than this value will, if possible,
  71371. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71372. */
  71373. mergeRegionArea: number;
  71374. /**
  71375. * The maximum number of vertices allowed for polygons generated during the
  71376. * contour to polygon conversion process. [Limit: >= 3]
  71377. */
  71378. maxVertsPerPoly: number;
  71379. /**
  71380. * Sets the sampling distance to use when generating the detail mesh.
  71381. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71382. */
  71383. detailSampleDist: number;
  71384. /**
  71385. * The maximum distance the detail mesh surface should deviate from heightfield
  71386. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71387. */
  71388. detailSampleMaxError: number;
  71389. }
  71390. }
  71391. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71392. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71393. import { Mesh } from "babylonjs/Meshes/mesh";
  71394. import { Scene } from "babylonjs/scene";
  71395. import { Vector3 } from "babylonjs/Maths/math";
  71396. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71397. /**
  71398. * RecastJS navigation plugin
  71399. */
  71400. export class RecastJSPlugin implements INavigationEnginePlugin {
  71401. /**
  71402. * Reference to the Recast library
  71403. */
  71404. bjsRECAST: any;
  71405. /**
  71406. * plugin name
  71407. */
  71408. name: string;
  71409. /**
  71410. * the first navmesh created. We might extend this to support multiple navmeshes
  71411. */
  71412. navMesh: any;
  71413. /**
  71414. * Initializes the recastJS plugin
  71415. * @param recastInjection can be used to inject your own recast reference
  71416. */
  71417. constructor(recastInjection?: any);
  71418. /**
  71419. * Creates a navigation mesh
  71420. * @param meshes array of all the geometry used to compute the navigatio mesh
  71421. * @param parameters bunch of parameters used to filter geometry
  71422. */
  71423. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71424. /**
  71425. * Create a navigation mesh debug mesh
  71426. * @param scene is where the mesh will be added
  71427. * @returns debug display mesh
  71428. */
  71429. createDebugNavMesh(scene: Scene): Mesh;
  71430. /**
  71431. * Get a navigation mesh constrained position, closest to the parameter position
  71432. * @param position world position
  71433. * @returns the closest point to position constrained by the navigation mesh
  71434. */
  71435. getClosestPoint(position: Vector3): Vector3;
  71436. /**
  71437. * Get a navigation mesh constrained position, closest to the parameter position
  71438. * @param position world position
  71439. * @param result output the closest point to position constrained by the navigation mesh
  71440. */
  71441. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71442. /**
  71443. * Get a navigation mesh constrained position, within a particular radius
  71444. * @param position world position
  71445. * @param maxRadius the maximum distance to the constrained world position
  71446. * @returns the closest point to position constrained by the navigation mesh
  71447. */
  71448. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71449. /**
  71450. * Get a navigation mesh constrained position, within a particular radius
  71451. * @param position world position
  71452. * @param maxRadius the maximum distance to the constrained world position
  71453. * @param result output the closest point to position constrained by the navigation mesh
  71454. */
  71455. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71456. /**
  71457. * Compute the final position from a segment made of destination-position
  71458. * @param position world position
  71459. * @param destination world position
  71460. * @returns the resulting point along the navmesh
  71461. */
  71462. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71463. /**
  71464. * Compute the final position from a segment made of destination-position
  71465. * @param position world position
  71466. * @param destination world position
  71467. * @param result output the resulting point along the navmesh
  71468. */
  71469. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71470. /**
  71471. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71472. * @param start world position
  71473. * @param end world position
  71474. * @returns array containing world position composing the path
  71475. */
  71476. computePath(start: Vector3, end: Vector3): Vector3[];
  71477. /**
  71478. * Create a new Crowd so you can add agents
  71479. * @param maxAgents the maximum agent count in the crowd
  71480. * @param maxAgentRadius the maximum radius an agent can have
  71481. * @param scene to attach the crowd to
  71482. * @returns the crowd you can add agents to
  71483. */
  71484. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71485. /**
  71486. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71487. * The queries will try to find a solution within those bounds
  71488. * default is (1,1,1)
  71489. * @param extent x,y,z value that define the extent around the queries point of reference
  71490. */
  71491. setDefaultQueryExtent(extent: Vector3): void;
  71492. /**
  71493. * Get the Bounding box extent specified by setDefaultQueryExtent
  71494. * @returns the box extent values
  71495. */
  71496. getDefaultQueryExtent(): Vector3;
  71497. /**
  71498. * build the navmesh from a previously saved state using getNavmeshData
  71499. * @param data the Uint8Array returned by getNavmeshData
  71500. */
  71501. buildFromNavmeshData(data: Uint8Array): void;
  71502. /**
  71503. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71504. * @returns data the Uint8Array that can be saved and reused
  71505. */
  71506. getNavmeshData(): Uint8Array;
  71507. /**
  71508. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71509. * @param result output the box extent values
  71510. */
  71511. getDefaultQueryExtentToRef(result: Vector3): void;
  71512. /**
  71513. * Disposes
  71514. */
  71515. dispose(): void;
  71516. /**
  71517. * If this plugin is supported
  71518. * @returns true if plugin is supported
  71519. */
  71520. isSupported(): boolean;
  71521. }
  71522. /**
  71523. * Recast detour crowd implementation
  71524. */
  71525. export class RecastJSCrowd implements ICrowd {
  71526. /**
  71527. * Recast/detour plugin
  71528. */
  71529. bjsRECASTPlugin: RecastJSPlugin;
  71530. /**
  71531. * Link to the detour crowd
  71532. */
  71533. recastCrowd: any;
  71534. /**
  71535. * One transform per agent
  71536. */
  71537. transforms: TransformNode[];
  71538. /**
  71539. * All agents created
  71540. */
  71541. agents: number[];
  71542. /**
  71543. * Link to the scene is kept to unregister the crowd from the scene
  71544. */
  71545. private _scene;
  71546. /**
  71547. * Observer for crowd updates
  71548. */
  71549. private _onBeforeAnimationsObserver;
  71550. /**
  71551. * Constructor
  71552. * @param plugin recastJS plugin
  71553. * @param maxAgents the maximum agent count in the crowd
  71554. * @param maxAgentRadius the maximum radius an agent can have
  71555. * @param scene to attach the crowd to
  71556. * @returns the crowd you can add agents to
  71557. */
  71558. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71559. /**
  71560. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71561. * You can attach anything to that node. The node position is updated in the scene update tick.
  71562. * @param pos world position that will be constrained by the navigation mesh
  71563. * @param parameters agent parameters
  71564. * @param transform hooked to the agent that will be update by the scene
  71565. * @returns agent index
  71566. */
  71567. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71568. /**
  71569. * Returns the agent position in world space
  71570. * @param index agent index returned by addAgent
  71571. * @returns world space position
  71572. */
  71573. getAgentPosition(index: number): Vector3;
  71574. /**
  71575. * Returns the agent position result in world space
  71576. * @param index agent index returned by addAgent
  71577. * @param result output world space position
  71578. */
  71579. getAgentPositionToRef(index: number, result: Vector3): void;
  71580. /**
  71581. * Returns the agent velocity in world space
  71582. * @param index agent index returned by addAgent
  71583. * @returns world space velocity
  71584. */
  71585. getAgentVelocity(index: number): Vector3;
  71586. /**
  71587. * Returns the agent velocity result in world space
  71588. * @param index agent index returned by addAgent
  71589. * @param result output world space velocity
  71590. */
  71591. getAgentVelocityToRef(index: number, result: Vector3): void;
  71592. /**
  71593. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71594. * @param index agent index returned by addAgent
  71595. * @param destination targeted world position
  71596. */
  71597. agentGoto(index: number, destination: Vector3): void;
  71598. /**
  71599. * Teleport the agent to a new position
  71600. * @param index agent index returned by addAgent
  71601. * @param destination targeted world position
  71602. */
  71603. agentTeleport(index: number, destination: Vector3): void;
  71604. /**
  71605. * Update agent parameters
  71606. * @param index agent index returned by addAgent
  71607. * @param parameters agent parameters
  71608. */
  71609. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71610. /**
  71611. * remove a particular agent previously created
  71612. * @param index agent index returned by addAgent
  71613. */
  71614. removeAgent(index: number): void;
  71615. /**
  71616. * get the list of all agents attached to this crowd
  71617. * @returns list of agent indices
  71618. */
  71619. getAgents(): number[];
  71620. /**
  71621. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71622. * @param deltaTime in seconds
  71623. */
  71624. update(deltaTime: number): void;
  71625. /**
  71626. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71627. * The queries will try to find a solution within those bounds
  71628. * default is (1,1,1)
  71629. * @param extent x,y,z value that define the extent around the queries point of reference
  71630. */
  71631. setDefaultQueryExtent(extent: Vector3): void;
  71632. /**
  71633. * Get the Bounding box extent specified by setDefaultQueryExtent
  71634. * @returns the box extent values
  71635. */
  71636. getDefaultQueryExtent(): Vector3;
  71637. /**
  71638. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71639. * @param result output the box extent values
  71640. */
  71641. getDefaultQueryExtentToRef(result: Vector3): void;
  71642. /**
  71643. * Release all resources
  71644. */
  71645. dispose(): void;
  71646. }
  71647. }
  71648. declare module "babylonjs/Navigation/Plugins/index" {
  71649. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71650. }
  71651. declare module "babylonjs/Navigation/index" {
  71652. export * from "babylonjs/Navigation/INavigationEngine";
  71653. export * from "babylonjs/Navigation/Plugins/index";
  71654. }
  71655. declare module "babylonjs/Offline/database" {
  71656. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71657. /**
  71658. * Class used to enable access to IndexedDB
  71659. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71660. */
  71661. export class Database implements IOfflineProvider {
  71662. private _callbackManifestChecked;
  71663. private _currentSceneUrl;
  71664. private _db;
  71665. private _enableSceneOffline;
  71666. private _enableTexturesOffline;
  71667. private _manifestVersionFound;
  71668. private _mustUpdateRessources;
  71669. private _hasReachedQuota;
  71670. private _isSupported;
  71671. private _idbFactory;
  71672. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71673. private static IsUASupportingBlobStorage;
  71674. /**
  71675. * Gets a boolean indicating if Database storate is enabled (off by default)
  71676. */
  71677. static IDBStorageEnabled: boolean;
  71678. /**
  71679. * Gets a boolean indicating if scene must be saved in the database
  71680. */
  71681. get enableSceneOffline(): boolean;
  71682. /**
  71683. * Gets a boolean indicating if textures must be saved in the database
  71684. */
  71685. get enableTexturesOffline(): boolean;
  71686. /**
  71687. * Creates a new Database
  71688. * @param urlToScene defines the url to load the scene
  71689. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71690. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71691. */
  71692. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71693. private static _ParseURL;
  71694. private static _ReturnFullUrlLocation;
  71695. private _checkManifestFile;
  71696. /**
  71697. * Open the database and make it available
  71698. * @param successCallback defines the callback to call on success
  71699. * @param errorCallback defines the callback to call on error
  71700. */
  71701. open(successCallback: () => void, errorCallback: () => void): void;
  71702. /**
  71703. * Loads an image from the database
  71704. * @param url defines the url to load from
  71705. * @param image defines the target DOM image
  71706. */
  71707. loadImage(url: string, image: HTMLImageElement): void;
  71708. private _loadImageFromDBAsync;
  71709. private _saveImageIntoDBAsync;
  71710. private _checkVersionFromDB;
  71711. private _loadVersionFromDBAsync;
  71712. private _saveVersionIntoDBAsync;
  71713. /**
  71714. * Loads a file from database
  71715. * @param url defines the URL to load from
  71716. * @param sceneLoaded defines a callback to call on success
  71717. * @param progressCallBack defines a callback to call when progress changed
  71718. * @param errorCallback defines a callback to call on error
  71719. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71720. */
  71721. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71722. private _loadFileAsync;
  71723. private _saveFileAsync;
  71724. /**
  71725. * Validates if xhr data is correct
  71726. * @param xhr defines the request to validate
  71727. * @param dataType defines the expected data type
  71728. * @returns true if data is correct
  71729. */
  71730. private static _ValidateXHRData;
  71731. }
  71732. }
  71733. declare module "babylonjs/Offline/index" {
  71734. export * from "babylonjs/Offline/database";
  71735. export * from "babylonjs/Offline/IOfflineProvider";
  71736. }
  71737. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71738. /** @hidden */
  71739. export var gpuUpdateParticlesPixelShader: {
  71740. name: string;
  71741. shader: string;
  71742. };
  71743. }
  71744. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71745. /** @hidden */
  71746. export var gpuUpdateParticlesVertexShader: {
  71747. name: string;
  71748. shader: string;
  71749. };
  71750. }
  71751. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71752. /** @hidden */
  71753. export var clipPlaneFragmentDeclaration2: {
  71754. name: string;
  71755. shader: string;
  71756. };
  71757. }
  71758. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71759. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71760. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71762. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71763. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71764. /** @hidden */
  71765. export var gpuRenderParticlesPixelShader: {
  71766. name: string;
  71767. shader: string;
  71768. };
  71769. }
  71770. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71771. /** @hidden */
  71772. export var clipPlaneVertexDeclaration2: {
  71773. name: string;
  71774. shader: string;
  71775. };
  71776. }
  71777. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71778. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71779. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71780. /** @hidden */
  71781. export var gpuRenderParticlesVertexShader: {
  71782. name: string;
  71783. shader: string;
  71784. };
  71785. }
  71786. declare module "babylonjs/Particles/gpuParticleSystem" {
  71787. import { Nullable } from "babylonjs/types";
  71788. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71789. import { Observable } from "babylonjs/Misc/observable";
  71790. import { Matrix } from "babylonjs/Maths/math.vector";
  71791. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71792. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71793. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71794. import { IDisposable } from "babylonjs/scene";
  71795. import { Effect } from "babylonjs/Materials/effect";
  71796. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71797. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71798. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71799. import { Scene } from "babylonjs/scene";
  71800. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71801. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71802. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71803. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71804. /**
  71805. * This represents a GPU particle system in Babylon
  71806. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71807. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71808. */
  71809. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71810. /**
  71811. * The layer mask we are rendering the particles through.
  71812. */
  71813. layerMask: number;
  71814. private _capacity;
  71815. private _activeCount;
  71816. private _currentActiveCount;
  71817. private _accumulatedCount;
  71818. private _renderEffect;
  71819. private _updateEffect;
  71820. private _buffer0;
  71821. private _buffer1;
  71822. private _spriteBuffer;
  71823. private _updateVAO;
  71824. private _renderVAO;
  71825. private _targetIndex;
  71826. private _sourceBuffer;
  71827. private _targetBuffer;
  71828. private _currentRenderId;
  71829. private _started;
  71830. private _stopped;
  71831. private _timeDelta;
  71832. private _randomTexture;
  71833. private _randomTexture2;
  71834. private _attributesStrideSize;
  71835. private _updateEffectOptions;
  71836. private _randomTextureSize;
  71837. private _actualFrame;
  71838. private _customEffect;
  71839. private readonly _rawTextureWidth;
  71840. /**
  71841. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71842. */
  71843. static get IsSupported(): boolean;
  71844. /**
  71845. * An event triggered when the system is disposed.
  71846. */
  71847. onDisposeObservable: Observable<IParticleSystem>;
  71848. /**
  71849. * An event triggered when the system is stopped
  71850. */
  71851. onStoppedObservable: Observable<IParticleSystem>;
  71852. /**
  71853. * Gets the maximum number of particles active at the same time.
  71854. * @returns The max number of active particles.
  71855. */
  71856. getCapacity(): number;
  71857. /**
  71858. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71859. * to override the particles.
  71860. */
  71861. forceDepthWrite: boolean;
  71862. /**
  71863. * Gets or set the number of active particles
  71864. */
  71865. get activeParticleCount(): number;
  71866. set activeParticleCount(value: number);
  71867. private _preWarmDone;
  71868. /**
  71869. * Specifies if the particles are updated in emitter local space or world space.
  71870. */
  71871. isLocal: boolean;
  71872. /** Gets or sets a matrix to use to compute projection */
  71873. defaultProjectionMatrix: Matrix;
  71874. /**
  71875. * Is this system ready to be used/rendered
  71876. * @return true if the system is ready
  71877. */
  71878. isReady(): boolean;
  71879. /**
  71880. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71881. * @returns True if it has been started, otherwise false.
  71882. */
  71883. isStarted(): boolean;
  71884. /**
  71885. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71886. * @returns True if it has been stopped, otherwise false.
  71887. */
  71888. isStopped(): boolean;
  71889. /**
  71890. * Gets a boolean indicating that the system is stopping
  71891. * @returns true if the system is currently stopping
  71892. */
  71893. isStopping(): boolean;
  71894. /**
  71895. * Gets the number of particles active at the same time.
  71896. * @returns The number of active particles.
  71897. */
  71898. getActiveCount(): number;
  71899. /**
  71900. * Starts the particle system and begins to emit
  71901. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71902. */
  71903. start(delay?: number): void;
  71904. /**
  71905. * Stops the particle system.
  71906. */
  71907. stop(): void;
  71908. /**
  71909. * Remove all active particles
  71910. */
  71911. reset(): void;
  71912. /**
  71913. * Returns the string "GPUParticleSystem"
  71914. * @returns a string containing the class name
  71915. */
  71916. getClassName(): string;
  71917. /**
  71918. * Gets the custom effect used to render the particles
  71919. * @param blendMode Blend mode for which the effect should be retrieved
  71920. * @returns The effect
  71921. */
  71922. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71923. /**
  71924. * Sets the custom effect used to render the particles
  71925. * @param effect The effect to set
  71926. * @param blendMode Blend mode for which the effect should be set
  71927. */
  71928. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71929. /** @hidden */
  71930. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71931. /**
  71932. * Observable that will be called just before the particles are drawn
  71933. */
  71934. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71935. /**
  71936. * Gets the name of the particle vertex shader
  71937. */
  71938. get vertexShaderName(): string;
  71939. private _colorGradientsTexture;
  71940. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71941. /**
  71942. * Adds a new color gradient
  71943. * @param gradient defines the gradient to use (between 0 and 1)
  71944. * @param color1 defines the color to affect to the specified gradient
  71945. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71946. * @returns the current particle system
  71947. */
  71948. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71949. private _refreshColorGradient;
  71950. /** Force the system to rebuild all gradients that need to be resync */
  71951. forceRefreshGradients(): void;
  71952. /**
  71953. * Remove a specific color gradient
  71954. * @param gradient defines the gradient to remove
  71955. * @returns the current particle system
  71956. */
  71957. removeColorGradient(gradient: number): GPUParticleSystem;
  71958. private _angularSpeedGradientsTexture;
  71959. private _sizeGradientsTexture;
  71960. private _velocityGradientsTexture;
  71961. private _limitVelocityGradientsTexture;
  71962. private _dragGradientsTexture;
  71963. private _addFactorGradient;
  71964. /**
  71965. * Adds a new size gradient
  71966. * @param gradient defines the gradient to use (between 0 and 1)
  71967. * @param factor defines the size factor to affect to the specified gradient
  71968. * @returns the current particle system
  71969. */
  71970. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71971. /**
  71972. * Remove a specific size gradient
  71973. * @param gradient defines the gradient to remove
  71974. * @returns the current particle system
  71975. */
  71976. removeSizeGradient(gradient: number): GPUParticleSystem;
  71977. private _refreshFactorGradient;
  71978. /**
  71979. * Adds a new angular speed gradient
  71980. * @param gradient defines the gradient to use (between 0 and 1)
  71981. * @param factor defines the angular speed to affect to the specified gradient
  71982. * @returns the current particle system
  71983. */
  71984. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71985. /**
  71986. * Remove a specific angular speed gradient
  71987. * @param gradient defines the gradient to remove
  71988. * @returns the current particle system
  71989. */
  71990. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71991. /**
  71992. * Adds a new velocity gradient
  71993. * @param gradient defines the gradient to use (between 0 and 1)
  71994. * @param factor defines the velocity to affect to the specified gradient
  71995. * @returns the current particle system
  71996. */
  71997. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71998. /**
  71999. * Remove a specific velocity gradient
  72000. * @param gradient defines the gradient to remove
  72001. * @returns the current particle system
  72002. */
  72003. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72004. /**
  72005. * Adds a new limit velocity gradient
  72006. * @param gradient defines the gradient to use (between 0 and 1)
  72007. * @param factor defines the limit velocity value to affect to the specified gradient
  72008. * @returns the current particle system
  72009. */
  72010. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72011. /**
  72012. * Remove a specific limit velocity gradient
  72013. * @param gradient defines the gradient to remove
  72014. * @returns the current particle system
  72015. */
  72016. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72017. /**
  72018. * Adds a new drag gradient
  72019. * @param gradient defines the gradient to use (between 0 and 1)
  72020. * @param factor defines the drag value to affect to the specified gradient
  72021. * @returns the current particle system
  72022. */
  72023. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72024. /**
  72025. * Remove a specific drag gradient
  72026. * @param gradient defines the gradient to remove
  72027. * @returns the current particle system
  72028. */
  72029. removeDragGradient(gradient: number): GPUParticleSystem;
  72030. /**
  72031. * Not supported by GPUParticleSystem
  72032. * @param gradient defines the gradient to use (between 0 and 1)
  72033. * @param factor defines the emit rate value to affect to the specified gradient
  72034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72035. * @returns the current particle system
  72036. */
  72037. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72038. /**
  72039. * Not supported by GPUParticleSystem
  72040. * @param gradient defines the gradient to remove
  72041. * @returns the current particle system
  72042. */
  72043. removeEmitRateGradient(gradient: number): IParticleSystem;
  72044. /**
  72045. * Not supported by GPUParticleSystem
  72046. * @param gradient defines the gradient to use (between 0 and 1)
  72047. * @param factor defines the start size value to affect to the specified gradient
  72048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72049. * @returns the current particle system
  72050. */
  72051. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72052. /**
  72053. * Not supported by GPUParticleSystem
  72054. * @param gradient defines the gradient to remove
  72055. * @returns the current particle system
  72056. */
  72057. removeStartSizeGradient(gradient: number): IParticleSystem;
  72058. /**
  72059. * Not supported by GPUParticleSystem
  72060. * @param gradient defines the gradient to use (between 0 and 1)
  72061. * @param min defines the color remap minimal range
  72062. * @param max defines the color remap maximal range
  72063. * @returns the current particle system
  72064. */
  72065. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72066. /**
  72067. * Not supported by GPUParticleSystem
  72068. * @param gradient defines the gradient to remove
  72069. * @returns the current particle system
  72070. */
  72071. removeColorRemapGradient(): IParticleSystem;
  72072. /**
  72073. * Not supported by GPUParticleSystem
  72074. * @param gradient defines the gradient to use (between 0 and 1)
  72075. * @param min defines the alpha remap minimal range
  72076. * @param max defines the alpha remap maximal range
  72077. * @returns the current particle system
  72078. */
  72079. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72080. /**
  72081. * Not supported by GPUParticleSystem
  72082. * @param gradient defines the gradient to remove
  72083. * @returns the current particle system
  72084. */
  72085. removeAlphaRemapGradient(): IParticleSystem;
  72086. /**
  72087. * Not supported by GPUParticleSystem
  72088. * @param gradient defines the gradient to use (between 0 and 1)
  72089. * @param color defines the color to affect to the specified gradient
  72090. * @returns the current particle system
  72091. */
  72092. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72093. /**
  72094. * Not supported by GPUParticleSystem
  72095. * @param gradient defines the gradient to remove
  72096. * @returns the current particle system
  72097. */
  72098. removeRampGradient(): IParticleSystem;
  72099. /**
  72100. * Not supported by GPUParticleSystem
  72101. * @returns the list of ramp gradients
  72102. */
  72103. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72104. /**
  72105. * Not supported by GPUParticleSystem
  72106. * Gets or sets a boolean indicating that ramp gradients must be used
  72107. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72108. */
  72109. get useRampGradients(): boolean;
  72110. set useRampGradients(value: boolean);
  72111. /**
  72112. * Not supported by GPUParticleSystem
  72113. * @param gradient defines the gradient to use (between 0 and 1)
  72114. * @param factor defines the life time factor to affect to the specified gradient
  72115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72116. * @returns the current particle system
  72117. */
  72118. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72119. /**
  72120. * Not supported by GPUParticleSystem
  72121. * @param gradient defines the gradient to remove
  72122. * @returns the current particle system
  72123. */
  72124. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72125. /**
  72126. * Instantiates a GPU particle system.
  72127. * 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.
  72128. * @param name The name of the particle system
  72129. * @param options The options used to create the system
  72130. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72131. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72132. * @param customEffect a custom effect used to change the way particles are rendered by default
  72133. */
  72134. constructor(name: string, options: Partial<{
  72135. capacity: number;
  72136. randomTextureSize: number;
  72137. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72138. protected _reset(): void;
  72139. private _createUpdateVAO;
  72140. private _createRenderVAO;
  72141. private _initialize;
  72142. /** @hidden */
  72143. _recreateUpdateEffect(): void;
  72144. private _getEffect;
  72145. /**
  72146. * Fill the defines array according to the current settings of the particle system
  72147. * @param defines Array to be updated
  72148. * @param blendMode blend mode to take into account when updating the array
  72149. */
  72150. fillDefines(defines: Array<string>, blendMode?: number): void;
  72151. /**
  72152. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72153. * @param uniforms Uniforms array to fill
  72154. * @param attributes Attributes array to fill
  72155. * @param samplers Samplers array to fill
  72156. */
  72157. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72158. /** @hidden */
  72159. _recreateRenderEffect(): Effect;
  72160. /**
  72161. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72162. * @param preWarm defines if we are in the pre-warmimg phase
  72163. */
  72164. animate(preWarm?: boolean): void;
  72165. private _createFactorGradientTexture;
  72166. private _createSizeGradientTexture;
  72167. private _createAngularSpeedGradientTexture;
  72168. private _createVelocityGradientTexture;
  72169. private _createLimitVelocityGradientTexture;
  72170. private _createDragGradientTexture;
  72171. private _createColorGradientTexture;
  72172. /**
  72173. * Renders the particle system in its current state
  72174. * @param preWarm defines if the system should only update the particles but not render them
  72175. * @returns the current number of particles
  72176. */
  72177. render(preWarm?: boolean): number;
  72178. /**
  72179. * Rebuilds the particle system
  72180. */
  72181. rebuild(): void;
  72182. private _releaseBuffers;
  72183. private _releaseVAOs;
  72184. /**
  72185. * Disposes the particle system and free the associated resources
  72186. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72187. */
  72188. dispose(disposeTexture?: boolean): void;
  72189. /**
  72190. * Clones the particle system.
  72191. * @param name The name of the cloned object
  72192. * @param newEmitter The new emitter to use
  72193. * @returns the cloned particle system
  72194. */
  72195. clone(name: string, newEmitter: any): GPUParticleSystem;
  72196. /**
  72197. * Serializes the particle system to a JSON object
  72198. * @param serializeTexture defines if the texture must be serialized as well
  72199. * @returns the JSON object
  72200. */
  72201. serialize(serializeTexture?: boolean): any;
  72202. /**
  72203. * Parses a JSON object to create a GPU particle system.
  72204. * @param parsedParticleSystem The JSON object to parse
  72205. * @param sceneOrEngine The scene or the engine to create the particle system in
  72206. * @param rootUrl The root url to use to load external dependencies like texture
  72207. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72208. * @returns the parsed GPU particle system
  72209. */
  72210. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72211. }
  72212. }
  72213. declare module "babylonjs/Particles/particleSystemSet" {
  72214. import { Nullable } from "babylonjs/types";
  72215. import { Color3 } from "babylonjs/Maths/math.color";
  72216. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72218. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72219. import { Scene, IDisposable } from "babylonjs/scene";
  72220. /**
  72221. * Represents a set of particle systems working together to create a specific effect
  72222. */
  72223. export class ParticleSystemSet implements IDisposable {
  72224. /**
  72225. * Gets or sets base Assets URL
  72226. */
  72227. static BaseAssetsUrl: string;
  72228. private _emitterCreationOptions;
  72229. private _emitterNode;
  72230. /**
  72231. * Gets the particle system list
  72232. */
  72233. systems: IParticleSystem[];
  72234. /**
  72235. * Gets the emitter node used with this set
  72236. */
  72237. get emitterNode(): Nullable<TransformNode>;
  72238. /**
  72239. * Creates a new emitter mesh as a sphere
  72240. * @param options defines the options used to create the sphere
  72241. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72242. * @param scene defines the hosting scene
  72243. */
  72244. setEmitterAsSphere(options: {
  72245. diameter: number;
  72246. segments: number;
  72247. color: Color3;
  72248. }, renderingGroupId: number, scene: Scene): void;
  72249. /**
  72250. * Starts all particle systems of the set
  72251. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72252. */
  72253. start(emitter?: AbstractMesh): void;
  72254. /**
  72255. * Release all associated resources
  72256. */
  72257. dispose(): void;
  72258. /**
  72259. * Serialize the set into a JSON compatible object
  72260. * @param serializeTexture defines if the texture must be serialized as well
  72261. * @returns a JSON compatible representation of the set
  72262. */
  72263. serialize(serializeTexture?: boolean): any;
  72264. /**
  72265. * Parse a new ParticleSystemSet from a serialized source
  72266. * @param data defines a JSON compatible representation of the set
  72267. * @param scene defines the hosting scene
  72268. * @param gpu defines if we want GPU particles or CPU particles
  72269. * @returns a new ParticleSystemSet
  72270. */
  72271. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72272. }
  72273. }
  72274. declare module "babylonjs/Particles/particleHelper" {
  72275. import { Nullable } from "babylonjs/types";
  72276. import { Scene } from "babylonjs/scene";
  72277. import { Vector3 } from "babylonjs/Maths/math.vector";
  72278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72279. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72280. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72281. /**
  72282. * This class is made for on one-liner static method to help creating particle system set.
  72283. */
  72284. export class ParticleHelper {
  72285. /**
  72286. * Gets or sets base Assets URL
  72287. */
  72288. static BaseAssetsUrl: string;
  72289. /** Define the Url to load snippets */
  72290. static SnippetUrl: string;
  72291. /**
  72292. * Create a default particle system that you can tweak
  72293. * @param emitter defines the emitter to use
  72294. * @param capacity defines the system capacity (default is 500 particles)
  72295. * @param scene defines the hosting scene
  72296. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72297. * @returns the new Particle system
  72298. */
  72299. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72300. /**
  72301. * This is the main static method (one-liner) of this helper to create different particle systems
  72302. * @param type This string represents the type to the particle system to create
  72303. * @param scene The scene where the particle system should live
  72304. * @param gpu If the system will use gpu
  72305. * @returns the ParticleSystemSet created
  72306. */
  72307. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72308. /**
  72309. * Static function used to export a particle system to a ParticleSystemSet variable.
  72310. * Please note that the emitter shape is not exported
  72311. * @param systems defines the particle systems to export
  72312. * @returns the created particle system set
  72313. */
  72314. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72315. /**
  72316. * Creates a particle system from a snippet saved in a remote file
  72317. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72318. * @param url defines the url to load from
  72319. * @param scene defines the hosting scene
  72320. * @param gpu If the system will use gpu
  72321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72322. * @returns a promise that will resolve to the new particle system
  72323. */
  72324. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72325. /**
  72326. * Creates a particle system from a snippet saved by the particle system editor
  72327. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72328. * @param scene defines the hosting scene
  72329. * @param gpu If the system will use gpu
  72330. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72331. * @returns a promise that will resolve to the new particle system
  72332. */
  72333. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72334. }
  72335. }
  72336. declare module "babylonjs/Particles/particleSystemComponent" {
  72337. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72338. import { Effect } from "babylonjs/Materials/effect";
  72339. import "babylonjs/Shaders/particles.vertex";
  72340. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72341. module "babylonjs/Engines/engine" {
  72342. interface Engine {
  72343. /**
  72344. * Create an effect to use with particle systems.
  72345. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72346. * the particle system for which you want to create a custom effect in the last parameter
  72347. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72348. * @param uniformsNames defines a list of attribute names
  72349. * @param samplers defines an array of string used to represent textures
  72350. * @param defines defines the string containing the defines to use to compile the shaders
  72351. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72352. * @param onCompiled defines a function to call when the effect creation is successful
  72353. * @param onError defines a function to call when the effect creation has failed
  72354. * @param particleSystem the particle system you want to create the effect for
  72355. * @returns the new Effect
  72356. */
  72357. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72358. }
  72359. }
  72360. module "babylonjs/Meshes/mesh" {
  72361. interface Mesh {
  72362. /**
  72363. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72364. * @returns an array of IParticleSystem
  72365. */
  72366. getEmittedParticleSystems(): IParticleSystem[];
  72367. /**
  72368. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72369. * @returns an array of IParticleSystem
  72370. */
  72371. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72372. }
  72373. }
  72374. }
  72375. declare module "babylonjs/Particles/pointsCloudSystem" {
  72376. import { Color4 } from "babylonjs/Maths/math";
  72377. import { Mesh } from "babylonjs/Meshes/mesh";
  72378. import { Scene, IDisposable } from "babylonjs/scene";
  72379. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72380. /** Defines the 4 color options */
  72381. export enum PointColor {
  72382. /** color value */
  72383. Color = 2,
  72384. /** uv value */
  72385. UV = 1,
  72386. /** random value */
  72387. Random = 0,
  72388. /** stated value */
  72389. Stated = 3
  72390. }
  72391. /**
  72392. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72393. * 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.
  72394. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72395. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72396. *
  72397. * Full documentation here : TO BE ENTERED
  72398. */
  72399. export class PointsCloudSystem implements IDisposable {
  72400. /**
  72401. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72402. * Example : var p = SPS.particles[i];
  72403. */
  72404. particles: CloudPoint[];
  72405. /**
  72406. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72407. */
  72408. nbParticles: number;
  72409. /**
  72410. * This a counter for your own usage. It's not set by any SPS functions.
  72411. */
  72412. counter: number;
  72413. /**
  72414. * The PCS name. This name is also given to the underlying mesh.
  72415. */
  72416. name: string;
  72417. /**
  72418. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72419. */
  72420. mesh: Mesh;
  72421. /**
  72422. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72423. * Please read :
  72424. */
  72425. vars: any;
  72426. /**
  72427. * @hidden
  72428. */
  72429. _size: number;
  72430. private _scene;
  72431. private _promises;
  72432. private _positions;
  72433. private _indices;
  72434. private _normals;
  72435. private _colors;
  72436. private _uvs;
  72437. private _indices32;
  72438. private _positions32;
  72439. private _colors32;
  72440. private _uvs32;
  72441. private _updatable;
  72442. private _isVisibilityBoxLocked;
  72443. private _alwaysVisible;
  72444. private _groups;
  72445. private _groupCounter;
  72446. private _computeParticleColor;
  72447. private _computeParticleTexture;
  72448. private _computeParticleRotation;
  72449. private _computeBoundingBox;
  72450. private _isReady;
  72451. /**
  72452. * Creates a PCS (Points Cloud System) object
  72453. * @param name (String) is the PCS name, this will be the underlying mesh name
  72454. * @param pointSize (number) is the size for each point
  72455. * @param scene (Scene) is the scene in which the PCS is added
  72456. * @param options defines the options of the PCS e.g.
  72457. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72458. */
  72459. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72460. updatable?: boolean;
  72461. });
  72462. /**
  72463. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72464. * If no points were added to the PCS, the returned mesh is just a single point.
  72465. * @returns a promise for the created mesh
  72466. */
  72467. buildMeshAsync(): Promise<Mesh>;
  72468. /**
  72469. * @hidden
  72470. */
  72471. private _buildMesh;
  72472. private _addParticle;
  72473. private _randomUnitVector;
  72474. private _getColorIndicesForCoord;
  72475. private _setPointsColorOrUV;
  72476. private _colorFromTexture;
  72477. private _calculateDensity;
  72478. /**
  72479. * Adds points to the PCS in random positions within a unit sphere
  72480. * @param nb (positive integer) the number of particles to be created from this model
  72481. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72482. * @returns the number of groups in the system
  72483. */
  72484. addPoints(nb: number, pointFunction?: any): number;
  72485. /**
  72486. * Adds points to the PCS from the surface of the model shape
  72487. * @param mesh is any Mesh object that will be used as a surface model for the points
  72488. * @param nb (positive integer) the number of particles to be created from this model
  72489. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72490. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72491. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72492. * @returns the number of groups in the system
  72493. */
  72494. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72495. /**
  72496. * Adds points to the PCS inside the model shape
  72497. * @param mesh is any Mesh object that will be used as a surface model for the points
  72498. * @param nb (positive integer) the number of particles to be created from this model
  72499. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72500. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72501. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72502. * @returns the number of groups in the system
  72503. */
  72504. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72505. /**
  72506. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72507. * This method calls `updateParticle()` for each particle of the SPS.
  72508. * For an animated SPS, it is usually called within the render loop.
  72509. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72510. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72511. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72512. * @returns the PCS.
  72513. */
  72514. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72515. /**
  72516. * Disposes the PCS.
  72517. */
  72518. dispose(): void;
  72519. /**
  72520. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72521. * doc :
  72522. * @returns the PCS.
  72523. */
  72524. refreshVisibleSize(): PointsCloudSystem;
  72525. /**
  72526. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72527. * @param size the size (float) of the visibility box
  72528. * note : this doesn't lock the PCS mesh bounding box.
  72529. * doc :
  72530. */
  72531. setVisibilityBox(size: number): void;
  72532. /**
  72533. * Gets whether the PCS is always visible or not
  72534. * doc :
  72535. */
  72536. get isAlwaysVisible(): boolean;
  72537. /**
  72538. * Sets the PCS as always visible or not
  72539. * doc :
  72540. */
  72541. set isAlwaysVisible(val: boolean);
  72542. /**
  72543. * Tells to `setParticles()` to compute the particle rotations or not
  72544. * Default value : false. The PCS is faster when it's set to false
  72545. * Note : particle rotations are only applied to parent particles
  72546. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72547. */
  72548. set computeParticleRotation(val: boolean);
  72549. /**
  72550. * Tells to `setParticles()` to compute the particle colors or not.
  72551. * Default value : true. The PCS is faster when it's set to false.
  72552. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72553. */
  72554. set computeParticleColor(val: boolean);
  72555. set computeParticleTexture(val: boolean);
  72556. /**
  72557. * Gets if `setParticles()` computes the particle colors or not.
  72558. * Default value : false. The PCS is faster when it's set to false.
  72559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72560. */
  72561. get computeParticleColor(): boolean;
  72562. /**
  72563. * Gets if `setParticles()` computes the particle textures or not.
  72564. * Default value : false. The PCS is faster when it's set to false.
  72565. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72566. */
  72567. get computeParticleTexture(): boolean;
  72568. /**
  72569. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72570. */
  72571. set computeBoundingBox(val: boolean);
  72572. /**
  72573. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72574. */
  72575. get computeBoundingBox(): boolean;
  72576. /**
  72577. * This function does nothing. It may be overwritten to set all the particle first values.
  72578. * The PCS doesn't call this function, you may have to call it by your own.
  72579. * doc :
  72580. */
  72581. initParticles(): void;
  72582. /**
  72583. * This function does nothing. It may be overwritten to recycle a particle
  72584. * The PCS doesn't call this function, you can to call it
  72585. * doc :
  72586. * @param particle The particle to recycle
  72587. * @returns the recycled particle
  72588. */
  72589. recycleParticle(particle: CloudPoint): CloudPoint;
  72590. /**
  72591. * Updates a particle : this function should be overwritten by the user.
  72592. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72593. * doc :
  72594. * @example : just set a particle position or velocity and recycle conditions
  72595. * @param particle The particle to update
  72596. * @returns the updated particle
  72597. */
  72598. updateParticle(particle: CloudPoint): CloudPoint;
  72599. /**
  72600. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72601. * This does nothing and may be overwritten by the user.
  72602. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72603. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72604. * @param update the boolean update value actually passed to setParticles()
  72605. */
  72606. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72607. /**
  72608. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72609. * This will be passed three parameters.
  72610. * This does nothing and may be overwritten by the user.
  72611. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72612. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72613. * @param update the boolean update value actually passed to setParticles()
  72614. */
  72615. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72616. }
  72617. }
  72618. declare module "babylonjs/Particles/cloudPoint" {
  72619. import { Nullable } from "babylonjs/types";
  72620. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72621. import { Mesh } from "babylonjs/Meshes/mesh";
  72622. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72623. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72624. /**
  72625. * Represents one particle of a points cloud system.
  72626. */
  72627. export class CloudPoint {
  72628. /**
  72629. * particle global index
  72630. */
  72631. idx: number;
  72632. /**
  72633. * The color of the particle
  72634. */
  72635. color: Nullable<Color4>;
  72636. /**
  72637. * The world space position of the particle.
  72638. */
  72639. position: Vector3;
  72640. /**
  72641. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72642. */
  72643. rotation: Vector3;
  72644. /**
  72645. * The world space rotation quaternion of the particle.
  72646. */
  72647. rotationQuaternion: Nullable<Quaternion>;
  72648. /**
  72649. * The uv of the particle.
  72650. */
  72651. uv: Nullable<Vector2>;
  72652. /**
  72653. * The current speed of the particle.
  72654. */
  72655. velocity: Vector3;
  72656. /**
  72657. * The pivot point in the particle local space.
  72658. */
  72659. pivot: Vector3;
  72660. /**
  72661. * Must the particle be translated from its pivot point in its local space ?
  72662. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72663. * Default : false
  72664. */
  72665. translateFromPivot: boolean;
  72666. /**
  72667. * Index of this particle in the global "positions" array (Internal use)
  72668. * @hidden
  72669. */
  72670. _pos: number;
  72671. /**
  72672. * @hidden Index of this particle in the global "indices" array (Internal use)
  72673. */
  72674. _ind: number;
  72675. /**
  72676. * Group this particle belongs to
  72677. */
  72678. _group: PointsGroup;
  72679. /**
  72680. * Group id of this particle
  72681. */
  72682. groupId: number;
  72683. /**
  72684. * Index of the particle in its group id (Internal use)
  72685. */
  72686. idxInGroup: number;
  72687. /**
  72688. * @hidden Particle BoundingInfo object (Internal use)
  72689. */
  72690. _boundingInfo: BoundingInfo;
  72691. /**
  72692. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72693. */
  72694. _pcs: PointsCloudSystem;
  72695. /**
  72696. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72697. */
  72698. _stillInvisible: boolean;
  72699. /**
  72700. * @hidden Last computed particle rotation matrix
  72701. */
  72702. _rotationMatrix: number[];
  72703. /**
  72704. * Parent particle Id, if any.
  72705. * Default null.
  72706. */
  72707. parentId: Nullable<number>;
  72708. /**
  72709. * @hidden Internal global position in the PCS.
  72710. */
  72711. _globalPosition: Vector3;
  72712. /**
  72713. * Creates a Point Cloud object.
  72714. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72715. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72716. * @param group (PointsGroup) is the group the particle belongs to
  72717. * @param groupId (integer) is the group identifier in the PCS.
  72718. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72719. * @param pcs defines the PCS it is associated to
  72720. */
  72721. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72722. /**
  72723. * get point size
  72724. */
  72725. get size(): Vector3;
  72726. /**
  72727. * Set point size
  72728. */
  72729. set size(scale: Vector3);
  72730. /**
  72731. * Legacy support, changed quaternion to rotationQuaternion
  72732. */
  72733. get quaternion(): Nullable<Quaternion>;
  72734. /**
  72735. * Legacy support, changed quaternion to rotationQuaternion
  72736. */
  72737. set quaternion(q: Nullable<Quaternion>);
  72738. /**
  72739. * Returns a boolean. True if the particle intersects a mesh, else false
  72740. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72741. * @param target is the object (point or mesh) what the intersection is computed against
  72742. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72743. * @returns true if it intersects
  72744. */
  72745. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72746. /**
  72747. * get the rotation matrix of the particle
  72748. * @hidden
  72749. */
  72750. getRotationMatrix(m: Matrix): void;
  72751. }
  72752. /**
  72753. * Represents a group of points in a points cloud system
  72754. * * PCS internal tool, don't use it manually.
  72755. */
  72756. export class PointsGroup {
  72757. /**
  72758. * The group id
  72759. * @hidden
  72760. */
  72761. groupID: number;
  72762. /**
  72763. * image data for group (internal use)
  72764. * @hidden
  72765. */
  72766. _groupImageData: Nullable<ArrayBufferView>;
  72767. /**
  72768. * Image Width (internal use)
  72769. * @hidden
  72770. */
  72771. _groupImgWidth: number;
  72772. /**
  72773. * Image Height (internal use)
  72774. * @hidden
  72775. */
  72776. _groupImgHeight: number;
  72777. /**
  72778. * Custom position function (internal use)
  72779. * @hidden
  72780. */
  72781. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72782. /**
  72783. * density per facet for surface points
  72784. * @hidden
  72785. */
  72786. _groupDensity: number[];
  72787. /**
  72788. * Only when points are colored by texture carries pointer to texture list array
  72789. * @hidden
  72790. */
  72791. _textureNb: number;
  72792. /**
  72793. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72794. * PCS internal tool, don't use it manually.
  72795. * @hidden
  72796. */
  72797. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72798. }
  72799. }
  72800. declare module "babylonjs/Particles/index" {
  72801. export * from "babylonjs/Particles/baseParticleSystem";
  72802. export * from "babylonjs/Particles/EmitterTypes/index";
  72803. export * from "babylonjs/Particles/gpuParticleSystem";
  72804. export * from "babylonjs/Particles/IParticleSystem";
  72805. export * from "babylonjs/Particles/particle";
  72806. export * from "babylonjs/Particles/particleHelper";
  72807. export * from "babylonjs/Particles/particleSystem";
  72808. import "babylonjs/Particles/particleSystemComponent";
  72809. export * from "babylonjs/Particles/particleSystemComponent";
  72810. export * from "babylonjs/Particles/particleSystemSet";
  72811. export * from "babylonjs/Particles/solidParticle";
  72812. export * from "babylonjs/Particles/solidParticleSystem";
  72813. export * from "babylonjs/Particles/cloudPoint";
  72814. export * from "babylonjs/Particles/pointsCloudSystem";
  72815. export * from "babylonjs/Particles/subEmitter";
  72816. }
  72817. declare module "babylonjs/Physics/physicsEngineComponent" {
  72818. import { Nullable } from "babylonjs/types";
  72819. import { Observable, Observer } from "babylonjs/Misc/observable";
  72820. import { Vector3 } from "babylonjs/Maths/math.vector";
  72821. import { Mesh } from "babylonjs/Meshes/mesh";
  72822. import { ISceneComponent } from "babylonjs/sceneComponent";
  72823. import { Scene } from "babylonjs/scene";
  72824. import { Node } from "babylonjs/node";
  72825. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72826. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72827. module "babylonjs/scene" {
  72828. interface Scene {
  72829. /** @hidden (Backing field) */
  72830. _physicsEngine: Nullable<IPhysicsEngine>;
  72831. /** @hidden */
  72832. _physicsTimeAccumulator: number;
  72833. /**
  72834. * Gets the current physics engine
  72835. * @returns a IPhysicsEngine or null if none attached
  72836. */
  72837. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72838. /**
  72839. * Enables physics to the current scene
  72840. * @param gravity defines the scene's gravity for the physics engine
  72841. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72842. * @return a boolean indicating if the physics engine was initialized
  72843. */
  72844. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72845. /**
  72846. * Disables and disposes the physics engine associated with the scene
  72847. */
  72848. disablePhysicsEngine(): void;
  72849. /**
  72850. * Gets a boolean indicating if there is an active physics engine
  72851. * @returns a boolean indicating if there is an active physics engine
  72852. */
  72853. isPhysicsEnabled(): boolean;
  72854. /**
  72855. * Deletes a physics compound impostor
  72856. * @param compound defines the compound to delete
  72857. */
  72858. deleteCompoundImpostor(compound: any): void;
  72859. /**
  72860. * An event triggered when physic simulation is about to be run
  72861. */
  72862. onBeforePhysicsObservable: Observable<Scene>;
  72863. /**
  72864. * An event triggered when physic simulation has been done
  72865. */
  72866. onAfterPhysicsObservable: Observable<Scene>;
  72867. }
  72868. }
  72869. module "babylonjs/Meshes/abstractMesh" {
  72870. interface AbstractMesh {
  72871. /** @hidden */
  72872. _physicsImpostor: Nullable<PhysicsImpostor>;
  72873. /**
  72874. * Gets or sets impostor used for physic simulation
  72875. * @see https://doc.babylonjs.com/features/physics_engine
  72876. */
  72877. physicsImpostor: Nullable<PhysicsImpostor>;
  72878. /**
  72879. * Gets the current physics impostor
  72880. * @see https://doc.babylonjs.com/features/physics_engine
  72881. * @returns a physics impostor or null
  72882. */
  72883. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72884. /** Apply a physic impulse to the mesh
  72885. * @param force defines the force to apply
  72886. * @param contactPoint defines where to apply the force
  72887. * @returns the current mesh
  72888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72889. */
  72890. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72891. /**
  72892. * Creates a physic joint between two meshes
  72893. * @param otherMesh defines the other mesh to use
  72894. * @param pivot1 defines the pivot to use on this mesh
  72895. * @param pivot2 defines the pivot to use on the other mesh
  72896. * @param options defines additional options (can be plugin dependent)
  72897. * @returns the current mesh
  72898. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72899. */
  72900. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72901. /** @hidden */
  72902. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72903. }
  72904. }
  72905. /**
  72906. * Defines the physics engine scene component responsible to manage a physics engine
  72907. */
  72908. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72909. /**
  72910. * The component name helpful to identify the component in the list of scene components.
  72911. */
  72912. readonly name: string;
  72913. /**
  72914. * The scene the component belongs to.
  72915. */
  72916. scene: Scene;
  72917. /**
  72918. * Creates a new instance of the component for the given scene
  72919. * @param scene Defines the scene to register the component in
  72920. */
  72921. constructor(scene: Scene);
  72922. /**
  72923. * Registers the component in a given scene
  72924. */
  72925. register(): void;
  72926. /**
  72927. * Rebuilds the elements related to this component in case of
  72928. * context lost for instance.
  72929. */
  72930. rebuild(): void;
  72931. /**
  72932. * Disposes the component and the associated ressources
  72933. */
  72934. dispose(): void;
  72935. }
  72936. }
  72937. declare module "babylonjs/Physics/physicsHelper" {
  72938. import { Nullable } from "babylonjs/types";
  72939. import { Vector3 } from "babylonjs/Maths/math.vector";
  72940. import { Mesh } from "babylonjs/Meshes/mesh";
  72941. import { Scene } from "babylonjs/scene";
  72942. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72943. /**
  72944. * A helper for physics simulations
  72945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72946. */
  72947. export class PhysicsHelper {
  72948. private _scene;
  72949. private _physicsEngine;
  72950. /**
  72951. * Initializes the Physics helper
  72952. * @param scene Babylon.js scene
  72953. */
  72954. constructor(scene: Scene);
  72955. /**
  72956. * Applies a radial explosion impulse
  72957. * @param origin the origin of the explosion
  72958. * @param radiusOrEventOptions the radius or the options of radial explosion
  72959. * @param strength the explosion strength
  72960. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72961. * @returns A physics radial explosion event, or null
  72962. */
  72963. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72964. /**
  72965. * Applies a radial explosion force
  72966. * @param origin the origin of the explosion
  72967. * @param radiusOrEventOptions the radius or the options of radial explosion
  72968. * @param strength the explosion strength
  72969. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72970. * @returns A physics radial explosion event, or null
  72971. */
  72972. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72973. /**
  72974. * Creates a gravitational field
  72975. * @param origin the origin of the explosion
  72976. * @param radiusOrEventOptions the radius or the options of radial explosion
  72977. * @param strength the explosion strength
  72978. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72979. * @returns A physics gravitational field event, or null
  72980. */
  72981. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72982. /**
  72983. * Creates a physics updraft event
  72984. * @param origin the origin of the updraft
  72985. * @param radiusOrEventOptions the radius or the options of the updraft
  72986. * @param strength the strength of the updraft
  72987. * @param height the height of the updraft
  72988. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72989. * @returns A physics updraft event, or null
  72990. */
  72991. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72992. /**
  72993. * Creates a physics vortex event
  72994. * @param origin the of the vortex
  72995. * @param radiusOrEventOptions the radius or the options of the vortex
  72996. * @param strength the strength of the vortex
  72997. * @param height the height of the vortex
  72998. * @returns a Physics vortex event, or null
  72999. * A physics vortex event or null
  73000. */
  73001. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73002. }
  73003. /**
  73004. * Represents a physics radial explosion event
  73005. */
  73006. class PhysicsRadialExplosionEvent {
  73007. private _scene;
  73008. private _options;
  73009. private _sphere;
  73010. private _dataFetched;
  73011. /**
  73012. * Initializes a radial explosioin event
  73013. * @param _scene BabylonJS scene
  73014. * @param _options The options for the vortex event
  73015. */
  73016. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73017. /**
  73018. * Returns the data related to the radial explosion event (sphere).
  73019. * @returns The radial explosion event data
  73020. */
  73021. getData(): PhysicsRadialExplosionEventData;
  73022. /**
  73023. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73024. * @param impostor A physics imposter
  73025. * @param origin the origin of the explosion
  73026. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73027. */
  73028. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73029. /**
  73030. * Triggers affecterd impostors callbacks
  73031. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73032. */
  73033. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73034. /**
  73035. * Disposes the sphere.
  73036. * @param force Specifies if the sphere should be disposed by force
  73037. */
  73038. dispose(force?: boolean): void;
  73039. /*** Helpers ***/
  73040. private _prepareSphere;
  73041. private _intersectsWithSphere;
  73042. }
  73043. /**
  73044. * Represents a gravitational field event
  73045. */
  73046. class PhysicsGravitationalFieldEvent {
  73047. private _physicsHelper;
  73048. private _scene;
  73049. private _origin;
  73050. private _options;
  73051. private _tickCallback;
  73052. private _sphere;
  73053. private _dataFetched;
  73054. /**
  73055. * Initializes the physics gravitational field event
  73056. * @param _physicsHelper A physics helper
  73057. * @param _scene BabylonJS scene
  73058. * @param _origin The origin position of the gravitational field event
  73059. * @param _options The options for the vortex event
  73060. */
  73061. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73062. /**
  73063. * Returns the data related to the gravitational field event (sphere).
  73064. * @returns A gravitational field event
  73065. */
  73066. getData(): PhysicsGravitationalFieldEventData;
  73067. /**
  73068. * Enables the gravitational field.
  73069. */
  73070. enable(): void;
  73071. /**
  73072. * Disables the gravitational field.
  73073. */
  73074. disable(): void;
  73075. /**
  73076. * Disposes the sphere.
  73077. * @param force The force to dispose from the gravitational field event
  73078. */
  73079. dispose(force?: boolean): void;
  73080. private _tick;
  73081. }
  73082. /**
  73083. * Represents a physics updraft event
  73084. */
  73085. class PhysicsUpdraftEvent {
  73086. private _scene;
  73087. private _origin;
  73088. private _options;
  73089. private _physicsEngine;
  73090. private _originTop;
  73091. private _originDirection;
  73092. private _tickCallback;
  73093. private _cylinder;
  73094. private _cylinderPosition;
  73095. private _dataFetched;
  73096. /**
  73097. * Initializes the physics updraft event
  73098. * @param _scene BabylonJS scene
  73099. * @param _origin The origin position of the updraft
  73100. * @param _options The options for the updraft event
  73101. */
  73102. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73103. /**
  73104. * Returns the data related to the updraft event (cylinder).
  73105. * @returns A physics updraft event
  73106. */
  73107. getData(): PhysicsUpdraftEventData;
  73108. /**
  73109. * Enables the updraft.
  73110. */
  73111. enable(): void;
  73112. /**
  73113. * Disables the updraft.
  73114. */
  73115. disable(): void;
  73116. /**
  73117. * Disposes the cylinder.
  73118. * @param force Specifies if the updraft should be disposed by force
  73119. */
  73120. dispose(force?: boolean): void;
  73121. private getImpostorHitData;
  73122. private _tick;
  73123. /*** Helpers ***/
  73124. private _prepareCylinder;
  73125. private _intersectsWithCylinder;
  73126. }
  73127. /**
  73128. * Represents a physics vortex event
  73129. */
  73130. class PhysicsVortexEvent {
  73131. private _scene;
  73132. private _origin;
  73133. private _options;
  73134. private _physicsEngine;
  73135. private _originTop;
  73136. private _tickCallback;
  73137. private _cylinder;
  73138. private _cylinderPosition;
  73139. private _dataFetched;
  73140. /**
  73141. * Initializes the physics vortex event
  73142. * @param _scene The BabylonJS scene
  73143. * @param _origin The origin position of the vortex
  73144. * @param _options The options for the vortex event
  73145. */
  73146. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73147. /**
  73148. * Returns the data related to the vortex event (cylinder).
  73149. * @returns The physics vortex event data
  73150. */
  73151. getData(): PhysicsVortexEventData;
  73152. /**
  73153. * Enables the vortex.
  73154. */
  73155. enable(): void;
  73156. /**
  73157. * Disables the cortex.
  73158. */
  73159. disable(): void;
  73160. /**
  73161. * Disposes the sphere.
  73162. * @param force
  73163. */
  73164. dispose(force?: boolean): void;
  73165. private getImpostorHitData;
  73166. private _tick;
  73167. /*** Helpers ***/
  73168. private _prepareCylinder;
  73169. private _intersectsWithCylinder;
  73170. }
  73171. /**
  73172. * Options fot the radial explosion event
  73173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73174. */
  73175. export class PhysicsRadialExplosionEventOptions {
  73176. /**
  73177. * The radius of the sphere for the radial explosion.
  73178. */
  73179. radius: number;
  73180. /**
  73181. * The strenth of the explosion.
  73182. */
  73183. strength: number;
  73184. /**
  73185. * The strenght of the force in correspondence to the distance of the affected object
  73186. */
  73187. falloff: PhysicsRadialImpulseFalloff;
  73188. /**
  73189. * Sphere options for the radial explosion.
  73190. */
  73191. sphere: {
  73192. segments: number;
  73193. diameter: number;
  73194. };
  73195. /**
  73196. * Sphere options for the radial explosion.
  73197. */
  73198. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73199. }
  73200. /**
  73201. * Options fot the updraft event
  73202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73203. */
  73204. export class PhysicsUpdraftEventOptions {
  73205. /**
  73206. * The radius of the cylinder for the vortex
  73207. */
  73208. radius: number;
  73209. /**
  73210. * The strenth of the updraft.
  73211. */
  73212. strength: number;
  73213. /**
  73214. * The height of the cylinder for the updraft.
  73215. */
  73216. height: number;
  73217. /**
  73218. * The mode for the the updraft.
  73219. */
  73220. updraftMode: PhysicsUpdraftMode;
  73221. }
  73222. /**
  73223. * Options fot the vortex event
  73224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73225. */
  73226. export class PhysicsVortexEventOptions {
  73227. /**
  73228. * The radius of the cylinder for the vortex
  73229. */
  73230. radius: number;
  73231. /**
  73232. * The strenth of the vortex.
  73233. */
  73234. strength: number;
  73235. /**
  73236. * The height of the cylinder for the vortex.
  73237. */
  73238. height: number;
  73239. /**
  73240. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73241. */
  73242. centripetalForceThreshold: number;
  73243. /**
  73244. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73245. */
  73246. centripetalForceMultiplier: number;
  73247. /**
  73248. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73249. */
  73250. centrifugalForceMultiplier: number;
  73251. /**
  73252. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73253. */
  73254. updraftForceMultiplier: number;
  73255. }
  73256. /**
  73257. * The strenght of the force in correspondence to the distance of the affected object
  73258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73259. */
  73260. export enum PhysicsRadialImpulseFalloff {
  73261. /** Defines that impulse is constant in strength across it's whole radius */
  73262. Constant = 0,
  73263. /** Defines that impulse gets weaker if it's further from the origin */
  73264. Linear = 1
  73265. }
  73266. /**
  73267. * The strength of the force in correspondence to the distance of the affected object
  73268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73269. */
  73270. export enum PhysicsUpdraftMode {
  73271. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73272. Center = 0,
  73273. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73274. Perpendicular = 1
  73275. }
  73276. /**
  73277. * Interface for a physics hit data
  73278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73279. */
  73280. export interface PhysicsHitData {
  73281. /**
  73282. * The force applied at the contact point
  73283. */
  73284. force: Vector3;
  73285. /**
  73286. * The contact point
  73287. */
  73288. contactPoint: Vector3;
  73289. /**
  73290. * The distance from the origin to the contact point
  73291. */
  73292. distanceFromOrigin: number;
  73293. }
  73294. /**
  73295. * Interface for radial explosion event data
  73296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73297. */
  73298. export interface PhysicsRadialExplosionEventData {
  73299. /**
  73300. * A sphere used for the radial explosion event
  73301. */
  73302. sphere: Mesh;
  73303. }
  73304. /**
  73305. * Interface for gravitational field event data
  73306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73307. */
  73308. export interface PhysicsGravitationalFieldEventData {
  73309. /**
  73310. * A sphere mesh used for the gravitational field event
  73311. */
  73312. sphere: Mesh;
  73313. }
  73314. /**
  73315. * Interface for updraft event data
  73316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73317. */
  73318. export interface PhysicsUpdraftEventData {
  73319. /**
  73320. * A cylinder used for the updraft event
  73321. */
  73322. cylinder: Mesh;
  73323. }
  73324. /**
  73325. * Interface for vortex event data
  73326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73327. */
  73328. export interface PhysicsVortexEventData {
  73329. /**
  73330. * A cylinder used for the vortex event
  73331. */
  73332. cylinder: Mesh;
  73333. }
  73334. /**
  73335. * Interface for an affected physics impostor
  73336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73337. */
  73338. export interface PhysicsAffectedImpostorWithData {
  73339. /**
  73340. * The impostor affected by the effect
  73341. */
  73342. impostor: PhysicsImpostor;
  73343. /**
  73344. * The data about the hit/horce from the explosion
  73345. */
  73346. hitData: PhysicsHitData;
  73347. }
  73348. }
  73349. declare module "babylonjs/Physics/Plugins/index" {
  73350. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73351. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73352. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73353. }
  73354. declare module "babylonjs/Physics/index" {
  73355. export * from "babylonjs/Physics/IPhysicsEngine";
  73356. export * from "babylonjs/Physics/physicsEngine";
  73357. export * from "babylonjs/Physics/physicsEngineComponent";
  73358. export * from "babylonjs/Physics/physicsHelper";
  73359. export * from "babylonjs/Physics/physicsImpostor";
  73360. export * from "babylonjs/Physics/physicsJoint";
  73361. export * from "babylonjs/Physics/Plugins/index";
  73362. }
  73363. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73364. /** @hidden */
  73365. export var blackAndWhitePixelShader: {
  73366. name: string;
  73367. shader: string;
  73368. };
  73369. }
  73370. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73371. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73372. import { Camera } from "babylonjs/Cameras/camera";
  73373. import { Engine } from "babylonjs/Engines/engine";
  73374. import "babylonjs/Shaders/blackAndWhite.fragment";
  73375. import { Nullable } from "babylonjs/types";
  73376. import { Scene } from "babylonjs/scene";
  73377. /**
  73378. * Post process used to render in black and white
  73379. */
  73380. export class BlackAndWhitePostProcess extends PostProcess {
  73381. /**
  73382. * Linear about to convert he result to black and white (default: 1)
  73383. */
  73384. degree: number;
  73385. /**
  73386. * Gets a string identifying the name of the class
  73387. * @returns "BlackAndWhitePostProcess" string
  73388. */
  73389. getClassName(): string;
  73390. /**
  73391. * Creates a black and white post process
  73392. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73393. * @param name The name of the effect.
  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. */
  73400. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73401. /** @hidden */
  73402. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73403. }
  73404. }
  73405. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73406. import { Nullable } from "babylonjs/types";
  73407. import { Camera } from "babylonjs/Cameras/camera";
  73408. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73409. import { Engine } from "babylonjs/Engines/engine";
  73410. /**
  73411. * This represents a set of one or more post processes in Babylon.
  73412. * A post process can be used to apply a shader to a texture after it is rendered.
  73413. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73414. */
  73415. export class PostProcessRenderEffect {
  73416. private _postProcesses;
  73417. private _getPostProcesses;
  73418. private _singleInstance;
  73419. private _cameras;
  73420. private _indicesForCamera;
  73421. /**
  73422. * Name of the effect
  73423. * @hidden
  73424. */
  73425. _name: string;
  73426. /**
  73427. * Instantiates a post process render effect.
  73428. * A post process can be used to apply a shader to a texture after it is rendered.
  73429. * @param engine The engine the effect is tied to
  73430. * @param name The name of the effect
  73431. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73432. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73433. */
  73434. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73435. /**
  73436. * Checks if all the post processes in the effect are supported.
  73437. */
  73438. get isSupported(): boolean;
  73439. /**
  73440. * Updates the current state of the effect
  73441. * @hidden
  73442. */
  73443. _update(): void;
  73444. /**
  73445. * Attaches the effect on cameras
  73446. * @param cameras The camera to attach to.
  73447. * @hidden
  73448. */
  73449. _attachCameras(cameras: Camera): void;
  73450. /**
  73451. * Attaches the effect on cameras
  73452. * @param cameras The camera to attach to.
  73453. * @hidden
  73454. */
  73455. _attachCameras(cameras: Camera[]): void;
  73456. /**
  73457. * Detaches the effect on cameras
  73458. * @param cameras The camera to detatch from.
  73459. * @hidden
  73460. */
  73461. _detachCameras(cameras: Camera): void;
  73462. /**
  73463. * Detatches the effect on cameras
  73464. * @param cameras The camera to detatch from.
  73465. * @hidden
  73466. */
  73467. _detachCameras(cameras: Camera[]): void;
  73468. /**
  73469. * Enables the effect on given cameras
  73470. * @param cameras The camera to enable.
  73471. * @hidden
  73472. */
  73473. _enable(cameras: Camera): void;
  73474. /**
  73475. * Enables the effect on given cameras
  73476. * @param cameras The camera to enable.
  73477. * @hidden
  73478. */
  73479. _enable(cameras: Nullable<Camera[]>): void;
  73480. /**
  73481. * Disables the effect on the given cameras
  73482. * @param cameras The camera to disable.
  73483. * @hidden
  73484. */
  73485. _disable(cameras: Camera): void;
  73486. /**
  73487. * Disables the effect on the given cameras
  73488. * @param cameras The camera to disable.
  73489. * @hidden
  73490. */
  73491. _disable(cameras: Nullable<Camera[]>): void;
  73492. /**
  73493. * Gets a list of the post processes contained in the effect.
  73494. * @param camera The camera to get the post processes on.
  73495. * @returns The list of the post processes in the effect.
  73496. */
  73497. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73498. }
  73499. }
  73500. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73502. /** @hidden */
  73503. export var extractHighlightsPixelShader: {
  73504. name: string;
  73505. shader: string;
  73506. };
  73507. }
  73508. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73509. import { Nullable } from "babylonjs/types";
  73510. import { Camera } from "babylonjs/Cameras/camera";
  73511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73512. import { Engine } from "babylonjs/Engines/engine";
  73513. import "babylonjs/Shaders/extractHighlights.fragment";
  73514. /**
  73515. * 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.
  73516. */
  73517. export class ExtractHighlightsPostProcess extends PostProcess {
  73518. /**
  73519. * The luminance threshold, pixels below this value will be set to black.
  73520. */
  73521. threshold: number;
  73522. /** @hidden */
  73523. _exposure: number;
  73524. /**
  73525. * Post process which has the input texture to be used when performing highlight extraction
  73526. * @hidden
  73527. */
  73528. _inputPostProcess: Nullable<PostProcess>;
  73529. /**
  73530. * Gets a string identifying the name of the class
  73531. * @returns "ExtractHighlightsPostProcess" string
  73532. */
  73533. getClassName(): string;
  73534. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73535. }
  73536. }
  73537. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73538. /** @hidden */
  73539. export var bloomMergePixelShader: {
  73540. name: string;
  73541. shader: string;
  73542. };
  73543. }
  73544. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73545. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73546. import { Nullable } from "babylonjs/types";
  73547. import { Engine } from "babylonjs/Engines/engine";
  73548. import { Camera } from "babylonjs/Cameras/camera";
  73549. import "babylonjs/Shaders/bloomMerge.fragment";
  73550. /**
  73551. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73552. */
  73553. export class BloomMergePostProcess extends PostProcess {
  73554. /** Weight of the bloom to be added to the original input. */
  73555. weight: number;
  73556. /**
  73557. * Gets a string identifying the name of the class
  73558. * @returns "BloomMergePostProcess" string
  73559. */
  73560. getClassName(): string;
  73561. /**
  73562. * Creates a new instance of @see BloomMergePostProcess
  73563. * @param name The name of the effect.
  73564. * @param originalFromInput Post process which's input will be used for the merge.
  73565. * @param blurred Blurred highlights post process which's output will be used.
  73566. * @param weight Weight of the bloom to be added to the original input.
  73567. * @param options The required width/height ratio to downsize to before computing the render pass.
  73568. * @param camera The camera to apply the render pass to.
  73569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73570. * @param engine The engine which the post process will be applied. (default: current engine)
  73571. * @param reusable If the post process can be reused on the same frame. (default: false)
  73572. * @param textureType Type of textures used when performing the post process. (default: 0)
  73573. * @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)
  73574. */
  73575. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73576. /** Weight of the bloom to be added to the original input. */
  73577. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73578. }
  73579. }
  73580. declare module "babylonjs/PostProcesses/bloomEffect" {
  73581. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73583. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73584. import { Camera } from "babylonjs/Cameras/camera";
  73585. import { Scene } from "babylonjs/scene";
  73586. /**
  73587. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73588. */
  73589. export class BloomEffect extends PostProcessRenderEffect {
  73590. private bloomScale;
  73591. /**
  73592. * @hidden Internal
  73593. */
  73594. _effects: Array<PostProcess>;
  73595. /**
  73596. * @hidden Internal
  73597. */
  73598. _downscale: ExtractHighlightsPostProcess;
  73599. private _blurX;
  73600. private _blurY;
  73601. private _merge;
  73602. /**
  73603. * The luminance threshold to find bright areas of the image to bloom.
  73604. */
  73605. get threshold(): number;
  73606. set threshold(value: number);
  73607. /**
  73608. * The strength of the bloom.
  73609. */
  73610. get weight(): number;
  73611. set weight(value: number);
  73612. /**
  73613. * Specifies the size of the bloom blur kernel, relative to the final output size
  73614. */
  73615. get kernel(): number;
  73616. set kernel(value: number);
  73617. /**
  73618. * Creates a new instance of @see BloomEffect
  73619. * @param scene The scene the effect belongs to.
  73620. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73621. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73622. * @param bloomWeight The the strength of bloom.
  73623. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73624. * @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)
  73625. */
  73626. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73627. /**
  73628. * Disposes each of the internal effects for a given camera.
  73629. * @param camera The camera to dispose the effect on.
  73630. */
  73631. disposeEffects(camera: Camera): void;
  73632. /**
  73633. * @hidden Internal
  73634. */
  73635. _updateEffects(): void;
  73636. /**
  73637. * Internal
  73638. * @returns if all the contained post processes are ready.
  73639. * @hidden
  73640. */
  73641. _isReady(): boolean;
  73642. }
  73643. }
  73644. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73645. /** @hidden */
  73646. export var chromaticAberrationPixelShader: {
  73647. name: string;
  73648. shader: string;
  73649. };
  73650. }
  73651. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73652. import { Vector2 } from "babylonjs/Maths/math.vector";
  73653. import { Nullable } from "babylonjs/types";
  73654. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73655. import { Camera } from "babylonjs/Cameras/camera";
  73656. import { Engine } from "babylonjs/Engines/engine";
  73657. import "babylonjs/Shaders/chromaticAberration.fragment";
  73658. import { Scene } from "babylonjs/scene";
  73659. /**
  73660. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73661. */
  73662. export class ChromaticAberrationPostProcess extends PostProcess {
  73663. /**
  73664. * The amount of seperation of rgb channels (default: 30)
  73665. */
  73666. aberrationAmount: number;
  73667. /**
  73668. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73669. */
  73670. radialIntensity: number;
  73671. /**
  73672. * 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))
  73673. */
  73674. direction: Vector2;
  73675. /**
  73676. * 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))
  73677. */
  73678. centerPosition: Vector2;
  73679. /** The width of the screen to apply the effect on */
  73680. screenWidth: number;
  73681. /** The height of the screen to apply the effect on */
  73682. screenHeight: number;
  73683. /**
  73684. * Gets a string identifying the name of the class
  73685. * @returns "ChromaticAberrationPostProcess" string
  73686. */
  73687. getClassName(): string;
  73688. /**
  73689. * Creates a new instance ChromaticAberrationPostProcess
  73690. * @param name The name of the effect.
  73691. * @param screenWidth The width of the screen to apply the effect on.
  73692. * @param screenHeight The height of the screen to apply the effect on.
  73693. * @param options The required width/height ratio to downsize to before computing the render pass.
  73694. * @param camera The camera to apply the render pass to.
  73695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73696. * @param engine The engine which the post process will be applied. (default: current engine)
  73697. * @param reusable If the post process can be reused on the same frame. (default: false)
  73698. * @param textureType Type of textures used when performing the post process. (default: 0)
  73699. * @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)
  73700. */
  73701. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73702. /** @hidden */
  73703. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73704. }
  73705. }
  73706. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73707. /** @hidden */
  73708. export var circleOfConfusionPixelShader: {
  73709. name: string;
  73710. shader: string;
  73711. };
  73712. }
  73713. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73714. import { Nullable } from "babylonjs/types";
  73715. import { Engine } from "babylonjs/Engines/engine";
  73716. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73717. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73718. import { Camera } from "babylonjs/Cameras/camera";
  73719. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73720. /**
  73721. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73722. */
  73723. export class CircleOfConfusionPostProcess extends PostProcess {
  73724. /**
  73725. * 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.
  73726. */
  73727. lensSize: number;
  73728. /**
  73729. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73730. */
  73731. fStop: number;
  73732. /**
  73733. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73734. */
  73735. focusDistance: number;
  73736. /**
  73737. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73738. */
  73739. focalLength: number;
  73740. /**
  73741. * Gets a string identifying the name of the class
  73742. * @returns "CircleOfConfusionPostProcess" string
  73743. */
  73744. getClassName(): string;
  73745. private _depthTexture;
  73746. /**
  73747. * Creates a new instance CircleOfConfusionPostProcess
  73748. * @param name The name of the effect.
  73749. * @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.
  73750. * @param options The required width/height ratio to downsize to before computing the render pass.
  73751. * @param camera The camera to apply the render pass to.
  73752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73753. * @param engine The engine which the post process will be applied. (default: current engine)
  73754. * @param reusable If the post process can be reused on the same frame. (default: false)
  73755. * @param textureType Type of textures used when performing the post process. (default: 0)
  73756. * @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)
  73757. */
  73758. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73759. /**
  73760. * 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.
  73761. */
  73762. set depthTexture(value: RenderTargetTexture);
  73763. }
  73764. }
  73765. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73766. /** @hidden */
  73767. export var colorCorrectionPixelShader: {
  73768. name: string;
  73769. shader: string;
  73770. };
  73771. }
  73772. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73774. import { Engine } from "babylonjs/Engines/engine";
  73775. import { Camera } from "babylonjs/Cameras/camera";
  73776. import "babylonjs/Shaders/colorCorrection.fragment";
  73777. import { Nullable } from "babylonjs/types";
  73778. import { Scene } from "babylonjs/scene";
  73779. /**
  73780. *
  73781. * This post-process allows the modification of rendered colors by using
  73782. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73783. *
  73784. * The object needs to be provided an url to a texture containing the color
  73785. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73786. * Use an image editing software to tweak the LUT to match your needs.
  73787. *
  73788. * For an example of a color LUT, see here:
  73789. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73790. * For explanations on color grading, see here:
  73791. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73792. *
  73793. */
  73794. export class ColorCorrectionPostProcess extends PostProcess {
  73795. private _colorTableTexture;
  73796. /**
  73797. * Gets the color table url used to create the LUT texture
  73798. */
  73799. colorTableUrl: string;
  73800. /**
  73801. * Gets a string identifying the name of the class
  73802. * @returns "ColorCorrectionPostProcess" string
  73803. */
  73804. getClassName(): string;
  73805. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73806. /** @hidden */
  73807. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73808. }
  73809. }
  73810. declare module "babylonjs/Shaders/convolution.fragment" {
  73811. /** @hidden */
  73812. export var convolutionPixelShader: {
  73813. name: string;
  73814. shader: string;
  73815. };
  73816. }
  73817. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73818. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73819. import { Nullable } from "babylonjs/types";
  73820. import { Camera } from "babylonjs/Cameras/camera";
  73821. import { Engine } from "babylonjs/Engines/engine";
  73822. import "babylonjs/Shaders/convolution.fragment";
  73823. import { Scene } from "babylonjs/scene";
  73824. /**
  73825. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73826. * input texture to perform effects such as edge detection or sharpening
  73827. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73828. */
  73829. export class ConvolutionPostProcess extends PostProcess {
  73830. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73831. kernel: number[];
  73832. /**
  73833. * Gets a string identifying the name of the class
  73834. * @returns "ConvolutionPostProcess" string
  73835. */
  73836. getClassName(): string;
  73837. /**
  73838. * Creates a new instance ConvolutionPostProcess
  73839. * @param name The name of the effect.
  73840. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73841. * @param options The required width/height ratio to downsize to before computing the render pass.
  73842. * @param camera The camera to apply the render pass to.
  73843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73844. * @param engine The engine which the post process will be applied. (default: current engine)
  73845. * @param reusable If the post process can be reused on the same frame. (default: false)
  73846. * @param textureType Type of textures used when performing the post process. (default: 0)
  73847. */
  73848. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73849. /** @hidden */
  73850. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73851. /**
  73852. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73853. */
  73854. static EdgeDetect0Kernel: number[];
  73855. /**
  73856. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73857. */
  73858. static EdgeDetect1Kernel: number[];
  73859. /**
  73860. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73861. */
  73862. static EdgeDetect2Kernel: number[];
  73863. /**
  73864. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73865. */
  73866. static SharpenKernel: number[];
  73867. /**
  73868. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73869. */
  73870. static EmbossKernel: number[];
  73871. /**
  73872. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73873. */
  73874. static GaussianKernel: number[];
  73875. }
  73876. }
  73877. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73878. import { Nullable } from "babylonjs/types";
  73879. import { Vector2 } from "babylonjs/Maths/math.vector";
  73880. import { Camera } from "babylonjs/Cameras/camera";
  73881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73882. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73883. import { Engine } from "babylonjs/Engines/engine";
  73884. import { Scene } from "babylonjs/scene";
  73885. /**
  73886. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73887. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73888. * based on samples that have a large difference in distance than the center pixel.
  73889. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73890. */
  73891. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73892. /**
  73893. * The direction the blur should be applied
  73894. */
  73895. direction: Vector2;
  73896. /**
  73897. * Gets a string identifying the name of the class
  73898. * @returns "DepthOfFieldBlurPostProcess" string
  73899. */
  73900. getClassName(): string;
  73901. /**
  73902. * Creates a new instance CircleOfConfusionPostProcess
  73903. * @param name The name of the effect.
  73904. * @param scene The scene the effect belongs to.
  73905. * @param direction The direction the blur should be applied.
  73906. * @param kernel The size of the kernel used to blur.
  73907. * @param options The required width/height ratio to downsize to before computing the render pass.
  73908. * @param camera The camera to apply the render pass to.
  73909. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73910. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73912. * @param engine The engine which the post process will be applied. (default: current engine)
  73913. * @param reusable If the post process can be reused on the same frame. (default: false)
  73914. * @param textureType Type of textures used when performing the post process. (default: 0)
  73915. * @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)
  73916. */
  73917. 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);
  73918. }
  73919. }
  73920. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73921. /** @hidden */
  73922. export var depthOfFieldMergePixelShader: {
  73923. name: string;
  73924. shader: string;
  73925. };
  73926. }
  73927. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73928. import { Nullable } from "babylonjs/types";
  73929. import { Camera } from "babylonjs/Cameras/camera";
  73930. import { Effect } from "babylonjs/Materials/effect";
  73931. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73932. import { Engine } from "babylonjs/Engines/engine";
  73933. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73934. /**
  73935. * Options to be set when merging outputs from the default pipeline.
  73936. */
  73937. export class DepthOfFieldMergePostProcessOptions {
  73938. /**
  73939. * The original image to merge on top of
  73940. */
  73941. originalFromInput: PostProcess;
  73942. /**
  73943. * Parameters to perform the merge of the depth of field effect
  73944. */
  73945. depthOfField?: {
  73946. circleOfConfusion: PostProcess;
  73947. blurSteps: Array<PostProcess>;
  73948. };
  73949. /**
  73950. * Parameters to perform the merge of bloom effect
  73951. */
  73952. bloom?: {
  73953. blurred: PostProcess;
  73954. weight: number;
  73955. };
  73956. }
  73957. /**
  73958. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73959. */
  73960. export class DepthOfFieldMergePostProcess extends PostProcess {
  73961. private blurSteps;
  73962. /**
  73963. * Gets a string identifying the name of the class
  73964. * @returns "DepthOfFieldMergePostProcess" string
  73965. */
  73966. getClassName(): string;
  73967. /**
  73968. * Creates a new instance of DepthOfFieldMergePostProcess
  73969. * @param name The name of the effect.
  73970. * @param originalFromInput Post process which's input will be used for the merge.
  73971. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73972. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73973. * @param options The required width/height ratio to downsize to before computing the render pass.
  73974. * @param camera The camera to apply the render pass to.
  73975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73976. * @param engine The engine which the post process will be applied. (default: current engine)
  73977. * @param reusable If the post process can be reused on the same frame. (default: false)
  73978. * @param textureType Type of textures used when performing the post process. (default: 0)
  73979. * @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)
  73980. */
  73981. 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);
  73982. /**
  73983. * Updates the effect with the current post process compile time values and recompiles the shader.
  73984. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73985. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73986. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73987. * @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
  73988. * @param onCompiled Called when the shader has been compiled.
  73989. * @param onError Called if there is an error when compiling a shader.
  73990. */
  73991. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73992. }
  73993. }
  73994. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73995. import { Nullable } from "babylonjs/types";
  73996. import { Camera } from "babylonjs/Cameras/camera";
  73997. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73998. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73999. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74000. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74001. import { Scene } from "babylonjs/scene";
  74002. /**
  74003. * Specifies the level of max blur that should be applied when using the depth of field effect
  74004. */
  74005. export enum DepthOfFieldEffectBlurLevel {
  74006. /**
  74007. * Subtle blur
  74008. */
  74009. Low = 0,
  74010. /**
  74011. * Medium blur
  74012. */
  74013. Medium = 1,
  74014. /**
  74015. * Large blur
  74016. */
  74017. High = 2
  74018. }
  74019. /**
  74020. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74021. */
  74022. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74023. private _circleOfConfusion;
  74024. /**
  74025. * @hidden Internal, blurs from high to low
  74026. */
  74027. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74028. private _depthOfFieldBlurY;
  74029. private _dofMerge;
  74030. /**
  74031. * @hidden Internal post processes in depth of field effect
  74032. */
  74033. _effects: Array<PostProcess>;
  74034. /**
  74035. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74036. */
  74037. set focalLength(value: number);
  74038. get focalLength(): number;
  74039. /**
  74040. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74041. */
  74042. set fStop(value: number);
  74043. get fStop(): number;
  74044. /**
  74045. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74046. */
  74047. set focusDistance(value: number);
  74048. get focusDistance(): number;
  74049. /**
  74050. * 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.
  74051. */
  74052. set lensSize(value: number);
  74053. get lensSize(): number;
  74054. /**
  74055. * Creates a new instance DepthOfFieldEffect
  74056. * @param scene The scene the effect belongs to.
  74057. * @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.
  74058. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74059. * @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)
  74060. */
  74061. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74062. /**
  74063. * Get the current class name of the current effet
  74064. * @returns "DepthOfFieldEffect"
  74065. */
  74066. getClassName(): string;
  74067. /**
  74068. * 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.
  74069. */
  74070. set depthTexture(value: RenderTargetTexture);
  74071. /**
  74072. * Disposes each of the internal effects for a given camera.
  74073. * @param camera The camera to dispose the effect on.
  74074. */
  74075. disposeEffects(camera: Camera): void;
  74076. /**
  74077. * @hidden Internal
  74078. */
  74079. _updateEffects(): void;
  74080. /**
  74081. * Internal
  74082. * @returns if all the contained post processes are ready.
  74083. * @hidden
  74084. */
  74085. _isReady(): boolean;
  74086. }
  74087. }
  74088. declare module "babylonjs/Shaders/displayPass.fragment" {
  74089. /** @hidden */
  74090. export var displayPassPixelShader: {
  74091. name: string;
  74092. shader: string;
  74093. };
  74094. }
  74095. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74096. import { Nullable } from "babylonjs/types";
  74097. import { Camera } from "babylonjs/Cameras/camera";
  74098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74099. import { Engine } from "babylonjs/Engines/engine";
  74100. import "babylonjs/Shaders/displayPass.fragment";
  74101. import { Scene } from "babylonjs/scene";
  74102. /**
  74103. * DisplayPassPostProcess which produces an output the same as it's input
  74104. */
  74105. export class DisplayPassPostProcess extends PostProcess {
  74106. /**
  74107. * Gets a string identifying the name of the class
  74108. * @returns "DisplayPassPostProcess" string
  74109. */
  74110. getClassName(): string;
  74111. /**
  74112. * Creates the DisplayPassPostProcess
  74113. * @param name The name of the effect.
  74114. * @param options The required width/height ratio to downsize to before computing the render pass.
  74115. * @param camera The camera to apply the render pass to.
  74116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74117. * @param engine The engine which the post process will be applied. (default: current engine)
  74118. * @param reusable If the post process can be reused on the same frame. (default: false)
  74119. */
  74120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74121. /** @hidden */
  74122. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74123. }
  74124. }
  74125. declare module "babylonjs/Shaders/filter.fragment" {
  74126. /** @hidden */
  74127. export var filterPixelShader: {
  74128. name: string;
  74129. shader: string;
  74130. };
  74131. }
  74132. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74133. import { Nullable } from "babylonjs/types";
  74134. import { Matrix } from "babylonjs/Maths/math.vector";
  74135. import { Camera } from "babylonjs/Cameras/camera";
  74136. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74137. import { Engine } from "babylonjs/Engines/engine";
  74138. import "babylonjs/Shaders/filter.fragment";
  74139. import { Scene } from "babylonjs/scene";
  74140. /**
  74141. * Applies a kernel filter to the image
  74142. */
  74143. export class FilterPostProcess extends PostProcess {
  74144. /** The matrix to be applied to the image */
  74145. kernelMatrix: Matrix;
  74146. /**
  74147. * Gets a string identifying the name of the class
  74148. * @returns "FilterPostProcess" string
  74149. */
  74150. getClassName(): string;
  74151. /**
  74152. *
  74153. * @param name The name of the effect.
  74154. * @param kernelMatrix The matrix to be applied to the image
  74155. * @param options The required width/height ratio to downsize to before computing the render pass.
  74156. * @param camera The camera to apply the render pass to.
  74157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74158. * @param engine The engine which the post process will be applied. (default: current engine)
  74159. * @param reusable If the post process can be reused on the same frame. (default: false)
  74160. */
  74161. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74162. /** @hidden */
  74163. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74164. }
  74165. }
  74166. declare module "babylonjs/Shaders/fxaa.fragment" {
  74167. /** @hidden */
  74168. export var fxaaPixelShader: {
  74169. name: string;
  74170. shader: string;
  74171. };
  74172. }
  74173. declare module "babylonjs/Shaders/fxaa.vertex" {
  74174. /** @hidden */
  74175. export var fxaaVertexShader: {
  74176. name: string;
  74177. shader: string;
  74178. };
  74179. }
  74180. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74181. import { Nullable } from "babylonjs/types";
  74182. import { Camera } from "babylonjs/Cameras/camera";
  74183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74184. import { Engine } from "babylonjs/Engines/engine";
  74185. import "babylonjs/Shaders/fxaa.fragment";
  74186. import "babylonjs/Shaders/fxaa.vertex";
  74187. import { Scene } from "babylonjs/scene";
  74188. /**
  74189. * Fxaa post process
  74190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74191. */
  74192. export class FxaaPostProcess extends PostProcess {
  74193. /**
  74194. * Gets a string identifying the name of the class
  74195. * @returns "FxaaPostProcess" string
  74196. */
  74197. getClassName(): string;
  74198. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74199. private _getDefines;
  74200. /** @hidden */
  74201. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74202. }
  74203. }
  74204. declare module "babylonjs/Shaders/grain.fragment" {
  74205. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74206. /** @hidden */
  74207. export var grainPixelShader: {
  74208. name: string;
  74209. shader: string;
  74210. };
  74211. }
  74212. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74213. import { Nullable } from "babylonjs/types";
  74214. import { Camera } from "babylonjs/Cameras/camera";
  74215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74216. import { Engine } from "babylonjs/Engines/engine";
  74217. import "babylonjs/Shaders/grain.fragment";
  74218. import { Scene } from "babylonjs/scene";
  74219. /**
  74220. * The GrainPostProcess adds noise to the image at mid luminance levels
  74221. */
  74222. export class GrainPostProcess extends PostProcess {
  74223. /**
  74224. * The intensity of the grain added (default: 30)
  74225. */
  74226. intensity: number;
  74227. /**
  74228. * If the grain should be randomized on every frame
  74229. */
  74230. animated: boolean;
  74231. /**
  74232. * Gets a string identifying the name of the class
  74233. * @returns "GrainPostProcess" string
  74234. */
  74235. getClassName(): string;
  74236. /**
  74237. * Creates a new instance of @see GrainPostProcess
  74238. * @param name The name of the effect.
  74239. * @param options The required width/height ratio to downsize to before computing the render pass.
  74240. * @param camera The camera to apply the render pass to.
  74241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74242. * @param engine The engine which the post process will be applied. (default: current engine)
  74243. * @param reusable If the post process can be reused on the same frame. (default: false)
  74244. * @param textureType Type of textures used when performing the post process. (default: 0)
  74245. * @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)
  74246. */
  74247. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74248. /** @hidden */
  74249. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74250. }
  74251. }
  74252. declare module "babylonjs/Shaders/highlights.fragment" {
  74253. /** @hidden */
  74254. export var highlightsPixelShader: {
  74255. name: string;
  74256. shader: string;
  74257. };
  74258. }
  74259. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74260. import { Nullable } from "babylonjs/types";
  74261. import { Camera } from "babylonjs/Cameras/camera";
  74262. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74263. import { Engine } from "babylonjs/Engines/engine";
  74264. import "babylonjs/Shaders/highlights.fragment";
  74265. /**
  74266. * Extracts highlights from the image
  74267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74268. */
  74269. export class HighlightsPostProcess extends PostProcess {
  74270. /**
  74271. * Gets a string identifying the name of the class
  74272. * @returns "HighlightsPostProcess" string
  74273. */
  74274. getClassName(): string;
  74275. /**
  74276. * Extracts highlights from the image
  74277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74278. * @param name The name of the effect.
  74279. * @param options The required width/height ratio to downsize to before computing the render pass.
  74280. * @param camera The camera to apply the render pass to.
  74281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74282. * @param engine The engine which the post process will be applied. (default: current engine)
  74283. * @param reusable If the post process can be reused on the same frame. (default: false)
  74284. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74285. */
  74286. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74287. }
  74288. }
  74289. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74290. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74291. /**
  74292. * Contains all parameters needed for the prepass to perform
  74293. * motion blur
  74294. */
  74295. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74296. /**
  74297. * Is motion blur enabled
  74298. */
  74299. enabled: boolean;
  74300. /**
  74301. * Name of the configuration
  74302. */
  74303. name: string;
  74304. /**
  74305. * Textures that should be present in the MRT for this effect to work
  74306. */
  74307. readonly texturesRequired: number[];
  74308. }
  74309. }
  74310. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74311. import { Nullable } from "babylonjs/types";
  74312. import { Scene } from "babylonjs/scene";
  74313. import { ISceneComponent } from "babylonjs/sceneComponent";
  74314. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74315. module "babylonjs/scene" {
  74316. interface Scene {
  74317. /** @hidden (Backing field) */
  74318. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74319. /**
  74320. * Gets or Sets the current geometry buffer associated to the scene.
  74321. */
  74322. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74323. /**
  74324. * Enables a GeometryBufferRender and associates it with the scene
  74325. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74326. * @returns the GeometryBufferRenderer
  74327. */
  74328. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74329. /**
  74330. * Disables the GeometryBufferRender associated with the scene
  74331. */
  74332. disableGeometryBufferRenderer(): void;
  74333. }
  74334. }
  74335. /**
  74336. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74337. * in several rendering techniques.
  74338. */
  74339. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74340. /**
  74341. * The component name helpful to identify the component in the list of scene components.
  74342. */
  74343. readonly name: string;
  74344. /**
  74345. * The scene the component belongs to.
  74346. */
  74347. scene: Scene;
  74348. /**
  74349. * Creates a new instance of the component for the given scene
  74350. * @param scene Defines the scene to register the component in
  74351. */
  74352. constructor(scene: Scene);
  74353. /**
  74354. * Registers the component in a given scene
  74355. */
  74356. register(): void;
  74357. /**
  74358. * Rebuilds the elements related to this component in case of
  74359. * context lost for instance.
  74360. */
  74361. rebuild(): void;
  74362. /**
  74363. * Disposes the component and the associated ressources
  74364. */
  74365. dispose(): void;
  74366. private _gatherRenderTargets;
  74367. }
  74368. }
  74369. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74370. /** @hidden */
  74371. export var motionBlurPixelShader: {
  74372. name: string;
  74373. shader: string;
  74374. };
  74375. }
  74376. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74377. import { Nullable } from "babylonjs/types";
  74378. import { Camera } from "babylonjs/Cameras/camera";
  74379. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74381. import "babylonjs/Animations/animatable";
  74382. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74383. import "babylonjs/Shaders/motionBlur.fragment";
  74384. import { Engine } from "babylonjs/Engines/engine";
  74385. import { Scene } from "babylonjs/scene";
  74386. /**
  74387. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74388. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74389. * As an example, all you have to do is to create the post-process:
  74390. * var mb = new BABYLON.MotionBlurPostProcess(
  74391. * 'mb', // The name of the effect.
  74392. * scene, // The scene containing the objects to blur according to their velocity.
  74393. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74394. * camera // The camera to apply the render pass to.
  74395. * );
  74396. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74397. */
  74398. export class MotionBlurPostProcess extends PostProcess {
  74399. /**
  74400. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74401. */
  74402. motionStrength: number;
  74403. /**
  74404. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74405. */
  74406. get motionBlurSamples(): number;
  74407. /**
  74408. * Sets the number of iterations to be used for motion blur quality
  74409. */
  74410. set motionBlurSamples(samples: number);
  74411. private _motionBlurSamples;
  74412. private _forceGeometryBuffer;
  74413. private _geometryBufferRenderer;
  74414. private _prePassRenderer;
  74415. /**
  74416. * Gets a string identifying the name of the class
  74417. * @returns "MotionBlurPostProcess" string
  74418. */
  74419. getClassName(): string;
  74420. /**
  74421. * Creates a new instance MotionBlurPostProcess
  74422. * @param name The name of the effect.
  74423. * @param scene The scene containing the objects to blur according to their velocity.
  74424. * @param options The required width/height ratio to downsize to before computing the render pass.
  74425. * @param camera The camera to apply the render pass to.
  74426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74427. * @param engine The engine which the post process will be applied. (default: current engine)
  74428. * @param reusable If the post process can be reused on the same frame. (default: false)
  74429. * @param textureType Type of textures used when performing the post process. (default: 0)
  74430. * @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)
  74431. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74432. */
  74433. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74434. /**
  74435. * Excludes the given skinned mesh from computing bones velocities.
  74436. * 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.
  74437. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74438. */
  74439. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74440. /**
  74441. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74442. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74443. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74444. */
  74445. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74446. /**
  74447. * Disposes the post process.
  74448. * @param camera The camera to dispose the post process on.
  74449. */
  74450. dispose(camera?: Camera): void;
  74451. /** @hidden */
  74452. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74453. }
  74454. }
  74455. declare module "babylonjs/Shaders/refraction.fragment" {
  74456. /** @hidden */
  74457. export var refractionPixelShader: {
  74458. name: string;
  74459. shader: string;
  74460. };
  74461. }
  74462. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74463. import { Color3 } from "babylonjs/Maths/math.color";
  74464. import { Camera } from "babylonjs/Cameras/camera";
  74465. import { Texture } from "babylonjs/Materials/Textures/texture";
  74466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74467. import { Engine } from "babylonjs/Engines/engine";
  74468. import "babylonjs/Shaders/refraction.fragment";
  74469. import { Scene } from "babylonjs/scene";
  74470. /**
  74471. * Post process which applies a refractin texture
  74472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74473. */
  74474. export class RefractionPostProcess extends PostProcess {
  74475. private _refTexture;
  74476. private _ownRefractionTexture;
  74477. /** the base color of the refraction (used to taint the rendering) */
  74478. color: Color3;
  74479. /** simulated refraction depth */
  74480. depth: number;
  74481. /** the coefficient of the base color (0 to remove base color tainting) */
  74482. colorLevel: number;
  74483. /** Gets the url used to load the refraction texture */
  74484. refractionTextureUrl: string;
  74485. /**
  74486. * Gets or sets the refraction texture
  74487. * Please note that you are responsible for disposing the texture if you set it manually
  74488. */
  74489. get refractionTexture(): Texture;
  74490. set refractionTexture(value: Texture);
  74491. /**
  74492. * Gets a string identifying the name of the class
  74493. * @returns "RefractionPostProcess" string
  74494. */
  74495. getClassName(): string;
  74496. /**
  74497. * Initializes the RefractionPostProcess
  74498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74499. * @param name The name of the effect.
  74500. * @param refractionTextureUrl Url of the refraction texture to use
  74501. * @param color the base color of the refraction (used to taint the rendering)
  74502. * @param depth simulated refraction depth
  74503. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74504. * @param camera The camera to apply the render pass to.
  74505. * @param options The required width/height ratio to downsize to before computing the render pass.
  74506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74507. * @param engine The engine which the post process will be applied. (default: current engine)
  74508. * @param reusable If the post process can be reused on the same frame. (default: false)
  74509. */
  74510. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74511. /**
  74512. * Disposes of the post process
  74513. * @param camera Camera to dispose post process on
  74514. */
  74515. dispose(camera: Camera): void;
  74516. /** @hidden */
  74517. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74518. }
  74519. }
  74520. declare module "babylonjs/Shaders/sharpen.fragment" {
  74521. /** @hidden */
  74522. export var sharpenPixelShader: {
  74523. name: string;
  74524. shader: string;
  74525. };
  74526. }
  74527. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74528. import { Nullable } from "babylonjs/types";
  74529. import { Camera } from "babylonjs/Cameras/camera";
  74530. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74531. import "babylonjs/Shaders/sharpen.fragment";
  74532. import { Engine } from "babylonjs/Engines/engine";
  74533. import { Scene } from "babylonjs/scene";
  74534. /**
  74535. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74536. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74537. */
  74538. export class SharpenPostProcess extends PostProcess {
  74539. /**
  74540. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74541. */
  74542. colorAmount: number;
  74543. /**
  74544. * How much sharpness should be applied (default: 0.3)
  74545. */
  74546. edgeAmount: number;
  74547. /**
  74548. * Gets a string identifying the name of the class
  74549. * @returns "SharpenPostProcess" string
  74550. */
  74551. getClassName(): string;
  74552. /**
  74553. * Creates a new instance ConvolutionPostProcess
  74554. * @param name The name of the effect.
  74555. * @param options The required width/height ratio to downsize to before computing the render pass.
  74556. * @param camera The camera to apply the render pass to.
  74557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74558. * @param engine The engine which the post process will be applied. (default: current engine)
  74559. * @param reusable If the post process can be reused on the same frame. (default: false)
  74560. * @param textureType Type of textures used when performing the post process. (default: 0)
  74561. * @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)
  74562. */
  74563. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74564. /** @hidden */
  74565. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74566. }
  74567. }
  74568. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74569. import { Nullable } from "babylonjs/types";
  74570. import { Camera } from "babylonjs/Cameras/camera";
  74571. import { Engine } from "babylonjs/Engines/engine";
  74572. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74573. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74574. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74575. /**
  74576. * PostProcessRenderPipeline
  74577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74578. */
  74579. export class PostProcessRenderPipeline {
  74580. private engine;
  74581. private _renderEffects;
  74582. private _renderEffectsForIsolatedPass;
  74583. /**
  74584. * List of inspectable custom properties (used by the Inspector)
  74585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74586. */
  74587. inspectableCustomProperties: IInspectable[];
  74588. /**
  74589. * @hidden
  74590. */
  74591. protected _cameras: Camera[];
  74592. /** @hidden */
  74593. _name: string;
  74594. /**
  74595. * Gets pipeline name
  74596. */
  74597. get name(): string;
  74598. /** Gets the list of attached cameras */
  74599. get cameras(): Camera[];
  74600. /**
  74601. * Initializes a PostProcessRenderPipeline
  74602. * @param engine engine to add the pipeline to
  74603. * @param name name of the pipeline
  74604. */
  74605. constructor(engine: Engine, name: string);
  74606. /**
  74607. * Gets the class name
  74608. * @returns "PostProcessRenderPipeline"
  74609. */
  74610. getClassName(): string;
  74611. /**
  74612. * If all the render effects in the pipeline are supported
  74613. */
  74614. get isSupported(): boolean;
  74615. /**
  74616. * Adds an effect to the pipeline
  74617. * @param renderEffect the effect to add
  74618. */
  74619. addEffect(renderEffect: PostProcessRenderEffect): void;
  74620. /** @hidden */
  74621. _rebuild(): void;
  74622. /** @hidden */
  74623. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74624. /** @hidden */
  74625. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74626. /** @hidden */
  74627. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74628. /** @hidden */
  74629. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74630. /** @hidden */
  74631. _attachCameras(cameras: Camera, unique: boolean): void;
  74632. /** @hidden */
  74633. _attachCameras(cameras: Camera[], unique: boolean): void;
  74634. /** @hidden */
  74635. _detachCameras(cameras: Camera): void;
  74636. /** @hidden */
  74637. _detachCameras(cameras: Nullable<Camera[]>): void;
  74638. /** @hidden */
  74639. _update(): void;
  74640. /** @hidden */
  74641. _reset(): void;
  74642. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74643. /**
  74644. * Sets the required values to the prepass renderer.
  74645. * @param prePassRenderer defines the prepass renderer to setup.
  74646. * @returns true if the pre pass is needed.
  74647. */
  74648. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74649. /**
  74650. * Disposes of the pipeline
  74651. */
  74652. dispose(): void;
  74653. }
  74654. }
  74655. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74656. import { Camera } from "babylonjs/Cameras/camera";
  74657. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74658. /**
  74659. * PostProcessRenderPipelineManager class
  74660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74661. */
  74662. export class PostProcessRenderPipelineManager {
  74663. private _renderPipelines;
  74664. /**
  74665. * Initializes a PostProcessRenderPipelineManager
  74666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74667. */
  74668. constructor();
  74669. /**
  74670. * Gets the list of supported render pipelines
  74671. */
  74672. get supportedPipelines(): PostProcessRenderPipeline[];
  74673. /**
  74674. * Adds a pipeline to the manager
  74675. * @param renderPipeline The pipeline to add
  74676. */
  74677. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74678. /**
  74679. * Attaches a camera to the pipeline
  74680. * @param renderPipelineName The name of the pipeline to attach to
  74681. * @param cameras the camera to attach
  74682. * @param unique if the camera can be attached multiple times to the pipeline
  74683. */
  74684. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74685. /**
  74686. * Detaches a camera from the pipeline
  74687. * @param renderPipelineName The name of the pipeline to detach from
  74688. * @param cameras the camera to detach
  74689. */
  74690. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74691. /**
  74692. * Enables an effect by name on a pipeline
  74693. * @param renderPipelineName the name of the pipeline to enable the effect in
  74694. * @param renderEffectName the name of the effect to enable
  74695. * @param cameras the cameras that the effect should be enabled on
  74696. */
  74697. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74698. /**
  74699. * Disables an effect by name on a pipeline
  74700. * @param renderPipelineName the name of the pipeline to disable the effect in
  74701. * @param renderEffectName the name of the effect to disable
  74702. * @param cameras the cameras that the effect should be disabled on
  74703. */
  74704. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74705. /**
  74706. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74707. */
  74708. update(): void;
  74709. /** @hidden */
  74710. _rebuild(): void;
  74711. /**
  74712. * Disposes of the manager and pipelines
  74713. */
  74714. dispose(): void;
  74715. }
  74716. }
  74717. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74718. import { ISceneComponent } from "babylonjs/sceneComponent";
  74719. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74720. import { Scene } from "babylonjs/scene";
  74721. module "babylonjs/scene" {
  74722. interface Scene {
  74723. /** @hidden (Backing field) */
  74724. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74725. /**
  74726. * Gets the postprocess render pipeline manager
  74727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74728. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74729. */
  74730. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74731. }
  74732. }
  74733. /**
  74734. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74735. */
  74736. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74737. /**
  74738. * The component name helpfull to identify the component in the list of scene components.
  74739. */
  74740. readonly name: string;
  74741. /**
  74742. * The scene the component belongs to.
  74743. */
  74744. scene: Scene;
  74745. /**
  74746. * Creates a new instance of the component for the given scene
  74747. * @param scene Defines the scene to register the component in
  74748. */
  74749. constructor(scene: Scene);
  74750. /**
  74751. * Registers the component in a given scene
  74752. */
  74753. register(): void;
  74754. /**
  74755. * Rebuilds the elements related to this component in case of
  74756. * context lost for instance.
  74757. */
  74758. rebuild(): void;
  74759. /**
  74760. * Disposes the component and the associated ressources
  74761. */
  74762. dispose(): void;
  74763. private _gatherRenderTargets;
  74764. }
  74765. }
  74766. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74767. import { Nullable } from "babylonjs/types";
  74768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74769. import { Camera } from "babylonjs/Cameras/camera";
  74770. import { IDisposable } from "babylonjs/scene";
  74771. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74772. import { Scene } from "babylonjs/scene";
  74773. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74774. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74775. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74776. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74777. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74778. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74779. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74780. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74781. import { Animation } from "babylonjs/Animations/animation";
  74782. /**
  74783. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74784. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74785. */
  74786. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74787. private _scene;
  74788. private _camerasToBeAttached;
  74789. /**
  74790. * ID of the sharpen post process,
  74791. */
  74792. private readonly SharpenPostProcessId;
  74793. /**
  74794. * @ignore
  74795. * ID of the image processing post process;
  74796. */
  74797. readonly ImageProcessingPostProcessId: string;
  74798. /**
  74799. * @ignore
  74800. * ID of the Fast Approximate Anti-Aliasing post process;
  74801. */
  74802. readonly FxaaPostProcessId: string;
  74803. /**
  74804. * ID of the chromatic aberration post process,
  74805. */
  74806. private readonly ChromaticAberrationPostProcessId;
  74807. /**
  74808. * ID of the grain post process
  74809. */
  74810. private readonly GrainPostProcessId;
  74811. /**
  74812. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74813. */
  74814. sharpen: SharpenPostProcess;
  74815. private _sharpenEffect;
  74816. private bloom;
  74817. /**
  74818. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74819. */
  74820. depthOfField: DepthOfFieldEffect;
  74821. /**
  74822. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74823. */
  74824. fxaa: FxaaPostProcess;
  74825. /**
  74826. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74827. */
  74828. imageProcessing: ImageProcessingPostProcess;
  74829. /**
  74830. * Chromatic aberration post process which will shift rgb colors in the image
  74831. */
  74832. chromaticAberration: ChromaticAberrationPostProcess;
  74833. private _chromaticAberrationEffect;
  74834. /**
  74835. * Grain post process which add noise to the image
  74836. */
  74837. grain: GrainPostProcess;
  74838. private _grainEffect;
  74839. /**
  74840. * Glow post process which adds a glow to emissive areas of the image
  74841. */
  74842. private _glowLayer;
  74843. /**
  74844. * Animations which can be used to tweak settings over a period of time
  74845. */
  74846. animations: Animation[];
  74847. private _imageProcessingConfigurationObserver;
  74848. private _sharpenEnabled;
  74849. private _bloomEnabled;
  74850. private _depthOfFieldEnabled;
  74851. private _depthOfFieldBlurLevel;
  74852. private _fxaaEnabled;
  74853. private _imageProcessingEnabled;
  74854. private _defaultPipelineTextureType;
  74855. private _bloomScale;
  74856. private _chromaticAberrationEnabled;
  74857. private _grainEnabled;
  74858. private _buildAllowed;
  74859. /**
  74860. * Gets active scene
  74861. */
  74862. get scene(): Scene;
  74863. /**
  74864. * Enable or disable the sharpen process from the pipeline
  74865. */
  74866. set sharpenEnabled(enabled: boolean);
  74867. get sharpenEnabled(): boolean;
  74868. private _resizeObserver;
  74869. private _hardwareScaleLevel;
  74870. private _bloomKernel;
  74871. /**
  74872. * Specifies the size of the bloom blur kernel, relative to the final output size
  74873. */
  74874. get bloomKernel(): number;
  74875. set bloomKernel(value: number);
  74876. /**
  74877. * Specifies the weight of the bloom in the final rendering
  74878. */
  74879. private _bloomWeight;
  74880. /**
  74881. * Specifies the luma threshold for the area that will be blurred by the bloom
  74882. */
  74883. private _bloomThreshold;
  74884. private _hdr;
  74885. /**
  74886. * The strength of the bloom.
  74887. */
  74888. set bloomWeight(value: number);
  74889. get bloomWeight(): number;
  74890. /**
  74891. * The strength of the bloom.
  74892. */
  74893. set bloomThreshold(value: number);
  74894. get bloomThreshold(): number;
  74895. /**
  74896. * The scale of the bloom, lower value will provide better performance.
  74897. */
  74898. set bloomScale(value: number);
  74899. get bloomScale(): number;
  74900. /**
  74901. * Enable or disable the bloom from the pipeline
  74902. */
  74903. set bloomEnabled(enabled: boolean);
  74904. get bloomEnabled(): boolean;
  74905. private _rebuildBloom;
  74906. /**
  74907. * If the depth of field is enabled.
  74908. */
  74909. get depthOfFieldEnabled(): boolean;
  74910. set depthOfFieldEnabled(enabled: boolean);
  74911. /**
  74912. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74913. */
  74914. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74915. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74916. /**
  74917. * If the anti aliasing is enabled.
  74918. */
  74919. set fxaaEnabled(enabled: boolean);
  74920. get fxaaEnabled(): boolean;
  74921. private _samples;
  74922. /**
  74923. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74924. */
  74925. set samples(sampleCount: number);
  74926. get samples(): number;
  74927. /**
  74928. * If image processing is enabled.
  74929. */
  74930. set imageProcessingEnabled(enabled: boolean);
  74931. get imageProcessingEnabled(): boolean;
  74932. /**
  74933. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74934. */
  74935. set glowLayerEnabled(enabled: boolean);
  74936. get glowLayerEnabled(): boolean;
  74937. /**
  74938. * Gets the glow layer (or null if not defined)
  74939. */
  74940. get glowLayer(): Nullable<GlowLayer>;
  74941. /**
  74942. * Enable or disable the chromaticAberration process from the pipeline
  74943. */
  74944. set chromaticAberrationEnabled(enabled: boolean);
  74945. get chromaticAberrationEnabled(): boolean;
  74946. /**
  74947. * Enable or disable the grain process from the pipeline
  74948. */
  74949. set grainEnabled(enabled: boolean);
  74950. get grainEnabled(): boolean;
  74951. /**
  74952. * @constructor
  74953. * @param name - The rendering pipeline name (default: "")
  74954. * @param hdr - If high dynamic range textures should be used (default: true)
  74955. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74956. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74957. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74958. */
  74959. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74960. /**
  74961. * Get the class name
  74962. * @returns "DefaultRenderingPipeline"
  74963. */
  74964. getClassName(): string;
  74965. /**
  74966. * Force the compilation of the entire pipeline.
  74967. */
  74968. prepare(): void;
  74969. private _hasCleared;
  74970. private _prevPostProcess;
  74971. private _prevPrevPostProcess;
  74972. private _setAutoClearAndTextureSharing;
  74973. private _depthOfFieldSceneObserver;
  74974. private _buildPipeline;
  74975. private _disposePostProcesses;
  74976. /**
  74977. * Adds a camera to the pipeline
  74978. * @param camera the camera to be added
  74979. */
  74980. addCamera(camera: Camera): void;
  74981. /**
  74982. * Removes a camera from the pipeline
  74983. * @param camera the camera to remove
  74984. */
  74985. removeCamera(camera: Camera): void;
  74986. /**
  74987. * Dispose of the pipeline and stop all post processes
  74988. */
  74989. dispose(): void;
  74990. /**
  74991. * Serialize the rendering pipeline (Used when exporting)
  74992. * @returns the serialized object
  74993. */
  74994. serialize(): any;
  74995. /**
  74996. * Parse the serialized pipeline
  74997. * @param source Source pipeline.
  74998. * @param scene The scene to load the pipeline to.
  74999. * @param rootUrl The URL of the serialized pipeline.
  75000. * @returns An instantiated pipeline from the serialized object.
  75001. */
  75002. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75003. }
  75004. }
  75005. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75006. /** @hidden */
  75007. export var lensHighlightsPixelShader: {
  75008. name: string;
  75009. shader: string;
  75010. };
  75011. }
  75012. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75013. /** @hidden */
  75014. export var depthOfFieldPixelShader: {
  75015. name: string;
  75016. shader: string;
  75017. };
  75018. }
  75019. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75020. import { Camera } from "babylonjs/Cameras/camera";
  75021. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75022. import { Scene } from "babylonjs/scene";
  75023. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75024. import "babylonjs/Shaders/chromaticAberration.fragment";
  75025. import "babylonjs/Shaders/lensHighlights.fragment";
  75026. import "babylonjs/Shaders/depthOfField.fragment";
  75027. /**
  75028. * BABYLON.JS Chromatic Aberration GLSL Shader
  75029. * Author: Olivier Guyot
  75030. * Separates very slightly R, G and B colors on the edges of the screen
  75031. * Inspired by Francois Tarlier & Martins Upitis
  75032. */
  75033. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75034. /**
  75035. * @ignore
  75036. * The chromatic aberration PostProcess id in the pipeline
  75037. */
  75038. LensChromaticAberrationEffect: string;
  75039. /**
  75040. * @ignore
  75041. * The highlights enhancing PostProcess id in the pipeline
  75042. */
  75043. HighlightsEnhancingEffect: string;
  75044. /**
  75045. * @ignore
  75046. * The depth-of-field PostProcess id in the pipeline
  75047. */
  75048. LensDepthOfFieldEffect: string;
  75049. private _scene;
  75050. private _depthTexture;
  75051. private _grainTexture;
  75052. private _chromaticAberrationPostProcess;
  75053. private _highlightsPostProcess;
  75054. private _depthOfFieldPostProcess;
  75055. private _edgeBlur;
  75056. private _grainAmount;
  75057. private _chromaticAberration;
  75058. private _distortion;
  75059. private _highlightsGain;
  75060. private _highlightsThreshold;
  75061. private _dofDistance;
  75062. private _dofAperture;
  75063. private _dofDarken;
  75064. private _dofPentagon;
  75065. private _blurNoise;
  75066. /**
  75067. * @constructor
  75068. *
  75069. * Effect parameters are as follow:
  75070. * {
  75071. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75072. * edge_blur: number; // from 0 to x (1 for realism)
  75073. * distortion: number; // from 0 to x (1 for realism)
  75074. * grain_amount: number; // from 0 to 1
  75075. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75076. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75077. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75078. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75079. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75080. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75081. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75082. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75083. * }
  75084. * Note: if an effect parameter is unset, effect is disabled
  75085. *
  75086. * @param name The rendering pipeline name
  75087. * @param parameters - An object containing all parameters (see above)
  75088. * @param scene The scene linked to this pipeline
  75089. * @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)
  75090. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75091. */
  75092. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75093. /**
  75094. * Get the class name
  75095. * @returns "LensRenderingPipeline"
  75096. */
  75097. getClassName(): string;
  75098. /**
  75099. * Gets associated scene
  75100. */
  75101. get scene(): Scene;
  75102. /**
  75103. * Gets or sets the edge blur
  75104. */
  75105. get edgeBlur(): number;
  75106. set edgeBlur(value: number);
  75107. /**
  75108. * Gets or sets the grain amount
  75109. */
  75110. get grainAmount(): number;
  75111. set grainAmount(value: number);
  75112. /**
  75113. * Gets or sets the chromatic aberration amount
  75114. */
  75115. get chromaticAberration(): number;
  75116. set chromaticAberration(value: number);
  75117. /**
  75118. * Gets or sets the depth of field aperture
  75119. */
  75120. get dofAperture(): number;
  75121. set dofAperture(value: number);
  75122. /**
  75123. * Gets or sets the edge distortion
  75124. */
  75125. get edgeDistortion(): number;
  75126. set edgeDistortion(value: number);
  75127. /**
  75128. * Gets or sets the depth of field distortion
  75129. */
  75130. get dofDistortion(): number;
  75131. set dofDistortion(value: number);
  75132. /**
  75133. * Gets or sets the darken out of focus amount
  75134. */
  75135. get darkenOutOfFocus(): number;
  75136. set darkenOutOfFocus(value: number);
  75137. /**
  75138. * Gets or sets a boolean indicating if blur noise is enabled
  75139. */
  75140. get blurNoise(): boolean;
  75141. set blurNoise(value: boolean);
  75142. /**
  75143. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75144. */
  75145. get pentagonBokeh(): boolean;
  75146. set pentagonBokeh(value: boolean);
  75147. /**
  75148. * Gets or sets the highlight grain amount
  75149. */
  75150. get highlightsGain(): number;
  75151. set highlightsGain(value: number);
  75152. /**
  75153. * Gets or sets the highlight threshold
  75154. */
  75155. get highlightsThreshold(): number;
  75156. set highlightsThreshold(value: number);
  75157. /**
  75158. * Sets the amount of blur at the edges
  75159. * @param amount blur amount
  75160. */
  75161. setEdgeBlur(amount: number): void;
  75162. /**
  75163. * Sets edge blur to 0
  75164. */
  75165. disableEdgeBlur(): void;
  75166. /**
  75167. * Sets the amout of grain
  75168. * @param amount Amount of grain
  75169. */
  75170. setGrainAmount(amount: number): void;
  75171. /**
  75172. * Set grain amount to 0
  75173. */
  75174. disableGrain(): void;
  75175. /**
  75176. * Sets the chromatic aberration amount
  75177. * @param amount amount of chromatic aberration
  75178. */
  75179. setChromaticAberration(amount: number): void;
  75180. /**
  75181. * Sets chromatic aberration amount to 0
  75182. */
  75183. disableChromaticAberration(): void;
  75184. /**
  75185. * Sets the EdgeDistortion amount
  75186. * @param amount amount of EdgeDistortion
  75187. */
  75188. setEdgeDistortion(amount: number): void;
  75189. /**
  75190. * Sets edge distortion to 0
  75191. */
  75192. disableEdgeDistortion(): void;
  75193. /**
  75194. * Sets the FocusDistance amount
  75195. * @param amount amount of FocusDistance
  75196. */
  75197. setFocusDistance(amount: number): void;
  75198. /**
  75199. * Disables depth of field
  75200. */
  75201. disableDepthOfField(): void;
  75202. /**
  75203. * Sets the Aperture amount
  75204. * @param amount amount of Aperture
  75205. */
  75206. setAperture(amount: number): void;
  75207. /**
  75208. * Sets the DarkenOutOfFocus amount
  75209. * @param amount amount of DarkenOutOfFocus
  75210. */
  75211. setDarkenOutOfFocus(amount: number): void;
  75212. private _pentagonBokehIsEnabled;
  75213. /**
  75214. * Creates a pentagon bokeh effect
  75215. */
  75216. enablePentagonBokeh(): void;
  75217. /**
  75218. * Disables the pentagon bokeh effect
  75219. */
  75220. disablePentagonBokeh(): void;
  75221. /**
  75222. * Enables noise blur
  75223. */
  75224. enableNoiseBlur(): void;
  75225. /**
  75226. * Disables noise blur
  75227. */
  75228. disableNoiseBlur(): void;
  75229. /**
  75230. * Sets the HighlightsGain amount
  75231. * @param amount amount of HighlightsGain
  75232. */
  75233. setHighlightsGain(amount: number): void;
  75234. /**
  75235. * Sets the HighlightsThreshold amount
  75236. * @param amount amount of HighlightsThreshold
  75237. */
  75238. setHighlightsThreshold(amount: number): void;
  75239. /**
  75240. * Disables highlights
  75241. */
  75242. disableHighlights(): void;
  75243. /**
  75244. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75245. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75246. */
  75247. dispose(disableDepthRender?: boolean): void;
  75248. private _createChromaticAberrationPostProcess;
  75249. private _createHighlightsPostProcess;
  75250. private _createDepthOfFieldPostProcess;
  75251. private _createGrainTexture;
  75252. }
  75253. }
  75254. declare module "babylonjs/Rendering/ssao2Configuration" {
  75255. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75256. /**
  75257. * Contains all parameters needed for the prepass to perform
  75258. * screen space subsurface scattering
  75259. */
  75260. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75261. /**
  75262. * Is subsurface enabled
  75263. */
  75264. enabled: boolean;
  75265. /**
  75266. * Name of the configuration
  75267. */
  75268. name: string;
  75269. /**
  75270. * Textures that should be present in the MRT for this effect to work
  75271. */
  75272. readonly texturesRequired: number[];
  75273. }
  75274. }
  75275. declare module "babylonjs/Shaders/ssao2.fragment" {
  75276. /** @hidden */
  75277. export var ssao2PixelShader: {
  75278. name: string;
  75279. shader: string;
  75280. };
  75281. }
  75282. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75283. /** @hidden */
  75284. export var ssaoCombinePixelShader: {
  75285. name: string;
  75286. shader: string;
  75287. };
  75288. }
  75289. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75290. import { Camera } from "babylonjs/Cameras/camera";
  75291. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75292. import { Scene } from "babylonjs/scene";
  75293. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75294. import "babylonjs/Shaders/ssao2.fragment";
  75295. import "babylonjs/Shaders/ssaoCombine.fragment";
  75296. /**
  75297. * Render pipeline to produce ssao effect
  75298. */
  75299. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75300. /**
  75301. * @ignore
  75302. * The PassPostProcess id in the pipeline that contains the original scene color
  75303. */
  75304. SSAOOriginalSceneColorEffect: string;
  75305. /**
  75306. * @ignore
  75307. * The SSAO PostProcess id in the pipeline
  75308. */
  75309. SSAORenderEffect: string;
  75310. /**
  75311. * @ignore
  75312. * The horizontal blur PostProcess id in the pipeline
  75313. */
  75314. SSAOBlurHRenderEffect: string;
  75315. /**
  75316. * @ignore
  75317. * The vertical blur PostProcess id in the pipeline
  75318. */
  75319. SSAOBlurVRenderEffect: string;
  75320. /**
  75321. * @ignore
  75322. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75323. */
  75324. SSAOCombineRenderEffect: string;
  75325. /**
  75326. * The output strength of the SSAO post-process. Default value is 1.0.
  75327. */
  75328. totalStrength: number;
  75329. /**
  75330. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75331. */
  75332. maxZ: number;
  75333. /**
  75334. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75335. */
  75336. minZAspect: number;
  75337. private _samples;
  75338. /**
  75339. * Number of samples used for the SSAO calculations. Default value is 8
  75340. */
  75341. set samples(n: number);
  75342. get samples(): number;
  75343. private _textureSamples;
  75344. /**
  75345. * Number of samples to use for antialiasing
  75346. */
  75347. set textureSamples(n: number);
  75348. get textureSamples(): number;
  75349. /**
  75350. * Force rendering the geometry through geometry buffer
  75351. */
  75352. private _forceGeometryBuffer;
  75353. /**
  75354. * Ratio object used for SSAO ratio and blur ratio
  75355. */
  75356. private _ratio;
  75357. /**
  75358. * Dynamically generated sphere sampler.
  75359. */
  75360. private _sampleSphere;
  75361. /**
  75362. * Blur filter offsets
  75363. */
  75364. private _samplerOffsets;
  75365. private _expensiveBlur;
  75366. /**
  75367. * If bilateral blur should be used
  75368. */
  75369. set expensiveBlur(b: boolean);
  75370. get expensiveBlur(): boolean;
  75371. /**
  75372. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75373. */
  75374. radius: number;
  75375. /**
  75376. * The base color of the SSAO post-process
  75377. * The final result is "base + ssao" between [0, 1]
  75378. */
  75379. base: number;
  75380. /**
  75381. * Support test.
  75382. */
  75383. static get IsSupported(): boolean;
  75384. private _scene;
  75385. private _randomTexture;
  75386. private _originalColorPostProcess;
  75387. private _ssaoPostProcess;
  75388. private _blurHPostProcess;
  75389. private _blurVPostProcess;
  75390. private _ssaoCombinePostProcess;
  75391. private _prePassRenderer;
  75392. /**
  75393. * Gets active scene
  75394. */
  75395. get scene(): Scene;
  75396. /**
  75397. * @constructor
  75398. * @param name The rendering pipeline name
  75399. * @param scene The scene linked to this pipeline
  75400. * @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 }
  75401. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75402. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75403. */
  75404. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75405. /**
  75406. * Get the class name
  75407. * @returns "SSAO2RenderingPipeline"
  75408. */
  75409. getClassName(): string;
  75410. /**
  75411. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75412. */
  75413. dispose(disableGeometryBufferRenderer?: boolean): void;
  75414. private _createBlurPostProcess;
  75415. /** @hidden */
  75416. _rebuild(): void;
  75417. private _bits;
  75418. private _radicalInverse_VdC;
  75419. private _hammersley;
  75420. private _hemisphereSample_uniform;
  75421. private _generateHemisphere;
  75422. private _getDefinesForSSAO;
  75423. private _createSSAOPostProcess;
  75424. private _createSSAOCombinePostProcess;
  75425. private _createRandomTexture;
  75426. /**
  75427. * Serialize the rendering pipeline (Used when exporting)
  75428. * @returns the serialized object
  75429. */
  75430. serialize(): any;
  75431. /**
  75432. * Parse the serialized pipeline
  75433. * @param source Source pipeline.
  75434. * @param scene The scene to load the pipeline to.
  75435. * @param rootUrl The URL of the serialized pipeline.
  75436. * @returns An instantiated pipeline from the serialized object.
  75437. */
  75438. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75439. }
  75440. }
  75441. declare module "babylonjs/Shaders/ssao.fragment" {
  75442. /** @hidden */
  75443. export var ssaoPixelShader: {
  75444. name: string;
  75445. shader: string;
  75446. };
  75447. }
  75448. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75449. import { Camera } from "babylonjs/Cameras/camera";
  75450. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75451. import { Scene } from "babylonjs/scene";
  75452. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75453. import "babylonjs/Shaders/ssao.fragment";
  75454. import "babylonjs/Shaders/ssaoCombine.fragment";
  75455. /**
  75456. * Render pipeline to produce ssao effect
  75457. */
  75458. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75459. /**
  75460. * @ignore
  75461. * The PassPostProcess id in the pipeline that contains the original scene color
  75462. */
  75463. SSAOOriginalSceneColorEffect: string;
  75464. /**
  75465. * @ignore
  75466. * The SSAO PostProcess id in the pipeline
  75467. */
  75468. SSAORenderEffect: string;
  75469. /**
  75470. * @ignore
  75471. * The horizontal blur PostProcess id in the pipeline
  75472. */
  75473. SSAOBlurHRenderEffect: string;
  75474. /**
  75475. * @ignore
  75476. * The vertical blur PostProcess id in the pipeline
  75477. */
  75478. SSAOBlurVRenderEffect: string;
  75479. /**
  75480. * @ignore
  75481. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75482. */
  75483. SSAOCombineRenderEffect: string;
  75484. /**
  75485. * The output strength of the SSAO post-process. Default value is 1.0.
  75486. */
  75487. totalStrength: number;
  75488. /**
  75489. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75490. */
  75491. radius: number;
  75492. /**
  75493. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75494. * Must not be equal to fallOff and superior to fallOff.
  75495. * Default value is 0.0075
  75496. */
  75497. area: number;
  75498. /**
  75499. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75500. * Must not be equal to area and inferior to area.
  75501. * Default value is 0.000001
  75502. */
  75503. fallOff: number;
  75504. /**
  75505. * The base color of the SSAO post-process
  75506. * The final result is "base + ssao" between [0, 1]
  75507. */
  75508. base: number;
  75509. private _scene;
  75510. private _depthTexture;
  75511. private _randomTexture;
  75512. private _originalColorPostProcess;
  75513. private _ssaoPostProcess;
  75514. private _blurHPostProcess;
  75515. private _blurVPostProcess;
  75516. private _ssaoCombinePostProcess;
  75517. private _firstUpdate;
  75518. /**
  75519. * Gets active scene
  75520. */
  75521. get scene(): Scene;
  75522. /**
  75523. * @constructor
  75524. * @param name - The rendering pipeline name
  75525. * @param scene - The scene linked to this pipeline
  75526. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  75527. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75528. */
  75529. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75530. /**
  75531. * Get the class name
  75532. * @returns "SSAORenderingPipeline"
  75533. */
  75534. getClassName(): string;
  75535. /**
  75536. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75537. */
  75538. dispose(disableDepthRender?: boolean): void;
  75539. private _createBlurPostProcess;
  75540. /** @hidden */
  75541. _rebuild(): void;
  75542. private _createSSAOPostProcess;
  75543. private _createSSAOCombinePostProcess;
  75544. private _createRandomTexture;
  75545. }
  75546. }
  75547. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75548. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75549. /**
  75550. * Contains all parameters needed for the prepass to perform
  75551. * screen space reflections
  75552. */
  75553. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75554. /**
  75555. * Is ssr enabled
  75556. */
  75557. enabled: boolean;
  75558. /**
  75559. * Name of the configuration
  75560. */
  75561. name: string;
  75562. /**
  75563. * Textures that should be present in the MRT for this effect to work
  75564. */
  75565. readonly texturesRequired: number[];
  75566. }
  75567. }
  75568. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75569. /** @hidden */
  75570. export var screenSpaceReflectionPixelShader: {
  75571. name: string;
  75572. shader: string;
  75573. };
  75574. }
  75575. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75576. import { Nullable } from "babylonjs/types";
  75577. import { Camera } from "babylonjs/Cameras/camera";
  75578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75579. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75580. import { Engine } from "babylonjs/Engines/engine";
  75581. import { Scene } from "babylonjs/scene";
  75582. /**
  75583. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75584. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75585. */
  75586. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75587. /**
  75588. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75589. */
  75590. threshold: number;
  75591. /**
  75592. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75593. */
  75594. strength: number;
  75595. /**
  75596. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75597. */
  75598. reflectionSpecularFalloffExponent: number;
  75599. /**
  75600. * 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]
  75601. */
  75602. step: number;
  75603. /**
  75604. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75605. */
  75606. roughnessFactor: number;
  75607. private _forceGeometryBuffer;
  75608. private _geometryBufferRenderer;
  75609. private _prePassRenderer;
  75610. private _enableSmoothReflections;
  75611. private _reflectionSamples;
  75612. private _smoothSteps;
  75613. /**
  75614. * Gets a string identifying the name of the class
  75615. * @returns "ScreenSpaceReflectionPostProcess" string
  75616. */
  75617. getClassName(): string;
  75618. /**
  75619. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75620. * @param name The name of the effect.
  75621. * @param scene The scene containing the objects to calculate reflections.
  75622. * @param options The required width/height ratio to downsize to before computing the render pass.
  75623. * @param camera The camera to apply the render pass to.
  75624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75625. * @param engine The engine which the post process will be applied. (default: current engine)
  75626. * @param reusable If the post process can be reused on the same frame. (default: false)
  75627. * @param textureType Type of textures used when performing the post process. (default: 0)
  75628. * @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)
  75629. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75630. */
  75631. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75632. /**
  75633. * Gets wether or not smoothing reflections is enabled.
  75634. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75635. */
  75636. get enableSmoothReflections(): boolean;
  75637. /**
  75638. * Sets wether or not smoothing reflections is enabled.
  75639. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75640. */
  75641. set enableSmoothReflections(enabled: boolean);
  75642. /**
  75643. * Gets the number of samples taken while computing reflections. More samples count is high,
  75644. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75645. */
  75646. get reflectionSamples(): number;
  75647. /**
  75648. * Sets the number of samples taken while computing reflections. More samples count is high,
  75649. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75650. */
  75651. set reflectionSamples(samples: number);
  75652. /**
  75653. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75654. * more the post-process will require GPU power and can generate a drop in FPS.
  75655. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75656. */
  75657. get smoothSteps(): number;
  75658. set smoothSteps(steps: number);
  75659. private _updateEffectDefines;
  75660. /** @hidden */
  75661. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75662. }
  75663. }
  75664. declare module "babylonjs/Shaders/standard.fragment" {
  75665. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75666. /** @hidden */
  75667. export var standardPixelShader: {
  75668. name: string;
  75669. shader: string;
  75670. };
  75671. }
  75672. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75673. import { Nullable } from "babylonjs/types";
  75674. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75675. import { Camera } from "babylonjs/Cameras/camera";
  75676. import { Texture } from "babylonjs/Materials/Textures/texture";
  75677. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75678. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75679. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75680. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75681. import { IDisposable } from "babylonjs/scene";
  75682. import { SpotLight } from "babylonjs/Lights/spotLight";
  75683. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75684. import { Scene } from "babylonjs/scene";
  75685. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75686. import { Animation } from "babylonjs/Animations/animation";
  75687. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75688. import "babylonjs/Shaders/standard.fragment";
  75689. /**
  75690. * Standard rendering pipeline
  75691. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75692. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75693. */
  75694. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75695. /**
  75696. * Public members
  75697. */
  75698. /**
  75699. * Post-process which contains the original scene color before the pipeline applies all the effects
  75700. */
  75701. originalPostProcess: Nullable<PostProcess>;
  75702. /**
  75703. * Post-process used to down scale an image x4
  75704. */
  75705. downSampleX4PostProcess: Nullable<PostProcess>;
  75706. /**
  75707. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75708. */
  75709. brightPassPostProcess: Nullable<PostProcess>;
  75710. /**
  75711. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75712. */
  75713. blurHPostProcesses: PostProcess[];
  75714. /**
  75715. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75716. */
  75717. blurVPostProcesses: PostProcess[];
  75718. /**
  75719. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75720. */
  75721. textureAdderPostProcess: Nullable<PostProcess>;
  75722. /**
  75723. * Post-process used to create volumetric lighting effect
  75724. */
  75725. volumetricLightPostProcess: Nullable<PostProcess>;
  75726. /**
  75727. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75728. */
  75729. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75730. /**
  75731. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75732. */
  75733. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75734. /**
  75735. * Post-process used to merge the volumetric light effect and the real scene color
  75736. */
  75737. volumetricLightMergePostProces: Nullable<PostProcess>;
  75738. /**
  75739. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75740. */
  75741. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75742. /**
  75743. * Base post-process used to calculate the average luminance of the final image for HDR
  75744. */
  75745. luminancePostProcess: Nullable<PostProcess>;
  75746. /**
  75747. * Post-processes used to create down sample post-processes in order to get
  75748. * the average luminance of the final image for HDR
  75749. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75750. */
  75751. luminanceDownSamplePostProcesses: PostProcess[];
  75752. /**
  75753. * Post-process used to create a HDR effect (light adaptation)
  75754. */
  75755. hdrPostProcess: Nullable<PostProcess>;
  75756. /**
  75757. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75758. */
  75759. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75760. /**
  75761. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75762. */
  75763. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75764. /**
  75765. * Post-process used to merge the final HDR post-process and the real scene color
  75766. */
  75767. hdrFinalPostProcess: Nullable<PostProcess>;
  75768. /**
  75769. * Post-process used to create a lens flare effect
  75770. */
  75771. lensFlarePostProcess: Nullable<PostProcess>;
  75772. /**
  75773. * Post-process that merges the result of the lens flare post-process and the real scene color
  75774. */
  75775. lensFlareComposePostProcess: Nullable<PostProcess>;
  75776. /**
  75777. * Post-process used to create a motion blur effect
  75778. */
  75779. motionBlurPostProcess: Nullable<PostProcess>;
  75780. /**
  75781. * Post-process used to create a depth of field effect
  75782. */
  75783. depthOfFieldPostProcess: Nullable<PostProcess>;
  75784. /**
  75785. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75786. */
  75787. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75788. /**
  75789. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75790. */
  75791. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75792. /**
  75793. * Represents the brightness threshold in order to configure the illuminated surfaces
  75794. */
  75795. brightThreshold: number;
  75796. /**
  75797. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75798. */
  75799. blurWidth: number;
  75800. /**
  75801. * Sets if the blur for highlighted surfaces must be only horizontal
  75802. */
  75803. horizontalBlur: boolean;
  75804. /**
  75805. * Gets the overall exposure used by the pipeline
  75806. */
  75807. get exposure(): number;
  75808. /**
  75809. * Sets the overall exposure used by the pipeline
  75810. */
  75811. set exposure(value: number);
  75812. /**
  75813. * Texture used typically to simulate "dirty" on camera lens
  75814. */
  75815. lensTexture: Nullable<Texture>;
  75816. /**
  75817. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75818. */
  75819. volumetricLightCoefficient: number;
  75820. /**
  75821. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75822. */
  75823. volumetricLightPower: number;
  75824. /**
  75825. * Used the set the blur intensity to smooth the volumetric lights
  75826. */
  75827. volumetricLightBlurScale: number;
  75828. /**
  75829. * Light (spot or directional) used to generate the volumetric lights rays
  75830. * The source light must have a shadow generate so the pipeline can get its
  75831. * depth map
  75832. */
  75833. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75834. /**
  75835. * For eye adaptation, represents the minimum luminance the eye can see
  75836. */
  75837. hdrMinimumLuminance: number;
  75838. /**
  75839. * For eye adaptation, represents the decrease luminance speed
  75840. */
  75841. hdrDecreaseRate: number;
  75842. /**
  75843. * For eye adaptation, represents the increase luminance speed
  75844. */
  75845. hdrIncreaseRate: number;
  75846. /**
  75847. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75848. */
  75849. get hdrAutoExposure(): boolean;
  75850. /**
  75851. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75852. */
  75853. set hdrAutoExposure(value: boolean);
  75854. /**
  75855. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75856. */
  75857. lensColorTexture: Nullable<Texture>;
  75858. /**
  75859. * The overall strengh for the lens flare effect
  75860. */
  75861. lensFlareStrength: number;
  75862. /**
  75863. * Dispersion coefficient for lens flare ghosts
  75864. */
  75865. lensFlareGhostDispersal: number;
  75866. /**
  75867. * Main lens flare halo width
  75868. */
  75869. lensFlareHaloWidth: number;
  75870. /**
  75871. * Based on the lens distortion effect, defines how much the lens flare result
  75872. * is distorted
  75873. */
  75874. lensFlareDistortionStrength: number;
  75875. /**
  75876. * Configures the blur intensity used for for lens flare (halo)
  75877. */
  75878. lensFlareBlurWidth: number;
  75879. /**
  75880. * Lens star texture must be used to simulate rays on the flares and is available
  75881. * in the documentation
  75882. */
  75883. lensStarTexture: Nullable<Texture>;
  75884. /**
  75885. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75886. * flare effect by taking account of the dirt texture
  75887. */
  75888. lensFlareDirtTexture: Nullable<Texture>;
  75889. /**
  75890. * Represents the focal length for the depth of field effect
  75891. */
  75892. depthOfFieldDistance: number;
  75893. /**
  75894. * Represents the blur intensity for the blurred part of the depth of field effect
  75895. */
  75896. depthOfFieldBlurWidth: number;
  75897. /**
  75898. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75899. */
  75900. get motionStrength(): number;
  75901. /**
  75902. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75903. */
  75904. set motionStrength(strength: number);
  75905. /**
  75906. * Gets wether or not the motion blur post-process is object based or screen based.
  75907. */
  75908. get objectBasedMotionBlur(): boolean;
  75909. /**
  75910. * Sets wether or not the motion blur post-process should be object based or screen based
  75911. */
  75912. set objectBasedMotionBlur(value: boolean);
  75913. /**
  75914. * List of animations for the pipeline (IAnimatable implementation)
  75915. */
  75916. animations: Animation[];
  75917. /**
  75918. * Private members
  75919. */
  75920. private _scene;
  75921. private _currentDepthOfFieldSource;
  75922. private _basePostProcess;
  75923. private _fixedExposure;
  75924. private _currentExposure;
  75925. private _hdrAutoExposure;
  75926. private _hdrCurrentLuminance;
  75927. private _motionStrength;
  75928. private _isObjectBasedMotionBlur;
  75929. private _floatTextureType;
  75930. private _camerasToBeAttached;
  75931. private _ratio;
  75932. private _bloomEnabled;
  75933. private _depthOfFieldEnabled;
  75934. private _vlsEnabled;
  75935. private _lensFlareEnabled;
  75936. private _hdrEnabled;
  75937. private _motionBlurEnabled;
  75938. private _fxaaEnabled;
  75939. private _screenSpaceReflectionsEnabled;
  75940. private _motionBlurSamples;
  75941. private _volumetricLightStepsCount;
  75942. private _samples;
  75943. /**
  75944. * @ignore
  75945. * Specifies if the bloom pipeline is enabled
  75946. */
  75947. get BloomEnabled(): boolean;
  75948. set BloomEnabled(enabled: boolean);
  75949. /**
  75950. * @ignore
  75951. * Specifies if the depth of field pipeline is enabed
  75952. */
  75953. get DepthOfFieldEnabled(): boolean;
  75954. set DepthOfFieldEnabled(enabled: boolean);
  75955. /**
  75956. * @ignore
  75957. * Specifies if the lens flare pipeline is enabed
  75958. */
  75959. get LensFlareEnabled(): boolean;
  75960. set LensFlareEnabled(enabled: boolean);
  75961. /**
  75962. * @ignore
  75963. * Specifies if the HDR pipeline is enabled
  75964. */
  75965. get HDREnabled(): boolean;
  75966. set HDREnabled(enabled: boolean);
  75967. /**
  75968. * @ignore
  75969. * Specifies if the volumetric lights scattering effect is enabled
  75970. */
  75971. get VLSEnabled(): boolean;
  75972. set VLSEnabled(enabled: boolean);
  75973. /**
  75974. * @ignore
  75975. * Specifies if the motion blur effect is enabled
  75976. */
  75977. get MotionBlurEnabled(): boolean;
  75978. set MotionBlurEnabled(enabled: boolean);
  75979. /**
  75980. * Specifies if anti-aliasing is enabled
  75981. */
  75982. get fxaaEnabled(): boolean;
  75983. set fxaaEnabled(enabled: boolean);
  75984. /**
  75985. * Specifies if screen space reflections are enabled.
  75986. */
  75987. get screenSpaceReflectionsEnabled(): boolean;
  75988. set screenSpaceReflectionsEnabled(enabled: boolean);
  75989. /**
  75990. * Specifies the number of steps used to calculate the volumetric lights
  75991. * Typically in interval [50, 200]
  75992. */
  75993. get volumetricLightStepsCount(): number;
  75994. set volumetricLightStepsCount(count: number);
  75995. /**
  75996. * Specifies the number of samples used for the motion blur effect
  75997. * Typically in interval [16, 64]
  75998. */
  75999. get motionBlurSamples(): number;
  76000. set motionBlurSamples(samples: number);
  76001. /**
  76002. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76003. */
  76004. get samples(): number;
  76005. set samples(sampleCount: number);
  76006. /**
  76007. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76008. * @constructor
  76009. * @param name The rendering pipeline name
  76010. * @param scene The scene linked to this pipeline
  76011. * @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)
  76012. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76013. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76014. */
  76015. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76016. private _buildPipeline;
  76017. private _createDownSampleX4PostProcess;
  76018. private _createBrightPassPostProcess;
  76019. private _createBlurPostProcesses;
  76020. private _createTextureAdderPostProcess;
  76021. private _createVolumetricLightPostProcess;
  76022. private _createLuminancePostProcesses;
  76023. private _createHdrPostProcess;
  76024. private _createLensFlarePostProcess;
  76025. private _createDepthOfFieldPostProcess;
  76026. private _createMotionBlurPostProcess;
  76027. private _getDepthTexture;
  76028. private _disposePostProcesses;
  76029. /**
  76030. * Dispose of the pipeline and stop all post processes
  76031. */
  76032. dispose(): void;
  76033. /**
  76034. * Serialize the rendering pipeline (Used when exporting)
  76035. * @returns the serialized object
  76036. */
  76037. serialize(): any;
  76038. /**
  76039. * Parse the serialized pipeline
  76040. * @param source Source pipeline.
  76041. * @param scene The scene to load the pipeline to.
  76042. * @param rootUrl The URL of the serialized pipeline.
  76043. * @returns An instantiated pipeline from the serialized object.
  76044. */
  76045. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76046. /**
  76047. * Luminance steps
  76048. */
  76049. static LuminanceSteps: number;
  76050. }
  76051. }
  76052. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76053. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76054. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76055. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76056. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76057. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76058. }
  76059. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76060. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76061. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76062. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76063. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76064. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76065. }
  76066. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76067. /** @hidden */
  76068. export var stereoscopicInterlacePixelShader: {
  76069. name: string;
  76070. shader: string;
  76071. };
  76072. }
  76073. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76074. import { Camera } from "babylonjs/Cameras/camera";
  76075. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76076. import { Engine } from "babylonjs/Engines/engine";
  76077. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76078. /**
  76079. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76080. */
  76081. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76082. private _stepSize;
  76083. private _passedProcess;
  76084. /**
  76085. * Gets a string identifying the name of the class
  76086. * @returns "StereoscopicInterlacePostProcessI" string
  76087. */
  76088. getClassName(): string;
  76089. /**
  76090. * Initializes a StereoscopicInterlacePostProcessI
  76091. * @param name The name of the effect.
  76092. * @param rigCameras The rig cameras to be appled to the post process
  76093. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76094. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76096. * @param engine The engine which the post process will be applied. (default: current engine)
  76097. * @param reusable If the post process can be reused on the same frame. (default: false)
  76098. */
  76099. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76100. }
  76101. /**
  76102. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76103. */
  76104. export class StereoscopicInterlacePostProcess extends PostProcess {
  76105. private _stepSize;
  76106. private _passedProcess;
  76107. /**
  76108. * Gets a string identifying the name of the class
  76109. * @returns "StereoscopicInterlacePostProcess" string
  76110. */
  76111. getClassName(): string;
  76112. /**
  76113. * Initializes a StereoscopicInterlacePostProcess
  76114. * @param name The name of the effect.
  76115. * @param rigCameras The rig cameras to be appled to the post process
  76116. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76118. * @param engine The engine which the post process will be applied. (default: current engine)
  76119. * @param reusable If the post process can be reused on the same frame. (default: false)
  76120. */
  76121. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76122. }
  76123. }
  76124. declare module "babylonjs/Shaders/tonemap.fragment" {
  76125. /** @hidden */
  76126. export var tonemapPixelShader: {
  76127. name: string;
  76128. shader: string;
  76129. };
  76130. }
  76131. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76132. import { Camera } from "babylonjs/Cameras/camera";
  76133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76134. import "babylonjs/Shaders/tonemap.fragment";
  76135. import { Engine } from "babylonjs/Engines/engine";
  76136. /** Defines operator used for tonemapping */
  76137. export enum TonemappingOperator {
  76138. /** Hable */
  76139. Hable = 0,
  76140. /** Reinhard */
  76141. Reinhard = 1,
  76142. /** HejiDawson */
  76143. HejiDawson = 2,
  76144. /** Photographic */
  76145. Photographic = 3
  76146. }
  76147. /**
  76148. * Defines a post process to apply tone mapping
  76149. */
  76150. export class TonemapPostProcess extends PostProcess {
  76151. private _operator;
  76152. /** Defines the required exposure adjustement */
  76153. exposureAdjustment: number;
  76154. /**
  76155. * Gets a string identifying the name of the class
  76156. * @returns "TonemapPostProcess" string
  76157. */
  76158. getClassName(): string;
  76159. /**
  76160. * Creates a new TonemapPostProcess
  76161. * @param name defines the name of the postprocess
  76162. * @param _operator defines the operator to use
  76163. * @param exposureAdjustment defines the required exposure adjustement
  76164. * @param camera defines the camera to use (can be null)
  76165. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76166. * @param engine defines the hosting engine (can be ignore if camera is set)
  76167. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76168. */
  76169. constructor(name: string, _operator: TonemappingOperator,
  76170. /** Defines the required exposure adjustement */
  76171. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76172. }
  76173. }
  76174. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76175. /** @hidden */
  76176. export var volumetricLightScatteringPixelShader: {
  76177. name: string;
  76178. shader: string;
  76179. };
  76180. }
  76181. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76182. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76184. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76186. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76187. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76188. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76189. /** @hidden */
  76190. export var volumetricLightScatteringPassVertexShader: {
  76191. name: string;
  76192. shader: string;
  76193. };
  76194. }
  76195. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76196. /** @hidden */
  76197. export var volumetricLightScatteringPassPixelShader: {
  76198. name: string;
  76199. shader: string;
  76200. };
  76201. }
  76202. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76203. import { Vector3 } from "babylonjs/Maths/math.vector";
  76204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76205. import { Mesh } from "babylonjs/Meshes/mesh";
  76206. import { Camera } from "babylonjs/Cameras/camera";
  76207. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76209. import { Scene } from "babylonjs/scene";
  76210. import "babylonjs/Meshes/Builders/planeBuilder";
  76211. import "babylonjs/Shaders/depth.vertex";
  76212. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76213. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76214. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76215. import { Engine } from "babylonjs/Engines/engine";
  76216. /**
  76217. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76218. */
  76219. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76220. private _volumetricLightScatteringPass;
  76221. private _volumetricLightScatteringRTT;
  76222. private _viewPort;
  76223. private _screenCoordinates;
  76224. private _cachedDefines;
  76225. /**
  76226. * If not undefined, the mesh position is computed from the attached node position
  76227. */
  76228. attachedNode: {
  76229. position: Vector3;
  76230. };
  76231. /**
  76232. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76233. */
  76234. customMeshPosition: Vector3;
  76235. /**
  76236. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76237. */
  76238. useCustomMeshPosition: boolean;
  76239. /**
  76240. * If the post-process should inverse the light scattering direction
  76241. */
  76242. invert: boolean;
  76243. /**
  76244. * The internal mesh used by the post-process
  76245. */
  76246. mesh: Mesh;
  76247. /**
  76248. * @hidden
  76249. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76250. */
  76251. get useDiffuseColor(): boolean;
  76252. set useDiffuseColor(useDiffuseColor: boolean);
  76253. /**
  76254. * Array containing the excluded meshes not rendered in the internal pass
  76255. */
  76256. excludedMeshes: AbstractMesh[];
  76257. /**
  76258. * Controls the overall intensity of the post-process
  76259. */
  76260. exposure: number;
  76261. /**
  76262. * Dissipates each sample's contribution in range [0, 1]
  76263. */
  76264. decay: number;
  76265. /**
  76266. * Controls the overall intensity of each sample
  76267. */
  76268. weight: number;
  76269. /**
  76270. * Controls the density of each sample
  76271. */
  76272. density: number;
  76273. /**
  76274. * @constructor
  76275. * @param name The post-process name
  76276. * @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)
  76277. * @param camera The camera that the post-process will be attached to
  76278. * @param mesh The mesh used to create the light scattering
  76279. * @param samples The post-process quality, default 100
  76280. * @param samplingModeThe post-process filtering mode
  76281. * @param engine The babylon engine
  76282. * @param reusable If the post-process is reusable
  76283. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76284. */
  76285. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76286. /**
  76287. * Returns the string "VolumetricLightScatteringPostProcess"
  76288. * @returns "VolumetricLightScatteringPostProcess"
  76289. */
  76290. getClassName(): string;
  76291. private _isReady;
  76292. /**
  76293. * Sets the new light position for light scattering effect
  76294. * @param position The new custom light position
  76295. */
  76296. setCustomMeshPosition(position: Vector3): void;
  76297. /**
  76298. * Returns the light position for light scattering effect
  76299. * @return Vector3 The custom light position
  76300. */
  76301. getCustomMeshPosition(): Vector3;
  76302. /**
  76303. * Disposes the internal assets and detaches the post-process from the camera
  76304. */
  76305. dispose(camera: Camera): void;
  76306. /**
  76307. * Returns the render target texture used by the post-process
  76308. * @return the render target texture used by the post-process
  76309. */
  76310. getPass(): RenderTargetTexture;
  76311. private _meshExcluded;
  76312. private _createPass;
  76313. private _updateMeshScreenCoordinates;
  76314. /**
  76315. * Creates a default mesh for the Volumeric Light Scattering post-process
  76316. * @param name The mesh name
  76317. * @param scene The scene where to create the mesh
  76318. * @return the default mesh
  76319. */
  76320. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76321. }
  76322. }
  76323. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76324. /** @hidden */
  76325. export var screenSpaceCurvaturePixelShader: {
  76326. name: string;
  76327. shader: string;
  76328. };
  76329. }
  76330. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76331. import { Nullable } from "babylonjs/types";
  76332. import { Camera } from "babylonjs/Cameras/camera";
  76333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76334. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76335. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76336. import { Engine } from "babylonjs/Engines/engine";
  76337. import { Scene } from "babylonjs/scene";
  76338. /**
  76339. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76340. */
  76341. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76342. /**
  76343. * Defines how much ridge the curvature effect displays.
  76344. */
  76345. ridge: number;
  76346. /**
  76347. * Defines how much valley the curvature effect displays.
  76348. */
  76349. valley: number;
  76350. private _geometryBufferRenderer;
  76351. /**
  76352. * Gets a string identifying the name of the class
  76353. * @returns "ScreenSpaceCurvaturePostProcess" string
  76354. */
  76355. getClassName(): string;
  76356. /**
  76357. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76358. * @param name The name of the effect.
  76359. * @param scene The scene containing the objects to blur according to their velocity.
  76360. * @param options The required width/height ratio to downsize to before computing the render pass.
  76361. * @param camera The camera to apply the render pass to.
  76362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76363. * @param engine The engine which the post process will be applied. (default: current engine)
  76364. * @param reusable If the post process can be reused on the same frame. (default: false)
  76365. * @param textureType Type of textures used when performing the post process. (default: 0)
  76366. * @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)
  76367. */
  76368. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76369. /**
  76370. * Support test.
  76371. */
  76372. static get IsSupported(): boolean;
  76373. /** @hidden */
  76374. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76375. }
  76376. }
  76377. declare module "babylonjs/PostProcesses/index" {
  76378. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76379. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76380. export * from "babylonjs/PostProcesses/bloomEffect";
  76381. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76382. export * from "babylonjs/PostProcesses/blurPostProcess";
  76383. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76384. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76385. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76386. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76387. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76388. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76389. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76390. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76391. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76392. export * from "babylonjs/PostProcesses/filterPostProcess";
  76393. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76394. export * from "babylonjs/PostProcesses/grainPostProcess";
  76395. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76396. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76397. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76398. export * from "babylonjs/PostProcesses/passPostProcess";
  76399. export * from "babylonjs/PostProcesses/postProcess";
  76400. export * from "babylonjs/PostProcesses/postProcessManager";
  76401. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76402. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76403. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76404. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76405. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76406. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76407. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76408. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76409. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76410. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76411. }
  76412. declare module "babylonjs/Probes/index" {
  76413. export * from "babylonjs/Probes/reflectionProbe";
  76414. }
  76415. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76416. import { Scene } from "babylonjs/scene";
  76417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76418. import { SmartArray } from "babylonjs/Misc/smartArray";
  76419. import { ISceneComponent } from "babylonjs/sceneComponent";
  76420. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76421. import "babylonjs/Meshes/Builders/boxBuilder";
  76422. import "babylonjs/Shaders/color.fragment";
  76423. import "babylonjs/Shaders/color.vertex";
  76424. import { Color3 } from "babylonjs/Maths/math.color";
  76425. import { Observable } from "babylonjs/Misc/observable";
  76426. module "babylonjs/scene" {
  76427. interface Scene {
  76428. /** @hidden (Backing field) */
  76429. _boundingBoxRenderer: BoundingBoxRenderer;
  76430. /** @hidden (Backing field) */
  76431. _forceShowBoundingBoxes: boolean;
  76432. /**
  76433. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76434. */
  76435. forceShowBoundingBoxes: boolean;
  76436. /**
  76437. * Gets the bounding box renderer associated with the scene
  76438. * @returns a BoundingBoxRenderer
  76439. */
  76440. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76441. }
  76442. }
  76443. module "babylonjs/Meshes/abstractMesh" {
  76444. interface AbstractMesh {
  76445. /** @hidden (Backing field) */
  76446. _showBoundingBox: boolean;
  76447. /**
  76448. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76449. */
  76450. showBoundingBox: boolean;
  76451. }
  76452. }
  76453. /**
  76454. * Component responsible of rendering the bounding box of the meshes in a scene.
  76455. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76456. */
  76457. export class BoundingBoxRenderer implements ISceneComponent {
  76458. /**
  76459. * The component name helpfull to identify the component in the list of scene components.
  76460. */
  76461. readonly name: string;
  76462. /**
  76463. * The scene the component belongs to.
  76464. */
  76465. scene: Scene;
  76466. /**
  76467. * Color of the bounding box lines placed in front of an object
  76468. */
  76469. frontColor: Color3;
  76470. /**
  76471. * Color of the bounding box lines placed behind an object
  76472. */
  76473. backColor: Color3;
  76474. /**
  76475. * Defines if the renderer should show the back lines or not
  76476. */
  76477. showBackLines: boolean;
  76478. /**
  76479. * Observable raised before rendering a bounding box
  76480. */
  76481. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76482. /**
  76483. * Observable raised after rendering a bounding box
  76484. */
  76485. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76486. /**
  76487. * @hidden
  76488. */
  76489. renderList: SmartArray<BoundingBox>;
  76490. private _colorShader;
  76491. private _vertexBuffers;
  76492. private _indexBuffer;
  76493. private _fillIndexBuffer;
  76494. private _fillIndexData;
  76495. /**
  76496. * Instantiates a new bounding box renderer in a scene.
  76497. * @param scene the scene the renderer renders in
  76498. */
  76499. constructor(scene: Scene);
  76500. /**
  76501. * Registers the component in a given scene
  76502. */
  76503. register(): void;
  76504. private _evaluateSubMesh;
  76505. private _activeMesh;
  76506. private _prepareRessources;
  76507. private _createIndexBuffer;
  76508. /**
  76509. * Rebuilds the elements related to this component in case of
  76510. * context lost for instance.
  76511. */
  76512. rebuild(): void;
  76513. /**
  76514. * @hidden
  76515. */
  76516. reset(): void;
  76517. /**
  76518. * Render the bounding boxes of a specific rendering group
  76519. * @param renderingGroupId defines the rendering group to render
  76520. */
  76521. render(renderingGroupId: number): void;
  76522. /**
  76523. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76524. * @param mesh Define the mesh to render the occlusion bounding box for
  76525. */
  76526. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76527. /**
  76528. * Dispose and release the resources attached to this renderer.
  76529. */
  76530. dispose(): void;
  76531. }
  76532. }
  76533. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76534. import { Nullable } from "babylonjs/types";
  76535. import { Scene } from "babylonjs/scene";
  76536. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76537. import { Camera } from "babylonjs/Cameras/camera";
  76538. import { ISceneComponent } from "babylonjs/sceneComponent";
  76539. module "babylonjs/scene" {
  76540. interface Scene {
  76541. /** @hidden (Backing field) */
  76542. _depthRenderer: {
  76543. [id: string]: DepthRenderer;
  76544. };
  76545. /**
  76546. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76547. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76548. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76549. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76550. * @returns the created depth renderer
  76551. */
  76552. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76553. /**
  76554. * Disables a depth renderer for a given camera
  76555. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76556. */
  76557. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76558. }
  76559. }
  76560. /**
  76561. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76562. * in several rendering techniques.
  76563. */
  76564. export class DepthRendererSceneComponent implements ISceneComponent {
  76565. /**
  76566. * The component name helpfull to identify the component in the list of scene components.
  76567. */
  76568. readonly name: string;
  76569. /**
  76570. * The scene the component belongs to.
  76571. */
  76572. scene: Scene;
  76573. /**
  76574. * Creates a new instance of the component for the given scene
  76575. * @param scene Defines the scene to register the component in
  76576. */
  76577. constructor(scene: Scene);
  76578. /**
  76579. * Registers the component in a given scene
  76580. */
  76581. register(): void;
  76582. /**
  76583. * Rebuilds the elements related to this component in case of
  76584. * context lost for instance.
  76585. */
  76586. rebuild(): void;
  76587. /**
  76588. * Disposes the component and the associated ressources
  76589. */
  76590. dispose(): void;
  76591. private _gatherRenderTargets;
  76592. private _gatherActiveCameraRenderTargets;
  76593. }
  76594. }
  76595. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76596. import { Nullable } from "babylonjs/types";
  76597. import { Scene } from "babylonjs/scene";
  76598. import { ISceneComponent } from "babylonjs/sceneComponent";
  76599. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76600. module "babylonjs/abstractScene" {
  76601. interface AbstractScene {
  76602. /** @hidden (Backing field) */
  76603. _prePassRenderer: Nullable<PrePassRenderer>;
  76604. /**
  76605. * Gets or Sets the current prepass renderer associated to the scene.
  76606. */
  76607. prePassRenderer: Nullable<PrePassRenderer>;
  76608. /**
  76609. * Enables the prepass and associates it with the scene
  76610. * @returns the PrePassRenderer
  76611. */
  76612. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76613. /**
  76614. * Disables the prepass associated with the scene
  76615. */
  76616. disablePrePassRenderer(): void;
  76617. }
  76618. }
  76619. /**
  76620. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76621. * in several rendering techniques.
  76622. */
  76623. export class PrePassRendererSceneComponent implements ISceneComponent {
  76624. /**
  76625. * The component name helpful to identify the component in the list of scene components.
  76626. */
  76627. readonly name: string;
  76628. /**
  76629. * The scene the component belongs to.
  76630. */
  76631. scene: Scene;
  76632. /**
  76633. * Creates a new instance of the component for the given scene
  76634. * @param scene Defines the scene to register the component in
  76635. */
  76636. constructor(scene: Scene);
  76637. /**
  76638. * Registers the component in a given scene
  76639. */
  76640. register(): void;
  76641. private _beforeCameraDraw;
  76642. private _afterCameraDraw;
  76643. private _beforeClearStage;
  76644. /**
  76645. * Rebuilds the elements related to this component in case of
  76646. * context lost for instance.
  76647. */
  76648. rebuild(): void;
  76649. /**
  76650. * Disposes the component and the associated ressources
  76651. */
  76652. dispose(): void;
  76653. }
  76654. }
  76655. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76656. /** @hidden */
  76657. export var fibonacci: {
  76658. name: string;
  76659. shader: string;
  76660. };
  76661. }
  76662. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76663. /** @hidden */
  76664. export var diffusionProfile: {
  76665. name: string;
  76666. shader: string;
  76667. };
  76668. }
  76669. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76670. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76672. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76673. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76674. /** @hidden */
  76675. export var subSurfaceScatteringPixelShader: {
  76676. name: string;
  76677. shader: string;
  76678. };
  76679. }
  76680. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76681. import { Nullable } from "babylonjs/types";
  76682. import { Camera } from "babylonjs/Cameras/camera";
  76683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76684. import { Engine } from "babylonjs/Engines/engine";
  76685. import { Scene } from "babylonjs/scene";
  76686. import "babylonjs/Shaders/imageProcessing.fragment";
  76687. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76688. import "babylonjs/Shaders/postprocess.vertex";
  76689. /**
  76690. * Sub surface scattering post process
  76691. */
  76692. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76693. /**
  76694. * Gets a string identifying the name of the class
  76695. * @returns "SubSurfaceScatteringPostProcess" string
  76696. */
  76697. getClassName(): string;
  76698. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76699. }
  76700. }
  76701. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76702. import { Scene } from "babylonjs/scene";
  76703. import { Color3 } from "babylonjs/Maths/math.color";
  76704. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76705. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76706. /**
  76707. * Contains all parameters needed for the prepass to perform
  76708. * screen space subsurface scattering
  76709. */
  76710. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76711. /** @hidden */
  76712. static _SceneComponentInitialization: (scene: Scene) => void;
  76713. private _ssDiffusionS;
  76714. private _ssFilterRadii;
  76715. private _ssDiffusionD;
  76716. /**
  76717. * Post process to attach for screen space subsurface scattering
  76718. */
  76719. postProcess: SubSurfaceScatteringPostProcess;
  76720. /**
  76721. * Diffusion profile color for subsurface scattering
  76722. */
  76723. get ssDiffusionS(): number[];
  76724. /**
  76725. * Diffusion profile max color channel value for subsurface scattering
  76726. */
  76727. get ssDiffusionD(): number[];
  76728. /**
  76729. * Diffusion profile filter radius for subsurface scattering
  76730. */
  76731. get ssFilterRadii(): number[];
  76732. /**
  76733. * Is subsurface enabled
  76734. */
  76735. enabled: boolean;
  76736. /**
  76737. * Name of the configuration
  76738. */
  76739. name: string;
  76740. /**
  76741. * Diffusion profile colors for subsurface scattering
  76742. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76743. * See ...
  76744. * Note that you can only store up to 5 of them
  76745. */
  76746. ssDiffusionProfileColors: Color3[];
  76747. /**
  76748. * Defines the ratio real world => scene units.
  76749. * Used for subsurface scattering
  76750. */
  76751. metersPerUnit: number;
  76752. /**
  76753. * Textures that should be present in the MRT for this effect to work
  76754. */
  76755. readonly texturesRequired: number[];
  76756. private _scene;
  76757. /**
  76758. * Builds a subsurface configuration object
  76759. * @param scene The scene
  76760. */
  76761. constructor(scene: Scene);
  76762. /**
  76763. * Adds a new diffusion profile.
  76764. * Useful for more realistic subsurface scattering on diverse materials.
  76765. * @param color The color of the diffusion profile. Should be the average color of the material.
  76766. * @return The index of the diffusion profile for the material subsurface configuration
  76767. */
  76768. addDiffusionProfile(color: Color3): number;
  76769. /**
  76770. * Creates the sss post process
  76771. * @return The created post process
  76772. */
  76773. createPostProcess(): SubSurfaceScatteringPostProcess;
  76774. /**
  76775. * Deletes all diffusion profiles.
  76776. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76777. */
  76778. clearAllDiffusionProfiles(): void;
  76779. /**
  76780. * Disposes this object
  76781. */
  76782. dispose(): void;
  76783. /**
  76784. * @hidden
  76785. * https://zero-radiance.github.io/post/sampling-diffusion/
  76786. *
  76787. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76788. * ------------------------------------------------------------------------------------
  76789. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76790. * PDF[r, phi, s] = r * R[r, phi, s]
  76791. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76792. * ------------------------------------------------------------------------------------
  76793. * We importance sample the color channel with the widest scattering distance.
  76794. */
  76795. getDiffusionProfileParameters(color: Color3): number;
  76796. /**
  76797. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76798. * 'u' is the random number (the value of the CDF): [0, 1).
  76799. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76800. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76801. */
  76802. private _sampleBurleyDiffusionProfile;
  76803. }
  76804. }
  76805. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76806. import { Nullable } from "babylonjs/types";
  76807. import { Scene } from "babylonjs/scene";
  76808. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76809. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76810. import { AbstractScene } from "babylonjs/abstractScene";
  76811. module "babylonjs/abstractScene" {
  76812. interface AbstractScene {
  76813. /** @hidden (Backing field) */
  76814. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76815. /**
  76816. * Gets or Sets the current prepass renderer associated to the scene.
  76817. */
  76818. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76819. /**
  76820. * Enables the subsurface effect for prepass
  76821. * @returns the SubSurfaceConfiguration
  76822. */
  76823. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76824. /**
  76825. * Disables the subsurface effect for prepass
  76826. */
  76827. disableSubSurfaceForPrePass(): void;
  76828. }
  76829. }
  76830. /**
  76831. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76832. * in several rendering techniques.
  76833. */
  76834. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76835. /**
  76836. * The component name helpful to identify the component in the list of scene components.
  76837. */
  76838. readonly name: string;
  76839. /**
  76840. * The scene the component belongs to.
  76841. */
  76842. scene: Scene;
  76843. /**
  76844. * Creates a new instance of the component for the given scene
  76845. * @param scene Defines the scene to register the component in
  76846. */
  76847. constructor(scene: Scene);
  76848. /**
  76849. * Registers the component in a given scene
  76850. */
  76851. register(): void;
  76852. /**
  76853. * Serializes the component data to the specified json object
  76854. * @param serializationObject The object to serialize to
  76855. */
  76856. serialize(serializationObject: any): void;
  76857. /**
  76858. * Adds all the elements from the container to the scene
  76859. * @param container the container holding the elements
  76860. */
  76861. addFromContainer(container: AbstractScene): void;
  76862. /**
  76863. * Removes all the elements in the container from the scene
  76864. * @param container contains the elements to remove
  76865. * @param dispose if the removed element should be disposed (default: false)
  76866. */
  76867. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76868. /**
  76869. * Rebuilds the elements related to this component in case of
  76870. * context lost for instance.
  76871. */
  76872. rebuild(): void;
  76873. /**
  76874. * Disposes the component and the associated ressources
  76875. */
  76876. dispose(): void;
  76877. }
  76878. }
  76879. declare module "babylonjs/Shaders/outline.fragment" {
  76880. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76881. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76882. /** @hidden */
  76883. export var outlinePixelShader: {
  76884. name: string;
  76885. shader: string;
  76886. };
  76887. }
  76888. declare module "babylonjs/Shaders/outline.vertex" {
  76889. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76893. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76895. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76896. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76897. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76898. /** @hidden */
  76899. export var outlineVertexShader: {
  76900. name: string;
  76901. shader: string;
  76902. };
  76903. }
  76904. declare module "babylonjs/Rendering/outlineRenderer" {
  76905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76906. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76907. import { Scene } from "babylonjs/scene";
  76908. import { ISceneComponent } from "babylonjs/sceneComponent";
  76909. import "babylonjs/Shaders/outline.fragment";
  76910. import "babylonjs/Shaders/outline.vertex";
  76911. module "babylonjs/scene" {
  76912. interface Scene {
  76913. /** @hidden */
  76914. _outlineRenderer: OutlineRenderer;
  76915. /**
  76916. * Gets the outline renderer associated with the scene
  76917. * @returns a OutlineRenderer
  76918. */
  76919. getOutlineRenderer(): OutlineRenderer;
  76920. }
  76921. }
  76922. module "babylonjs/Meshes/abstractMesh" {
  76923. interface AbstractMesh {
  76924. /** @hidden (Backing field) */
  76925. _renderOutline: boolean;
  76926. /**
  76927. * Gets or sets a boolean indicating if the outline must be rendered as well
  76928. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76929. */
  76930. renderOutline: boolean;
  76931. /** @hidden (Backing field) */
  76932. _renderOverlay: boolean;
  76933. /**
  76934. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76935. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76936. */
  76937. renderOverlay: boolean;
  76938. }
  76939. }
  76940. /**
  76941. * This class is responsible to draw bothe outline/overlay of meshes.
  76942. * It should not be used directly but through the available method on mesh.
  76943. */
  76944. export class OutlineRenderer implements ISceneComponent {
  76945. /**
  76946. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76947. */
  76948. private static _StencilReference;
  76949. /**
  76950. * The name of the component. Each component must have a unique name.
  76951. */
  76952. name: string;
  76953. /**
  76954. * The scene the component belongs to.
  76955. */
  76956. scene: Scene;
  76957. /**
  76958. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76959. */
  76960. zOffset: number;
  76961. private _engine;
  76962. private _effect;
  76963. private _cachedDefines;
  76964. private _savedDepthWrite;
  76965. /**
  76966. * Instantiates a new outline renderer. (There could be only one per scene).
  76967. * @param scene Defines the scene it belongs to
  76968. */
  76969. constructor(scene: Scene);
  76970. /**
  76971. * Register the component to one instance of a scene.
  76972. */
  76973. register(): void;
  76974. /**
  76975. * Rebuilds the elements related to this component in case of
  76976. * context lost for instance.
  76977. */
  76978. rebuild(): void;
  76979. /**
  76980. * Disposes the component and the associated ressources.
  76981. */
  76982. dispose(): void;
  76983. /**
  76984. * Renders the outline in the canvas.
  76985. * @param subMesh Defines the sumesh to render
  76986. * @param batch Defines the batch of meshes in case of instances
  76987. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76988. */
  76989. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76990. /**
  76991. * Returns whether or not the outline renderer is ready for a given submesh.
  76992. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76993. * @param subMesh Defines the submesh to check readyness for
  76994. * @param useInstances Defines wheter wee are trying to render instances or not
  76995. * @returns true if ready otherwise false
  76996. */
  76997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76998. private _beforeRenderingMesh;
  76999. private _afterRenderingMesh;
  77000. }
  77001. }
  77002. declare module "babylonjs/Rendering/index" {
  77003. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77004. export * from "babylonjs/Rendering/depthRenderer";
  77005. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77006. export * from "babylonjs/Rendering/edgesRenderer";
  77007. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77008. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77009. export * from "babylonjs/Rendering/prePassRenderer";
  77010. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77011. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77012. export * from "babylonjs/Rendering/outlineRenderer";
  77013. export * from "babylonjs/Rendering/renderingGroup";
  77014. export * from "babylonjs/Rendering/renderingManager";
  77015. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77016. }
  77017. declare module "babylonjs/Sprites/ISprites" {
  77018. /**
  77019. * Defines the basic options interface of a Sprite Frame Source Size.
  77020. */
  77021. export interface ISpriteJSONSpriteSourceSize {
  77022. /**
  77023. * number of the original width of the Frame
  77024. */
  77025. w: number;
  77026. /**
  77027. * number of the original height of the Frame
  77028. */
  77029. h: number;
  77030. }
  77031. /**
  77032. * Defines the basic options interface of a Sprite Frame Data.
  77033. */
  77034. export interface ISpriteJSONSpriteFrameData {
  77035. /**
  77036. * number of the x offset of the Frame
  77037. */
  77038. x: number;
  77039. /**
  77040. * number of the y offset of the Frame
  77041. */
  77042. y: number;
  77043. /**
  77044. * number of the width of the Frame
  77045. */
  77046. w: number;
  77047. /**
  77048. * number of the height of the Frame
  77049. */
  77050. h: number;
  77051. }
  77052. /**
  77053. * Defines the basic options interface of a JSON Sprite.
  77054. */
  77055. export interface ISpriteJSONSprite {
  77056. /**
  77057. * string name of the Frame
  77058. */
  77059. filename: string;
  77060. /**
  77061. * ISpriteJSONSpriteFrame basic object of the frame data
  77062. */
  77063. frame: ISpriteJSONSpriteFrameData;
  77064. /**
  77065. * boolean to flag is the frame was rotated.
  77066. */
  77067. rotated: boolean;
  77068. /**
  77069. * boolean to flag is the frame was trimmed.
  77070. */
  77071. trimmed: boolean;
  77072. /**
  77073. * ISpriteJSONSpriteFrame basic object of the source data
  77074. */
  77075. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77076. /**
  77077. * ISpriteJSONSpriteFrame basic object of the source data
  77078. */
  77079. sourceSize: ISpriteJSONSpriteSourceSize;
  77080. }
  77081. /**
  77082. * Defines the basic options interface of a JSON atlas.
  77083. */
  77084. export interface ISpriteJSONAtlas {
  77085. /**
  77086. * Array of objects that contain the frame data.
  77087. */
  77088. frames: Array<ISpriteJSONSprite>;
  77089. /**
  77090. * object basic object containing the sprite meta data.
  77091. */
  77092. meta?: object;
  77093. }
  77094. }
  77095. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77096. /** @hidden */
  77097. export var spriteMapPixelShader: {
  77098. name: string;
  77099. shader: string;
  77100. };
  77101. }
  77102. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77103. /** @hidden */
  77104. export var spriteMapVertexShader: {
  77105. name: string;
  77106. shader: string;
  77107. };
  77108. }
  77109. declare module "babylonjs/Sprites/spriteMap" {
  77110. import { IDisposable, Scene } from "babylonjs/scene";
  77111. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77112. import { Texture } from "babylonjs/Materials/Textures/texture";
  77113. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77114. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77115. import "babylonjs/Meshes/Builders/planeBuilder";
  77116. import "babylonjs/Shaders/spriteMap.fragment";
  77117. import "babylonjs/Shaders/spriteMap.vertex";
  77118. /**
  77119. * Defines the basic options interface of a SpriteMap
  77120. */
  77121. export interface ISpriteMapOptions {
  77122. /**
  77123. * Vector2 of the number of cells in the grid.
  77124. */
  77125. stageSize?: Vector2;
  77126. /**
  77127. * Vector2 of the size of the output plane in World Units.
  77128. */
  77129. outputSize?: Vector2;
  77130. /**
  77131. * Vector3 of the position of the output plane in World Units.
  77132. */
  77133. outputPosition?: Vector3;
  77134. /**
  77135. * Vector3 of the rotation of the output plane.
  77136. */
  77137. outputRotation?: Vector3;
  77138. /**
  77139. * number of layers that the system will reserve in resources.
  77140. */
  77141. layerCount?: number;
  77142. /**
  77143. * number of max animation frames a single cell will reserve in resources.
  77144. */
  77145. maxAnimationFrames?: number;
  77146. /**
  77147. * number cell index of the base tile when the system compiles.
  77148. */
  77149. baseTile?: number;
  77150. /**
  77151. * boolean flip the sprite after its been repositioned by the framing data.
  77152. */
  77153. flipU?: boolean;
  77154. /**
  77155. * Vector3 scalar of the global RGB values of the SpriteMap.
  77156. */
  77157. colorMultiply?: Vector3;
  77158. }
  77159. /**
  77160. * Defines the IDisposable interface in order to be cleanable from resources.
  77161. */
  77162. export interface ISpriteMap extends IDisposable {
  77163. /**
  77164. * String name of the SpriteMap.
  77165. */
  77166. name: string;
  77167. /**
  77168. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77169. */
  77170. atlasJSON: ISpriteJSONAtlas;
  77171. /**
  77172. * Texture of the SpriteMap.
  77173. */
  77174. spriteSheet: Texture;
  77175. /**
  77176. * The parameters to initialize the SpriteMap with.
  77177. */
  77178. options: ISpriteMapOptions;
  77179. }
  77180. /**
  77181. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77182. */
  77183. export class SpriteMap implements ISpriteMap {
  77184. /** The Name of the spriteMap */
  77185. name: string;
  77186. /** The JSON file with the frame and meta data */
  77187. atlasJSON: ISpriteJSONAtlas;
  77188. /** The systems Sprite Sheet Texture */
  77189. spriteSheet: Texture;
  77190. /** Arguments passed with the Constructor */
  77191. options: ISpriteMapOptions;
  77192. /** Public Sprite Storage array, parsed from atlasJSON */
  77193. sprites: Array<ISpriteJSONSprite>;
  77194. /** Returns the Number of Sprites in the System */
  77195. get spriteCount(): number;
  77196. /** Returns the Position of Output Plane*/
  77197. get position(): Vector3;
  77198. /** Returns the Position of Output Plane*/
  77199. set position(v: Vector3);
  77200. /** Returns the Rotation of Output Plane*/
  77201. get rotation(): Vector3;
  77202. /** Returns the Rotation of Output Plane*/
  77203. set rotation(v: Vector3);
  77204. /** Sets the AnimationMap*/
  77205. get animationMap(): RawTexture;
  77206. /** Sets the AnimationMap*/
  77207. set animationMap(v: RawTexture);
  77208. /** Scene that the SpriteMap was created in */
  77209. private _scene;
  77210. /** Texture Buffer of Float32 that holds tile frame data*/
  77211. private _frameMap;
  77212. /** Texture Buffers of Float32 that holds tileMap data*/
  77213. private _tileMaps;
  77214. /** Texture Buffer of Float32 that holds Animation Data*/
  77215. private _animationMap;
  77216. /** Custom ShaderMaterial Central to the System*/
  77217. private _material;
  77218. /** Custom ShaderMaterial Central to the System*/
  77219. private _output;
  77220. /** Systems Time Ticker*/
  77221. private _time;
  77222. /**
  77223. * Creates a new SpriteMap
  77224. * @param name defines the SpriteMaps Name
  77225. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77226. * @param spriteSheet is the Texture that the Sprites are on.
  77227. * @param options a basic deployment configuration
  77228. * @param scene The Scene that the map is deployed on
  77229. */
  77230. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77231. /**
  77232. * Returns tileID location
  77233. * @returns Vector2 the cell position ID
  77234. */
  77235. getTileID(): Vector2;
  77236. /**
  77237. * Gets the UV location of the mouse over the SpriteMap.
  77238. * @returns Vector2 the UV position of the mouse interaction
  77239. */
  77240. getMousePosition(): Vector2;
  77241. /**
  77242. * Creates the "frame" texture Buffer
  77243. * -------------------------------------
  77244. * Structure of frames
  77245. * "filename": "Falling-Water-2.png",
  77246. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77247. * "rotated": true,
  77248. * "trimmed": true,
  77249. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77250. * "sourceSize": {"w":32,"h":32}
  77251. * @returns RawTexture of the frameMap
  77252. */
  77253. private _createFrameBuffer;
  77254. /**
  77255. * Creates the tileMap texture Buffer
  77256. * @param buffer normally and array of numbers, or a false to generate from scratch
  77257. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77258. * @returns RawTexture of the tileMap
  77259. */
  77260. private _createTileBuffer;
  77261. /**
  77262. * Modifies the data of the tileMaps
  77263. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77264. * @param pos is the iVector2 Coordinates of the Tile
  77265. * @param tile The SpriteIndex of the new Tile
  77266. */
  77267. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77268. /**
  77269. * Creates the animationMap texture Buffer
  77270. * @param buffer normally and array of numbers, or a false to generate from scratch
  77271. * @returns RawTexture of the animationMap
  77272. */
  77273. private _createTileAnimationBuffer;
  77274. /**
  77275. * Modifies the data of the animationMap
  77276. * @param cellID is the Index of the Sprite
  77277. * @param _frame is the target Animation frame
  77278. * @param toCell is the Target Index of the next frame of the animation
  77279. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77280. * @param speed is a global scalar of the time variable on the map.
  77281. */
  77282. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77283. /**
  77284. * Exports the .tilemaps file
  77285. */
  77286. saveTileMaps(): void;
  77287. /**
  77288. * Imports the .tilemaps file
  77289. * @param url of the .tilemaps file
  77290. */
  77291. loadTileMaps(url: string): void;
  77292. /**
  77293. * Release associated resources
  77294. */
  77295. dispose(): void;
  77296. }
  77297. }
  77298. declare module "babylonjs/Sprites/spritePackedManager" {
  77299. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77300. import { Scene } from "babylonjs/scene";
  77301. /**
  77302. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77303. * @see https://doc.babylonjs.com/babylon101/sprites
  77304. */
  77305. export class SpritePackedManager extends SpriteManager {
  77306. /** defines the packed manager's name */
  77307. name: string;
  77308. /**
  77309. * Creates a new sprite manager from a packed sprite sheet
  77310. * @param name defines the manager's name
  77311. * @param imgUrl defines the sprite sheet url
  77312. * @param capacity defines the maximum allowed number of sprites
  77313. * @param scene defines the hosting scene
  77314. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77315. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77316. * @param samplingMode defines the smapling mode to use with spritesheet
  77317. * @param fromPacked set to true; do not alter
  77318. */
  77319. constructor(
  77320. /** defines the packed manager's name */
  77321. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77322. }
  77323. }
  77324. declare module "babylonjs/Sprites/index" {
  77325. export * from "babylonjs/Sprites/sprite";
  77326. export * from "babylonjs/Sprites/ISprites";
  77327. export * from "babylonjs/Sprites/spriteManager";
  77328. export * from "babylonjs/Sprites/spriteMap";
  77329. export * from "babylonjs/Sprites/spritePackedManager";
  77330. export * from "babylonjs/Sprites/spriteSceneComponent";
  77331. }
  77332. declare module "babylonjs/States/index" {
  77333. export * from "babylonjs/States/alphaCullingState";
  77334. export * from "babylonjs/States/depthCullingState";
  77335. export * from "babylonjs/States/stencilState";
  77336. }
  77337. declare module "babylonjs/Misc/assetsManager" {
  77338. import { Scene } from "babylonjs/scene";
  77339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77340. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77341. import { Skeleton } from "babylonjs/Bones/skeleton";
  77342. import { Observable } from "babylonjs/Misc/observable";
  77343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77344. import { Texture } from "babylonjs/Materials/Textures/texture";
  77345. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77346. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77347. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77348. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77349. import { AssetContainer } from "babylonjs/assetContainer";
  77350. /**
  77351. * Defines the list of states available for a task inside a AssetsManager
  77352. */
  77353. export enum AssetTaskState {
  77354. /**
  77355. * Initialization
  77356. */
  77357. INIT = 0,
  77358. /**
  77359. * Running
  77360. */
  77361. RUNNING = 1,
  77362. /**
  77363. * Done
  77364. */
  77365. DONE = 2,
  77366. /**
  77367. * Error
  77368. */
  77369. ERROR = 3
  77370. }
  77371. /**
  77372. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77373. */
  77374. export abstract class AbstractAssetTask {
  77375. /**
  77376. * Task name
  77377. */ name: string;
  77378. /**
  77379. * Callback called when the task is successful
  77380. */
  77381. onSuccess: (task: any) => void;
  77382. /**
  77383. * Callback called when the task is not successful
  77384. */
  77385. onError: (task: any, message?: string, exception?: any) => void;
  77386. /**
  77387. * Creates a new AssetsManager
  77388. * @param name defines the name of the task
  77389. */
  77390. constructor(
  77391. /**
  77392. * Task name
  77393. */ name: string);
  77394. private _isCompleted;
  77395. private _taskState;
  77396. private _errorObject;
  77397. /**
  77398. * Get if the task is completed
  77399. */
  77400. get isCompleted(): boolean;
  77401. /**
  77402. * Gets the current state of the task
  77403. */
  77404. get taskState(): AssetTaskState;
  77405. /**
  77406. * Gets the current error object (if task is in error)
  77407. */
  77408. get errorObject(): {
  77409. message?: string;
  77410. exception?: any;
  77411. };
  77412. /**
  77413. * Internal only
  77414. * @hidden
  77415. */
  77416. _setErrorObject(message?: string, exception?: any): void;
  77417. /**
  77418. * Execute the current task
  77419. * @param scene defines the scene where you want your assets to be loaded
  77420. * @param onSuccess is a callback called when the task is successfully executed
  77421. * @param onError is a callback called if an error occurs
  77422. */
  77423. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77424. /**
  77425. * Execute the current task
  77426. * @param scene defines the scene where you want your assets to be loaded
  77427. * @param onSuccess is a callback called when the task is successfully executed
  77428. * @param onError is a callback called if an error occurs
  77429. */
  77430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77431. /**
  77432. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77433. * This can be used with failed tasks that have the reason for failure fixed.
  77434. */
  77435. reset(): void;
  77436. private onErrorCallback;
  77437. private onDoneCallback;
  77438. }
  77439. /**
  77440. * Define the interface used by progress events raised during assets loading
  77441. */
  77442. export interface IAssetsProgressEvent {
  77443. /**
  77444. * Defines the number of remaining tasks to process
  77445. */
  77446. remainingCount: number;
  77447. /**
  77448. * Defines the total number of tasks
  77449. */
  77450. totalCount: number;
  77451. /**
  77452. * Defines the task that was just processed
  77453. */
  77454. task: AbstractAssetTask;
  77455. }
  77456. /**
  77457. * Class used to share progress information about assets loading
  77458. */
  77459. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77460. /**
  77461. * Defines the number of remaining tasks to process
  77462. */
  77463. remainingCount: number;
  77464. /**
  77465. * Defines the total number of tasks
  77466. */
  77467. totalCount: number;
  77468. /**
  77469. * Defines the task that was just processed
  77470. */
  77471. task: AbstractAssetTask;
  77472. /**
  77473. * Creates a AssetsProgressEvent
  77474. * @param remainingCount defines the number of remaining tasks to process
  77475. * @param totalCount defines the total number of tasks
  77476. * @param task defines the task that was just processed
  77477. */
  77478. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77479. }
  77480. /**
  77481. * Define a task used by AssetsManager to load assets into a container
  77482. */
  77483. export class ContainerAssetTask extends AbstractAssetTask {
  77484. /**
  77485. * Defines the name of the task
  77486. */
  77487. name: string;
  77488. /**
  77489. * Defines the list of mesh's names you want to load
  77490. */
  77491. meshesNames: any;
  77492. /**
  77493. * Defines the root url to use as a base to load your meshes and associated resources
  77494. */
  77495. rootUrl: string;
  77496. /**
  77497. * Defines the filename or File of the scene to load from
  77498. */
  77499. sceneFilename: string | File;
  77500. /**
  77501. * Get the loaded asset container
  77502. */
  77503. loadedContainer: AssetContainer;
  77504. /**
  77505. * Gets the list of loaded meshes
  77506. */
  77507. loadedMeshes: Array<AbstractMesh>;
  77508. /**
  77509. * Gets the list of loaded particle systems
  77510. */
  77511. loadedParticleSystems: Array<IParticleSystem>;
  77512. /**
  77513. * Gets the list of loaded skeletons
  77514. */
  77515. loadedSkeletons: Array<Skeleton>;
  77516. /**
  77517. * Gets the list of loaded animation groups
  77518. */
  77519. loadedAnimationGroups: Array<AnimationGroup>;
  77520. /**
  77521. * Callback called when the task is successful
  77522. */
  77523. onSuccess: (task: ContainerAssetTask) => void;
  77524. /**
  77525. * Callback called when the task is successful
  77526. */
  77527. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77528. /**
  77529. * Creates a new ContainerAssetTask
  77530. * @param name defines the name of the task
  77531. * @param meshesNames defines the list of mesh's names you want to load
  77532. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77533. * @param sceneFilename defines the filename or File of the scene to load from
  77534. */
  77535. constructor(
  77536. /**
  77537. * Defines the name of the task
  77538. */
  77539. name: string,
  77540. /**
  77541. * Defines the list of mesh's names you want to load
  77542. */
  77543. meshesNames: any,
  77544. /**
  77545. * Defines the root url to use as a base to load your meshes and associated resources
  77546. */
  77547. rootUrl: string,
  77548. /**
  77549. * Defines the filename or File of the scene to load from
  77550. */
  77551. sceneFilename: string | File);
  77552. /**
  77553. * Execute the current task
  77554. * @param scene defines the scene where you want your assets to be loaded
  77555. * @param onSuccess is a callback called when the task is successfully executed
  77556. * @param onError is a callback called if an error occurs
  77557. */
  77558. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77559. }
  77560. /**
  77561. * Define a task used by AssetsManager to load meshes
  77562. */
  77563. export class MeshAssetTask extends AbstractAssetTask {
  77564. /**
  77565. * Defines the name of the task
  77566. */
  77567. name: string;
  77568. /**
  77569. * Defines the list of mesh's names you want to load
  77570. */
  77571. meshesNames: any;
  77572. /**
  77573. * Defines the root url to use as a base to load your meshes and associated resources
  77574. */
  77575. rootUrl: string;
  77576. /**
  77577. * Defines the filename or File of the scene to load from
  77578. */
  77579. sceneFilename: string | File;
  77580. /**
  77581. * Gets the list of loaded meshes
  77582. */
  77583. loadedMeshes: Array<AbstractMesh>;
  77584. /**
  77585. * Gets the list of loaded particle systems
  77586. */
  77587. loadedParticleSystems: Array<IParticleSystem>;
  77588. /**
  77589. * Gets the list of loaded skeletons
  77590. */
  77591. loadedSkeletons: Array<Skeleton>;
  77592. /**
  77593. * Gets the list of loaded animation groups
  77594. */
  77595. loadedAnimationGroups: Array<AnimationGroup>;
  77596. /**
  77597. * Callback called when the task is successful
  77598. */
  77599. onSuccess: (task: MeshAssetTask) => void;
  77600. /**
  77601. * Callback called when the task is successful
  77602. */
  77603. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77604. /**
  77605. * Creates a new MeshAssetTask
  77606. * @param name defines the name of the task
  77607. * @param meshesNames defines the list of mesh's names you want to load
  77608. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77609. * @param sceneFilename defines the filename or File of the scene to load from
  77610. */
  77611. constructor(
  77612. /**
  77613. * Defines the name of the task
  77614. */
  77615. name: string,
  77616. /**
  77617. * Defines the list of mesh's names you want to load
  77618. */
  77619. meshesNames: any,
  77620. /**
  77621. * Defines the root url to use as a base to load your meshes and associated resources
  77622. */
  77623. rootUrl: string,
  77624. /**
  77625. * Defines the filename or File of the scene to load from
  77626. */
  77627. sceneFilename: string | File);
  77628. /**
  77629. * Execute the current task
  77630. * @param scene defines the scene where you want your assets to be loaded
  77631. * @param onSuccess is a callback called when the task is successfully executed
  77632. * @param onError is a callback called if an error occurs
  77633. */
  77634. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77635. }
  77636. /**
  77637. * Define a task used by AssetsManager to load text content
  77638. */
  77639. export class TextFileAssetTask extends AbstractAssetTask {
  77640. /**
  77641. * Defines the name of the task
  77642. */
  77643. name: string;
  77644. /**
  77645. * Defines the location of the file to load
  77646. */
  77647. url: string;
  77648. /**
  77649. * Gets the loaded text string
  77650. */
  77651. text: string;
  77652. /**
  77653. * Callback called when the task is successful
  77654. */
  77655. onSuccess: (task: TextFileAssetTask) => void;
  77656. /**
  77657. * Callback called when the task is successful
  77658. */
  77659. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77660. /**
  77661. * Creates a new TextFileAssetTask object
  77662. * @param name defines the name of the task
  77663. * @param url defines the location of the file to load
  77664. */
  77665. constructor(
  77666. /**
  77667. * Defines the name of the task
  77668. */
  77669. name: string,
  77670. /**
  77671. * Defines the location of the file to load
  77672. */
  77673. url: string);
  77674. /**
  77675. * Execute the current task
  77676. * @param scene defines the scene where you want your assets to be loaded
  77677. * @param onSuccess is a callback called when the task is successfully executed
  77678. * @param onError is a callback called if an error occurs
  77679. */
  77680. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77681. }
  77682. /**
  77683. * Define a task used by AssetsManager to load binary data
  77684. */
  77685. export class BinaryFileAssetTask extends AbstractAssetTask {
  77686. /**
  77687. * Defines the name of the task
  77688. */
  77689. name: string;
  77690. /**
  77691. * Defines the location of the file to load
  77692. */
  77693. url: string;
  77694. /**
  77695. * Gets the lodaded data (as an array buffer)
  77696. */
  77697. data: ArrayBuffer;
  77698. /**
  77699. * Callback called when the task is successful
  77700. */
  77701. onSuccess: (task: BinaryFileAssetTask) => void;
  77702. /**
  77703. * Callback called when the task is successful
  77704. */
  77705. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77706. /**
  77707. * Creates a new BinaryFileAssetTask object
  77708. * @param name defines the name of the new task
  77709. * @param url defines the location of the file to load
  77710. */
  77711. constructor(
  77712. /**
  77713. * Defines the name of the task
  77714. */
  77715. name: string,
  77716. /**
  77717. * Defines the location of the file to load
  77718. */
  77719. url: string);
  77720. /**
  77721. * Execute the current task
  77722. * @param scene defines the scene where you want your assets to be loaded
  77723. * @param onSuccess is a callback called when the task is successfully executed
  77724. * @param onError is a callback called if an error occurs
  77725. */
  77726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77727. }
  77728. /**
  77729. * Define a task used by AssetsManager to load images
  77730. */
  77731. export class ImageAssetTask extends AbstractAssetTask {
  77732. /**
  77733. * Defines the name of the task
  77734. */
  77735. name: string;
  77736. /**
  77737. * Defines the location of the image to load
  77738. */
  77739. url: string;
  77740. /**
  77741. * Gets the loaded images
  77742. */
  77743. image: HTMLImageElement;
  77744. /**
  77745. * Callback called when the task is successful
  77746. */
  77747. onSuccess: (task: ImageAssetTask) => void;
  77748. /**
  77749. * Callback called when the task is successful
  77750. */
  77751. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77752. /**
  77753. * Creates a new ImageAssetTask
  77754. * @param name defines the name of the task
  77755. * @param url defines the location of the image to load
  77756. */
  77757. constructor(
  77758. /**
  77759. * Defines the name of the task
  77760. */
  77761. name: string,
  77762. /**
  77763. * Defines the location of the image to load
  77764. */
  77765. url: string);
  77766. /**
  77767. * Execute the current task
  77768. * @param scene defines the scene where you want your assets to be loaded
  77769. * @param onSuccess is a callback called when the task is successfully executed
  77770. * @param onError is a callback called if an error occurs
  77771. */
  77772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77773. }
  77774. /**
  77775. * Defines the interface used by texture loading tasks
  77776. */
  77777. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77778. /**
  77779. * Gets the loaded texture
  77780. */
  77781. texture: TEX;
  77782. }
  77783. /**
  77784. * Define a task used by AssetsManager to load 2D textures
  77785. */
  77786. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77787. /**
  77788. * Defines the name of the task
  77789. */
  77790. name: string;
  77791. /**
  77792. * Defines the location of the file to load
  77793. */
  77794. url: string;
  77795. /**
  77796. * Defines if mipmap should not be generated (default is false)
  77797. */
  77798. noMipmap?: boolean | undefined;
  77799. /**
  77800. * Defines if texture must be inverted on Y axis (default is true)
  77801. */
  77802. invertY: boolean;
  77803. /**
  77804. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77805. */
  77806. samplingMode: number;
  77807. /**
  77808. * Gets the loaded texture
  77809. */
  77810. texture: Texture;
  77811. /**
  77812. * Callback called when the task is successful
  77813. */
  77814. onSuccess: (task: TextureAssetTask) => void;
  77815. /**
  77816. * Callback called when the task is successful
  77817. */
  77818. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77819. /**
  77820. * Creates a new TextureAssetTask object
  77821. * @param name defines the name of the task
  77822. * @param url defines the location of the file to load
  77823. * @param noMipmap defines if mipmap should not be generated (default is false)
  77824. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77825. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77826. */
  77827. constructor(
  77828. /**
  77829. * Defines the name of the task
  77830. */
  77831. name: string,
  77832. /**
  77833. * Defines the location of the file to load
  77834. */
  77835. url: string,
  77836. /**
  77837. * Defines if mipmap should not be generated (default is false)
  77838. */
  77839. noMipmap?: boolean | undefined,
  77840. /**
  77841. * Defines if texture must be inverted on Y axis (default is true)
  77842. */
  77843. invertY?: boolean,
  77844. /**
  77845. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77846. */
  77847. samplingMode?: number);
  77848. /**
  77849. * Execute the current task
  77850. * @param scene defines the scene where you want your assets to be loaded
  77851. * @param onSuccess is a callback called when the task is successfully executed
  77852. * @param onError is a callback called if an error occurs
  77853. */
  77854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77855. }
  77856. /**
  77857. * Define a task used by AssetsManager to load cube textures
  77858. */
  77859. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77860. /**
  77861. * Defines the name of the task
  77862. */
  77863. name: string;
  77864. /**
  77865. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77866. */
  77867. url: string;
  77868. /**
  77869. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77870. */
  77871. extensions?: string[] | undefined;
  77872. /**
  77873. * Defines if mipmaps should not be generated (default is false)
  77874. */
  77875. noMipmap?: boolean | undefined;
  77876. /**
  77877. * Defines the explicit list of files (undefined by default)
  77878. */
  77879. files?: string[] | undefined;
  77880. /**
  77881. * Gets the loaded texture
  77882. */
  77883. texture: CubeTexture;
  77884. /**
  77885. * Callback called when the task is successful
  77886. */
  77887. onSuccess: (task: CubeTextureAssetTask) => void;
  77888. /**
  77889. * Callback called when the task is successful
  77890. */
  77891. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77892. /**
  77893. * Creates a new CubeTextureAssetTask
  77894. * @param name defines the name of the task
  77895. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77896. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77897. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77898. * @param files defines the explicit list of files (undefined by default)
  77899. */
  77900. constructor(
  77901. /**
  77902. * Defines the name of the task
  77903. */
  77904. name: string,
  77905. /**
  77906. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77907. */
  77908. url: string,
  77909. /**
  77910. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77911. */
  77912. extensions?: string[] | undefined,
  77913. /**
  77914. * Defines if mipmaps should not be generated (default is false)
  77915. */
  77916. noMipmap?: boolean | undefined,
  77917. /**
  77918. * Defines the explicit list of files (undefined by default)
  77919. */
  77920. files?: string[] | undefined);
  77921. /**
  77922. * Execute the current task
  77923. * @param scene defines the scene where you want your assets to be loaded
  77924. * @param onSuccess is a callback called when the task is successfully executed
  77925. * @param onError is a callback called if an error occurs
  77926. */
  77927. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77928. }
  77929. /**
  77930. * Define a task used by AssetsManager to load HDR cube textures
  77931. */
  77932. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77933. /**
  77934. * Defines the name of the task
  77935. */
  77936. name: string;
  77937. /**
  77938. * Defines the location of the file to load
  77939. */
  77940. url: string;
  77941. /**
  77942. * Defines the desired size (the more it increases the longer the generation will be)
  77943. */
  77944. size: number;
  77945. /**
  77946. * Defines if mipmaps should not be generated (default is false)
  77947. */
  77948. noMipmap: boolean;
  77949. /**
  77950. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77951. */
  77952. generateHarmonics: boolean;
  77953. /**
  77954. * 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)
  77955. */
  77956. gammaSpace: boolean;
  77957. /**
  77958. * Internal Use Only
  77959. */
  77960. reserved: boolean;
  77961. /**
  77962. * Gets the loaded texture
  77963. */
  77964. texture: HDRCubeTexture;
  77965. /**
  77966. * Callback called when the task is successful
  77967. */
  77968. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77969. /**
  77970. * Callback called when the task is successful
  77971. */
  77972. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77973. /**
  77974. * Creates a new HDRCubeTextureAssetTask object
  77975. * @param name defines the name of the task
  77976. * @param url defines the location of the file to load
  77977. * @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.
  77978. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77979. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77980. * @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)
  77981. * @param reserved Internal use only
  77982. */
  77983. constructor(
  77984. /**
  77985. * Defines the name of the task
  77986. */
  77987. name: string,
  77988. /**
  77989. * Defines the location of the file to load
  77990. */
  77991. url: string,
  77992. /**
  77993. * Defines the desired size (the more it increases the longer the generation will be)
  77994. */
  77995. size: number,
  77996. /**
  77997. * Defines if mipmaps should not be generated (default is false)
  77998. */
  77999. noMipmap?: boolean,
  78000. /**
  78001. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78002. */
  78003. generateHarmonics?: boolean,
  78004. /**
  78005. * 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)
  78006. */
  78007. gammaSpace?: boolean,
  78008. /**
  78009. * Internal Use Only
  78010. */
  78011. reserved?: boolean);
  78012. /**
  78013. * Execute the current task
  78014. * @param scene defines the scene where you want your assets to be loaded
  78015. * @param onSuccess is a callback called when the task is successfully executed
  78016. * @param onError is a callback called if an error occurs
  78017. */
  78018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78019. }
  78020. /**
  78021. * Define a task used by AssetsManager to load Equirectangular cube textures
  78022. */
  78023. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78024. /**
  78025. * Defines the name of the task
  78026. */
  78027. name: string;
  78028. /**
  78029. * Defines the location of the file to load
  78030. */
  78031. url: string;
  78032. /**
  78033. * Defines the desired size (the more it increases the longer the generation will be)
  78034. */
  78035. size: number;
  78036. /**
  78037. * Defines if mipmaps should not be generated (default is false)
  78038. */
  78039. noMipmap: boolean;
  78040. /**
  78041. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78042. * but the standard material would require them in Gamma space) (default is true)
  78043. */
  78044. gammaSpace: boolean;
  78045. /**
  78046. * Gets the loaded texture
  78047. */
  78048. texture: EquiRectangularCubeTexture;
  78049. /**
  78050. * Callback called when the task is successful
  78051. */
  78052. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78053. /**
  78054. * Callback called when the task is successful
  78055. */
  78056. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78057. /**
  78058. * Creates a new EquiRectangularCubeTextureAssetTask object
  78059. * @param name defines the name of the task
  78060. * @param url defines the location of the file to load
  78061. * @param size defines the desired size (the more it increases the longer the generation will be)
  78062. * If the size is omitted this implies you are using a preprocessed cubemap.
  78063. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78064. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78065. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78066. * (default is true)
  78067. */
  78068. constructor(
  78069. /**
  78070. * Defines the name of the task
  78071. */
  78072. name: string,
  78073. /**
  78074. * Defines the location of the file to load
  78075. */
  78076. url: string,
  78077. /**
  78078. * Defines the desired size (the more it increases the longer the generation will be)
  78079. */
  78080. size: number,
  78081. /**
  78082. * Defines if mipmaps should not be generated (default is false)
  78083. */
  78084. noMipmap?: boolean,
  78085. /**
  78086. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78087. * but the standard material would require them in Gamma space) (default is true)
  78088. */
  78089. gammaSpace?: boolean);
  78090. /**
  78091. * Execute the current task
  78092. * @param scene defines the scene where you want your assets to be loaded
  78093. * @param onSuccess is a callback called when the task is successfully executed
  78094. * @param onError is a callback called if an error occurs
  78095. */
  78096. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78097. }
  78098. /**
  78099. * This class can be used to easily import assets into a scene
  78100. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78101. */
  78102. export class AssetsManager {
  78103. private _scene;
  78104. private _isLoading;
  78105. protected _tasks: AbstractAssetTask[];
  78106. protected _waitingTasksCount: number;
  78107. protected _totalTasksCount: number;
  78108. /**
  78109. * Callback called when all tasks are processed
  78110. */
  78111. onFinish: (tasks: AbstractAssetTask[]) => void;
  78112. /**
  78113. * Callback called when a task is successful
  78114. */
  78115. onTaskSuccess: (task: AbstractAssetTask) => void;
  78116. /**
  78117. * Callback called when a task had an error
  78118. */
  78119. onTaskError: (task: AbstractAssetTask) => void;
  78120. /**
  78121. * Callback called when a task is done (whatever the result is)
  78122. */
  78123. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78124. /**
  78125. * Observable called when all tasks are processed
  78126. */
  78127. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78128. /**
  78129. * Observable called when a task had an error
  78130. */
  78131. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78132. /**
  78133. * Observable called when all tasks were executed
  78134. */
  78135. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78136. /**
  78137. * Observable called when a task is done (whatever the result is)
  78138. */
  78139. onProgressObservable: Observable<IAssetsProgressEvent>;
  78140. /**
  78141. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78142. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78143. */
  78144. useDefaultLoadingScreen: boolean;
  78145. /**
  78146. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78147. * when all assets have been downloaded.
  78148. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78149. */
  78150. autoHideLoadingUI: boolean;
  78151. /**
  78152. * Creates a new AssetsManager
  78153. * @param scene defines the scene to work on
  78154. */
  78155. constructor(scene: Scene);
  78156. /**
  78157. * Add a ContainerAssetTask to the list of active tasks
  78158. * @param taskName defines the name of the new task
  78159. * @param meshesNames defines the name of meshes to load
  78160. * @param rootUrl defines the root url to use to locate files
  78161. * @param sceneFilename defines the filename of the scene file
  78162. * @returns a new ContainerAssetTask object
  78163. */
  78164. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78165. /**
  78166. * Add a MeshAssetTask to the list of active tasks
  78167. * @param taskName defines the name of the new task
  78168. * @param meshesNames defines the name of meshes to load
  78169. * @param rootUrl defines the root url to use to locate files
  78170. * @param sceneFilename defines the filename of the scene file
  78171. * @returns a new MeshAssetTask object
  78172. */
  78173. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78174. /**
  78175. * Add a TextFileAssetTask to the list of active tasks
  78176. * @param taskName defines the name of the new task
  78177. * @param url defines the url of the file to load
  78178. * @returns a new TextFileAssetTask object
  78179. */
  78180. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78181. /**
  78182. * Add a BinaryFileAssetTask to the list of active tasks
  78183. * @param taskName defines the name of the new task
  78184. * @param url defines the url of the file to load
  78185. * @returns a new BinaryFileAssetTask object
  78186. */
  78187. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78188. /**
  78189. * Add a ImageAssetTask to the list of active tasks
  78190. * @param taskName defines the name of the new task
  78191. * @param url defines the url of the file to load
  78192. * @returns a new ImageAssetTask object
  78193. */
  78194. addImageTask(taskName: string, url: string): ImageAssetTask;
  78195. /**
  78196. * Add a TextureAssetTask to the list of active tasks
  78197. * @param taskName defines the name of the new task
  78198. * @param url defines the url of the file to load
  78199. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78200. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78201. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78202. * @returns a new TextureAssetTask object
  78203. */
  78204. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78205. /**
  78206. * Add a CubeTextureAssetTask to the list of active tasks
  78207. * @param taskName defines the name of the new task
  78208. * @param url defines the url of the file to load
  78209. * @param extensions defines the extension to use to load the cube map (can be null)
  78210. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78211. * @param files defines the list of files to load (can be null)
  78212. * @returns a new CubeTextureAssetTask object
  78213. */
  78214. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78215. /**
  78216. *
  78217. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78218. * @param taskName defines the name of the new task
  78219. * @param url defines the url of the file to load
  78220. * @param size defines the size you want for the cubemap (can be null)
  78221. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78222. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78223. * @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)
  78224. * @param reserved Internal use only
  78225. * @returns a new HDRCubeTextureAssetTask object
  78226. */
  78227. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78228. /**
  78229. *
  78230. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78231. * @param taskName defines the name of the new task
  78232. * @param url defines the url of the file to load
  78233. * @param size defines the size you want for the cubemap (can be null)
  78234. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78235. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78236. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78237. * @returns a new EquiRectangularCubeTextureAssetTask object
  78238. */
  78239. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78240. /**
  78241. * Remove a task from the assets manager.
  78242. * @param task the task to remove
  78243. */
  78244. removeTask(task: AbstractAssetTask): void;
  78245. private _decreaseWaitingTasksCount;
  78246. private _runTask;
  78247. /**
  78248. * Reset the AssetsManager and remove all tasks
  78249. * @return the current instance of the AssetsManager
  78250. */
  78251. reset(): AssetsManager;
  78252. /**
  78253. * Start the loading process
  78254. * @return the current instance of the AssetsManager
  78255. */
  78256. load(): AssetsManager;
  78257. /**
  78258. * Start the loading process as an async operation
  78259. * @return a promise returning the list of failed tasks
  78260. */
  78261. loadAsync(): Promise<void>;
  78262. }
  78263. }
  78264. declare module "babylonjs/Misc/deferred" {
  78265. /**
  78266. * Wrapper class for promise with external resolve and reject.
  78267. */
  78268. export class Deferred<T> {
  78269. /**
  78270. * The promise associated with this deferred object.
  78271. */
  78272. readonly promise: Promise<T>;
  78273. private _resolve;
  78274. private _reject;
  78275. /**
  78276. * The resolve method of the promise associated with this deferred object.
  78277. */
  78278. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78279. /**
  78280. * The reject method of the promise associated with this deferred object.
  78281. */
  78282. get reject(): (reason?: any) => void;
  78283. /**
  78284. * Constructor for this deferred object.
  78285. */
  78286. constructor();
  78287. }
  78288. }
  78289. declare module "babylonjs/Misc/meshExploder" {
  78290. import { Mesh } from "babylonjs/Meshes/mesh";
  78291. /**
  78292. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78293. */
  78294. export class MeshExploder {
  78295. private _centerMesh;
  78296. private _meshes;
  78297. private _meshesOrigins;
  78298. private _toCenterVectors;
  78299. private _scaledDirection;
  78300. private _newPosition;
  78301. private _centerPosition;
  78302. /**
  78303. * Explodes meshes from a center mesh.
  78304. * @param meshes The meshes to explode.
  78305. * @param centerMesh The mesh to be center of explosion.
  78306. */
  78307. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78308. private _setCenterMesh;
  78309. /**
  78310. * Get class name
  78311. * @returns "MeshExploder"
  78312. */
  78313. getClassName(): string;
  78314. /**
  78315. * "Exploded meshes"
  78316. * @returns Array of meshes with the centerMesh at index 0.
  78317. */
  78318. getMeshes(): Array<Mesh>;
  78319. /**
  78320. * Explodes meshes giving a specific direction
  78321. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78322. */
  78323. explode(direction?: number): void;
  78324. }
  78325. }
  78326. declare module "babylonjs/Misc/filesInput" {
  78327. import { Engine } from "babylonjs/Engines/engine";
  78328. import { Scene } from "babylonjs/scene";
  78329. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78330. import { Nullable } from "babylonjs/types";
  78331. /**
  78332. * Class used to help managing file picking and drag'n'drop
  78333. */
  78334. export class FilesInput {
  78335. /**
  78336. * List of files ready to be loaded
  78337. */
  78338. static get FilesToLoad(): {
  78339. [key: string]: File;
  78340. };
  78341. /**
  78342. * Callback called when a file is processed
  78343. */
  78344. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78345. private _engine;
  78346. private _currentScene;
  78347. private _sceneLoadedCallback;
  78348. private _progressCallback;
  78349. private _additionalRenderLoopLogicCallback;
  78350. private _textureLoadingCallback;
  78351. private _startingProcessingFilesCallback;
  78352. private _onReloadCallback;
  78353. private _errorCallback;
  78354. private _elementToMonitor;
  78355. private _sceneFileToLoad;
  78356. private _filesToLoad;
  78357. /**
  78358. * Creates a new FilesInput
  78359. * @param engine defines the rendering engine
  78360. * @param scene defines the hosting scene
  78361. * @param sceneLoadedCallback callback called when scene is loaded
  78362. * @param progressCallback callback called to track progress
  78363. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78364. * @param textureLoadingCallback callback called when a texture is loading
  78365. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78366. * @param onReloadCallback callback called when a reload is requested
  78367. * @param errorCallback callback call if an error occurs
  78368. */
  78369. 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>);
  78370. private _dragEnterHandler;
  78371. private _dragOverHandler;
  78372. private _dropHandler;
  78373. /**
  78374. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78375. * @param elementToMonitor defines the DOM element to track
  78376. */
  78377. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78378. /** Gets the current list of files to load */
  78379. get filesToLoad(): File[];
  78380. /**
  78381. * Release all associated resources
  78382. */
  78383. dispose(): void;
  78384. private renderFunction;
  78385. private drag;
  78386. private drop;
  78387. private _traverseFolder;
  78388. private _processFiles;
  78389. /**
  78390. * Load files from a drop event
  78391. * @param event defines the drop event to use as source
  78392. */
  78393. loadFiles(event: any): void;
  78394. private _processReload;
  78395. /**
  78396. * Reload the current scene from the loaded files
  78397. */
  78398. reload(): void;
  78399. }
  78400. }
  78401. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78402. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78403. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78404. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78405. }
  78406. declare module "babylonjs/Misc/sceneOptimizer" {
  78407. import { Scene, IDisposable } from "babylonjs/scene";
  78408. import { Observable } from "babylonjs/Misc/observable";
  78409. /**
  78410. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78411. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78412. */
  78413. export class SceneOptimization {
  78414. /**
  78415. * Defines the priority of this optimization (0 by default which means first in the list)
  78416. */
  78417. priority: number;
  78418. /**
  78419. * Gets a string describing the action executed by the current optimization
  78420. * @returns description string
  78421. */
  78422. getDescription(): string;
  78423. /**
  78424. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78425. * @param scene defines the current scene where to apply this optimization
  78426. * @param optimizer defines the current optimizer
  78427. * @returns true if everything that can be done was applied
  78428. */
  78429. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78430. /**
  78431. * Creates the SceneOptimization object
  78432. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78433. * @param desc defines the description associated with the optimization
  78434. */
  78435. constructor(
  78436. /**
  78437. * Defines the priority of this optimization (0 by default which means first in the list)
  78438. */
  78439. priority?: number);
  78440. }
  78441. /**
  78442. * Defines an optimization used to reduce the size of render target textures
  78443. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78444. */
  78445. export class TextureOptimization extends SceneOptimization {
  78446. /**
  78447. * Defines the priority of this optimization (0 by default which means first in the list)
  78448. */
  78449. priority: number;
  78450. /**
  78451. * 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
  78452. */
  78453. maximumSize: number;
  78454. /**
  78455. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78456. */
  78457. step: number;
  78458. /**
  78459. * Gets a string describing the action executed by the current optimization
  78460. * @returns description string
  78461. */
  78462. getDescription(): string;
  78463. /**
  78464. * Creates the TextureOptimization object
  78465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78466. * @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
  78467. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78468. */
  78469. constructor(
  78470. /**
  78471. * Defines the priority of this optimization (0 by default which means first in the list)
  78472. */
  78473. priority?: number,
  78474. /**
  78475. * 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
  78476. */
  78477. maximumSize?: number,
  78478. /**
  78479. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78480. */
  78481. step?: number);
  78482. /**
  78483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78484. * @param scene defines the current scene where to apply this optimization
  78485. * @param optimizer defines the current optimizer
  78486. * @returns true if everything that can be done was applied
  78487. */
  78488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78489. }
  78490. /**
  78491. * Defines an optimization used to increase or decrease the rendering resolution
  78492. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78493. */
  78494. export class HardwareScalingOptimization extends SceneOptimization {
  78495. /**
  78496. * Defines the priority of this optimization (0 by default which means first in the list)
  78497. */
  78498. priority: number;
  78499. /**
  78500. * Defines the maximum scale to use (2 by default)
  78501. */
  78502. maximumScale: number;
  78503. /**
  78504. * Defines the step to use between two passes (0.5 by default)
  78505. */
  78506. step: number;
  78507. private _currentScale;
  78508. private _directionOffset;
  78509. /**
  78510. * Gets a string describing the action executed by the current optimization
  78511. * @return description string
  78512. */
  78513. getDescription(): string;
  78514. /**
  78515. * Creates the HardwareScalingOptimization object
  78516. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78517. * @param maximumScale defines the maximum scale to use (2 by default)
  78518. * @param step defines the step to use between two passes (0.5 by default)
  78519. */
  78520. constructor(
  78521. /**
  78522. * Defines the priority of this optimization (0 by default which means first in the list)
  78523. */
  78524. priority?: number,
  78525. /**
  78526. * Defines the maximum scale to use (2 by default)
  78527. */
  78528. maximumScale?: number,
  78529. /**
  78530. * Defines the step to use between two passes (0.5 by default)
  78531. */
  78532. step?: number);
  78533. /**
  78534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78535. * @param scene defines the current scene where to apply this optimization
  78536. * @param optimizer defines the current optimizer
  78537. * @returns true if everything that can be done was applied
  78538. */
  78539. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78540. }
  78541. /**
  78542. * Defines an optimization used to remove shadows
  78543. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78544. */
  78545. export class ShadowsOptimization extends SceneOptimization {
  78546. /**
  78547. * Gets a string describing the action executed by the current optimization
  78548. * @return description string
  78549. */
  78550. getDescription(): string;
  78551. /**
  78552. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78553. * @param scene defines the current scene where to apply this optimization
  78554. * @param optimizer defines the current optimizer
  78555. * @returns true if everything that can be done was applied
  78556. */
  78557. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78558. }
  78559. /**
  78560. * Defines an optimization used to turn post-processes off
  78561. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78562. */
  78563. export class PostProcessesOptimization extends SceneOptimization {
  78564. /**
  78565. * Gets a string describing the action executed by the current optimization
  78566. * @return description string
  78567. */
  78568. getDescription(): string;
  78569. /**
  78570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78571. * @param scene defines the current scene where to apply this optimization
  78572. * @param optimizer defines the current optimizer
  78573. * @returns true if everything that can be done was applied
  78574. */
  78575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78576. }
  78577. /**
  78578. * Defines an optimization used to turn lens flares off
  78579. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78580. */
  78581. export class LensFlaresOptimization extends SceneOptimization {
  78582. /**
  78583. * Gets a string describing the action executed by the current optimization
  78584. * @return description string
  78585. */
  78586. getDescription(): string;
  78587. /**
  78588. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78589. * @param scene defines the current scene where to apply this optimization
  78590. * @param optimizer defines the current optimizer
  78591. * @returns true if everything that can be done was applied
  78592. */
  78593. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78594. }
  78595. /**
  78596. * Defines an optimization based on user defined callback.
  78597. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78598. */
  78599. export class CustomOptimization extends SceneOptimization {
  78600. /**
  78601. * Callback called to apply the custom optimization.
  78602. */
  78603. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78604. /**
  78605. * Callback called to get custom description
  78606. */
  78607. onGetDescription: () => string;
  78608. /**
  78609. * Gets a string describing the action executed by the current optimization
  78610. * @returns description string
  78611. */
  78612. getDescription(): string;
  78613. /**
  78614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78615. * @param scene defines the current scene where to apply this optimization
  78616. * @param optimizer defines the current optimizer
  78617. * @returns true if everything that can be done was applied
  78618. */
  78619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78620. }
  78621. /**
  78622. * Defines an optimization used to turn particles off
  78623. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78624. */
  78625. export class ParticlesOptimization extends SceneOptimization {
  78626. /**
  78627. * Gets a string describing the action executed by the current optimization
  78628. * @return description string
  78629. */
  78630. getDescription(): string;
  78631. /**
  78632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78633. * @param scene defines the current scene where to apply this optimization
  78634. * @param optimizer defines the current optimizer
  78635. * @returns true if everything that can be done was applied
  78636. */
  78637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78638. }
  78639. /**
  78640. * Defines an optimization used to turn render targets off
  78641. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78642. */
  78643. export class RenderTargetsOptimization extends SceneOptimization {
  78644. /**
  78645. * Gets a string describing the action executed by the current optimization
  78646. * @return description string
  78647. */
  78648. getDescription(): string;
  78649. /**
  78650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78651. * @param scene defines the current scene where to apply this optimization
  78652. * @param optimizer defines the current optimizer
  78653. * @returns true if everything that can be done was applied
  78654. */
  78655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78656. }
  78657. /**
  78658. * Defines an optimization used to merge meshes with compatible materials
  78659. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78660. */
  78661. export class MergeMeshesOptimization extends SceneOptimization {
  78662. private static _UpdateSelectionTree;
  78663. /**
  78664. * Gets or sets a boolean which defines if optimization octree has to be updated
  78665. */
  78666. static get UpdateSelectionTree(): boolean;
  78667. /**
  78668. * Gets or sets a boolean which defines if optimization octree has to be updated
  78669. */
  78670. static set UpdateSelectionTree(value: boolean);
  78671. /**
  78672. * Gets a string describing the action executed by the current optimization
  78673. * @return description string
  78674. */
  78675. getDescription(): string;
  78676. private _canBeMerged;
  78677. /**
  78678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78679. * @param scene defines the current scene where to apply this optimization
  78680. * @param optimizer defines the current optimizer
  78681. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78682. * @returns true if everything that can be done was applied
  78683. */
  78684. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78685. }
  78686. /**
  78687. * Defines a list of options used by SceneOptimizer
  78688. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78689. */
  78690. export class SceneOptimizerOptions {
  78691. /**
  78692. * Defines the target frame rate to reach (60 by default)
  78693. */
  78694. targetFrameRate: number;
  78695. /**
  78696. * Defines the interval between two checkes (2000ms by default)
  78697. */
  78698. trackerDuration: number;
  78699. /**
  78700. * Gets the list of optimizations to apply
  78701. */
  78702. optimizations: SceneOptimization[];
  78703. /**
  78704. * Creates a new list of options used by SceneOptimizer
  78705. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78706. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78707. */
  78708. constructor(
  78709. /**
  78710. * Defines the target frame rate to reach (60 by default)
  78711. */
  78712. targetFrameRate?: number,
  78713. /**
  78714. * Defines the interval between two checkes (2000ms by default)
  78715. */
  78716. trackerDuration?: number);
  78717. /**
  78718. * Add a new optimization
  78719. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78720. * @returns the current SceneOptimizerOptions
  78721. */
  78722. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78723. /**
  78724. * Add a new custom optimization
  78725. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78726. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78727. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78728. * @returns the current SceneOptimizerOptions
  78729. */
  78730. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78731. /**
  78732. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78733. * @param targetFrameRate defines the target frame rate (60 by default)
  78734. * @returns a SceneOptimizerOptions object
  78735. */
  78736. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78737. /**
  78738. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78739. * @param targetFrameRate defines the target frame rate (60 by default)
  78740. * @returns a SceneOptimizerOptions object
  78741. */
  78742. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78743. /**
  78744. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78745. * @param targetFrameRate defines the target frame rate (60 by default)
  78746. * @returns a SceneOptimizerOptions object
  78747. */
  78748. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78749. }
  78750. /**
  78751. * Class used to run optimizations in order to reach a target frame rate
  78752. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78753. */
  78754. export class SceneOptimizer implements IDisposable {
  78755. private _isRunning;
  78756. private _options;
  78757. private _scene;
  78758. private _currentPriorityLevel;
  78759. private _targetFrameRate;
  78760. private _trackerDuration;
  78761. private _currentFrameRate;
  78762. private _sceneDisposeObserver;
  78763. private _improvementMode;
  78764. /**
  78765. * Defines an observable called when the optimizer reaches the target frame rate
  78766. */
  78767. onSuccessObservable: Observable<SceneOptimizer>;
  78768. /**
  78769. * Defines an observable called when the optimizer enables an optimization
  78770. */
  78771. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78772. /**
  78773. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78774. */
  78775. onFailureObservable: Observable<SceneOptimizer>;
  78776. /**
  78777. * Gets a boolean indicating if the optimizer is in improvement mode
  78778. */
  78779. get isInImprovementMode(): boolean;
  78780. /**
  78781. * Gets the current priority level (0 at start)
  78782. */
  78783. get currentPriorityLevel(): number;
  78784. /**
  78785. * Gets the current frame rate checked by the SceneOptimizer
  78786. */
  78787. get currentFrameRate(): number;
  78788. /**
  78789. * Gets or sets the current target frame rate (60 by default)
  78790. */
  78791. get targetFrameRate(): number;
  78792. /**
  78793. * Gets or sets the current target frame rate (60 by default)
  78794. */
  78795. set targetFrameRate(value: number);
  78796. /**
  78797. * Gets or sets the current interval between two checks (every 2000ms by default)
  78798. */
  78799. get trackerDuration(): number;
  78800. /**
  78801. * Gets or sets the current interval between two checks (every 2000ms by default)
  78802. */
  78803. set trackerDuration(value: number);
  78804. /**
  78805. * Gets the list of active optimizations
  78806. */
  78807. get optimizations(): SceneOptimization[];
  78808. /**
  78809. * Creates a new SceneOptimizer
  78810. * @param scene defines the scene to work on
  78811. * @param options defines the options to use with the SceneOptimizer
  78812. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78813. * @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)
  78814. */
  78815. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78816. /**
  78817. * Stops the current optimizer
  78818. */
  78819. stop(): void;
  78820. /**
  78821. * Reset the optimizer to initial step (current priority level = 0)
  78822. */
  78823. reset(): void;
  78824. /**
  78825. * Start the optimizer. By default it will try to reach a specific framerate
  78826. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78827. */
  78828. start(): void;
  78829. private _checkCurrentState;
  78830. /**
  78831. * Release all resources
  78832. */
  78833. dispose(): void;
  78834. /**
  78835. * Helper function to create a SceneOptimizer with one single line of code
  78836. * @param scene defines the scene to work on
  78837. * @param options defines the options to use with the SceneOptimizer
  78838. * @param onSuccess defines a callback to call on success
  78839. * @param onFailure defines a callback to call on failure
  78840. * @returns the new SceneOptimizer object
  78841. */
  78842. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78843. }
  78844. }
  78845. declare module "babylonjs/Misc/sceneSerializer" {
  78846. import { Scene } from "babylonjs/scene";
  78847. /**
  78848. * Class used to serialize a scene into a string
  78849. */
  78850. export class SceneSerializer {
  78851. /**
  78852. * Clear cache used by a previous serialization
  78853. */
  78854. static ClearCache(): void;
  78855. /**
  78856. * Serialize a scene into a JSON compatible object
  78857. * @param scene defines the scene to serialize
  78858. * @returns a JSON compatible object
  78859. */
  78860. static Serialize(scene: Scene): any;
  78861. /**
  78862. * Serialize a mesh into a JSON compatible object
  78863. * @param toSerialize defines the mesh to serialize
  78864. * @param withParents defines if parents must be serialized as well
  78865. * @param withChildren defines if children must be serialized as well
  78866. * @returns a JSON compatible object
  78867. */
  78868. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78869. }
  78870. }
  78871. declare module "babylonjs/Misc/textureTools" {
  78872. import { Texture } from "babylonjs/Materials/Textures/texture";
  78873. /**
  78874. * Class used to host texture specific utilities
  78875. */
  78876. export class TextureTools {
  78877. /**
  78878. * Uses the GPU to create a copy texture rescaled at a given size
  78879. * @param texture Texture to copy from
  78880. * @param width defines the desired width
  78881. * @param height defines the desired height
  78882. * @param useBilinearMode defines if bilinear mode has to be used
  78883. * @return the generated texture
  78884. */
  78885. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78886. }
  78887. }
  78888. declare module "babylonjs/Misc/videoRecorder" {
  78889. import { Nullable } from "babylonjs/types";
  78890. import { Engine } from "babylonjs/Engines/engine";
  78891. /**
  78892. * This represents the different options available for the video capture.
  78893. */
  78894. export interface VideoRecorderOptions {
  78895. /** Defines the mime type of the video. */
  78896. mimeType: string;
  78897. /** Defines the FPS the video should be recorded at. */
  78898. fps: number;
  78899. /** Defines the chunk size for the recording data. */
  78900. recordChunckSize: number;
  78901. /** The audio tracks to attach to the recording. */
  78902. audioTracks?: MediaStreamTrack[];
  78903. }
  78904. /**
  78905. * This can help with recording videos from BabylonJS.
  78906. * This is based on the available WebRTC functionalities of the browser.
  78907. *
  78908. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78909. */
  78910. export class VideoRecorder {
  78911. private static readonly _defaultOptions;
  78912. /**
  78913. * Returns whether or not the VideoRecorder is available in your browser.
  78914. * @param engine Defines the Babylon Engine.
  78915. * @returns true if supported otherwise false.
  78916. */
  78917. static IsSupported(engine: Engine): boolean;
  78918. private readonly _options;
  78919. private _canvas;
  78920. private _mediaRecorder;
  78921. private _recordedChunks;
  78922. private _fileName;
  78923. private _resolve;
  78924. private _reject;
  78925. /**
  78926. * True when a recording is already in progress.
  78927. */
  78928. get isRecording(): boolean;
  78929. /**
  78930. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78931. * @param engine Defines the BabylonJS Engine you wish to record.
  78932. * @param options Defines options that can be used to customize the capture.
  78933. */
  78934. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78935. /**
  78936. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78937. */
  78938. stopRecording(): void;
  78939. /**
  78940. * Starts recording the canvas for a max duration specified in parameters.
  78941. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78942. * If null no automatic download will start and you can rely on the promise to get the data back.
  78943. * @param maxDuration Defines the maximum recording time in seconds.
  78944. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78945. * @return A promise callback at the end of the recording with the video data in Blob.
  78946. */
  78947. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78948. /**
  78949. * Releases internal resources used during the recording.
  78950. */
  78951. dispose(): void;
  78952. private _handleDataAvailable;
  78953. private _handleError;
  78954. private _handleStop;
  78955. }
  78956. }
  78957. declare module "babylonjs/Misc/screenshotTools" {
  78958. import { Camera } from "babylonjs/Cameras/camera";
  78959. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78960. import { Engine } from "babylonjs/Engines/engine";
  78961. /**
  78962. * Class containing a set of static utilities functions for screenshots
  78963. */
  78964. export class ScreenshotTools {
  78965. /**
  78966. * Captures a screenshot of the current rendering
  78967. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78968. * @param engine defines the rendering engine
  78969. * @param camera defines the source camera
  78970. * @param size This parameter can be set to a single number or to an object with the
  78971. * following (optional) properties: precision, width, height. If a single number is passed,
  78972. * it will be used for both width and height. If an object is passed, the screenshot size
  78973. * will be derived from the parameters. The precision property is a multiplier allowing
  78974. * rendering at a higher or lower resolution
  78975. * @param successCallback defines the callback receives a single parameter which contains the
  78976. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78977. * src parameter of an <img> to display it
  78978. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78979. * Check your browser for supported MIME types
  78980. */
  78981. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78982. /**
  78983. * Captures a screenshot of the current rendering
  78984. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78985. * @param engine defines the rendering engine
  78986. * @param camera defines the source camera
  78987. * @param size This parameter can be set to a single number or to an object with the
  78988. * following (optional) properties: precision, width, height. If a single number is passed,
  78989. * it will be used for both width and height. If an object is passed, the screenshot size
  78990. * will be derived from the parameters. The precision property is a multiplier allowing
  78991. * rendering at a higher or lower resolution
  78992. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78993. * Check your browser for supported MIME types
  78994. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78995. * to the src parameter of an <img> to display it
  78996. */
  78997. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78998. /**
  78999. * Generates an image screenshot from the specified camera.
  79000. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79001. * @param engine The engine to use for rendering
  79002. * @param camera The camera to use for rendering
  79003. * @param size This parameter can be set to a single number or to an object with the
  79004. * following (optional) properties: precision, width, height. If a single number is passed,
  79005. * it will be used for both width and height. If an object is passed, the screenshot size
  79006. * will be derived from the parameters. The precision property is a multiplier allowing
  79007. * rendering at a higher or lower resolution
  79008. * @param successCallback The callback receives a single parameter which contains the
  79009. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79010. * src parameter of an <img> to display it
  79011. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79012. * Check your browser for supported MIME types
  79013. * @param samples Texture samples (default: 1)
  79014. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79015. * @param fileName A name for for the downloaded file.
  79016. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79017. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79018. */
  79019. 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;
  79020. /**
  79021. * Generates an image screenshot from the specified camera.
  79022. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79023. * @param engine The engine to use for rendering
  79024. * @param camera The camera to use for rendering
  79025. * @param size This parameter can be set to a single number or to an object with the
  79026. * following (optional) properties: precision, width, height. If a single number is passed,
  79027. * it will be used for both width and height. If an object is passed, the screenshot size
  79028. * will be derived from the parameters. The precision property is a multiplier allowing
  79029. * rendering at a higher or lower resolution
  79030. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79031. * Check your browser for supported MIME types
  79032. * @param samples Texture samples (default: 1)
  79033. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79034. * @param fileName A name for for the downloaded file.
  79035. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79036. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79037. * to the src parameter of an <img> to display it
  79038. */
  79039. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79040. /**
  79041. * Gets height and width for screenshot size
  79042. * @private
  79043. */
  79044. private static _getScreenshotSize;
  79045. }
  79046. }
  79047. declare module "babylonjs/Misc/dataReader" {
  79048. /**
  79049. * Interface for a data buffer
  79050. */
  79051. export interface IDataBuffer {
  79052. /**
  79053. * Reads bytes from the data buffer.
  79054. * @param byteOffset The byte offset to read
  79055. * @param byteLength The byte length to read
  79056. * @returns A promise that resolves when the bytes are read
  79057. */
  79058. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79059. /**
  79060. * The byte length of the buffer.
  79061. */
  79062. readonly byteLength: number;
  79063. }
  79064. /**
  79065. * Utility class for reading from a data buffer
  79066. */
  79067. export class DataReader {
  79068. /**
  79069. * The data buffer associated with this data reader.
  79070. */
  79071. readonly buffer: IDataBuffer;
  79072. /**
  79073. * The current byte offset from the beginning of the data buffer.
  79074. */
  79075. byteOffset: number;
  79076. private _dataView;
  79077. private _dataByteOffset;
  79078. /**
  79079. * Constructor
  79080. * @param buffer The buffer to read
  79081. */
  79082. constructor(buffer: IDataBuffer);
  79083. /**
  79084. * Loads the given byte length.
  79085. * @param byteLength The byte length to load
  79086. * @returns A promise that resolves when the load is complete
  79087. */
  79088. loadAsync(byteLength: number): Promise<void>;
  79089. /**
  79090. * Read a unsigned 32-bit integer from the currently loaded data range.
  79091. * @returns The 32-bit integer read
  79092. */
  79093. readUint32(): number;
  79094. /**
  79095. * Read a byte array from the currently loaded data range.
  79096. * @param byteLength The byte length to read
  79097. * @returns The byte array read
  79098. */
  79099. readUint8Array(byteLength: number): Uint8Array;
  79100. /**
  79101. * Read a string from the currently loaded data range.
  79102. * @param byteLength The byte length to read
  79103. * @returns The string read
  79104. */
  79105. readString(byteLength: number): string;
  79106. /**
  79107. * Skips the given byte length the currently loaded data range.
  79108. * @param byteLength The byte length to skip
  79109. */
  79110. skipBytes(byteLength: number): void;
  79111. }
  79112. }
  79113. declare module "babylonjs/Misc/dataStorage" {
  79114. /**
  79115. * Class for storing data to local storage if available or in-memory storage otherwise
  79116. */
  79117. export class DataStorage {
  79118. private static _Storage;
  79119. private static _GetStorage;
  79120. /**
  79121. * Reads a string from the data storage
  79122. * @param key The key to read
  79123. * @param defaultValue The value if the key doesn't exist
  79124. * @returns The string value
  79125. */
  79126. static ReadString(key: string, defaultValue: string): string;
  79127. /**
  79128. * Writes a string to the data storage
  79129. * @param key The key to write
  79130. * @param value The value to write
  79131. */
  79132. static WriteString(key: string, value: string): void;
  79133. /**
  79134. * Reads a boolean from the data storage
  79135. * @param key The key to read
  79136. * @param defaultValue The value if the key doesn't exist
  79137. * @returns The boolean value
  79138. */
  79139. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79140. /**
  79141. * Writes a boolean to the data storage
  79142. * @param key The key to write
  79143. * @param value The value to write
  79144. */
  79145. static WriteBoolean(key: string, value: boolean): void;
  79146. /**
  79147. * Reads a number from the data storage
  79148. * @param key The key to read
  79149. * @param defaultValue The value if the key doesn't exist
  79150. * @returns The number value
  79151. */
  79152. static ReadNumber(key: string, defaultValue: number): number;
  79153. /**
  79154. * Writes a number to the data storage
  79155. * @param key The key to write
  79156. * @param value The value to write
  79157. */
  79158. static WriteNumber(key: string, value: number): void;
  79159. }
  79160. }
  79161. declare module "babylonjs/Misc/sceneRecorder" {
  79162. import { Scene } from "babylonjs/scene";
  79163. /**
  79164. * Class used to record delta files between 2 scene states
  79165. */
  79166. export class SceneRecorder {
  79167. private _trackedScene;
  79168. private _savedJSON;
  79169. /**
  79170. * Track a given scene. This means the current scene state will be considered the original state
  79171. * @param scene defines the scene to track
  79172. */
  79173. track(scene: Scene): void;
  79174. /**
  79175. * Get the delta between current state and original state
  79176. * @returns a string containing the delta
  79177. */
  79178. getDelta(): any;
  79179. private _compareArray;
  79180. private _compareObjects;
  79181. private _compareCollections;
  79182. private static GetShadowGeneratorById;
  79183. /**
  79184. * Apply a given delta to a given scene
  79185. * @param deltaJSON defines the JSON containing the delta
  79186. * @param scene defines the scene to apply the delta to
  79187. */
  79188. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79189. private static _ApplyPropertiesToEntity;
  79190. private static _ApplyDeltaForEntity;
  79191. }
  79192. }
  79193. declare module "babylonjs/Misc/trajectoryClassifier" {
  79194. import { DeepImmutable, Nullable } from "babylonjs/types";
  79195. import { Vector3 } from "babylonjs/Maths/math.vector";
  79196. /**
  79197. * A 3D trajectory consisting of an order list of vectors describing a
  79198. * path of motion through 3D space.
  79199. */
  79200. export class Trajectory {
  79201. private _points;
  79202. private readonly _segmentLength;
  79203. /**
  79204. * Serialize to JSON.
  79205. * @returns serialized JSON string
  79206. */
  79207. serialize(): string;
  79208. /**
  79209. * Deserialize from JSON.
  79210. * @param json serialized JSON string
  79211. * @returns deserialized Trajectory
  79212. */
  79213. static Deserialize(json: string): Trajectory;
  79214. /**
  79215. * Create a new empty Trajectory.
  79216. * @param segmentLength radius of discretization for Trajectory points
  79217. */
  79218. constructor(segmentLength?: number);
  79219. /**
  79220. * Get the length of the Trajectory.
  79221. * @returns length of the Trajectory
  79222. */
  79223. getLength(): number;
  79224. /**
  79225. * Append a new point to the Trajectory.
  79226. * NOTE: This implementation has many allocations.
  79227. * @param point point to append to the Trajectory
  79228. */
  79229. add(point: DeepImmutable<Vector3>): void;
  79230. /**
  79231. * Create a new Trajectory with a segment length chosen to make it
  79232. * probable that the new Trajectory will have a specified number of
  79233. * segments. This operation is imprecise.
  79234. * @param targetResolution number of segments desired
  79235. * @returns new Trajectory with approximately the requested number of segments
  79236. */
  79237. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79238. /**
  79239. * Convert Trajectory segments into tokenized representation. This
  79240. * representation is an array of numbers where each nth number is the
  79241. * index of the token which is most similar to the nth segment of the
  79242. * Trajectory.
  79243. * @param tokens list of vectors which serve as discrete tokens
  79244. * @returns list of indices of most similar token per segment
  79245. */
  79246. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79247. private static _forwardDir;
  79248. private static _inverseFromVec;
  79249. private static _upDir;
  79250. private static _fromToVec;
  79251. private static _lookMatrix;
  79252. /**
  79253. * Transform the rotation (i.e., direction) of a segment to isolate
  79254. * the relative transformation represented by the segment. This operation
  79255. * may or may not succeed due to singularities in the equations that define
  79256. * motion relativity in this context.
  79257. * @param priorVec the origin of the prior segment
  79258. * @param fromVec the origin of the current segment
  79259. * @param toVec the destination of the current segment
  79260. * @param result reference to output variable
  79261. * @returns whether or not transformation was successful
  79262. */
  79263. private static _transformSegmentDirToRef;
  79264. private static _bestMatch;
  79265. private static _score;
  79266. private static _bestScore;
  79267. /**
  79268. * Determine which token vector is most similar to the
  79269. * segment vector.
  79270. * @param segment segment vector
  79271. * @param tokens token vector list
  79272. * @returns index of the most similar token to the segment
  79273. */
  79274. private static _tokenizeSegment;
  79275. }
  79276. /**
  79277. * Class representing a set of known, named trajectories to which Trajectories can be
  79278. * added and using which Trajectories can be recognized.
  79279. */
  79280. export class TrajectoryClassifier {
  79281. private _maximumAllowableMatchCost;
  79282. private _vector3Alphabet;
  79283. private _levenshteinAlphabet;
  79284. private _nameToDescribedTrajectory;
  79285. /**
  79286. * Serialize to JSON.
  79287. * @returns JSON serialization
  79288. */
  79289. serialize(): string;
  79290. /**
  79291. * Deserialize from JSON.
  79292. * @param json JSON serialization
  79293. * @returns deserialized TrajectorySet
  79294. */
  79295. static Deserialize(json: string): TrajectoryClassifier;
  79296. /**
  79297. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79298. * VERY naive, need to be generating these things from known
  79299. * sets. Better version later, probably eliminating this one.
  79300. * @returns auto-generated TrajectorySet
  79301. */
  79302. static Generate(): TrajectoryClassifier;
  79303. private constructor();
  79304. /**
  79305. * Add a new Trajectory to the set with a given name.
  79306. * @param trajectory new Trajectory to be added
  79307. * @param classification name to which to add the Trajectory
  79308. */
  79309. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79310. /**
  79311. * Remove a known named trajectory and all Trajectories associated with it.
  79312. * @param classification name to remove
  79313. * @returns whether anything was removed
  79314. */
  79315. deleteClassification(classification: string): boolean;
  79316. /**
  79317. * Attempt to recognize a Trajectory from among all the classifications
  79318. * already known to the classifier.
  79319. * @param trajectory Trajectory to be recognized
  79320. * @returns classification of Trajectory if recognized, null otherwise
  79321. */
  79322. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79323. }
  79324. }
  79325. declare module "babylonjs/Misc/index" {
  79326. export * from "babylonjs/Misc/andOrNotEvaluator";
  79327. export * from "babylonjs/Misc/assetsManager";
  79328. export * from "babylonjs/Misc/basis";
  79329. export * from "babylonjs/Misc/dds";
  79330. export * from "babylonjs/Misc/decorators";
  79331. export * from "babylonjs/Misc/deferred";
  79332. export * from "babylonjs/Misc/environmentTextureTools";
  79333. export * from "babylonjs/Misc/meshExploder";
  79334. export * from "babylonjs/Misc/filesInput";
  79335. export * from "babylonjs/Misc/HighDynamicRange/index";
  79336. export * from "babylonjs/Misc/khronosTextureContainer";
  79337. export * from "babylonjs/Misc/observable";
  79338. export * from "babylonjs/Misc/performanceMonitor";
  79339. export * from "babylonjs/Misc/promise";
  79340. export * from "babylonjs/Misc/sceneOptimizer";
  79341. export * from "babylonjs/Misc/sceneSerializer";
  79342. export * from "babylonjs/Misc/smartArray";
  79343. export * from "babylonjs/Misc/stringDictionary";
  79344. export * from "babylonjs/Misc/tags";
  79345. export * from "babylonjs/Misc/textureTools";
  79346. export * from "babylonjs/Misc/tga";
  79347. export * from "babylonjs/Misc/tools";
  79348. export * from "babylonjs/Misc/videoRecorder";
  79349. export * from "babylonjs/Misc/virtualJoystick";
  79350. export * from "babylonjs/Misc/workerPool";
  79351. export * from "babylonjs/Misc/logger";
  79352. export * from "babylonjs/Misc/typeStore";
  79353. export * from "babylonjs/Misc/filesInputStore";
  79354. export * from "babylonjs/Misc/deepCopier";
  79355. export * from "babylonjs/Misc/pivotTools";
  79356. export * from "babylonjs/Misc/precisionDate";
  79357. export * from "babylonjs/Misc/screenshotTools";
  79358. export * from "babylonjs/Misc/typeStore";
  79359. export * from "babylonjs/Misc/webRequest";
  79360. export * from "babylonjs/Misc/iInspectable";
  79361. export * from "babylonjs/Misc/brdfTextureTools";
  79362. export * from "babylonjs/Misc/rgbdTextureTools";
  79363. export * from "babylonjs/Misc/gradients";
  79364. export * from "babylonjs/Misc/perfCounter";
  79365. export * from "babylonjs/Misc/fileRequest";
  79366. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79367. export * from "babylonjs/Misc/retryStrategy";
  79368. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79369. export * from "babylonjs/Misc/canvasGenerator";
  79370. export * from "babylonjs/Misc/fileTools";
  79371. export * from "babylonjs/Misc/stringTools";
  79372. export * from "babylonjs/Misc/dataReader";
  79373. export * from "babylonjs/Misc/minMaxReducer";
  79374. export * from "babylonjs/Misc/depthReducer";
  79375. export * from "babylonjs/Misc/dataStorage";
  79376. export * from "babylonjs/Misc/sceneRecorder";
  79377. export * from "babylonjs/Misc/khronosTextureContainer2";
  79378. export * from "babylonjs/Misc/trajectoryClassifier";
  79379. export * from "babylonjs/Misc/timer";
  79380. }
  79381. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79382. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79383. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79384. import { Observable } from "babylonjs/Misc/observable";
  79385. import { Matrix } from "babylonjs/Maths/math.vector";
  79386. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79387. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79388. /**
  79389. * An interface for all Hit test features
  79390. */
  79391. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79392. /**
  79393. * Triggered when new babylon (transformed) hit test results are available
  79394. */
  79395. onHitTestResultObservable: Observable<T[]>;
  79396. }
  79397. /**
  79398. * Options used for hit testing
  79399. */
  79400. export interface IWebXRLegacyHitTestOptions {
  79401. /**
  79402. * Only test when user interacted with the scene. Default - hit test every frame
  79403. */
  79404. testOnPointerDownOnly?: boolean;
  79405. /**
  79406. * The node to use to transform the local results to world coordinates
  79407. */
  79408. worldParentNode?: TransformNode;
  79409. }
  79410. /**
  79411. * Interface defining the babylon result of raycasting/hit-test
  79412. */
  79413. export interface IWebXRLegacyHitResult {
  79414. /**
  79415. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79416. */
  79417. transformationMatrix: Matrix;
  79418. /**
  79419. * The native hit test result
  79420. */
  79421. xrHitResult: XRHitResult | XRHitTestResult;
  79422. }
  79423. /**
  79424. * The currently-working hit-test module.
  79425. * Hit test (or Ray-casting) is used to interact with the real world.
  79426. * For further information read here - https://github.com/immersive-web/hit-test
  79427. */
  79428. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79429. /**
  79430. * options to use when constructing this feature
  79431. */
  79432. readonly options: IWebXRLegacyHitTestOptions;
  79433. private _direction;
  79434. private _mat;
  79435. private _onSelectEnabled;
  79436. private _origin;
  79437. /**
  79438. * The module's name
  79439. */
  79440. static readonly Name: string;
  79441. /**
  79442. * The (Babylon) version of this module.
  79443. * This is an integer representing the implementation version.
  79444. * This number does not correspond to the WebXR specs version
  79445. */
  79446. static readonly Version: number;
  79447. /**
  79448. * Populated with the last native XR Hit Results
  79449. */
  79450. lastNativeXRHitResults: XRHitResult[];
  79451. /**
  79452. * Triggered when new babylon (transformed) hit test results are available
  79453. */
  79454. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79455. /**
  79456. * Creates a new instance of the (legacy version) hit test feature
  79457. * @param _xrSessionManager an instance of WebXRSessionManager
  79458. * @param options options to use when constructing this feature
  79459. */
  79460. constructor(_xrSessionManager: WebXRSessionManager,
  79461. /**
  79462. * options to use when constructing this feature
  79463. */
  79464. options?: IWebXRLegacyHitTestOptions);
  79465. /**
  79466. * execute a hit test with an XR Ray
  79467. *
  79468. * @param xrSession a native xrSession that will execute this hit test
  79469. * @param xrRay the ray (position and direction) to use for ray-casting
  79470. * @param referenceSpace native XR reference space to use for the hit-test
  79471. * @param filter filter function that will filter the results
  79472. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79473. */
  79474. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79475. /**
  79476. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79477. * @param event the (select) event to use to select with
  79478. * @param referenceSpace the reference space to use for this hit test
  79479. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79480. */
  79481. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79482. /**
  79483. * attach this feature
  79484. * Will usually be called by the features manager
  79485. *
  79486. * @returns true if successful.
  79487. */
  79488. attach(): boolean;
  79489. /**
  79490. * detach this feature.
  79491. * Will usually be called by the features manager
  79492. *
  79493. * @returns true if successful.
  79494. */
  79495. detach(): boolean;
  79496. /**
  79497. * Dispose this feature and all of the resources attached
  79498. */
  79499. dispose(): void;
  79500. protected _onXRFrame(frame: XRFrame): void;
  79501. private _onHitTestResults;
  79502. private _onSelect;
  79503. }
  79504. }
  79505. declare module "babylonjs/XR/features/WebXRHitTest" {
  79506. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79507. import { Observable } from "babylonjs/Misc/observable";
  79508. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79509. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79510. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79511. /**
  79512. * Options used for hit testing (version 2)
  79513. */
  79514. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79515. /**
  79516. * Do not create a permanent hit test. Will usually be used when only
  79517. * transient inputs are needed.
  79518. */
  79519. disablePermanentHitTest?: boolean;
  79520. /**
  79521. * Enable transient (for example touch-based) hit test inspections
  79522. */
  79523. enableTransientHitTest?: boolean;
  79524. /**
  79525. * Offset ray for the permanent hit test
  79526. */
  79527. offsetRay?: Vector3;
  79528. /**
  79529. * Offset ray for the transient hit test
  79530. */
  79531. transientOffsetRay?: Vector3;
  79532. /**
  79533. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79534. */
  79535. useReferenceSpace?: boolean;
  79536. /**
  79537. * Override the default entity type(s) of the hit-test result
  79538. */
  79539. entityTypes?: XRHitTestTrackableType[];
  79540. }
  79541. /**
  79542. * Interface defining the babylon result of hit-test
  79543. */
  79544. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79545. /**
  79546. * The input source that generated this hit test (if transient)
  79547. */
  79548. inputSource?: XRInputSource;
  79549. /**
  79550. * Is this a transient hit test
  79551. */
  79552. isTransient?: boolean;
  79553. /**
  79554. * Position of the hit test result
  79555. */
  79556. position: Vector3;
  79557. /**
  79558. * Rotation of the hit test result
  79559. */
  79560. rotationQuaternion: Quaternion;
  79561. /**
  79562. * The native hit test result
  79563. */
  79564. xrHitResult: XRHitTestResult;
  79565. }
  79566. /**
  79567. * The currently-working hit-test module.
  79568. * Hit test (or Ray-casting) is used to interact with the real world.
  79569. * For further information read here - https://github.com/immersive-web/hit-test
  79570. *
  79571. * Tested on chrome (mobile) 80.
  79572. */
  79573. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79574. /**
  79575. * options to use when constructing this feature
  79576. */
  79577. readonly options: IWebXRHitTestOptions;
  79578. private _tmpMat;
  79579. private _tmpPos;
  79580. private _tmpQuat;
  79581. private _transientXrHitTestSource;
  79582. private _xrHitTestSource;
  79583. private initHitTestSource;
  79584. /**
  79585. * The module's name
  79586. */
  79587. static readonly Name: string;
  79588. /**
  79589. * The (Babylon) version of this module.
  79590. * This is an integer representing the implementation version.
  79591. * This number does not correspond to the WebXR specs version
  79592. */
  79593. static readonly Version: number;
  79594. /**
  79595. * When set to true, each hit test will have its own position/rotation objects
  79596. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79597. * the developers will clone them or copy them as they see fit.
  79598. */
  79599. autoCloneTransformation: boolean;
  79600. /**
  79601. * Triggered when new babylon (transformed) hit test results are available
  79602. * Note - this will be called when results come back from the device. It can be an empty array!!
  79603. */
  79604. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79605. /**
  79606. * Use this to temporarily pause hit test checks.
  79607. */
  79608. paused: boolean;
  79609. /**
  79610. * Creates a new instance of the hit test feature
  79611. * @param _xrSessionManager an instance of WebXRSessionManager
  79612. * @param options options to use when constructing this feature
  79613. */
  79614. constructor(_xrSessionManager: WebXRSessionManager,
  79615. /**
  79616. * options to use when constructing this feature
  79617. */
  79618. options?: IWebXRHitTestOptions);
  79619. /**
  79620. * attach this feature
  79621. * Will usually be called by the features manager
  79622. *
  79623. * @returns true if successful.
  79624. */
  79625. attach(): boolean;
  79626. /**
  79627. * detach this feature.
  79628. * Will usually be called by the features manager
  79629. *
  79630. * @returns true if successful.
  79631. */
  79632. detach(): boolean;
  79633. /**
  79634. * Dispose this feature and all of the resources attached
  79635. */
  79636. dispose(): void;
  79637. protected _onXRFrame(frame: XRFrame): void;
  79638. private _processWebXRHitTestResult;
  79639. }
  79640. }
  79641. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79642. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79643. import { Observable } from "babylonjs/Misc/observable";
  79644. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79645. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79646. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79647. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79648. /**
  79649. * Configuration options of the anchor system
  79650. */
  79651. export interface IWebXRAnchorSystemOptions {
  79652. /**
  79653. * a node that will be used to convert local to world coordinates
  79654. */
  79655. worldParentNode?: TransformNode;
  79656. /**
  79657. * If set to true a reference of the created anchors will be kept until the next session starts
  79658. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79659. */
  79660. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79661. }
  79662. /**
  79663. * A babylon container for an XR Anchor
  79664. */
  79665. export interface IWebXRAnchor {
  79666. /**
  79667. * A babylon-assigned ID for this anchor
  79668. */
  79669. id: number;
  79670. /**
  79671. * Transformation matrix to apply to an object attached to this anchor
  79672. */
  79673. transformationMatrix: Matrix;
  79674. /**
  79675. * The native anchor object
  79676. */
  79677. xrAnchor: XRAnchor;
  79678. /**
  79679. * if defined, this object will be constantly updated by the anchor's position and rotation
  79680. */
  79681. attachedNode?: TransformNode;
  79682. }
  79683. /**
  79684. * An implementation of the anchor system for WebXR.
  79685. * For further information see https://github.com/immersive-web/anchors/
  79686. */
  79687. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79688. private _options;
  79689. private _lastFrameDetected;
  79690. private _trackedAnchors;
  79691. private _referenceSpaceForFrameAnchors;
  79692. private _futureAnchors;
  79693. /**
  79694. * The module's name
  79695. */
  79696. static readonly Name: string;
  79697. /**
  79698. * The (Babylon) version of this module.
  79699. * This is an integer representing the implementation version.
  79700. * This number does not correspond to the WebXR specs version
  79701. */
  79702. static readonly Version: number;
  79703. /**
  79704. * Observers registered here will be executed when a new anchor was added to the session
  79705. */
  79706. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79707. /**
  79708. * Observers registered here will be executed when an anchor was removed from the session
  79709. */
  79710. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79711. /**
  79712. * Observers registered here will be executed when an existing anchor updates
  79713. * This can execute N times every frame
  79714. */
  79715. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79716. /**
  79717. * Set the reference space to use for anchor creation, when not using a hit test.
  79718. * Will default to the session's reference space if not defined
  79719. */
  79720. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79721. /**
  79722. * constructs a new anchor system
  79723. * @param _xrSessionManager an instance of WebXRSessionManager
  79724. * @param _options configuration object for this feature
  79725. */
  79726. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79727. private _tmpVector;
  79728. private _tmpQuaternion;
  79729. private _populateTmpTransformation;
  79730. /**
  79731. * Create a new anchor point using a hit test result at a specific point in the scene
  79732. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79733. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79734. *
  79735. * @param hitTestResult The hit test result to use for this anchor creation
  79736. * @param position an optional position offset for this anchor
  79737. * @param rotationQuaternion an optional rotation offset for this anchor
  79738. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79739. */
  79740. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79741. /**
  79742. * Add a new anchor at a specific position and rotation
  79743. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79744. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79745. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79746. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79747. *
  79748. * @param position the position in which to add an anchor
  79749. * @param rotationQuaternion an optional rotation for the anchor transformation
  79750. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79751. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79752. */
  79753. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79754. /**
  79755. * detach this feature.
  79756. * Will usually be called by the features manager
  79757. *
  79758. * @returns true if successful.
  79759. */
  79760. detach(): boolean;
  79761. /**
  79762. * Dispose this feature and all of the resources attached
  79763. */
  79764. dispose(): void;
  79765. protected _onXRFrame(frame: XRFrame): void;
  79766. /**
  79767. * avoiding using Array.find for global support.
  79768. * @param xrAnchor the plane to find in the array
  79769. */
  79770. private _findIndexInAnchorArray;
  79771. private _updateAnchorWithXRFrame;
  79772. private _createAnchorAtTransformation;
  79773. }
  79774. }
  79775. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79776. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79777. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79778. import { Observable } from "babylonjs/Misc/observable";
  79779. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79780. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79781. /**
  79782. * Options used in the plane detector module
  79783. */
  79784. export interface IWebXRPlaneDetectorOptions {
  79785. /**
  79786. * The node to use to transform the local results to world coordinates
  79787. */
  79788. worldParentNode?: TransformNode;
  79789. /**
  79790. * If set to true a reference of the created planes will be kept until the next session starts
  79791. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79792. */
  79793. doNotRemovePlanesOnSessionEnded?: boolean;
  79794. }
  79795. /**
  79796. * A babylon interface for a WebXR plane.
  79797. * A Plane is actually a polygon, built from N points in space
  79798. *
  79799. * Supported in chrome 79, not supported in canary 81 ATM
  79800. */
  79801. export interface IWebXRPlane {
  79802. /**
  79803. * a babylon-assigned ID for this polygon
  79804. */
  79805. id: number;
  79806. /**
  79807. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79808. */
  79809. polygonDefinition: Array<Vector3>;
  79810. /**
  79811. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79812. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79813. */
  79814. transformationMatrix: Matrix;
  79815. /**
  79816. * the native xr-plane object
  79817. */
  79818. xrPlane: XRPlane;
  79819. }
  79820. /**
  79821. * The plane detector is used to detect planes in the real world when in AR
  79822. * For more information see https://github.com/immersive-web/real-world-geometry/
  79823. */
  79824. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79825. private _options;
  79826. private _detectedPlanes;
  79827. private _enabled;
  79828. private _lastFrameDetected;
  79829. /**
  79830. * The module's name
  79831. */
  79832. static readonly Name: string;
  79833. /**
  79834. * The (Babylon) version of this module.
  79835. * This is an integer representing the implementation version.
  79836. * This number does not correspond to the WebXR specs version
  79837. */
  79838. static readonly Version: number;
  79839. /**
  79840. * Observers registered here will be executed when a new plane was added to the session
  79841. */
  79842. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79843. /**
  79844. * Observers registered here will be executed when a plane is no longer detected in the session
  79845. */
  79846. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79847. /**
  79848. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79849. * This can execute N times every frame
  79850. */
  79851. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79852. /**
  79853. * construct a new Plane Detector
  79854. * @param _xrSessionManager an instance of xr Session manager
  79855. * @param _options configuration to use when constructing this feature
  79856. */
  79857. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79858. /**
  79859. * detach this feature.
  79860. * Will usually be called by the features manager
  79861. *
  79862. * @returns true if successful.
  79863. */
  79864. detach(): boolean;
  79865. /**
  79866. * Dispose this feature and all of the resources attached
  79867. */
  79868. dispose(): void;
  79869. protected _onXRFrame(frame: XRFrame): void;
  79870. private _init;
  79871. private _updatePlaneWithXRPlane;
  79872. /**
  79873. * avoiding using Array.find for global support.
  79874. * @param xrPlane the plane to find in the array
  79875. */
  79876. private findIndexInPlaneArray;
  79877. }
  79878. }
  79879. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79880. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79882. import { Observable } from "babylonjs/Misc/observable";
  79883. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79884. /**
  79885. * Options interface for the background remover plugin
  79886. */
  79887. export interface IWebXRBackgroundRemoverOptions {
  79888. /**
  79889. * Further background meshes to disable when entering AR
  79890. */
  79891. backgroundMeshes?: AbstractMesh[];
  79892. /**
  79893. * flags to configure the removal of the environment helper.
  79894. * If not set, the entire background will be removed. If set, flags should be set as well.
  79895. */
  79896. environmentHelperRemovalFlags?: {
  79897. /**
  79898. * Should the skybox be removed (default false)
  79899. */
  79900. skyBox?: boolean;
  79901. /**
  79902. * Should the ground be removed (default false)
  79903. */
  79904. ground?: boolean;
  79905. };
  79906. /**
  79907. * don't disable the environment helper
  79908. */
  79909. ignoreEnvironmentHelper?: boolean;
  79910. }
  79911. /**
  79912. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79913. */
  79914. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79915. /**
  79916. * read-only options to be used in this module
  79917. */
  79918. readonly options: IWebXRBackgroundRemoverOptions;
  79919. /**
  79920. * The module's name
  79921. */
  79922. static readonly Name: string;
  79923. /**
  79924. * The (Babylon) version of this module.
  79925. * This is an integer representing the implementation version.
  79926. * This number does not correspond to the WebXR specs version
  79927. */
  79928. static readonly Version: number;
  79929. /**
  79930. * registered observers will be triggered when the background state changes
  79931. */
  79932. onBackgroundStateChangedObservable: Observable<boolean>;
  79933. /**
  79934. * constructs a new background remover module
  79935. * @param _xrSessionManager the session manager for this module
  79936. * @param options read-only options to be used in this module
  79937. */
  79938. constructor(_xrSessionManager: WebXRSessionManager,
  79939. /**
  79940. * read-only options to be used in this module
  79941. */
  79942. options?: IWebXRBackgroundRemoverOptions);
  79943. /**
  79944. * attach this feature
  79945. * Will usually be called by the features manager
  79946. *
  79947. * @returns true if successful.
  79948. */
  79949. attach(): boolean;
  79950. /**
  79951. * detach this feature.
  79952. * Will usually be called by the features manager
  79953. *
  79954. * @returns true if successful.
  79955. */
  79956. detach(): boolean;
  79957. /**
  79958. * Dispose this feature and all of the resources attached
  79959. */
  79960. dispose(): void;
  79961. protected _onXRFrame(_xrFrame: XRFrame): void;
  79962. private _setBackgroundState;
  79963. }
  79964. }
  79965. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79966. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79967. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79968. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79969. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79970. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79971. import { Nullable } from "babylonjs/types";
  79972. /**
  79973. * Options for the controller physics feature
  79974. */
  79975. export class IWebXRControllerPhysicsOptions {
  79976. /**
  79977. * Should the headset get its own impostor
  79978. */
  79979. enableHeadsetImpostor?: boolean;
  79980. /**
  79981. * Optional parameters for the headset impostor
  79982. */
  79983. headsetImpostorParams?: {
  79984. /**
  79985. * The type of impostor to create. Default is sphere
  79986. */
  79987. impostorType: number;
  79988. /**
  79989. * the size of the impostor. Defaults to 10cm
  79990. */
  79991. impostorSize?: number | {
  79992. width: number;
  79993. height: number;
  79994. depth: number;
  79995. };
  79996. /**
  79997. * Friction definitions
  79998. */
  79999. friction?: number;
  80000. /**
  80001. * Restitution
  80002. */
  80003. restitution?: number;
  80004. };
  80005. /**
  80006. * The physics properties of the future impostors
  80007. */
  80008. physicsProperties?: {
  80009. /**
  80010. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80011. * Note that this requires a physics engine that supports mesh impostors!
  80012. */
  80013. useControllerMesh?: boolean;
  80014. /**
  80015. * The type of impostor to create. Default is sphere
  80016. */
  80017. impostorType?: number;
  80018. /**
  80019. * the size of the impostor. Defaults to 10cm
  80020. */
  80021. impostorSize?: number | {
  80022. width: number;
  80023. height: number;
  80024. depth: number;
  80025. };
  80026. /**
  80027. * Friction definitions
  80028. */
  80029. friction?: number;
  80030. /**
  80031. * Restitution
  80032. */
  80033. restitution?: number;
  80034. };
  80035. /**
  80036. * the xr input to use with this pointer selection
  80037. */
  80038. xrInput: WebXRInput;
  80039. }
  80040. /**
  80041. * Add physics impostor to your webxr controllers,
  80042. * including naive calculation of their linear and angular velocity
  80043. */
  80044. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80045. private readonly _options;
  80046. private _attachController;
  80047. private _controllers;
  80048. private _debugMode;
  80049. private _delta;
  80050. private _headsetImpostor?;
  80051. private _headsetMesh?;
  80052. private _lastTimestamp;
  80053. private _tmpQuaternion;
  80054. private _tmpVector;
  80055. /**
  80056. * The module's name
  80057. */
  80058. static readonly Name: string;
  80059. /**
  80060. * The (Babylon) version of this module.
  80061. * This is an integer representing the implementation version.
  80062. * This number does not correspond to the webxr specs version
  80063. */
  80064. static readonly Version: number;
  80065. /**
  80066. * Construct a new Controller Physics Feature
  80067. * @param _xrSessionManager the corresponding xr session manager
  80068. * @param _options options to create this feature with
  80069. */
  80070. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80071. /**
  80072. * @hidden
  80073. * enable debugging - will show console outputs and the impostor mesh
  80074. */
  80075. _enablePhysicsDebug(): void;
  80076. /**
  80077. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80078. * @param xrController the controller to add
  80079. */
  80080. addController(xrController: WebXRInputSource): void;
  80081. /**
  80082. * attach this feature
  80083. * Will usually be called by the features manager
  80084. *
  80085. * @returns true if successful.
  80086. */
  80087. attach(): boolean;
  80088. /**
  80089. * detach this feature.
  80090. * Will usually be called by the features manager
  80091. *
  80092. * @returns true if successful.
  80093. */
  80094. detach(): boolean;
  80095. /**
  80096. * Get the headset impostor, if enabled
  80097. * @returns the impostor
  80098. */
  80099. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80100. /**
  80101. * Get the physics impostor of a specific controller.
  80102. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80103. * @param controller the controller or the controller id of which to get the impostor
  80104. * @returns the impostor or null
  80105. */
  80106. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80107. /**
  80108. * Update the physics properties provided in the constructor
  80109. * @param newProperties the new properties object
  80110. */
  80111. setPhysicsProperties(newProperties: {
  80112. impostorType?: number;
  80113. impostorSize?: number | {
  80114. width: number;
  80115. height: number;
  80116. depth: number;
  80117. };
  80118. friction?: number;
  80119. restitution?: number;
  80120. }): void;
  80121. protected _onXRFrame(_xrFrame: any): void;
  80122. private _detachController;
  80123. }
  80124. }
  80125. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80126. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80127. import { Observable } from "babylonjs/Misc/observable";
  80128. import { Vector3 } from "babylonjs/Maths/math.vector";
  80129. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80130. /**
  80131. * A babylon interface for a "WebXR" feature point.
  80132. * Represents the position and confidence value of a given feature point.
  80133. */
  80134. export interface IWebXRFeaturePoint {
  80135. /**
  80136. * Represents the position of the feature point in world space.
  80137. */
  80138. position: Vector3;
  80139. /**
  80140. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80141. */
  80142. confidenceValue: number;
  80143. }
  80144. /**
  80145. * The feature point system is used to detect feature points from real world geometry.
  80146. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80147. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80148. */
  80149. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80150. private _enabled;
  80151. private _featurePointCloud;
  80152. /**
  80153. * The module's name
  80154. */
  80155. static readonly Name: string;
  80156. /**
  80157. * The (Babylon) version of this module.
  80158. * This is an integer representing the implementation version.
  80159. * This number does not correspond to the WebXR specs version
  80160. */
  80161. static readonly Version: number;
  80162. /**
  80163. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80164. * Will notify the observers about which feature points have been added.
  80165. */
  80166. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80167. /**
  80168. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80169. * Will notify the observers about which feature points have been updated.
  80170. */
  80171. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80172. /**
  80173. * The current feature point cloud maintained across frames.
  80174. */
  80175. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80176. /**
  80177. * construct the feature point system
  80178. * @param _xrSessionManager an instance of xr Session manager
  80179. */
  80180. constructor(_xrSessionManager: WebXRSessionManager);
  80181. /**
  80182. * Detach this feature.
  80183. * Will usually be called by the features manager
  80184. *
  80185. * @returns true if successful.
  80186. */
  80187. detach(): boolean;
  80188. /**
  80189. * Dispose this feature and all of the resources attached
  80190. */
  80191. dispose(): void;
  80192. /**
  80193. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80194. */
  80195. protected _onXRFrame(frame: XRFrame): void;
  80196. /**
  80197. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80198. */
  80199. private _init;
  80200. }
  80201. }
  80202. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80203. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80204. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80206. import { Mesh } from "babylonjs/Meshes/mesh";
  80207. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80208. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80209. import { Nullable } from "babylonjs/types";
  80210. import { IDisposable } from "babylonjs/scene";
  80211. import { Observable } from "babylonjs/Misc/observable";
  80212. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80213. /**
  80214. * Configuration interface for the hand tracking feature
  80215. */
  80216. export interface IWebXRHandTrackingOptions {
  80217. /**
  80218. * The xrInput that will be used as source for new hands
  80219. */
  80220. xrInput: WebXRInput;
  80221. /**
  80222. * Configuration object for the joint meshes
  80223. */
  80224. jointMeshes?: {
  80225. /**
  80226. * Should the meshes created be invisible (defaults to false)
  80227. */
  80228. invisible?: boolean;
  80229. /**
  80230. * A source mesh to be used to create instances. Defaults to a sphere.
  80231. * This mesh will be the source for all other (25) meshes.
  80232. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80233. */
  80234. sourceMesh?: Mesh;
  80235. /**
  80236. * This function will be called after a mesh was created for a specific joint.
  80237. * Using this function you can either manipulate the instance or return a new mesh.
  80238. * When returning a new mesh the instance created before will be disposed
  80239. */
  80240. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80241. /**
  80242. * Should the source mesh stay visible. Defaults to false
  80243. */
  80244. keepOriginalVisible?: boolean;
  80245. /**
  80246. * Scale factor for all instances (defaults to 2)
  80247. */
  80248. scaleFactor?: number;
  80249. /**
  80250. * Should each instance have its own physics impostor
  80251. */
  80252. enablePhysics?: boolean;
  80253. /**
  80254. * If enabled, override default physics properties
  80255. */
  80256. physicsProps?: {
  80257. friction?: number;
  80258. restitution?: number;
  80259. impostorType?: number;
  80260. };
  80261. /**
  80262. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80263. */
  80264. handMesh?: AbstractMesh;
  80265. };
  80266. }
  80267. /**
  80268. * Parts of the hands divided to writs and finger names
  80269. */
  80270. export const enum HandPart {
  80271. /**
  80272. * HandPart - Wrist
  80273. */
  80274. WRIST = "wrist",
  80275. /**
  80276. * HandPart - The THumb
  80277. */
  80278. THUMB = "thumb",
  80279. /**
  80280. * HandPart - Index finger
  80281. */
  80282. INDEX = "index",
  80283. /**
  80284. * HandPart - Middle finger
  80285. */
  80286. MIDDLE = "middle",
  80287. /**
  80288. * HandPart - Ring finger
  80289. */
  80290. RING = "ring",
  80291. /**
  80292. * HandPart - Little finger
  80293. */
  80294. LITTLE = "little"
  80295. }
  80296. /**
  80297. * Representing a single hand (with its corresponding native XRHand object)
  80298. */
  80299. export class WebXRHand implements IDisposable {
  80300. /** the controller to which the hand correlates */
  80301. readonly xrController: WebXRInputSource;
  80302. /** the meshes to be used to track the hand joints */
  80303. readonly trackedMeshes: AbstractMesh[];
  80304. /**
  80305. * Hand-parts definition (key is HandPart)
  80306. */
  80307. handPartsDefinition: {
  80308. [key: string]: number[];
  80309. };
  80310. /**
  80311. * Populate the HandPartsDefinition object.
  80312. * This is called as a side effect since certain browsers don't have XRHand defined.
  80313. */
  80314. private generateHandPartsDefinition;
  80315. /**
  80316. * Construct a new hand object
  80317. * @param xrController the controller to which the hand correlates
  80318. * @param trackedMeshes the meshes to be used to track the hand joints
  80319. */
  80320. constructor(
  80321. /** the controller to which the hand correlates */
  80322. xrController: WebXRInputSource,
  80323. /** the meshes to be used to track the hand joints */
  80324. trackedMeshes: AbstractMesh[]);
  80325. /**
  80326. * Update this hand from the latest xr frame
  80327. * @param xrFrame xrFrame to update from
  80328. * @param referenceSpace The current viewer reference space
  80329. * @param scaleFactor optional scale factor for the meshes
  80330. */
  80331. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80332. /**
  80333. * Get meshes of part of the hand
  80334. * @param part the part of hand to get
  80335. * @returns An array of meshes that correlate to the hand part requested
  80336. */
  80337. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80338. /**
  80339. * Dispose this Hand object
  80340. */
  80341. dispose(): void;
  80342. }
  80343. /**
  80344. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80345. */
  80346. export class WebXRHandTracking extends WebXRAbstractFeature {
  80347. /**
  80348. * options to use when constructing this feature
  80349. */
  80350. readonly options: IWebXRHandTrackingOptions;
  80351. private static _idCounter;
  80352. /**
  80353. * The module's name
  80354. */
  80355. static readonly Name: string;
  80356. /**
  80357. * The (Babylon) version of this module.
  80358. * This is an integer representing the implementation version.
  80359. * This number does not correspond to the WebXR specs version
  80360. */
  80361. static readonly Version: number;
  80362. /**
  80363. * This observable will notify registered observers when a new hand object was added and initialized
  80364. */
  80365. onHandAddedObservable: Observable<WebXRHand>;
  80366. /**
  80367. * This observable will notify its observers right before the hand object is disposed
  80368. */
  80369. onHandRemovedObservable: Observable<WebXRHand>;
  80370. private _hands;
  80371. /**
  80372. * Creates a new instance of the hit test feature
  80373. * @param _xrSessionManager an instance of WebXRSessionManager
  80374. * @param options options to use when constructing this feature
  80375. */
  80376. constructor(_xrSessionManager: WebXRSessionManager,
  80377. /**
  80378. * options to use when constructing this feature
  80379. */
  80380. options: IWebXRHandTrackingOptions);
  80381. /**
  80382. * Check if the needed objects are defined.
  80383. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80384. */
  80385. isCompatible(): boolean;
  80386. /**
  80387. * attach this feature
  80388. * Will usually be called by the features manager
  80389. *
  80390. * @returns true if successful.
  80391. */
  80392. attach(): boolean;
  80393. /**
  80394. * detach this feature.
  80395. * Will usually be called by the features manager
  80396. *
  80397. * @returns true if successful.
  80398. */
  80399. detach(): boolean;
  80400. /**
  80401. * Dispose this feature and all of the resources attached
  80402. */
  80403. dispose(): void;
  80404. /**
  80405. * Get the hand object according to the controller id
  80406. * @param controllerId the controller id to which we want to get the hand
  80407. * @returns null if not found or the WebXRHand object if found
  80408. */
  80409. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80410. /**
  80411. * Get a hand object according to the requested handedness
  80412. * @param handedness the handedness to request
  80413. * @returns null if not found or the WebXRHand object if found
  80414. */
  80415. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80416. protected _onXRFrame(_xrFrame: XRFrame): void;
  80417. private _attachHand;
  80418. private _detachHand;
  80419. }
  80420. }
  80421. declare module "babylonjs/XR/features/index" {
  80422. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80423. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80424. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80425. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80426. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80427. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80428. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80429. export * from "babylonjs/XR/features/WebXRHitTest";
  80430. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80431. export * from "babylonjs/XR/features/WebXRHandTracking";
  80432. }
  80433. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80434. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80436. import { Scene } from "babylonjs/scene";
  80437. /**
  80438. * The motion controller class for all microsoft mixed reality controllers
  80439. */
  80440. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80441. protected readonly _mapping: {
  80442. defaultButton: {
  80443. valueNodeName: string;
  80444. unpressedNodeName: string;
  80445. pressedNodeName: string;
  80446. };
  80447. defaultAxis: {
  80448. valueNodeName: string;
  80449. minNodeName: string;
  80450. maxNodeName: string;
  80451. };
  80452. buttons: {
  80453. "xr-standard-trigger": {
  80454. rootNodeName: string;
  80455. componentProperty: string;
  80456. states: string[];
  80457. };
  80458. "xr-standard-squeeze": {
  80459. rootNodeName: string;
  80460. componentProperty: string;
  80461. states: string[];
  80462. };
  80463. "xr-standard-touchpad": {
  80464. rootNodeName: string;
  80465. labelAnchorNodeName: string;
  80466. touchPointNodeName: string;
  80467. };
  80468. "xr-standard-thumbstick": {
  80469. rootNodeName: string;
  80470. componentProperty: string;
  80471. states: string[];
  80472. };
  80473. };
  80474. axes: {
  80475. "xr-standard-touchpad": {
  80476. "x-axis": {
  80477. rootNodeName: string;
  80478. };
  80479. "y-axis": {
  80480. rootNodeName: string;
  80481. };
  80482. };
  80483. "xr-standard-thumbstick": {
  80484. "x-axis": {
  80485. rootNodeName: string;
  80486. };
  80487. "y-axis": {
  80488. rootNodeName: string;
  80489. };
  80490. };
  80491. };
  80492. };
  80493. /**
  80494. * The base url used to load the left and right controller models
  80495. */
  80496. static MODEL_BASE_URL: string;
  80497. /**
  80498. * The name of the left controller model file
  80499. */
  80500. static MODEL_LEFT_FILENAME: string;
  80501. /**
  80502. * The name of the right controller model file
  80503. */
  80504. static MODEL_RIGHT_FILENAME: string;
  80505. profileId: string;
  80506. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80507. protected _getFilenameAndPath(): {
  80508. filename: string;
  80509. path: string;
  80510. };
  80511. protected _getModelLoadingConstraints(): boolean;
  80512. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80513. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80514. protected _updateModel(): void;
  80515. }
  80516. }
  80517. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80518. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80520. import { Scene } from "babylonjs/scene";
  80521. /**
  80522. * The motion controller class for oculus touch (quest, rift).
  80523. * This class supports legacy mapping as well the standard xr mapping
  80524. */
  80525. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80526. private _forceLegacyControllers;
  80527. private _modelRootNode;
  80528. /**
  80529. * The base url used to load the left and right controller models
  80530. */
  80531. static MODEL_BASE_URL: string;
  80532. /**
  80533. * The name of the left controller model file
  80534. */
  80535. static MODEL_LEFT_FILENAME: string;
  80536. /**
  80537. * The name of the right controller model file
  80538. */
  80539. static MODEL_RIGHT_FILENAME: string;
  80540. /**
  80541. * Base Url for the Quest controller model.
  80542. */
  80543. static QUEST_MODEL_BASE_URL: string;
  80544. profileId: string;
  80545. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80546. protected _getFilenameAndPath(): {
  80547. filename: string;
  80548. path: string;
  80549. };
  80550. protected _getModelLoadingConstraints(): boolean;
  80551. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80552. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80553. protected _updateModel(): void;
  80554. /**
  80555. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80556. * between the touch and touch 2.
  80557. */
  80558. private _isQuest;
  80559. }
  80560. }
  80561. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80562. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80563. import { Scene } from "babylonjs/scene";
  80564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80565. /**
  80566. * The motion controller class for the standard HTC-Vive controllers
  80567. */
  80568. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80569. private _modelRootNode;
  80570. /**
  80571. * The base url used to load the left and right controller models
  80572. */
  80573. static MODEL_BASE_URL: string;
  80574. /**
  80575. * File name for the controller model.
  80576. */
  80577. static MODEL_FILENAME: string;
  80578. profileId: string;
  80579. /**
  80580. * Create a new Vive motion controller object
  80581. * @param scene the scene to use to create this controller
  80582. * @param gamepadObject the corresponding gamepad object
  80583. * @param handedness the handedness of the controller
  80584. */
  80585. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80586. protected _getFilenameAndPath(): {
  80587. filename: string;
  80588. path: string;
  80589. };
  80590. protected _getModelLoadingConstraints(): boolean;
  80591. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80592. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80593. protected _updateModel(): void;
  80594. }
  80595. }
  80596. declare module "babylonjs/XR/motionController/index" {
  80597. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80598. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80599. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80600. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80601. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80602. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80603. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80604. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80605. }
  80606. declare module "babylonjs/XR/index" {
  80607. export * from "babylonjs/XR/webXRCamera";
  80608. export * from "babylonjs/XR/webXREnterExitUI";
  80609. export * from "babylonjs/XR/webXRExperienceHelper";
  80610. export * from "babylonjs/XR/webXRInput";
  80611. export * from "babylonjs/XR/webXRInputSource";
  80612. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80613. export * from "babylonjs/XR/webXRTypes";
  80614. export * from "babylonjs/XR/webXRSessionManager";
  80615. export * from "babylonjs/XR/webXRDefaultExperience";
  80616. export * from "babylonjs/XR/webXRFeaturesManager";
  80617. export * from "babylonjs/XR/features/index";
  80618. export * from "babylonjs/XR/motionController/index";
  80619. }
  80620. declare module "babylonjs/index" {
  80621. export * from "babylonjs/abstractScene";
  80622. export * from "babylonjs/Actions/index";
  80623. export * from "babylonjs/Animations/index";
  80624. export * from "babylonjs/assetContainer";
  80625. export * from "babylonjs/Audio/index";
  80626. export * from "babylonjs/Behaviors/index";
  80627. export * from "babylonjs/Bones/index";
  80628. export * from "babylonjs/Cameras/index";
  80629. export * from "babylonjs/Collisions/index";
  80630. export * from "babylonjs/Culling/index";
  80631. export * from "babylonjs/Debug/index";
  80632. export * from "babylonjs/DeviceInput/index";
  80633. export * from "babylonjs/Engines/index";
  80634. export * from "babylonjs/Events/index";
  80635. export * from "babylonjs/Gamepads/index";
  80636. export * from "babylonjs/Gizmos/index";
  80637. export * from "babylonjs/Helpers/index";
  80638. export * from "babylonjs/Instrumentation/index";
  80639. export * from "babylonjs/Layers/index";
  80640. export * from "babylonjs/LensFlares/index";
  80641. export * from "babylonjs/Lights/index";
  80642. export * from "babylonjs/Loading/index";
  80643. export * from "babylonjs/Materials/index";
  80644. export * from "babylonjs/Maths/index";
  80645. export * from "babylonjs/Meshes/index";
  80646. export * from "babylonjs/Morph/index";
  80647. export * from "babylonjs/Navigation/index";
  80648. export * from "babylonjs/node";
  80649. export * from "babylonjs/Offline/index";
  80650. export * from "babylonjs/Particles/index";
  80651. export * from "babylonjs/Physics/index";
  80652. export * from "babylonjs/PostProcesses/index";
  80653. export * from "babylonjs/Probes/index";
  80654. export * from "babylonjs/Rendering/index";
  80655. export * from "babylonjs/scene";
  80656. export * from "babylonjs/sceneComponent";
  80657. export * from "babylonjs/Sprites/index";
  80658. export * from "babylonjs/States/index";
  80659. export * from "babylonjs/Misc/index";
  80660. export * from "babylonjs/XR/index";
  80661. export * from "babylonjs/types";
  80662. }
  80663. declare module "babylonjs/Animations/pathCursor" {
  80664. import { Vector3 } from "babylonjs/Maths/math.vector";
  80665. import { Path2 } from "babylonjs/Maths/math.path";
  80666. /**
  80667. * A cursor which tracks a point on a path
  80668. */
  80669. export class PathCursor {
  80670. private path;
  80671. /**
  80672. * Stores path cursor callbacks for when an onchange event is triggered
  80673. */
  80674. private _onchange;
  80675. /**
  80676. * The value of the path cursor
  80677. */
  80678. value: number;
  80679. /**
  80680. * The animation array of the path cursor
  80681. */
  80682. animations: Animation[];
  80683. /**
  80684. * Initializes the path cursor
  80685. * @param path The path to track
  80686. */
  80687. constructor(path: Path2);
  80688. /**
  80689. * Gets the cursor point on the path
  80690. * @returns A point on the path cursor at the cursor location
  80691. */
  80692. getPoint(): Vector3;
  80693. /**
  80694. * Moves the cursor ahead by the step amount
  80695. * @param step The amount to move the cursor forward
  80696. * @returns This path cursor
  80697. */
  80698. moveAhead(step?: number): PathCursor;
  80699. /**
  80700. * Moves the cursor behind by the step amount
  80701. * @param step The amount to move the cursor back
  80702. * @returns This path cursor
  80703. */
  80704. moveBack(step?: number): PathCursor;
  80705. /**
  80706. * Moves the cursor by the step amount
  80707. * If the step amount is greater than one, an exception is thrown
  80708. * @param step The amount to move the cursor
  80709. * @returns This path cursor
  80710. */
  80711. move(step: number): PathCursor;
  80712. /**
  80713. * Ensures that the value is limited between zero and one
  80714. * @returns This path cursor
  80715. */
  80716. private ensureLimits;
  80717. /**
  80718. * Runs onchange callbacks on change (used by the animation engine)
  80719. * @returns This path cursor
  80720. */
  80721. private raiseOnChange;
  80722. /**
  80723. * Executes a function on change
  80724. * @param f A path cursor onchange callback
  80725. * @returns This path cursor
  80726. */
  80727. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80728. }
  80729. }
  80730. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80731. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80732. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80733. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80734. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80735. }
  80736. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80737. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80738. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80739. }
  80740. declare module "babylonjs/Engines/Processors/index" {
  80741. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80742. export * from "babylonjs/Engines/Processors/Expressions/index";
  80743. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80744. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80745. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80746. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80747. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80748. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80749. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80750. }
  80751. declare module "babylonjs/Legacy/legacy" {
  80752. import * as Babylon from "babylonjs/index";
  80753. export * from "babylonjs/index";
  80754. }
  80755. declare module "babylonjs/Shaders/blur.fragment" {
  80756. /** @hidden */
  80757. export var blurPixelShader: {
  80758. name: string;
  80759. shader: string;
  80760. };
  80761. }
  80762. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80763. /** @hidden */
  80764. export var pointCloudVertexDeclaration: {
  80765. name: string;
  80766. shader: string;
  80767. };
  80768. }
  80769. declare module "babylonjs" {
  80770. export * from "babylonjs/Legacy/legacy";
  80771. }
  80772. declare module BABYLON {
  80773. /** Alias type for value that can be null */
  80774. export type Nullable<T> = T | null;
  80775. /**
  80776. * Alias type for number that are floats
  80777. * @ignorenaming
  80778. */
  80779. export type float = number;
  80780. /**
  80781. * Alias type for number that are doubles.
  80782. * @ignorenaming
  80783. */
  80784. export type double = number;
  80785. /**
  80786. * Alias type for number that are integer
  80787. * @ignorenaming
  80788. */
  80789. export type int = number;
  80790. /** Alias type for number array or Float32Array */
  80791. export type FloatArray = number[] | Float32Array;
  80792. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80793. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80794. /**
  80795. * Alias for types that can be used by a Buffer or VertexBuffer.
  80796. */
  80797. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80798. /**
  80799. * Alias type for primitive types
  80800. * @ignorenaming
  80801. */
  80802. type Primitive = undefined | null | boolean | string | number | Function;
  80803. /**
  80804. * Type modifier to make all the properties of an object Readonly
  80805. */
  80806. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80807. /**
  80808. * Type modifier to make all the properties of an object Readonly recursively
  80809. */
  80810. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80811. /**
  80812. * Type modifier to make object properties readonly.
  80813. */
  80814. export type DeepImmutableObject<T> = {
  80815. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80816. };
  80817. /** @hidden */
  80818. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80819. }
  80820. }
  80821. declare module BABYLON {
  80822. /**
  80823. * A class serves as a medium between the observable and its observers
  80824. */
  80825. export class EventState {
  80826. /**
  80827. * Create a new EventState
  80828. * @param mask defines the mask associated with this state
  80829. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80830. * @param target defines the original target of the state
  80831. * @param currentTarget defines the current target of the state
  80832. */
  80833. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80834. /**
  80835. * Initialize the current event state
  80836. * @param mask defines the mask associated with this state
  80837. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80838. * @param target defines the original target of the state
  80839. * @param currentTarget defines the current target of the state
  80840. * @returns the current event state
  80841. */
  80842. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80843. /**
  80844. * An Observer can set this property to true to prevent subsequent observers of being notified
  80845. */
  80846. skipNextObservers: boolean;
  80847. /**
  80848. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80849. */
  80850. mask: number;
  80851. /**
  80852. * The object that originally notified the event
  80853. */
  80854. target?: any;
  80855. /**
  80856. * The current object in the bubbling phase
  80857. */
  80858. currentTarget?: any;
  80859. /**
  80860. * This will be populated with the return value of the last function that was executed.
  80861. * If it is the first function in the callback chain it will be the event data.
  80862. */
  80863. lastReturnValue?: any;
  80864. /**
  80865. * User defined information that will be sent to observers
  80866. */
  80867. userInfo?: any;
  80868. }
  80869. /**
  80870. * Represent an Observer registered to a given Observable object.
  80871. */
  80872. export class Observer<T> {
  80873. /**
  80874. * Defines the callback to call when the observer is notified
  80875. */
  80876. callback: (eventData: T, eventState: EventState) => void;
  80877. /**
  80878. * Defines the mask of the observer (used to filter notifications)
  80879. */
  80880. mask: number;
  80881. /**
  80882. * Defines the current scope used to restore the JS context
  80883. */
  80884. scope: any;
  80885. /** @hidden */
  80886. _willBeUnregistered: boolean;
  80887. /**
  80888. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80889. */
  80890. unregisterOnNextCall: boolean;
  80891. /**
  80892. * Creates a new observer
  80893. * @param callback defines the callback to call when the observer is notified
  80894. * @param mask defines the mask of the observer (used to filter notifications)
  80895. * @param scope defines the current scope used to restore the JS context
  80896. */
  80897. constructor(
  80898. /**
  80899. * Defines the callback to call when the observer is notified
  80900. */
  80901. callback: (eventData: T, eventState: EventState) => void,
  80902. /**
  80903. * Defines the mask of the observer (used to filter notifications)
  80904. */
  80905. mask: number,
  80906. /**
  80907. * Defines the current scope used to restore the JS context
  80908. */
  80909. scope?: any);
  80910. }
  80911. /**
  80912. * Represent a list of observers registered to multiple Observables object.
  80913. */
  80914. export class MultiObserver<T> {
  80915. private _observers;
  80916. private _observables;
  80917. /**
  80918. * Release associated resources
  80919. */
  80920. dispose(): void;
  80921. /**
  80922. * Raise a callback when one of the observable will notify
  80923. * @param observables defines a list of observables to watch
  80924. * @param callback defines the callback to call on notification
  80925. * @param mask defines the mask used to filter notifications
  80926. * @param scope defines the current scope used to restore the JS context
  80927. * @returns the new MultiObserver
  80928. */
  80929. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80930. }
  80931. /**
  80932. * The Observable class is a simple implementation of the Observable pattern.
  80933. *
  80934. * 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.
  80935. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80936. * 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).
  80937. * 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.
  80938. */
  80939. export class Observable<T> {
  80940. private _observers;
  80941. private _eventState;
  80942. private _onObserverAdded;
  80943. /**
  80944. * Gets the list of observers
  80945. */
  80946. get observers(): Array<Observer<T>>;
  80947. /**
  80948. * Creates a new observable
  80949. * @param onObserverAdded defines a callback to call when a new observer is added
  80950. */
  80951. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80952. /**
  80953. * Create a new Observer with the specified callback
  80954. * @param callback the callback that will be executed for that Observer
  80955. * @param mask the mask used to filter observers
  80956. * @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.
  80957. * @param scope optional scope for the callback to be called from
  80958. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80959. * @returns the new observer created for the callback
  80960. */
  80961. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80962. /**
  80963. * Create a new Observer with the specified callback and unregisters after the next notification
  80964. * @param callback the callback that will be executed for that Observer
  80965. * @returns the new observer created for the callback
  80966. */
  80967. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80968. /**
  80969. * Remove an Observer from the Observable object
  80970. * @param observer the instance of the Observer to remove
  80971. * @returns false if it doesn't belong to this Observable
  80972. */
  80973. remove(observer: Nullable<Observer<T>>): boolean;
  80974. /**
  80975. * Remove a callback from the Observable object
  80976. * @param callback the callback to remove
  80977. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80978. * @returns false if it doesn't belong to this Observable
  80979. */
  80980. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80981. private _deferUnregister;
  80982. private _remove;
  80983. /**
  80984. * Moves the observable to the top of the observer list making it get called first when notified
  80985. * @param observer the observer to move
  80986. */
  80987. makeObserverTopPriority(observer: Observer<T>): void;
  80988. /**
  80989. * Moves the observable to the bottom of the observer list making it get called last when notified
  80990. * @param observer the observer to move
  80991. */
  80992. makeObserverBottomPriority(observer: Observer<T>): void;
  80993. /**
  80994. * Notify all Observers by calling their respective callback with the given data
  80995. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80996. * @param eventData defines the data to send to all observers
  80997. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80998. * @param target defines the original target of the state
  80999. * @param currentTarget defines the current target of the state
  81000. * @param userInfo defines any user info to send to observers
  81001. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81002. */
  81003. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81004. /**
  81005. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81006. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81007. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81008. * and it is crucial that all callbacks will be executed.
  81009. * The order of the callbacks is kept, callbacks are not executed parallel.
  81010. *
  81011. * @param eventData The data to be sent to each callback
  81012. * @param mask is used to filter observers defaults to -1
  81013. * @param target defines the callback target (see EventState)
  81014. * @param currentTarget defines he current object in the bubbling phase
  81015. * @param userInfo defines any user info to send to observers
  81016. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81017. */
  81018. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81019. /**
  81020. * Notify a specific observer
  81021. * @param observer defines the observer to notify
  81022. * @param eventData defines the data to be sent to each callback
  81023. * @param mask is used to filter observers defaults to -1
  81024. */
  81025. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81026. /**
  81027. * Gets a boolean indicating if the observable has at least one observer
  81028. * @returns true is the Observable has at least one Observer registered
  81029. */
  81030. hasObservers(): boolean;
  81031. /**
  81032. * Clear the list of observers
  81033. */
  81034. clear(): void;
  81035. /**
  81036. * Clone the current observable
  81037. * @returns a new observable
  81038. */
  81039. clone(): Observable<T>;
  81040. /**
  81041. * Does this observable handles observer registered with a given mask
  81042. * @param mask defines the mask to be tested
  81043. * @return whether or not one observer registered with the given mask is handeled
  81044. **/
  81045. hasSpecificMask(mask?: number): boolean;
  81046. }
  81047. }
  81048. declare module BABYLON {
  81049. /**
  81050. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81051. * Babylon.js
  81052. */
  81053. export class DomManagement {
  81054. /**
  81055. * Checks if the window object exists
  81056. * @returns true if the window object exists
  81057. */
  81058. static IsWindowObjectExist(): boolean;
  81059. /**
  81060. * Checks if the navigator object exists
  81061. * @returns true if the navigator object exists
  81062. */
  81063. static IsNavigatorAvailable(): boolean;
  81064. /**
  81065. * Check if the document object exists
  81066. * @returns true if the document object exists
  81067. */
  81068. static IsDocumentAvailable(): boolean;
  81069. /**
  81070. * Extracts text content from a DOM element hierarchy
  81071. * @param element defines the root element
  81072. * @returns a string
  81073. */
  81074. static GetDOMTextContent(element: HTMLElement): string;
  81075. }
  81076. }
  81077. declare module BABYLON {
  81078. /**
  81079. * Logger used througouht the application to allow configuration of
  81080. * the log level required for the messages.
  81081. */
  81082. export class Logger {
  81083. /**
  81084. * No log
  81085. */
  81086. static readonly NoneLogLevel: number;
  81087. /**
  81088. * Only message logs
  81089. */
  81090. static readonly MessageLogLevel: number;
  81091. /**
  81092. * Only warning logs
  81093. */
  81094. static readonly WarningLogLevel: number;
  81095. /**
  81096. * Only error logs
  81097. */
  81098. static readonly ErrorLogLevel: number;
  81099. /**
  81100. * All logs
  81101. */
  81102. static readonly AllLogLevel: number;
  81103. private static _LogCache;
  81104. /**
  81105. * Gets a value indicating the number of loading errors
  81106. * @ignorenaming
  81107. */
  81108. static errorsCount: number;
  81109. /**
  81110. * Callback called when a new log is added
  81111. */
  81112. static OnNewCacheEntry: (entry: string) => void;
  81113. private static _AddLogEntry;
  81114. private static _FormatMessage;
  81115. private static _LogDisabled;
  81116. private static _LogEnabled;
  81117. private static _WarnDisabled;
  81118. private static _WarnEnabled;
  81119. private static _ErrorDisabled;
  81120. private static _ErrorEnabled;
  81121. /**
  81122. * Log a message to the console
  81123. */
  81124. static Log: (message: string) => void;
  81125. /**
  81126. * Write a warning message to the console
  81127. */
  81128. static Warn: (message: string) => void;
  81129. /**
  81130. * Write an error message to the console
  81131. */
  81132. static Error: (message: string) => void;
  81133. /**
  81134. * Gets current log cache (list of logs)
  81135. */
  81136. static get LogCache(): string;
  81137. /**
  81138. * Clears the log cache
  81139. */
  81140. static ClearLogCache(): void;
  81141. /**
  81142. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81143. */
  81144. static set LogLevels(level: number);
  81145. }
  81146. }
  81147. declare module BABYLON {
  81148. /** @hidden */
  81149. export class _TypeStore {
  81150. /** @hidden */
  81151. static RegisteredTypes: {
  81152. [key: string]: Object;
  81153. };
  81154. /** @hidden */
  81155. static GetClass(fqdn: string): any;
  81156. }
  81157. }
  81158. declare module BABYLON {
  81159. /**
  81160. * Helper to manipulate strings
  81161. */
  81162. export class StringTools {
  81163. /**
  81164. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81165. * @param str Source string
  81166. * @param suffix Suffix to search for in the source string
  81167. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81168. */
  81169. static EndsWith(str: string, suffix: string): boolean;
  81170. /**
  81171. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81172. * @param str Source string
  81173. * @param suffix Suffix to search for in the source string
  81174. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81175. */
  81176. static StartsWith(str: string, suffix: string): boolean;
  81177. /**
  81178. * Decodes a buffer into a string
  81179. * @param buffer The buffer to decode
  81180. * @returns The decoded string
  81181. */
  81182. static Decode(buffer: Uint8Array | Uint16Array): string;
  81183. /**
  81184. * Encode a buffer to a base64 string
  81185. * @param buffer defines the buffer to encode
  81186. * @returns the encoded string
  81187. */
  81188. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81189. /**
  81190. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81191. * @param num the number to convert and pad
  81192. * @param length the expected length of the string
  81193. * @returns the padded string
  81194. */
  81195. static PadNumber(num: number, length: number): string;
  81196. }
  81197. }
  81198. declare module BABYLON {
  81199. /**
  81200. * Class containing a set of static utilities functions for deep copy.
  81201. */
  81202. export class DeepCopier {
  81203. /**
  81204. * Tries to copy an object by duplicating every property
  81205. * @param source defines the source object
  81206. * @param destination defines the target object
  81207. * @param doNotCopyList defines a list of properties to avoid
  81208. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81209. */
  81210. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81211. }
  81212. }
  81213. declare module BABYLON {
  81214. /**
  81215. * Class containing a set of static utilities functions for precision date
  81216. */
  81217. export class PrecisionDate {
  81218. /**
  81219. * Gets either window.performance.now() if supported or Date.now() else
  81220. */
  81221. static get Now(): number;
  81222. }
  81223. }
  81224. declare module BABYLON {
  81225. /** @hidden */
  81226. export class _DevTools {
  81227. static WarnImport(name: string): string;
  81228. }
  81229. }
  81230. declare module BABYLON {
  81231. /**
  81232. * Interface used to define the mechanism to get data from the network
  81233. */
  81234. export interface IWebRequest {
  81235. /**
  81236. * Returns client's response url
  81237. */
  81238. responseURL: string;
  81239. /**
  81240. * Returns client's status
  81241. */
  81242. status: number;
  81243. /**
  81244. * Returns client's status as a text
  81245. */
  81246. statusText: string;
  81247. }
  81248. }
  81249. declare module BABYLON {
  81250. /**
  81251. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81252. */
  81253. export class WebRequest implements IWebRequest {
  81254. private _xhr;
  81255. /**
  81256. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81257. * i.e. when loading files, where the server/service expects an Authorization header
  81258. */
  81259. static CustomRequestHeaders: {
  81260. [key: string]: string;
  81261. };
  81262. /**
  81263. * Add callback functions in this array to update all the requests before they get sent to the network
  81264. */
  81265. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81266. private _injectCustomRequestHeaders;
  81267. /**
  81268. * Gets or sets a function to be called when loading progress changes
  81269. */
  81270. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81271. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81272. /**
  81273. * Returns client's state
  81274. */
  81275. get readyState(): number;
  81276. /**
  81277. * Returns client's status
  81278. */
  81279. get status(): number;
  81280. /**
  81281. * Returns client's status as a text
  81282. */
  81283. get statusText(): string;
  81284. /**
  81285. * Returns client's response
  81286. */
  81287. get response(): any;
  81288. /**
  81289. * Returns client's response url
  81290. */
  81291. get responseURL(): string;
  81292. /**
  81293. * Returns client's response as text
  81294. */
  81295. get responseText(): string;
  81296. /**
  81297. * Gets or sets the expected response type
  81298. */
  81299. get responseType(): XMLHttpRequestResponseType;
  81300. set responseType(value: XMLHttpRequestResponseType);
  81301. /** @hidden */
  81302. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81303. /** @hidden */
  81304. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81305. /**
  81306. * Cancels any network activity
  81307. */
  81308. abort(): void;
  81309. /**
  81310. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81311. * @param body defines an optional request body
  81312. */
  81313. send(body?: Document | BodyInit | null): void;
  81314. /**
  81315. * Sets the request method, request URL
  81316. * @param method defines the method to use (GET, POST, etc..)
  81317. * @param url defines the url to connect with
  81318. */
  81319. open(method: string, url: string): void;
  81320. /**
  81321. * Sets the value of a request header.
  81322. * @param name The name of the header whose value is to be set
  81323. * @param value The value to set as the body of the header
  81324. */
  81325. setRequestHeader(name: string, value: string): void;
  81326. /**
  81327. * Get the string containing the text of a particular header's value.
  81328. * @param name The name of the header
  81329. * @returns The string containing the text of the given header name
  81330. */
  81331. getResponseHeader(name: string): Nullable<string>;
  81332. }
  81333. }
  81334. declare module BABYLON {
  81335. /**
  81336. * File request interface
  81337. */
  81338. export interface IFileRequest {
  81339. /**
  81340. * Raised when the request is complete (success or error).
  81341. */
  81342. onCompleteObservable: Observable<IFileRequest>;
  81343. /**
  81344. * Aborts the request for a file.
  81345. */
  81346. abort: () => void;
  81347. }
  81348. }
  81349. declare module BABYLON {
  81350. /**
  81351. * Define options used to create a render target texture
  81352. */
  81353. export class RenderTargetCreationOptions {
  81354. /**
  81355. * Specifies is mipmaps must be generated
  81356. */
  81357. generateMipMaps?: boolean;
  81358. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81359. generateDepthBuffer?: boolean;
  81360. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81361. generateStencilBuffer?: boolean;
  81362. /** Defines texture type (int by default) */
  81363. type?: number;
  81364. /** Defines sampling mode (trilinear by default) */
  81365. samplingMode?: number;
  81366. /** Defines format (RGBA by default) */
  81367. format?: number;
  81368. }
  81369. }
  81370. declare module BABYLON {
  81371. /** Defines the cross module used constants to avoid circular dependncies */
  81372. export class Constants {
  81373. /** Defines that alpha blending is disabled */
  81374. static readonly ALPHA_DISABLE: number;
  81375. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81376. static readonly ALPHA_ADD: number;
  81377. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81378. static readonly ALPHA_COMBINE: number;
  81379. /** Defines that alpha blending is DEST - SRC * DEST */
  81380. static readonly ALPHA_SUBTRACT: number;
  81381. /** Defines that alpha blending is SRC * DEST */
  81382. static readonly ALPHA_MULTIPLY: number;
  81383. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81384. static readonly ALPHA_MAXIMIZED: number;
  81385. /** Defines that alpha blending is SRC + DEST */
  81386. static readonly ALPHA_ONEONE: number;
  81387. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81388. static readonly ALPHA_PREMULTIPLIED: number;
  81389. /**
  81390. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81391. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81392. */
  81393. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81394. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81395. static readonly ALPHA_INTERPOLATE: number;
  81396. /**
  81397. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81398. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81399. */
  81400. static readonly ALPHA_SCREENMODE: number;
  81401. /**
  81402. * Defines that alpha blending is SRC + DST
  81403. * Alpha will be set to SRC ALPHA + DST ALPHA
  81404. */
  81405. static readonly ALPHA_ONEONE_ONEONE: number;
  81406. /**
  81407. * Defines that alpha blending is SRC * DST ALPHA + DST
  81408. * Alpha will be set to 0
  81409. */
  81410. static readonly ALPHA_ALPHATOCOLOR: number;
  81411. /**
  81412. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81413. */
  81414. static readonly ALPHA_REVERSEONEMINUS: number;
  81415. /**
  81416. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81417. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81418. */
  81419. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81420. /**
  81421. * Defines that alpha blending is SRC + DST
  81422. * Alpha will be set to SRC ALPHA
  81423. */
  81424. static readonly ALPHA_ONEONE_ONEZERO: number;
  81425. /**
  81426. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81427. * Alpha will be set to DST ALPHA
  81428. */
  81429. static readonly ALPHA_EXCLUSION: number;
  81430. /** Defines that alpha blending equation a SUM */
  81431. static readonly ALPHA_EQUATION_ADD: number;
  81432. /** Defines that alpha blending equation a SUBSTRACTION */
  81433. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81434. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81435. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81436. /** Defines that alpha blending equation a MAX operation */
  81437. static readonly ALPHA_EQUATION_MAX: number;
  81438. /** Defines that alpha blending equation a MIN operation */
  81439. static readonly ALPHA_EQUATION_MIN: number;
  81440. /**
  81441. * Defines that alpha blending equation a DARKEN operation:
  81442. * It takes the min of the src and sums the alpha channels.
  81443. */
  81444. static readonly ALPHA_EQUATION_DARKEN: number;
  81445. /** Defines that the ressource is not delayed*/
  81446. static readonly DELAYLOADSTATE_NONE: number;
  81447. /** Defines that the ressource was successfully delay loaded */
  81448. static readonly DELAYLOADSTATE_LOADED: number;
  81449. /** Defines that the ressource is currently delay loading */
  81450. static readonly DELAYLOADSTATE_LOADING: number;
  81451. /** Defines that the ressource is delayed and has not started loading */
  81452. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81454. static readonly NEVER: number;
  81455. /** 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 */
  81456. static readonly ALWAYS: number;
  81457. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81458. static readonly LESS: number;
  81459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81460. static readonly EQUAL: number;
  81461. /** 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 */
  81462. static readonly LEQUAL: number;
  81463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81464. static readonly GREATER: number;
  81465. /** 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 */
  81466. static readonly GEQUAL: number;
  81467. /** 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 */
  81468. static readonly NOTEQUAL: number;
  81469. /** Passed to stencilOperation to specify that stencil value must be kept */
  81470. static readonly KEEP: number;
  81471. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81472. static readonly REPLACE: number;
  81473. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81474. static readonly INCR: number;
  81475. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81476. static readonly DECR: number;
  81477. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81478. static readonly INVERT: number;
  81479. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81480. static readonly INCR_WRAP: number;
  81481. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81482. static readonly DECR_WRAP: number;
  81483. /** Texture is not repeating outside of 0..1 UVs */
  81484. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81485. /** Texture is repeating outside of 0..1 UVs */
  81486. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81487. /** Texture is repeating and mirrored */
  81488. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81489. /** ALPHA */
  81490. static readonly TEXTUREFORMAT_ALPHA: number;
  81491. /** LUMINANCE */
  81492. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81493. /** LUMINANCE_ALPHA */
  81494. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81495. /** RGB */
  81496. static readonly TEXTUREFORMAT_RGB: number;
  81497. /** RGBA */
  81498. static readonly TEXTUREFORMAT_RGBA: number;
  81499. /** RED */
  81500. static readonly TEXTUREFORMAT_RED: number;
  81501. /** RED (2nd reference) */
  81502. static readonly TEXTUREFORMAT_R: number;
  81503. /** RG */
  81504. static readonly TEXTUREFORMAT_RG: number;
  81505. /** RED_INTEGER */
  81506. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81507. /** RED_INTEGER (2nd reference) */
  81508. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81509. /** RG_INTEGER */
  81510. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81511. /** RGB_INTEGER */
  81512. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81513. /** RGBA_INTEGER */
  81514. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81515. /** UNSIGNED_BYTE */
  81516. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81517. /** UNSIGNED_BYTE (2nd reference) */
  81518. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81519. /** FLOAT */
  81520. static readonly TEXTURETYPE_FLOAT: number;
  81521. /** HALF_FLOAT */
  81522. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81523. /** BYTE */
  81524. static readonly TEXTURETYPE_BYTE: number;
  81525. /** SHORT */
  81526. static readonly TEXTURETYPE_SHORT: number;
  81527. /** UNSIGNED_SHORT */
  81528. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81529. /** INT */
  81530. static readonly TEXTURETYPE_INT: number;
  81531. /** UNSIGNED_INT */
  81532. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81533. /** UNSIGNED_SHORT_4_4_4_4 */
  81534. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81535. /** UNSIGNED_SHORT_5_5_5_1 */
  81536. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81537. /** UNSIGNED_SHORT_5_6_5 */
  81538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81539. /** UNSIGNED_INT_2_10_10_10_REV */
  81540. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81541. /** UNSIGNED_INT_24_8 */
  81542. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81543. /** UNSIGNED_INT_10F_11F_11F_REV */
  81544. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81545. /** UNSIGNED_INT_5_9_9_9_REV */
  81546. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81547. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81548. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81549. /** nearest is mag = nearest and min = nearest and no mip */
  81550. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81551. /** mag = nearest and min = nearest and mip = none */
  81552. static readonly TEXTURE_NEAREST_NEAREST: number;
  81553. /** Bilinear is mag = linear and min = linear and no mip */
  81554. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81555. /** mag = linear and min = linear and mip = none */
  81556. static readonly TEXTURE_LINEAR_LINEAR: number;
  81557. /** Trilinear is mag = linear and min = linear and mip = linear */
  81558. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81559. /** Trilinear is mag = linear and min = linear and mip = linear */
  81560. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81561. /** mag = nearest and min = nearest and mip = nearest */
  81562. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81563. /** mag = nearest and min = linear and mip = nearest */
  81564. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81565. /** mag = nearest and min = linear and mip = linear */
  81566. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81567. /** mag = nearest and min = linear and mip = none */
  81568. static readonly TEXTURE_NEAREST_LINEAR: number;
  81569. /** nearest is mag = nearest and min = nearest and mip = linear */
  81570. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81571. /** mag = linear and min = nearest and mip = nearest */
  81572. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81573. /** mag = linear and min = nearest and mip = linear */
  81574. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81575. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81576. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81577. /** mag = linear and min = nearest and mip = none */
  81578. static readonly TEXTURE_LINEAR_NEAREST: number;
  81579. /** Explicit coordinates mode */
  81580. static readonly TEXTURE_EXPLICIT_MODE: number;
  81581. /** Spherical coordinates mode */
  81582. static readonly TEXTURE_SPHERICAL_MODE: number;
  81583. /** Planar coordinates mode */
  81584. static readonly TEXTURE_PLANAR_MODE: number;
  81585. /** Cubic coordinates mode */
  81586. static readonly TEXTURE_CUBIC_MODE: number;
  81587. /** Projection coordinates mode */
  81588. static readonly TEXTURE_PROJECTION_MODE: number;
  81589. /** Skybox coordinates mode */
  81590. static readonly TEXTURE_SKYBOX_MODE: number;
  81591. /** Inverse Cubic coordinates mode */
  81592. static readonly TEXTURE_INVCUBIC_MODE: number;
  81593. /** Equirectangular coordinates mode */
  81594. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81595. /** Equirectangular Fixed coordinates mode */
  81596. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81597. /** Equirectangular Fixed Mirrored coordinates mode */
  81598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81599. /** Offline (baking) quality for texture filtering */
  81600. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81601. /** High quality for texture filtering */
  81602. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81603. /** Medium quality for texture filtering */
  81604. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81605. /** Low quality for texture filtering */
  81606. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81607. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81608. static readonly SCALEMODE_FLOOR: number;
  81609. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81610. static readonly SCALEMODE_NEAREST: number;
  81611. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81612. static readonly SCALEMODE_CEILING: number;
  81613. /**
  81614. * The dirty texture flag value
  81615. */
  81616. static readonly MATERIAL_TextureDirtyFlag: number;
  81617. /**
  81618. * The dirty light flag value
  81619. */
  81620. static readonly MATERIAL_LightDirtyFlag: number;
  81621. /**
  81622. * The dirty fresnel flag value
  81623. */
  81624. static readonly MATERIAL_FresnelDirtyFlag: number;
  81625. /**
  81626. * The dirty attribute flag value
  81627. */
  81628. static readonly MATERIAL_AttributesDirtyFlag: number;
  81629. /**
  81630. * The dirty misc flag value
  81631. */
  81632. static readonly MATERIAL_MiscDirtyFlag: number;
  81633. /**
  81634. * The dirty prepass flag value
  81635. */
  81636. static readonly MATERIAL_PrePassDirtyFlag: number;
  81637. /**
  81638. * The all dirty flag value
  81639. */
  81640. static readonly MATERIAL_AllDirtyFlag: number;
  81641. /**
  81642. * Returns the triangle fill mode
  81643. */
  81644. static readonly MATERIAL_TriangleFillMode: number;
  81645. /**
  81646. * Returns the wireframe mode
  81647. */
  81648. static readonly MATERIAL_WireFrameFillMode: number;
  81649. /**
  81650. * Returns the point fill mode
  81651. */
  81652. static readonly MATERIAL_PointFillMode: number;
  81653. /**
  81654. * Returns the point list draw mode
  81655. */
  81656. static readonly MATERIAL_PointListDrawMode: number;
  81657. /**
  81658. * Returns the line list draw mode
  81659. */
  81660. static readonly MATERIAL_LineListDrawMode: number;
  81661. /**
  81662. * Returns the line loop draw mode
  81663. */
  81664. static readonly MATERIAL_LineLoopDrawMode: number;
  81665. /**
  81666. * Returns the line strip draw mode
  81667. */
  81668. static readonly MATERIAL_LineStripDrawMode: number;
  81669. /**
  81670. * Returns the triangle strip draw mode
  81671. */
  81672. static readonly MATERIAL_TriangleStripDrawMode: number;
  81673. /**
  81674. * Returns the triangle fan draw mode
  81675. */
  81676. static readonly MATERIAL_TriangleFanDrawMode: number;
  81677. /**
  81678. * Stores the clock-wise side orientation
  81679. */
  81680. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81681. /**
  81682. * Stores the counter clock-wise side orientation
  81683. */
  81684. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81685. /**
  81686. * Nothing
  81687. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81688. */
  81689. static readonly ACTION_NothingTrigger: number;
  81690. /**
  81691. * On pick
  81692. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81693. */
  81694. static readonly ACTION_OnPickTrigger: number;
  81695. /**
  81696. * On left pick
  81697. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81698. */
  81699. static readonly ACTION_OnLeftPickTrigger: number;
  81700. /**
  81701. * On right pick
  81702. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81703. */
  81704. static readonly ACTION_OnRightPickTrigger: number;
  81705. /**
  81706. * On center pick
  81707. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81708. */
  81709. static readonly ACTION_OnCenterPickTrigger: number;
  81710. /**
  81711. * On pick down
  81712. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81713. */
  81714. static readonly ACTION_OnPickDownTrigger: number;
  81715. /**
  81716. * On double pick
  81717. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81718. */
  81719. static readonly ACTION_OnDoublePickTrigger: number;
  81720. /**
  81721. * On pick up
  81722. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81723. */
  81724. static readonly ACTION_OnPickUpTrigger: number;
  81725. /**
  81726. * On pick out.
  81727. * This trigger will only be raised if you also declared a OnPickDown
  81728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81729. */
  81730. static readonly ACTION_OnPickOutTrigger: number;
  81731. /**
  81732. * On long press
  81733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81734. */
  81735. static readonly ACTION_OnLongPressTrigger: number;
  81736. /**
  81737. * On pointer over
  81738. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81739. */
  81740. static readonly ACTION_OnPointerOverTrigger: number;
  81741. /**
  81742. * On pointer out
  81743. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81744. */
  81745. static readonly ACTION_OnPointerOutTrigger: number;
  81746. /**
  81747. * On every frame
  81748. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81749. */
  81750. static readonly ACTION_OnEveryFrameTrigger: number;
  81751. /**
  81752. * On intersection enter
  81753. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81754. */
  81755. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81756. /**
  81757. * On intersection exit
  81758. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81759. */
  81760. static readonly ACTION_OnIntersectionExitTrigger: number;
  81761. /**
  81762. * On key down
  81763. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81764. */
  81765. static readonly ACTION_OnKeyDownTrigger: number;
  81766. /**
  81767. * On key up
  81768. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81769. */
  81770. static readonly ACTION_OnKeyUpTrigger: number;
  81771. /**
  81772. * Billboard mode will only apply to Y axis
  81773. */
  81774. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81775. /**
  81776. * Billboard mode will apply to all axes
  81777. */
  81778. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81779. /**
  81780. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81781. */
  81782. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81783. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81784. * Test order :
  81785. * Is the bounding sphere outside the frustum ?
  81786. * If not, are the bounding box vertices outside the frustum ?
  81787. * It not, then the cullable object is in the frustum.
  81788. */
  81789. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81790. /** Culling strategy : Bounding Sphere Only.
  81791. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81792. * It's also less accurate than the standard because some not visible objects can still be selected.
  81793. * Test : is the bounding sphere outside the frustum ?
  81794. * If not, then the cullable object is in the frustum.
  81795. */
  81796. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81797. /** Culling strategy : Optimistic Inclusion.
  81798. * This in an inclusion test first, then the standard exclusion test.
  81799. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81800. * 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.
  81801. * Anyway, it's as accurate as the standard strategy.
  81802. * Test :
  81803. * Is the cullable object bounding sphere center in the frustum ?
  81804. * If not, apply the default culling strategy.
  81805. */
  81806. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81807. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81808. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81809. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81810. * 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.
  81811. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81812. * Test :
  81813. * Is the cullable object bounding sphere center in the frustum ?
  81814. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81815. */
  81816. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81817. /**
  81818. * No logging while loading
  81819. */
  81820. static readonly SCENELOADER_NO_LOGGING: number;
  81821. /**
  81822. * Minimal logging while loading
  81823. */
  81824. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81825. /**
  81826. * Summary logging while loading
  81827. */
  81828. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81829. /**
  81830. * Detailled logging while loading
  81831. */
  81832. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81833. /**
  81834. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81835. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81836. */
  81837. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81838. /**
  81839. * Constant used to retrieve the position texture index in the textures array in the prepass
  81840. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81841. */
  81842. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81843. /**
  81844. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81845. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81846. */
  81847. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81848. /**
  81849. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81850. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81851. */
  81852. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81853. /**
  81854. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81855. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81856. */
  81857. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81858. /**
  81859. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81860. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81861. */
  81862. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81863. /**
  81864. * Constant used to retrieve albedo index in the textures array in the prepass
  81865. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81866. */
  81867. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81868. }
  81869. }
  81870. declare module BABYLON {
  81871. /**
  81872. * This represents the required contract to create a new type of texture loader.
  81873. */
  81874. export interface IInternalTextureLoader {
  81875. /**
  81876. * Defines wether the loader supports cascade loading the different faces.
  81877. */
  81878. supportCascades: boolean;
  81879. /**
  81880. * This returns if the loader support the current file information.
  81881. * @param extension defines the file extension of the file being loaded
  81882. * @param mimeType defines the optional mime type of the file being loaded
  81883. * @returns true if the loader can load the specified file
  81884. */
  81885. canLoad(extension: string, mimeType?: string): boolean;
  81886. /**
  81887. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81888. * @param data contains the texture data
  81889. * @param texture defines the BabylonJS internal texture
  81890. * @param createPolynomials will be true if polynomials have been requested
  81891. * @param onLoad defines the callback to trigger once the texture is ready
  81892. * @param onError defines the callback to trigger in case of error
  81893. */
  81894. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81895. /**
  81896. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81897. * @param data contains the texture data
  81898. * @param texture defines the BabylonJS internal texture
  81899. * @param callback defines the method to call once ready to upload
  81900. */
  81901. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81902. }
  81903. }
  81904. declare module BABYLON {
  81905. /**
  81906. * Class used to store and describe the pipeline context associated with an effect
  81907. */
  81908. export interface IPipelineContext {
  81909. /**
  81910. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81911. */
  81912. isAsync: boolean;
  81913. /**
  81914. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81915. */
  81916. isReady: boolean;
  81917. /** @hidden */
  81918. _getVertexShaderCode(): string | null;
  81919. /** @hidden */
  81920. _getFragmentShaderCode(): string | null;
  81921. /** @hidden */
  81922. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81923. }
  81924. }
  81925. declare module BABYLON {
  81926. /**
  81927. * Class used to store gfx data (like WebGLBuffer)
  81928. */
  81929. export class DataBuffer {
  81930. /**
  81931. * Gets or sets the number of objects referencing this buffer
  81932. */
  81933. references: number;
  81934. /** Gets or sets the size of the underlying buffer */
  81935. capacity: number;
  81936. /**
  81937. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81938. */
  81939. is32Bits: boolean;
  81940. /**
  81941. * Gets the underlying buffer
  81942. */
  81943. get underlyingResource(): any;
  81944. }
  81945. }
  81946. declare module BABYLON {
  81947. /** @hidden */
  81948. export interface IShaderProcessor {
  81949. attributeProcessor?: (attribute: string) => string;
  81950. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81951. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81952. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81953. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81954. lineProcessor?: (line: string, isFragment: boolean) => string;
  81955. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81956. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81957. }
  81958. }
  81959. declare module BABYLON {
  81960. /** @hidden */
  81961. export interface ProcessingOptions {
  81962. defines: string[];
  81963. indexParameters: any;
  81964. isFragment: boolean;
  81965. shouldUseHighPrecisionShader: boolean;
  81966. supportsUniformBuffers: boolean;
  81967. shadersRepository: string;
  81968. includesShadersStore: {
  81969. [key: string]: string;
  81970. };
  81971. processor?: IShaderProcessor;
  81972. version: string;
  81973. platformName: string;
  81974. lookForClosingBracketForUniformBuffer?: boolean;
  81975. }
  81976. }
  81977. declare module BABYLON {
  81978. /** @hidden */
  81979. export class ShaderCodeNode {
  81980. line: string;
  81981. children: ShaderCodeNode[];
  81982. additionalDefineKey?: string;
  81983. additionalDefineValue?: string;
  81984. isValid(preprocessors: {
  81985. [key: string]: string;
  81986. }): boolean;
  81987. process(preprocessors: {
  81988. [key: string]: string;
  81989. }, options: ProcessingOptions): string;
  81990. }
  81991. }
  81992. declare module BABYLON {
  81993. /** @hidden */
  81994. export class ShaderCodeCursor {
  81995. private _lines;
  81996. lineIndex: number;
  81997. get currentLine(): string;
  81998. get canRead(): boolean;
  81999. set lines(value: string[]);
  82000. }
  82001. }
  82002. declare module BABYLON {
  82003. /** @hidden */
  82004. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82005. process(preprocessors: {
  82006. [key: string]: string;
  82007. }, options: ProcessingOptions): string;
  82008. }
  82009. }
  82010. declare module BABYLON {
  82011. /** @hidden */
  82012. export class ShaderDefineExpression {
  82013. isTrue(preprocessors: {
  82014. [key: string]: string;
  82015. }): boolean;
  82016. private static _OperatorPriority;
  82017. private static _Stack;
  82018. static postfixToInfix(postfix: string[]): string;
  82019. static infixToPostfix(infix: string): string[];
  82020. }
  82021. }
  82022. declare module BABYLON {
  82023. /** @hidden */
  82024. export class ShaderCodeTestNode extends ShaderCodeNode {
  82025. testExpression: ShaderDefineExpression;
  82026. isValid(preprocessors: {
  82027. [key: string]: string;
  82028. }): boolean;
  82029. }
  82030. }
  82031. declare module BABYLON {
  82032. /** @hidden */
  82033. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82034. define: string;
  82035. not: boolean;
  82036. constructor(define: string, not?: boolean);
  82037. isTrue(preprocessors: {
  82038. [key: string]: string;
  82039. }): boolean;
  82040. }
  82041. }
  82042. declare module BABYLON {
  82043. /** @hidden */
  82044. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82045. leftOperand: ShaderDefineExpression;
  82046. rightOperand: ShaderDefineExpression;
  82047. isTrue(preprocessors: {
  82048. [key: string]: string;
  82049. }): boolean;
  82050. }
  82051. }
  82052. declare module BABYLON {
  82053. /** @hidden */
  82054. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82055. leftOperand: ShaderDefineExpression;
  82056. rightOperand: ShaderDefineExpression;
  82057. isTrue(preprocessors: {
  82058. [key: string]: string;
  82059. }): boolean;
  82060. }
  82061. }
  82062. declare module BABYLON {
  82063. /** @hidden */
  82064. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82065. define: string;
  82066. operand: string;
  82067. testValue: string;
  82068. constructor(define: string, operand: string, testValue: string);
  82069. isTrue(preprocessors: {
  82070. [key: string]: string;
  82071. }): boolean;
  82072. }
  82073. }
  82074. declare module BABYLON {
  82075. /**
  82076. * Class used to enable access to offline support
  82077. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82078. */
  82079. export interface IOfflineProvider {
  82080. /**
  82081. * Gets a boolean indicating if scene must be saved in the database
  82082. */
  82083. enableSceneOffline: boolean;
  82084. /**
  82085. * Gets a boolean indicating if textures must be saved in the database
  82086. */
  82087. enableTexturesOffline: boolean;
  82088. /**
  82089. * Open the offline support and make it available
  82090. * @param successCallback defines the callback to call on success
  82091. * @param errorCallback defines the callback to call on error
  82092. */
  82093. open(successCallback: () => void, errorCallback: () => void): void;
  82094. /**
  82095. * Loads an image from the offline support
  82096. * @param url defines the url to load from
  82097. * @param image defines the target DOM image
  82098. */
  82099. loadImage(url: string, image: HTMLImageElement): void;
  82100. /**
  82101. * Loads a file from offline support
  82102. * @param url defines the URL to load from
  82103. * @param sceneLoaded defines a callback to call on success
  82104. * @param progressCallBack defines a callback to call when progress changed
  82105. * @param errorCallback defines a callback to call on error
  82106. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82107. */
  82108. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82109. }
  82110. }
  82111. declare module BABYLON {
  82112. /**
  82113. * Class used to help managing file picking and drag'n'drop
  82114. * File Storage
  82115. */
  82116. export class FilesInputStore {
  82117. /**
  82118. * List of files ready to be loaded
  82119. */
  82120. static FilesToLoad: {
  82121. [key: string]: File;
  82122. };
  82123. }
  82124. }
  82125. declare module BABYLON {
  82126. /**
  82127. * Class used to define a retry strategy when error happens while loading assets
  82128. */
  82129. export class RetryStrategy {
  82130. /**
  82131. * Function used to defines an exponential back off strategy
  82132. * @param maxRetries defines the maximum number of retries (3 by default)
  82133. * @param baseInterval defines the interval between retries
  82134. * @returns the strategy function to use
  82135. */
  82136. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82137. }
  82138. }
  82139. declare module BABYLON {
  82140. /**
  82141. * @ignore
  82142. * Application error to support additional information when loading a file
  82143. */
  82144. export abstract class BaseError extends Error {
  82145. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82146. }
  82147. }
  82148. declare module BABYLON {
  82149. /** @ignore */
  82150. export class LoadFileError extends BaseError {
  82151. request?: WebRequest;
  82152. file?: File;
  82153. /**
  82154. * Creates a new LoadFileError
  82155. * @param message defines the message of the error
  82156. * @param request defines the optional web request
  82157. * @param file defines the optional file
  82158. */
  82159. constructor(message: string, object?: WebRequest | File);
  82160. }
  82161. /** @ignore */
  82162. export class RequestFileError extends BaseError {
  82163. request: WebRequest;
  82164. /**
  82165. * Creates a new LoadFileError
  82166. * @param message defines the message of the error
  82167. * @param request defines the optional web request
  82168. */
  82169. constructor(message: string, request: WebRequest);
  82170. }
  82171. /** @ignore */
  82172. export class ReadFileError extends BaseError {
  82173. file: File;
  82174. /**
  82175. * Creates a new ReadFileError
  82176. * @param message defines the message of the error
  82177. * @param file defines the optional file
  82178. */
  82179. constructor(message: string, file: File);
  82180. }
  82181. /**
  82182. * @hidden
  82183. */
  82184. export class FileTools {
  82185. /**
  82186. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82187. */
  82188. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82189. /**
  82190. * Gets or sets the base URL to use to load assets
  82191. */
  82192. static BaseUrl: string;
  82193. /**
  82194. * Default behaviour for cors in the application.
  82195. * It can be a string if the expected behavior is identical in the entire app.
  82196. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82197. */
  82198. static CorsBehavior: string | ((url: string | string[]) => string);
  82199. /**
  82200. * Gets or sets a function used to pre-process url before using them to load assets
  82201. */
  82202. static PreprocessUrl: (url: string) => string;
  82203. /**
  82204. * Removes unwanted characters from an url
  82205. * @param url defines the url to clean
  82206. * @returns the cleaned url
  82207. */
  82208. private static _CleanUrl;
  82209. /**
  82210. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82211. * @param url define the url we are trying
  82212. * @param element define the dom element where to configure the cors policy
  82213. */
  82214. static SetCorsBehavior(url: string | string[], element: {
  82215. crossOrigin: string | null;
  82216. }): void;
  82217. /**
  82218. * Loads an image as an HTMLImageElement.
  82219. * @param input url string, ArrayBuffer, or Blob to load
  82220. * @param onLoad callback called when the image successfully loads
  82221. * @param onError callback called when the image fails to load
  82222. * @param offlineProvider offline provider for caching
  82223. * @param mimeType optional mime type
  82224. * @returns the HTMLImageElement of the loaded image
  82225. */
  82226. 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>;
  82227. /**
  82228. * Reads a file from a File object
  82229. * @param file defines the file to load
  82230. * @param onSuccess defines the callback to call when data is loaded
  82231. * @param onProgress defines the callback to call during loading process
  82232. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82233. * @param onError defines the callback to call when an error occurs
  82234. * @returns a file request object
  82235. */
  82236. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82237. /**
  82238. * Loads a file from a url
  82239. * @param url url to load
  82240. * @param onSuccess callback called when the file successfully loads
  82241. * @param onProgress callback called while file is loading (if the server supports this mode)
  82242. * @param offlineProvider defines the offline provider for caching
  82243. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82244. * @param onError callback called when the file fails to load
  82245. * @returns a file request object
  82246. */
  82247. 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;
  82248. /**
  82249. * Loads a file
  82250. * @param url url to load
  82251. * @param onSuccess callback called when the file successfully loads
  82252. * @param onProgress callback called while file is loading (if the server supports this mode)
  82253. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82254. * @param onError callback called when the file fails to load
  82255. * @param onOpened callback called when the web request is opened
  82256. * @returns a file request object
  82257. */
  82258. 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;
  82259. /**
  82260. * Checks if the loaded document was accessed via `file:`-Protocol.
  82261. * @returns boolean
  82262. */
  82263. static IsFileURL(): boolean;
  82264. }
  82265. }
  82266. declare module BABYLON {
  82267. /** @hidden */
  82268. export class ShaderProcessor {
  82269. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82270. private static _ProcessPrecision;
  82271. private static _ExtractOperation;
  82272. private static _BuildSubExpression;
  82273. private static _BuildExpression;
  82274. private static _MoveCursorWithinIf;
  82275. private static _MoveCursor;
  82276. private static _EvaluatePreProcessors;
  82277. private static _PreparePreProcessors;
  82278. private static _ProcessShaderConversion;
  82279. private static _ProcessIncludes;
  82280. /**
  82281. * Loads a file from a url
  82282. * @param url url to load
  82283. * @param onSuccess callback called when the file successfully loads
  82284. * @param onProgress callback called while file is loading (if the server supports this mode)
  82285. * @param offlineProvider defines the offline provider for caching
  82286. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82287. * @param onError callback called when the file fails to load
  82288. * @returns a file request object
  82289. * @hidden
  82290. */
  82291. 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;
  82292. }
  82293. }
  82294. declare module BABYLON {
  82295. /**
  82296. * @hidden
  82297. */
  82298. export interface IColor4Like {
  82299. r: float;
  82300. g: float;
  82301. b: float;
  82302. a: float;
  82303. }
  82304. /**
  82305. * @hidden
  82306. */
  82307. export interface IColor3Like {
  82308. r: float;
  82309. g: float;
  82310. b: float;
  82311. }
  82312. /**
  82313. * @hidden
  82314. */
  82315. export interface IVector4Like {
  82316. x: float;
  82317. y: float;
  82318. z: float;
  82319. w: float;
  82320. }
  82321. /**
  82322. * @hidden
  82323. */
  82324. export interface IVector3Like {
  82325. x: float;
  82326. y: float;
  82327. z: float;
  82328. }
  82329. /**
  82330. * @hidden
  82331. */
  82332. export interface IVector2Like {
  82333. x: float;
  82334. y: float;
  82335. }
  82336. /**
  82337. * @hidden
  82338. */
  82339. export interface IMatrixLike {
  82340. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82341. updateFlag: int;
  82342. }
  82343. /**
  82344. * @hidden
  82345. */
  82346. export interface IViewportLike {
  82347. x: float;
  82348. y: float;
  82349. width: float;
  82350. height: float;
  82351. }
  82352. /**
  82353. * @hidden
  82354. */
  82355. export interface IPlaneLike {
  82356. normal: IVector3Like;
  82357. d: float;
  82358. normalize(): void;
  82359. }
  82360. }
  82361. declare module BABYLON {
  82362. /**
  82363. * Interface used to define common properties for effect fallbacks
  82364. */
  82365. export interface IEffectFallbacks {
  82366. /**
  82367. * Removes the defines that should be removed when falling back.
  82368. * @param currentDefines defines the current define statements for the shader.
  82369. * @param effect defines the current effect we try to compile
  82370. * @returns The resulting defines with defines of the current rank removed.
  82371. */
  82372. reduce(currentDefines: string, effect: Effect): string;
  82373. /**
  82374. * Removes the fallback from the bound mesh.
  82375. */
  82376. unBindMesh(): void;
  82377. /**
  82378. * Checks to see if more fallbacks are still availible.
  82379. */
  82380. hasMoreFallbacks: boolean;
  82381. }
  82382. }
  82383. declare module BABYLON {
  82384. /**
  82385. * Class used to evalaute queries containing `and` and `or` operators
  82386. */
  82387. export class AndOrNotEvaluator {
  82388. /**
  82389. * Evaluate a query
  82390. * @param query defines the query to evaluate
  82391. * @param evaluateCallback defines the callback used to filter result
  82392. * @returns true if the query matches
  82393. */
  82394. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82395. private static _HandleParenthesisContent;
  82396. private static _SimplifyNegation;
  82397. }
  82398. }
  82399. declare module BABYLON {
  82400. /**
  82401. * Class used to store custom tags
  82402. */
  82403. export class Tags {
  82404. /**
  82405. * Adds support for tags on the given object
  82406. * @param obj defines the object to use
  82407. */
  82408. static EnableFor(obj: any): void;
  82409. /**
  82410. * Removes tags support
  82411. * @param obj defines the object to use
  82412. */
  82413. static DisableFor(obj: any): void;
  82414. /**
  82415. * Gets a boolean indicating if the given object has tags
  82416. * @param obj defines the object to use
  82417. * @returns a boolean
  82418. */
  82419. static HasTags(obj: any): boolean;
  82420. /**
  82421. * Gets the tags available on a given object
  82422. * @param obj defines the object to use
  82423. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82424. * @returns the tags
  82425. */
  82426. static GetTags(obj: any, asString?: boolean): any;
  82427. /**
  82428. * Adds tags to an object
  82429. * @param obj defines the object to use
  82430. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82431. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82432. */
  82433. static AddTagsTo(obj: any, tagsString: string): void;
  82434. /**
  82435. * @hidden
  82436. */
  82437. static _AddTagTo(obj: any, tag: string): void;
  82438. /**
  82439. * Removes specific tags from a specific object
  82440. * @param obj defines the object to use
  82441. * @param tagsString defines the tags to remove
  82442. */
  82443. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82444. /**
  82445. * @hidden
  82446. */
  82447. static _RemoveTagFrom(obj: any, tag: string): void;
  82448. /**
  82449. * Defines if tags hosted on an object match a given query
  82450. * @param obj defines the object to use
  82451. * @param tagsQuery defines the tag query
  82452. * @returns a boolean
  82453. */
  82454. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82455. }
  82456. }
  82457. declare module BABYLON {
  82458. /**
  82459. * Scalar computation library
  82460. */
  82461. export class Scalar {
  82462. /**
  82463. * Two pi constants convenient for computation.
  82464. */
  82465. static TwoPi: number;
  82466. /**
  82467. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82468. * @param a number
  82469. * @param b number
  82470. * @param epsilon (default = 1.401298E-45)
  82471. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82472. */
  82473. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82474. /**
  82475. * Returns a string : the upper case translation of the number i to hexadecimal.
  82476. * @param i number
  82477. * @returns the upper case translation of the number i to hexadecimal.
  82478. */
  82479. static ToHex(i: number): string;
  82480. /**
  82481. * Returns -1 if value is negative and +1 is value is positive.
  82482. * @param value the value
  82483. * @returns the value itself if it's equal to zero.
  82484. */
  82485. static Sign(value: number): number;
  82486. /**
  82487. * Returns the value itself if it's between min and max.
  82488. * Returns min if the value is lower than min.
  82489. * Returns max if the value is greater than max.
  82490. * @param value the value to clmap
  82491. * @param min the min value to clamp to (default: 0)
  82492. * @param max the max value to clamp to (default: 1)
  82493. * @returns the clamped value
  82494. */
  82495. static Clamp(value: number, min?: number, max?: number): number;
  82496. /**
  82497. * the log2 of value.
  82498. * @param value the value to compute log2 of
  82499. * @returns the log2 of value.
  82500. */
  82501. static Log2(value: number): number;
  82502. /**
  82503. * Loops the value, so that it is never larger than length and never smaller than 0.
  82504. *
  82505. * This is similar to the modulo operator but it works with floating point numbers.
  82506. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82507. * With t = 5 and length = 2.5, the result would be 0.0.
  82508. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82509. * @param value the value
  82510. * @param length the length
  82511. * @returns the looped value
  82512. */
  82513. static Repeat(value: number, length: number): number;
  82514. /**
  82515. * Normalize the value between 0.0 and 1.0 using min and max values
  82516. * @param value value to normalize
  82517. * @param min max to normalize between
  82518. * @param max min to normalize between
  82519. * @returns the normalized value
  82520. */
  82521. static Normalize(value: number, min: number, max: number): number;
  82522. /**
  82523. * Denormalize the value from 0.0 and 1.0 using min and max values
  82524. * @param normalized value to denormalize
  82525. * @param min max to denormalize between
  82526. * @param max min to denormalize between
  82527. * @returns the denormalized value
  82528. */
  82529. static Denormalize(normalized: number, min: number, max: number): number;
  82530. /**
  82531. * Calculates the shortest difference between two given angles given in degrees.
  82532. * @param current current angle in degrees
  82533. * @param target target angle in degrees
  82534. * @returns the delta
  82535. */
  82536. static DeltaAngle(current: number, target: number): number;
  82537. /**
  82538. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82539. * @param tx value
  82540. * @param length length
  82541. * @returns The returned value will move back and forth between 0 and length
  82542. */
  82543. static PingPong(tx: number, length: number): number;
  82544. /**
  82545. * Interpolates between min and max with smoothing at the limits.
  82546. *
  82547. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82548. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82549. * @param from from
  82550. * @param to to
  82551. * @param tx value
  82552. * @returns the smooth stepped value
  82553. */
  82554. static SmoothStep(from: number, to: number, tx: number): number;
  82555. /**
  82556. * Moves a value current towards target.
  82557. *
  82558. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82559. * Negative values of maxDelta pushes the value away from target.
  82560. * @param current current value
  82561. * @param target target value
  82562. * @param maxDelta max distance to move
  82563. * @returns resulting value
  82564. */
  82565. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82566. /**
  82567. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82568. *
  82569. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82570. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82571. * @param current current value
  82572. * @param target target value
  82573. * @param maxDelta max distance to move
  82574. * @returns resulting angle
  82575. */
  82576. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82577. /**
  82578. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82579. * @param start start value
  82580. * @param end target value
  82581. * @param amount amount to lerp between
  82582. * @returns the lerped value
  82583. */
  82584. static Lerp(start: number, end: number, amount: number): number;
  82585. /**
  82586. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82587. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82588. * @param start start value
  82589. * @param end target value
  82590. * @param amount amount to lerp between
  82591. * @returns the lerped value
  82592. */
  82593. static LerpAngle(start: number, end: number, amount: number): number;
  82594. /**
  82595. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82596. * @param a start value
  82597. * @param b target value
  82598. * @param value value between a and b
  82599. * @returns the inverseLerp value
  82600. */
  82601. static InverseLerp(a: number, b: number, value: number): number;
  82602. /**
  82603. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82604. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82605. * @param value1 spline value
  82606. * @param tangent1 spline value
  82607. * @param value2 spline value
  82608. * @param tangent2 spline value
  82609. * @param amount input value
  82610. * @returns hermite result
  82611. */
  82612. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82613. /**
  82614. * Returns a random float number between and min and max values
  82615. * @param min min value of random
  82616. * @param max max value of random
  82617. * @returns random value
  82618. */
  82619. static RandomRange(min: number, max: number): number;
  82620. /**
  82621. * This function returns percentage of a number in a given range.
  82622. *
  82623. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82624. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82625. * @param number to convert to percentage
  82626. * @param min min range
  82627. * @param max max range
  82628. * @returns the percentage
  82629. */
  82630. static RangeToPercent(number: number, min: number, max: number): number;
  82631. /**
  82632. * This function returns number that corresponds to the percentage in a given range.
  82633. *
  82634. * PercentToRange(0.34,0,100) will return 34.
  82635. * @param percent to convert to number
  82636. * @param min min range
  82637. * @param max max range
  82638. * @returns the number
  82639. */
  82640. static PercentToRange(percent: number, min: number, max: number): number;
  82641. /**
  82642. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82643. * @param angle The angle to normalize in radian.
  82644. * @return The converted angle.
  82645. */
  82646. static NormalizeRadians(angle: number): number;
  82647. }
  82648. }
  82649. declare module BABYLON {
  82650. /**
  82651. * Constant used to convert a value to gamma space
  82652. * @ignorenaming
  82653. */
  82654. export const ToGammaSpace: number;
  82655. /**
  82656. * Constant used to convert a value to linear space
  82657. * @ignorenaming
  82658. */
  82659. export const ToLinearSpace = 2.2;
  82660. /**
  82661. * Constant used to define the minimal number value in Babylon.js
  82662. * @ignorenaming
  82663. */
  82664. let Epsilon: number;
  82665. }
  82666. declare module BABYLON {
  82667. /**
  82668. * Class used to represent a viewport on screen
  82669. */
  82670. export class Viewport {
  82671. /** viewport left coordinate */
  82672. x: number;
  82673. /** viewport top coordinate */
  82674. y: number;
  82675. /**viewport width */
  82676. width: number;
  82677. /** viewport height */
  82678. height: number;
  82679. /**
  82680. * Creates a Viewport object located at (x, y) and sized (width, height)
  82681. * @param x defines viewport left coordinate
  82682. * @param y defines viewport top coordinate
  82683. * @param width defines the viewport width
  82684. * @param height defines the viewport height
  82685. */
  82686. constructor(
  82687. /** viewport left coordinate */
  82688. x: number,
  82689. /** viewport top coordinate */
  82690. y: number,
  82691. /**viewport width */
  82692. width: number,
  82693. /** viewport height */
  82694. height: number);
  82695. /**
  82696. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82697. * @param renderWidth defines the rendering width
  82698. * @param renderHeight defines the rendering height
  82699. * @returns a new Viewport
  82700. */
  82701. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82702. /**
  82703. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82704. * @param renderWidth defines the rendering width
  82705. * @param renderHeight defines the rendering height
  82706. * @param ref defines the target viewport
  82707. * @returns the current viewport
  82708. */
  82709. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82710. /**
  82711. * Returns a new Viewport copied from the current one
  82712. * @returns a new Viewport
  82713. */
  82714. clone(): Viewport;
  82715. }
  82716. }
  82717. declare module BABYLON {
  82718. /**
  82719. * Class containing a set of static utilities functions for arrays.
  82720. */
  82721. export class ArrayTools {
  82722. /**
  82723. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82724. * @param size the number of element to construct and put in the array
  82725. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82726. * @returns a new array filled with new objects
  82727. */
  82728. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82729. }
  82730. }
  82731. declare module BABYLON {
  82732. /**
  82733. * Represents a plane by the equation ax + by + cz + d = 0
  82734. */
  82735. export class Plane {
  82736. private static _TmpMatrix;
  82737. /**
  82738. * Normal of the plane (a,b,c)
  82739. */
  82740. normal: Vector3;
  82741. /**
  82742. * d component of the plane
  82743. */
  82744. d: number;
  82745. /**
  82746. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82747. * @param a a component of the plane
  82748. * @param b b component of the plane
  82749. * @param c c component of the plane
  82750. * @param d d component of the plane
  82751. */
  82752. constructor(a: number, b: number, c: number, d: number);
  82753. /**
  82754. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82755. */
  82756. asArray(): number[];
  82757. /**
  82758. * @returns a new plane copied from the current Plane.
  82759. */
  82760. clone(): Plane;
  82761. /**
  82762. * @returns the string "Plane".
  82763. */
  82764. getClassName(): string;
  82765. /**
  82766. * @returns the Plane hash code.
  82767. */
  82768. getHashCode(): number;
  82769. /**
  82770. * Normalize the current Plane in place.
  82771. * @returns the updated Plane.
  82772. */
  82773. normalize(): Plane;
  82774. /**
  82775. * Applies a transformation the plane and returns the result
  82776. * @param transformation the transformation matrix to be applied to the plane
  82777. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82778. */
  82779. transform(transformation: DeepImmutable<Matrix>): Plane;
  82780. /**
  82781. * Compute the dot product between the point and the plane normal
  82782. * @param point point to calculate the dot product with
  82783. * @returns the dot product (float) of the point coordinates and the plane normal.
  82784. */
  82785. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82786. /**
  82787. * Updates the current Plane from the plane defined by the three given points.
  82788. * @param point1 one of the points used to contruct the plane
  82789. * @param point2 one of the points used to contruct the plane
  82790. * @param point3 one of the points used to contruct the plane
  82791. * @returns the updated Plane.
  82792. */
  82793. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82794. /**
  82795. * Checks if the plane is facing a given direction
  82796. * @param direction the direction to check if the plane is facing
  82797. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82798. * @returns True is the vector "direction" is the same side than the plane normal.
  82799. */
  82800. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82801. /**
  82802. * Calculates the distance to a point
  82803. * @param point point to calculate distance to
  82804. * @returns the signed distance (float) from the given point to the Plane.
  82805. */
  82806. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82807. /**
  82808. * Creates a plane from an array
  82809. * @param array the array to create a plane from
  82810. * @returns a new Plane from the given array.
  82811. */
  82812. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82813. /**
  82814. * Creates a plane from three points
  82815. * @param point1 point used to create the plane
  82816. * @param point2 point used to create the plane
  82817. * @param point3 point used to create the plane
  82818. * @returns a new Plane defined by the three given points.
  82819. */
  82820. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82821. /**
  82822. * Creates a plane from an origin point and a normal
  82823. * @param origin origin of the plane to be constructed
  82824. * @param normal normal of the plane to be constructed
  82825. * @returns a new Plane the normal vector to this plane at the given origin point.
  82826. * Note : the vector "normal" is updated because normalized.
  82827. */
  82828. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82829. /**
  82830. * Calculates the distance from a plane and a point
  82831. * @param origin origin of the plane to be constructed
  82832. * @param normal normal of the plane to be constructed
  82833. * @param point point to calculate distance to
  82834. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82835. */
  82836. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82837. }
  82838. }
  82839. declare module BABYLON {
  82840. /** @hidden */
  82841. export class PerformanceConfigurator {
  82842. /** @hidden */
  82843. static MatrixUse64Bits: boolean;
  82844. /** @hidden */
  82845. static MatrixTrackPrecisionChange: boolean;
  82846. /** @hidden */
  82847. static MatrixCurrentType: any;
  82848. /** @hidden */
  82849. static MatrixTrackedMatrices: Array<any> | null;
  82850. /** @hidden */
  82851. static SetMatrixPrecision(use64bits: boolean): void;
  82852. }
  82853. }
  82854. declare module BABYLON {
  82855. /**
  82856. * Class representing a vector containing 2 coordinates
  82857. */
  82858. export class Vector2 {
  82859. /** defines the first coordinate */
  82860. x: number;
  82861. /** defines the second coordinate */
  82862. y: number;
  82863. /**
  82864. * Creates a new Vector2 from the given x and y coordinates
  82865. * @param x defines the first coordinate
  82866. * @param y defines the second coordinate
  82867. */
  82868. constructor(
  82869. /** defines the first coordinate */
  82870. x?: number,
  82871. /** defines the second coordinate */
  82872. y?: number);
  82873. /**
  82874. * Gets a string with the Vector2 coordinates
  82875. * @returns a string with the Vector2 coordinates
  82876. */
  82877. toString(): string;
  82878. /**
  82879. * Gets class name
  82880. * @returns the string "Vector2"
  82881. */
  82882. getClassName(): string;
  82883. /**
  82884. * Gets current vector hash code
  82885. * @returns the Vector2 hash code as a number
  82886. */
  82887. getHashCode(): number;
  82888. /**
  82889. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82890. * @param array defines the source array
  82891. * @param index defines the offset in source array
  82892. * @returns the current Vector2
  82893. */
  82894. toArray(array: FloatArray, index?: number): Vector2;
  82895. /**
  82896. * Update the current vector from an array
  82897. * @param array defines the destination array
  82898. * @param index defines the offset in the destination array
  82899. * @returns the current Vector3
  82900. */
  82901. fromArray(array: FloatArray, index?: number): Vector2;
  82902. /**
  82903. * Copy the current vector to an array
  82904. * @returns a new array with 2 elements: the Vector2 coordinates.
  82905. */
  82906. asArray(): number[];
  82907. /**
  82908. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82909. * @param source defines the source Vector2
  82910. * @returns the current updated Vector2
  82911. */
  82912. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82913. /**
  82914. * Sets the Vector2 coordinates with the given floats
  82915. * @param x defines the first coordinate
  82916. * @param y defines the second coordinate
  82917. * @returns the current updated Vector2
  82918. */
  82919. copyFromFloats(x: number, y: number): Vector2;
  82920. /**
  82921. * Sets the Vector2 coordinates with the given floats
  82922. * @param x defines the first coordinate
  82923. * @param y defines the second coordinate
  82924. * @returns the current updated Vector2
  82925. */
  82926. set(x: number, y: number): Vector2;
  82927. /**
  82928. * Add another vector with the current one
  82929. * @param otherVector defines the other vector
  82930. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82931. */
  82932. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82933. /**
  82934. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82935. * @param otherVector defines the other vector
  82936. * @param result defines the target vector
  82937. * @returns the unmodified current Vector2
  82938. */
  82939. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82940. /**
  82941. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82942. * @param otherVector defines the other vector
  82943. * @returns the current updated Vector2
  82944. */
  82945. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82946. /**
  82947. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82948. * @param otherVector defines the other vector
  82949. * @returns a new Vector2
  82950. */
  82951. addVector3(otherVector: Vector3): Vector2;
  82952. /**
  82953. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82954. * @param otherVector defines the other vector
  82955. * @returns a new Vector2
  82956. */
  82957. subtract(otherVector: Vector2): Vector2;
  82958. /**
  82959. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82960. * @param otherVector defines the other vector
  82961. * @param result defines the target vector
  82962. * @returns the unmodified current Vector2
  82963. */
  82964. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82965. /**
  82966. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82967. * @param otherVector defines the other vector
  82968. * @returns the current updated Vector2
  82969. */
  82970. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82971. /**
  82972. * Multiplies in place the current Vector2 coordinates by the given ones
  82973. * @param otherVector defines the other vector
  82974. * @returns the current updated Vector2
  82975. */
  82976. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82977. /**
  82978. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82979. * @param otherVector defines the other vector
  82980. * @returns a new Vector2
  82981. */
  82982. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82983. /**
  82984. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82985. * @param otherVector defines the other vector
  82986. * @param result defines the target vector
  82987. * @returns the unmodified current Vector2
  82988. */
  82989. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82990. /**
  82991. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82992. * @param x defines the first coordinate
  82993. * @param y defines the second coordinate
  82994. * @returns a new Vector2
  82995. */
  82996. multiplyByFloats(x: number, y: number): Vector2;
  82997. /**
  82998. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82999. * @param otherVector defines the other vector
  83000. * @returns a new Vector2
  83001. */
  83002. divide(otherVector: Vector2): Vector2;
  83003. /**
  83004. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83005. * @param otherVector defines the other vector
  83006. * @param result defines the target vector
  83007. * @returns the unmodified current Vector2
  83008. */
  83009. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83010. /**
  83011. * Divides the current Vector2 coordinates by the given ones
  83012. * @param otherVector defines the other vector
  83013. * @returns the current updated Vector2
  83014. */
  83015. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83016. /**
  83017. * Gets a new Vector2 with current Vector2 negated coordinates
  83018. * @returns a new Vector2
  83019. */
  83020. negate(): Vector2;
  83021. /**
  83022. * Negate this vector in place
  83023. * @returns this
  83024. */
  83025. negateInPlace(): Vector2;
  83026. /**
  83027. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83028. * @param result defines the Vector3 object where to store the result
  83029. * @returns the current Vector2
  83030. */
  83031. negateToRef(result: Vector2): Vector2;
  83032. /**
  83033. * Multiply the Vector2 coordinates by scale
  83034. * @param scale defines the scaling factor
  83035. * @returns the current updated Vector2
  83036. */
  83037. scaleInPlace(scale: number): Vector2;
  83038. /**
  83039. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83040. * @param scale defines the scaling factor
  83041. * @returns a new Vector2
  83042. */
  83043. scale(scale: number): Vector2;
  83044. /**
  83045. * Scale the current Vector2 values by a factor to a given Vector2
  83046. * @param scale defines the scale factor
  83047. * @param result defines the Vector2 object where to store the result
  83048. * @returns the unmodified current Vector2
  83049. */
  83050. scaleToRef(scale: number, result: Vector2): Vector2;
  83051. /**
  83052. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83053. * @param scale defines the scale factor
  83054. * @param result defines the Vector2 object where to store the result
  83055. * @returns the unmodified current Vector2
  83056. */
  83057. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83058. /**
  83059. * Gets a boolean if two vectors are equals
  83060. * @param otherVector defines the other vector
  83061. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83062. */
  83063. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83064. /**
  83065. * Gets a boolean if two vectors are equals (using an epsilon value)
  83066. * @param otherVector defines the other vector
  83067. * @param epsilon defines the minimal distance to consider equality
  83068. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83069. */
  83070. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83071. /**
  83072. * Gets a new Vector2 from current Vector2 floored values
  83073. * @returns a new Vector2
  83074. */
  83075. floor(): Vector2;
  83076. /**
  83077. * Gets a new Vector2 from current Vector2 floored values
  83078. * @returns a new Vector2
  83079. */
  83080. fract(): Vector2;
  83081. /**
  83082. * Gets the length of the vector
  83083. * @returns the vector length (float)
  83084. */
  83085. length(): number;
  83086. /**
  83087. * Gets the vector squared length
  83088. * @returns the vector squared length (float)
  83089. */
  83090. lengthSquared(): number;
  83091. /**
  83092. * Normalize the vector
  83093. * @returns the current updated Vector2
  83094. */
  83095. normalize(): Vector2;
  83096. /**
  83097. * Gets a new Vector2 copied from the Vector2
  83098. * @returns a new Vector2
  83099. */
  83100. clone(): Vector2;
  83101. /**
  83102. * Gets a new Vector2(0, 0)
  83103. * @returns a new Vector2
  83104. */
  83105. static Zero(): Vector2;
  83106. /**
  83107. * Gets a new Vector2(1, 1)
  83108. * @returns a new Vector2
  83109. */
  83110. static One(): Vector2;
  83111. /**
  83112. * Gets a new Vector2 set from the given index element of the given array
  83113. * @param array defines the data source
  83114. * @param offset defines the offset in the data source
  83115. * @returns a new Vector2
  83116. */
  83117. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83118. /**
  83119. * Sets "result" from the given index element of the given array
  83120. * @param array defines the data source
  83121. * @param offset defines the offset in the data source
  83122. * @param result defines the target vector
  83123. */
  83124. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83125. /**
  83126. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83127. * @param value1 defines 1st point of control
  83128. * @param value2 defines 2nd point of control
  83129. * @param value3 defines 3rd point of control
  83130. * @param value4 defines 4th point of control
  83131. * @param amount defines the interpolation factor
  83132. * @returns a new Vector2
  83133. */
  83134. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83135. /**
  83136. * 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".
  83137. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83138. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83139. * @param value defines the value to clamp
  83140. * @param min defines the lower limit
  83141. * @param max defines the upper limit
  83142. * @returns a new Vector2
  83143. */
  83144. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83145. /**
  83146. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83147. * @param value1 defines the 1st control point
  83148. * @param tangent1 defines the outgoing tangent
  83149. * @param value2 defines the 2nd control point
  83150. * @param tangent2 defines the incoming tangent
  83151. * @param amount defines the interpolation factor
  83152. * @returns a new Vector2
  83153. */
  83154. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83155. /**
  83156. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83157. * @param start defines the start vector
  83158. * @param end defines the end vector
  83159. * @param amount defines the interpolation factor
  83160. * @returns a new Vector2
  83161. */
  83162. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83163. /**
  83164. * Gets the dot product of the vector "left" and the vector "right"
  83165. * @param left defines first vector
  83166. * @param right defines second vector
  83167. * @returns the dot product (float)
  83168. */
  83169. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83170. /**
  83171. * Returns a new Vector2 equal to the normalized given vector
  83172. * @param vector defines the vector to normalize
  83173. * @returns a new Vector2
  83174. */
  83175. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83176. /**
  83177. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83178. * @param left defines 1st vector
  83179. * @param right defines 2nd vector
  83180. * @returns a new Vector2
  83181. */
  83182. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83183. /**
  83184. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83185. * @param left defines 1st vector
  83186. * @param right defines 2nd vector
  83187. * @returns a new Vector2
  83188. */
  83189. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83190. /**
  83191. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83192. * @param vector defines the vector to transform
  83193. * @param transformation defines the matrix to apply
  83194. * @returns a new Vector2
  83195. */
  83196. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83197. /**
  83198. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83199. * @param vector defines the vector to transform
  83200. * @param transformation defines the matrix to apply
  83201. * @param result defines the target vector
  83202. */
  83203. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83204. /**
  83205. * Determines if a given vector is included in a triangle
  83206. * @param p defines the vector to test
  83207. * @param p0 defines 1st triangle point
  83208. * @param p1 defines 2nd triangle point
  83209. * @param p2 defines 3rd triangle point
  83210. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83211. */
  83212. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83213. /**
  83214. * Gets the distance between the vectors "value1" and "value2"
  83215. * @param value1 defines first vector
  83216. * @param value2 defines second vector
  83217. * @returns the distance between vectors
  83218. */
  83219. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83220. /**
  83221. * Returns the squared distance between the vectors "value1" and "value2"
  83222. * @param value1 defines first vector
  83223. * @param value2 defines second vector
  83224. * @returns the squared distance between vectors
  83225. */
  83226. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83227. /**
  83228. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83229. * @param value1 defines first vector
  83230. * @param value2 defines second vector
  83231. * @returns a new Vector2
  83232. */
  83233. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83234. /**
  83235. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83236. * @param p defines the middle point
  83237. * @param segA defines one point of the segment
  83238. * @param segB defines the other point of the segment
  83239. * @returns the shortest distance
  83240. */
  83241. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83242. }
  83243. /**
  83244. * Class used to store (x,y,z) vector representation
  83245. * A Vector3 is the main object used in 3D geometry
  83246. * It can represent etiher the coordinates of a point the space, either a direction
  83247. * Reminder: js uses a left handed forward facing system
  83248. */
  83249. export class Vector3 {
  83250. private static _UpReadOnly;
  83251. private static _ZeroReadOnly;
  83252. /** @hidden */
  83253. _x: number;
  83254. /** @hidden */
  83255. _y: number;
  83256. /** @hidden */
  83257. _z: number;
  83258. /** @hidden */
  83259. _isDirty: boolean;
  83260. /** Gets or sets the x coordinate */
  83261. get x(): number;
  83262. set x(value: number);
  83263. /** Gets or sets the y coordinate */
  83264. get y(): number;
  83265. set y(value: number);
  83266. /** Gets or sets the z coordinate */
  83267. get z(): number;
  83268. set z(value: number);
  83269. /**
  83270. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83271. * @param x defines the first coordinates (on X axis)
  83272. * @param y defines the second coordinates (on Y axis)
  83273. * @param z defines the third coordinates (on Z axis)
  83274. */
  83275. constructor(x?: number, y?: number, z?: number);
  83276. /**
  83277. * Creates a string representation of the Vector3
  83278. * @returns a string with the Vector3 coordinates.
  83279. */
  83280. toString(): string;
  83281. /**
  83282. * Gets the class name
  83283. * @returns the string "Vector3"
  83284. */
  83285. getClassName(): string;
  83286. /**
  83287. * Creates the Vector3 hash code
  83288. * @returns a number which tends to be unique between Vector3 instances
  83289. */
  83290. getHashCode(): number;
  83291. /**
  83292. * Creates an array containing three elements : the coordinates of the Vector3
  83293. * @returns a new array of numbers
  83294. */
  83295. asArray(): number[];
  83296. /**
  83297. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83298. * @param array defines the destination array
  83299. * @param index defines the offset in the destination array
  83300. * @returns the current Vector3
  83301. */
  83302. toArray(array: FloatArray, index?: number): Vector3;
  83303. /**
  83304. * Update the current vector from an array
  83305. * @param array defines the destination array
  83306. * @param index defines the offset in the destination array
  83307. * @returns the current Vector3
  83308. */
  83309. fromArray(array: FloatArray, index?: number): Vector3;
  83310. /**
  83311. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83312. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83313. */
  83314. toQuaternion(): Quaternion;
  83315. /**
  83316. * Adds the given vector to the current Vector3
  83317. * @param otherVector defines the second operand
  83318. * @returns the current updated Vector3
  83319. */
  83320. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83321. /**
  83322. * Adds the given coordinates to the current Vector3
  83323. * @param x defines the x coordinate of the operand
  83324. * @param y defines the y coordinate of the operand
  83325. * @param z defines the z coordinate of the operand
  83326. * @returns the current updated Vector3
  83327. */
  83328. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83329. /**
  83330. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83331. * @param otherVector defines the second operand
  83332. * @returns the resulting Vector3
  83333. */
  83334. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83335. /**
  83336. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83337. * @param otherVector defines the second operand
  83338. * @param result defines the Vector3 object where to store the result
  83339. * @returns the current Vector3
  83340. */
  83341. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83342. /**
  83343. * Subtract the given vector from the current Vector3
  83344. * @param otherVector defines the second operand
  83345. * @returns the current updated Vector3
  83346. */
  83347. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83348. /**
  83349. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83350. * @param otherVector defines the second operand
  83351. * @returns the resulting Vector3
  83352. */
  83353. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83354. /**
  83355. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83356. * @param otherVector defines the second operand
  83357. * @param result defines the Vector3 object where to store the result
  83358. * @returns the current Vector3
  83359. */
  83360. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83361. /**
  83362. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83363. * @param x defines the x coordinate of the operand
  83364. * @param y defines the y coordinate of the operand
  83365. * @param z defines the z coordinate of the operand
  83366. * @returns the resulting Vector3
  83367. */
  83368. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83369. /**
  83370. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83371. * @param x defines the x coordinate of the operand
  83372. * @param y defines the y coordinate of the operand
  83373. * @param z defines the z coordinate of the operand
  83374. * @param result defines the Vector3 object where to store the result
  83375. * @returns the current Vector3
  83376. */
  83377. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83378. /**
  83379. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83380. * @returns a new Vector3
  83381. */
  83382. negate(): Vector3;
  83383. /**
  83384. * Negate this vector in place
  83385. * @returns this
  83386. */
  83387. negateInPlace(): Vector3;
  83388. /**
  83389. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83390. * @param result defines the Vector3 object where to store the result
  83391. * @returns the current Vector3
  83392. */
  83393. negateToRef(result: Vector3): Vector3;
  83394. /**
  83395. * Multiplies the Vector3 coordinates by the float "scale"
  83396. * @param scale defines the multiplier factor
  83397. * @returns the current updated Vector3
  83398. */
  83399. scaleInPlace(scale: number): Vector3;
  83400. /**
  83401. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83402. * @param scale defines the multiplier factor
  83403. * @returns a new Vector3
  83404. */
  83405. scale(scale: number): Vector3;
  83406. /**
  83407. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83408. * @param scale defines the multiplier factor
  83409. * @param result defines the Vector3 object where to store the result
  83410. * @returns the current Vector3
  83411. */
  83412. scaleToRef(scale: number, result: Vector3): Vector3;
  83413. /**
  83414. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83415. * @param scale defines the scale factor
  83416. * @param result defines the Vector3 object where to store the result
  83417. * @returns the unmodified current Vector3
  83418. */
  83419. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83420. /**
  83421. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83422. * @param origin defines the origin of the projection ray
  83423. * @param plane defines the plane to project to
  83424. * @returns the projected vector3
  83425. */
  83426. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83427. /**
  83428. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83429. * @param origin defines the origin of the projection ray
  83430. * @param plane defines the plane to project to
  83431. * @param result defines the Vector3 where to store the result
  83432. */
  83433. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83434. /**
  83435. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83436. * @param otherVector defines the second operand
  83437. * @returns true if both vectors are equals
  83438. */
  83439. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83440. /**
  83441. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83442. * @param otherVector defines the second operand
  83443. * @param epsilon defines the minimal distance to define values as equals
  83444. * @returns true if both vectors are distant less than epsilon
  83445. */
  83446. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83447. /**
  83448. * Returns true if the current Vector3 coordinates equals the given floats
  83449. * @param x defines the x coordinate of the operand
  83450. * @param y defines the y coordinate of the operand
  83451. * @param z defines the z coordinate of the operand
  83452. * @returns true if both vectors are equals
  83453. */
  83454. equalsToFloats(x: number, y: number, z: number): boolean;
  83455. /**
  83456. * Multiplies the current Vector3 coordinates by the given ones
  83457. * @param otherVector defines the second operand
  83458. * @returns the current updated Vector3
  83459. */
  83460. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83461. /**
  83462. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83463. * @param otherVector defines the second operand
  83464. * @returns the new Vector3
  83465. */
  83466. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83467. /**
  83468. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83469. * @param otherVector defines the second operand
  83470. * @param result defines the Vector3 object where to store the result
  83471. * @returns the current Vector3
  83472. */
  83473. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83474. /**
  83475. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83476. * @param x defines the x coordinate of the operand
  83477. * @param y defines the y coordinate of the operand
  83478. * @param z defines the z coordinate of the operand
  83479. * @returns the new Vector3
  83480. */
  83481. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83482. /**
  83483. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83484. * @param otherVector defines the second operand
  83485. * @returns the new Vector3
  83486. */
  83487. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83488. /**
  83489. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83490. * @param otherVector defines the second operand
  83491. * @param result defines the Vector3 object where to store the result
  83492. * @returns the current Vector3
  83493. */
  83494. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83495. /**
  83496. * Divides the current Vector3 coordinates by the given ones.
  83497. * @param otherVector defines the second operand
  83498. * @returns the current updated Vector3
  83499. */
  83500. divideInPlace(otherVector: Vector3): Vector3;
  83501. /**
  83502. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83503. * @param other defines the second operand
  83504. * @returns the current updated Vector3
  83505. */
  83506. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83507. /**
  83508. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83509. * @param other defines the second operand
  83510. * @returns the current updated Vector3
  83511. */
  83512. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83513. /**
  83514. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83515. * @param x defines the x coordinate of the operand
  83516. * @param y defines the y coordinate of the operand
  83517. * @param z defines the z coordinate of the operand
  83518. * @returns the current updated Vector3
  83519. */
  83520. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83521. /**
  83522. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83523. * @param x defines the x coordinate of the operand
  83524. * @param y defines the y coordinate of the operand
  83525. * @param z defines the z coordinate of the operand
  83526. * @returns the current updated Vector3
  83527. */
  83528. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83529. /**
  83530. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83531. * Check if is non uniform within a certain amount of decimal places to account for this
  83532. * @param epsilon the amount the values can differ
  83533. * @returns if the the vector is non uniform to a certain number of decimal places
  83534. */
  83535. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83536. /**
  83537. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83538. */
  83539. get isNonUniform(): boolean;
  83540. /**
  83541. * Gets a new Vector3 from current Vector3 floored values
  83542. * @returns a new Vector3
  83543. */
  83544. floor(): Vector3;
  83545. /**
  83546. * Gets a new Vector3 from current Vector3 floored values
  83547. * @returns a new Vector3
  83548. */
  83549. fract(): Vector3;
  83550. /**
  83551. * Gets the length of the Vector3
  83552. * @returns the length of the Vector3
  83553. */
  83554. length(): number;
  83555. /**
  83556. * Gets the squared length of the Vector3
  83557. * @returns squared length of the Vector3
  83558. */
  83559. lengthSquared(): number;
  83560. /**
  83561. * Normalize the current Vector3.
  83562. * Please note that this is an in place operation.
  83563. * @returns the current updated Vector3
  83564. */
  83565. normalize(): Vector3;
  83566. /**
  83567. * Reorders the x y z properties of the vector in place
  83568. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83569. * @returns the current updated vector
  83570. */
  83571. reorderInPlace(order: string): this;
  83572. /**
  83573. * Rotates the vector around 0,0,0 by a quaternion
  83574. * @param quaternion the rotation quaternion
  83575. * @param result vector to store the result
  83576. * @returns the resulting vector
  83577. */
  83578. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83579. /**
  83580. * Rotates a vector around a given point
  83581. * @param quaternion the rotation quaternion
  83582. * @param point the point to rotate around
  83583. * @param result vector to store the result
  83584. * @returns the resulting vector
  83585. */
  83586. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83587. /**
  83588. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83589. * The cross product is then orthogonal to both current and "other"
  83590. * @param other defines the right operand
  83591. * @returns the cross product
  83592. */
  83593. cross(other: Vector3): Vector3;
  83594. /**
  83595. * Normalize the current Vector3 with the given input length.
  83596. * Please note that this is an in place operation.
  83597. * @param len the length of the vector
  83598. * @returns the current updated Vector3
  83599. */
  83600. normalizeFromLength(len: number): Vector3;
  83601. /**
  83602. * Normalize the current Vector3 to a new vector
  83603. * @returns the new Vector3
  83604. */
  83605. normalizeToNew(): Vector3;
  83606. /**
  83607. * Normalize the current Vector3 to the reference
  83608. * @param reference define the Vector3 to update
  83609. * @returns the updated Vector3
  83610. */
  83611. normalizeToRef(reference: Vector3): Vector3;
  83612. /**
  83613. * Creates a new Vector3 copied from the current Vector3
  83614. * @returns the new Vector3
  83615. */
  83616. clone(): Vector3;
  83617. /**
  83618. * Copies the given vector coordinates to the current Vector3 ones
  83619. * @param source defines the source Vector3
  83620. * @returns the current updated Vector3
  83621. */
  83622. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83623. /**
  83624. * Copies the given floats to the current Vector3 coordinates
  83625. * @param x defines the x coordinate of the operand
  83626. * @param y defines the y coordinate of the operand
  83627. * @param z defines the z coordinate of the operand
  83628. * @returns the current updated Vector3
  83629. */
  83630. copyFromFloats(x: number, y: number, z: number): Vector3;
  83631. /**
  83632. * Copies the given floats to the current Vector3 coordinates
  83633. * @param x defines the x coordinate of the operand
  83634. * @param y defines the y coordinate of the operand
  83635. * @param z defines the z coordinate of the operand
  83636. * @returns the current updated Vector3
  83637. */
  83638. set(x: number, y: number, z: number): Vector3;
  83639. /**
  83640. * Copies the given float to the current Vector3 coordinates
  83641. * @param v defines the x, y and z coordinates of the operand
  83642. * @returns the current updated Vector3
  83643. */
  83644. setAll(v: number): Vector3;
  83645. /**
  83646. * Get the clip factor between two vectors
  83647. * @param vector0 defines the first operand
  83648. * @param vector1 defines the second operand
  83649. * @param axis defines the axis to use
  83650. * @param size defines the size along the axis
  83651. * @returns the clip factor
  83652. */
  83653. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83654. /**
  83655. * Get angle between two vectors
  83656. * @param vector0 angle between vector0 and vector1
  83657. * @param vector1 angle between vector0 and vector1
  83658. * @param normal direction of the normal
  83659. * @return the angle between vector0 and vector1
  83660. */
  83661. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83662. /**
  83663. * Returns a new Vector3 set from the index "offset" of the given array
  83664. * @param array defines the source array
  83665. * @param offset defines the offset in the source array
  83666. * @returns the new Vector3
  83667. */
  83668. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83669. /**
  83670. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83671. * @param array defines the source array
  83672. * @param offset defines the offset in the source array
  83673. * @returns the new Vector3
  83674. * @deprecated Please use FromArray instead.
  83675. */
  83676. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83677. /**
  83678. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83679. * @param array defines the source array
  83680. * @param offset defines the offset in the source array
  83681. * @param result defines the Vector3 where to store the result
  83682. */
  83683. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83684. /**
  83685. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83686. * @param array defines the source array
  83687. * @param offset defines the offset in the source array
  83688. * @param result defines the Vector3 where to store the result
  83689. * @deprecated Please use FromArrayToRef instead.
  83690. */
  83691. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83692. /**
  83693. * Sets the given vector "result" with the given floats.
  83694. * @param x defines the x coordinate of the source
  83695. * @param y defines the y coordinate of the source
  83696. * @param z defines the z coordinate of the source
  83697. * @param result defines the Vector3 where to store the result
  83698. */
  83699. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83700. /**
  83701. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83702. * @returns a new empty Vector3
  83703. */
  83704. static Zero(): Vector3;
  83705. /**
  83706. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83707. * @returns a new unit Vector3
  83708. */
  83709. static One(): Vector3;
  83710. /**
  83711. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83712. * @returns a new up Vector3
  83713. */
  83714. static Up(): Vector3;
  83715. /**
  83716. * Gets a up Vector3 that must not be updated
  83717. */
  83718. static get UpReadOnly(): DeepImmutable<Vector3>;
  83719. /**
  83720. * Gets a zero Vector3 that must not be updated
  83721. */
  83722. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83723. /**
  83724. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83725. * @returns a new down Vector3
  83726. */
  83727. static Down(): Vector3;
  83728. /**
  83729. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83730. * @param rightHandedSystem is the scene right-handed (negative z)
  83731. * @returns a new forward Vector3
  83732. */
  83733. static Forward(rightHandedSystem?: boolean): Vector3;
  83734. /**
  83735. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83736. * @param rightHandedSystem is the scene right-handed (negative-z)
  83737. * @returns a new forward Vector3
  83738. */
  83739. static Backward(rightHandedSystem?: boolean): Vector3;
  83740. /**
  83741. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83742. * @returns a new right Vector3
  83743. */
  83744. static Right(): Vector3;
  83745. /**
  83746. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83747. * @returns a new left Vector3
  83748. */
  83749. static Left(): Vector3;
  83750. /**
  83751. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83752. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83753. * @param vector defines the Vector3 to transform
  83754. * @param transformation defines the transformation matrix
  83755. * @returns the transformed Vector3
  83756. */
  83757. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83758. /**
  83759. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83760. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83761. * @param vector defines the Vector3 to transform
  83762. * @param transformation defines the transformation matrix
  83763. * @param result defines the Vector3 where to store the result
  83764. */
  83765. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83766. /**
  83767. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83768. * This method computes tranformed coordinates only, not transformed direction vectors
  83769. * @param x define the x coordinate of the source vector
  83770. * @param y define the y coordinate of the source vector
  83771. * @param z define the z coordinate of the source vector
  83772. * @param transformation defines the transformation matrix
  83773. * @param result defines the Vector3 where to store the result
  83774. */
  83775. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83776. /**
  83777. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83778. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83779. * @param vector defines the Vector3 to transform
  83780. * @param transformation defines the transformation matrix
  83781. * @returns the new Vector3
  83782. */
  83783. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83784. /**
  83785. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83786. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83787. * @param vector defines the Vector3 to transform
  83788. * @param transformation defines the transformation matrix
  83789. * @param result defines the Vector3 where to store the result
  83790. */
  83791. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83792. /**
  83793. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83794. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83795. * @param x define the x coordinate of the source vector
  83796. * @param y define the y coordinate of the source vector
  83797. * @param z define the z coordinate of the source vector
  83798. * @param transformation defines the transformation matrix
  83799. * @param result defines the Vector3 where to store the result
  83800. */
  83801. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83802. /**
  83803. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83804. * @param value1 defines the first control point
  83805. * @param value2 defines the second control point
  83806. * @param value3 defines the third control point
  83807. * @param value4 defines the fourth control point
  83808. * @param amount defines the amount on the spline to use
  83809. * @returns the new Vector3
  83810. */
  83811. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83812. /**
  83813. * 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"
  83814. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83815. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83816. * @param value defines the current value
  83817. * @param min defines the lower range value
  83818. * @param max defines the upper range value
  83819. * @returns the new Vector3
  83820. */
  83821. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83822. /**
  83823. * 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"
  83824. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83825. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83826. * @param value defines the current value
  83827. * @param min defines the lower range value
  83828. * @param max defines the upper range value
  83829. * @param result defines the Vector3 where to store the result
  83830. */
  83831. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83832. /**
  83833. * Checks if a given vector is inside a specific range
  83834. * @param v defines the vector to test
  83835. * @param min defines the minimum range
  83836. * @param max defines the maximum range
  83837. */
  83838. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83839. /**
  83840. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83841. * @param value1 defines the first control point
  83842. * @param tangent1 defines the first tangent vector
  83843. * @param value2 defines the second control point
  83844. * @param tangent2 defines the second tangent vector
  83845. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83846. * @returns the new Vector3
  83847. */
  83848. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83849. /**
  83850. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83851. * @param start defines the start value
  83852. * @param end defines the end value
  83853. * @param amount max defines amount between both (between 0 and 1)
  83854. * @returns the new Vector3
  83855. */
  83856. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83857. /**
  83858. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83859. * @param start defines the start value
  83860. * @param end defines the end value
  83861. * @param amount max defines amount between both (between 0 and 1)
  83862. * @param result defines the Vector3 where to store the result
  83863. */
  83864. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83865. /**
  83866. * Returns the dot product (float) between the vectors "left" and "right"
  83867. * @param left defines the left operand
  83868. * @param right defines the right operand
  83869. * @returns the dot product
  83870. */
  83871. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83872. /**
  83873. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83874. * The cross product is then orthogonal to both "left" and "right"
  83875. * @param left defines the left operand
  83876. * @param right defines the right operand
  83877. * @returns the cross product
  83878. */
  83879. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83880. /**
  83881. * Sets the given vector "result" with the cross product of "left" and "right"
  83882. * The cross product is then orthogonal to both "left" and "right"
  83883. * @param left defines the left operand
  83884. * @param right defines the right operand
  83885. * @param result defines the Vector3 where to store the result
  83886. */
  83887. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83888. /**
  83889. * Returns a new Vector3 as the normalization of the given vector
  83890. * @param vector defines the Vector3 to normalize
  83891. * @returns the new Vector3
  83892. */
  83893. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83894. /**
  83895. * Sets the given vector "result" with the normalization of the given first vector
  83896. * @param vector defines the Vector3 to normalize
  83897. * @param result defines the Vector3 where to store the result
  83898. */
  83899. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83900. /**
  83901. * Project a Vector3 onto screen space
  83902. * @param vector defines the Vector3 to project
  83903. * @param world defines the world matrix to use
  83904. * @param transform defines the transform (view x projection) matrix to use
  83905. * @param viewport defines the screen viewport to use
  83906. * @returns the new Vector3
  83907. */
  83908. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83909. /**
  83910. * Project a Vector3 onto screen space to reference
  83911. * @param vector defines the Vector3 to project
  83912. * @param world defines the world matrix to use
  83913. * @param transform defines the transform (view x projection) matrix to use
  83914. * @param viewport defines the screen viewport to use
  83915. * @param result the vector in which the screen space will be stored
  83916. * @returns the new Vector3
  83917. */
  83918. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  83919. /** @hidden */
  83920. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83921. /**
  83922. * Unproject from screen space to object space
  83923. * @param source defines the screen space Vector3 to use
  83924. * @param viewportWidth defines the current width of the viewport
  83925. * @param viewportHeight defines the current height of the viewport
  83926. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83927. * @param transform defines the transform (view x projection) matrix to use
  83928. * @returns the new Vector3
  83929. */
  83930. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83931. /**
  83932. * Unproject from screen space to object space
  83933. * @param source defines the screen space Vector3 to use
  83934. * @param viewportWidth defines the current width of the viewport
  83935. * @param viewportHeight defines the current height of the viewport
  83936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83937. * @param view defines the view matrix to use
  83938. * @param projection defines the projection matrix to use
  83939. * @returns the new Vector3
  83940. */
  83941. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83942. /**
  83943. * Unproject from screen space to object space
  83944. * @param source defines the screen space Vector3 to use
  83945. * @param viewportWidth defines the current width of the viewport
  83946. * @param viewportHeight defines the current height of the viewport
  83947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83948. * @param view defines the view matrix to use
  83949. * @param projection defines the projection matrix to use
  83950. * @param result defines the Vector3 where to store the result
  83951. */
  83952. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83953. /**
  83954. * Unproject from screen space to object space
  83955. * @param sourceX defines the screen space x coordinate to use
  83956. * @param sourceY defines the screen space y coordinate to use
  83957. * @param sourceZ defines the screen space z coordinate to use
  83958. * @param viewportWidth defines the current width of the viewport
  83959. * @param viewportHeight defines the current height of the viewport
  83960. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83961. * @param view defines the view matrix to use
  83962. * @param projection defines the projection matrix to use
  83963. * @param result defines the Vector3 where to store the result
  83964. */
  83965. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83966. /**
  83967. * Gets the minimal coordinate values between two Vector3
  83968. * @param left defines the first operand
  83969. * @param right defines the second operand
  83970. * @returns the new Vector3
  83971. */
  83972. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83973. /**
  83974. * Gets the maximal coordinate values between two Vector3
  83975. * @param left defines the first operand
  83976. * @param right defines the second operand
  83977. * @returns the new Vector3
  83978. */
  83979. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83980. /**
  83981. * Returns the distance between the vectors "value1" and "value2"
  83982. * @param value1 defines the first operand
  83983. * @param value2 defines the second operand
  83984. * @returns the distance
  83985. */
  83986. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83987. /**
  83988. * Returns the squared distance between the vectors "value1" and "value2"
  83989. * @param value1 defines the first operand
  83990. * @param value2 defines the second operand
  83991. * @returns the squared distance
  83992. */
  83993. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83994. /**
  83995. * Returns a new Vector3 located at the center between "value1" and "value2"
  83996. * @param value1 defines the first operand
  83997. * @param value2 defines the second operand
  83998. * @returns the new Vector3
  83999. */
  84000. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84001. /**
  84002. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84003. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84004. * to something in order to rotate it from its local system to the given target system
  84005. * Note: axis1, axis2 and axis3 are normalized during this operation
  84006. * @param axis1 defines the first axis
  84007. * @param axis2 defines the second axis
  84008. * @param axis3 defines the third axis
  84009. * @returns a new Vector3
  84010. */
  84011. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84012. /**
  84013. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84014. * @param axis1 defines the first axis
  84015. * @param axis2 defines the second axis
  84016. * @param axis3 defines the third axis
  84017. * @param ref defines the Vector3 where to store the result
  84018. */
  84019. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84020. }
  84021. /**
  84022. * Vector4 class created for EulerAngle class conversion to Quaternion
  84023. */
  84024. export class Vector4 {
  84025. /** x value of the vector */
  84026. x: number;
  84027. /** y value of the vector */
  84028. y: number;
  84029. /** z value of the vector */
  84030. z: number;
  84031. /** w value of the vector */
  84032. w: number;
  84033. /**
  84034. * Creates a Vector4 object from the given floats.
  84035. * @param x x value of the vector
  84036. * @param y y value of the vector
  84037. * @param z z value of the vector
  84038. * @param w w value of the vector
  84039. */
  84040. constructor(
  84041. /** x value of the vector */
  84042. x: number,
  84043. /** y value of the vector */
  84044. y: number,
  84045. /** z value of the vector */
  84046. z: number,
  84047. /** w value of the vector */
  84048. w: number);
  84049. /**
  84050. * Returns the string with the Vector4 coordinates.
  84051. * @returns a string containing all the vector values
  84052. */
  84053. toString(): string;
  84054. /**
  84055. * Returns the string "Vector4".
  84056. * @returns "Vector4"
  84057. */
  84058. getClassName(): string;
  84059. /**
  84060. * Returns the Vector4 hash code.
  84061. * @returns a unique hash code
  84062. */
  84063. getHashCode(): number;
  84064. /**
  84065. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84066. * @returns the resulting array
  84067. */
  84068. asArray(): number[];
  84069. /**
  84070. * Populates the given array from the given index with the Vector4 coordinates.
  84071. * @param array array to populate
  84072. * @param index index of the array to start at (default: 0)
  84073. * @returns the Vector4.
  84074. */
  84075. toArray(array: FloatArray, index?: number): Vector4;
  84076. /**
  84077. * Update the current vector from an array
  84078. * @param array defines the destination array
  84079. * @param index defines the offset in the destination array
  84080. * @returns the current Vector3
  84081. */
  84082. fromArray(array: FloatArray, index?: number): Vector4;
  84083. /**
  84084. * Adds the given vector to the current Vector4.
  84085. * @param otherVector the vector to add
  84086. * @returns the updated Vector4.
  84087. */
  84088. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84089. /**
  84090. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84091. * @param otherVector the vector to add
  84092. * @returns the resulting vector
  84093. */
  84094. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84095. /**
  84096. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84097. * @param otherVector the vector to add
  84098. * @param result the vector to store the result
  84099. * @returns the current Vector4.
  84100. */
  84101. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84102. /**
  84103. * Subtract in place the given vector from the current Vector4.
  84104. * @param otherVector the vector to subtract
  84105. * @returns the updated Vector4.
  84106. */
  84107. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84108. /**
  84109. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84110. * @param otherVector the vector to add
  84111. * @returns the new vector with the result
  84112. */
  84113. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84114. /**
  84115. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84116. * @param otherVector the vector to subtract
  84117. * @param result the vector to store the result
  84118. * @returns the current Vector4.
  84119. */
  84120. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84121. /**
  84122. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84123. */
  84124. /**
  84125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84126. * @param x value to subtract
  84127. * @param y value to subtract
  84128. * @param z value to subtract
  84129. * @param w value to subtract
  84130. * @returns new vector containing the result
  84131. */
  84132. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84133. /**
  84134. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84135. * @param x value to subtract
  84136. * @param y value to subtract
  84137. * @param z value to subtract
  84138. * @param w value to subtract
  84139. * @param result the vector to store the result in
  84140. * @returns the current Vector4.
  84141. */
  84142. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84143. /**
  84144. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84145. * @returns a new vector with the negated values
  84146. */
  84147. negate(): Vector4;
  84148. /**
  84149. * Negate this vector in place
  84150. * @returns this
  84151. */
  84152. negateInPlace(): Vector4;
  84153. /**
  84154. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84155. * @param result defines the Vector3 object where to store the result
  84156. * @returns the current Vector4
  84157. */
  84158. negateToRef(result: Vector4): Vector4;
  84159. /**
  84160. * Multiplies the current Vector4 coordinates by scale (float).
  84161. * @param scale the number to scale with
  84162. * @returns the updated Vector4.
  84163. */
  84164. scaleInPlace(scale: number): Vector4;
  84165. /**
  84166. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84167. * @param scale the number to scale with
  84168. * @returns a new vector with the result
  84169. */
  84170. scale(scale: number): Vector4;
  84171. /**
  84172. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84173. * @param scale the number to scale with
  84174. * @param result a vector to store the result in
  84175. * @returns the current Vector4.
  84176. */
  84177. scaleToRef(scale: number, result: Vector4): Vector4;
  84178. /**
  84179. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84180. * @param scale defines the scale factor
  84181. * @param result defines the Vector4 object where to store the result
  84182. * @returns the unmodified current Vector4
  84183. */
  84184. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84185. /**
  84186. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84187. * @param otherVector the vector to compare against
  84188. * @returns true if they are equal
  84189. */
  84190. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84191. /**
  84192. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84193. * @param otherVector vector to compare against
  84194. * @param epsilon (Default: very small number)
  84195. * @returns true if they are equal
  84196. */
  84197. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84198. /**
  84199. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84200. * @param x x value to compare against
  84201. * @param y y value to compare against
  84202. * @param z z value to compare against
  84203. * @param w w value to compare against
  84204. * @returns true if equal
  84205. */
  84206. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84207. /**
  84208. * Multiplies in place the current Vector4 by the given one.
  84209. * @param otherVector vector to multiple with
  84210. * @returns the updated Vector4.
  84211. */
  84212. multiplyInPlace(otherVector: Vector4): Vector4;
  84213. /**
  84214. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84215. * @param otherVector vector to multiple with
  84216. * @returns resulting new vector
  84217. */
  84218. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84219. /**
  84220. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84221. * @param otherVector vector to multiple with
  84222. * @param result vector to store the result
  84223. * @returns the current Vector4.
  84224. */
  84225. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84226. /**
  84227. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84228. * @param x x value multiply with
  84229. * @param y y value multiply with
  84230. * @param z z value multiply with
  84231. * @param w w value multiply with
  84232. * @returns resulting new vector
  84233. */
  84234. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84235. /**
  84236. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84237. * @param otherVector vector to devide with
  84238. * @returns resulting new vector
  84239. */
  84240. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84241. /**
  84242. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84243. * @param otherVector vector to devide with
  84244. * @param result vector to store the result
  84245. * @returns the current Vector4.
  84246. */
  84247. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84248. /**
  84249. * Divides the current Vector3 coordinates by the given ones.
  84250. * @param otherVector vector to devide with
  84251. * @returns the updated Vector3.
  84252. */
  84253. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84254. /**
  84255. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84256. * @param other defines the second operand
  84257. * @returns the current updated Vector4
  84258. */
  84259. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84260. /**
  84261. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84262. * @param other defines the second operand
  84263. * @returns the current updated Vector4
  84264. */
  84265. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84266. /**
  84267. * Gets a new Vector4 from current Vector4 floored values
  84268. * @returns a new Vector4
  84269. */
  84270. floor(): Vector4;
  84271. /**
  84272. * Gets a new Vector4 from current Vector3 floored values
  84273. * @returns a new Vector4
  84274. */
  84275. fract(): Vector4;
  84276. /**
  84277. * Returns the Vector4 length (float).
  84278. * @returns the length
  84279. */
  84280. length(): number;
  84281. /**
  84282. * Returns the Vector4 squared length (float).
  84283. * @returns the length squared
  84284. */
  84285. lengthSquared(): number;
  84286. /**
  84287. * Normalizes in place the Vector4.
  84288. * @returns the updated Vector4.
  84289. */
  84290. normalize(): Vector4;
  84291. /**
  84292. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84293. * @returns this converted to a new vector3
  84294. */
  84295. toVector3(): Vector3;
  84296. /**
  84297. * Returns a new Vector4 copied from the current one.
  84298. * @returns the new cloned vector
  84299. */
  84300. clone(): Vector4;
  84301. /**
  84302. * Updates the current Vector4 with the given one coordinates.
  84303. * @param source the source vector to copy from
  84304. * @returns the updated Vector4.
  84305. */
  84306. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84307. /**
  84308. * Updates the current Vector4 coordinates with the given floats.
  84309. * @param x float to copy from
  84310. * @param y float to copy from
  84311. * @param z float to copy from
  84312. * @param w float to copy from
  84313. * @returns the updated Vector4.
  84314. */
  84315. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84316. /**
  84317. * Updates the current Vector4 coordinates with the given floats.
  84318. * @param x float to set from
  84319. * @param y float to set from
  84320. * @param z float to set from
  84321. * @param w float to set from
  84322. * @returns the updated Vector4.
  84323. */
  84324. set(x: number, y: number, z: number, w: number): Vector4;
  84325. /**
  84326. * Copies the given float to the current Vector3 coordinates
  84327. * @param v defines the x, y, z and w coordinates of the operand
  84328. * @returns the current updated Vector3
  84329. */
  84330. setAll(v: number): Vector4;
  84331. /**
  84332. * Returns a new Vector4 set from the starting index of the given array.
  84333. * @param array the array to pull values from
  84334. * @param offset the offset into the array to start at
  84335. * @returns the new vector
  84336. */
  84337. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84338. /**
  84339. * Updates the given vector "result" from the starting index of the given array.
  84340. * @param array the array to pull values from
  84341. * @param offset the offset into the array to start at
  84342. * @param result the vector to store the result in
  84343. */
  84344. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84345. /**
  84346. * Updates the given vector "result" from the starting index of the given Float32Array.
  84347. * @param array the array to pull values from
  84348. * @param offset the offset into the array to start at
  84349. * @param result the vector to store the result in
  84350. */
  84351. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84352. /**
  84353. * Updates the given vector "result" coordinates from the given floats.
  84354. * @param x float to set from
  84355. * @param y float to set from
  84356. * @param z float to set from
  84357. * @param w float to set from
  84358. * @param result the vector to the floats in
  84359. */
  84360. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84361. /**
  84362. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84363. * @returns the new vector
  84364. */
  84365. static Zero(): Vector4;
  84366. /**
  84367. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84368. * @returns the new vector
  84369. */
  84370. static One(): Vector4;
  84371. /**
  84372. * Returns a new normalized Vector4 from the given one.
  84373. * @param vector the vector to normalize
  84374. * @returns the vector
  84375. */
  84376. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84377. /**
  84378. * Updates the given vector "result" from the normalization of the given one.
  84379. * @param vector the vector to normalize
  84380. * @param result the vector to store the result in
  84381. */
  84382. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84383. /**
  84384. * Returns a vector with the minimum values from the left and right vectors
  84385. * @param left left vector to minimize
  84386. * @param right right vector to minimize
  84387. * @returns a new vector with the minimum of the left and right vector values
  84388. */
  84389. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84390. /**
  84391. * Returns a vector with the maximum values from the left and right vectors
  84392. * @param left left vector to maximize
  84393. * @param right right vector to maximize
  84394. * @returns a new vector with the maximum of the left and right vector values
  84395. */
  84396. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84397. /**
  84398. * Returns the distance (float) between the vectors "value1" and "value2".
  84399. * @param value1 value to calulate the distance between
  84400. * @param value2 value to calulate the distance between
  84401. * @return the distance between the two vectors
  84402. */
  84403. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84404. /**
  84405. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84406. * @param value1 value to calulate the distance between
  84407. * @param value2 value to calulate the distance between
  84408. * @return the distance between the two vectors squared
  84409. */
  84410. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84411. /**
  84412. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84413. * @param value1 value to calulate the center between
  84414. * @param value2 value to calulate the center between
  84415. * @return the center between the two vectors
  84416. */
  84417. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84418. /**
  84419. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84420. * This methods computes transformed normalized direction vectors only.
  84421. * @param vector the vector to transform
  84422. * @param transformation the transformation matrix to apply
  84423. * @returns the new vector
  84424. */
  84425. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84426. /**
  84427. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84428. * This methods computes transformed normalized direction vectors only.
  84429. * @param vector the vector to transform
  84430. * @param transformation the transformation matrix to apply
  84431. * @param result the vector to store the result in
  84432. */
  84433. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84434. /**
  84435. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84436. * This methods computes transformed normalized direction vectors only.
  84437. * @param x value to transform
  84438. * @param y value to transform
  84439. * @param z value to transform
  84440. * @param w value to transform
  84441. * @param transformation the transformation matrix to apply
  84442. * @param result the vector to store the results in
  84443. */
  84444. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84445. /**
  84446. * Creates a new Vector4 from a Vector3
  84447. * @param source defines the source data
  84448. * @param w defines the 4th component (default is 0)
  84449. * @returns a new Vector4
  84450. */
  84451. static FromVector3(source: Vector3, w?: number): Vector4;
  84452. }
  84453. /**
  84454. * Class used to store quaternion data
  84455. * @see https://en.wikipedia.org/wiki/Quaternion
  84456. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84457. */
  84458. export class Quaternion {
  84459. /** @hidden */
  84460. _x: number;
  84461. /** @hidden */
  84462. _y: number;
  84463. /** @hidden */
  84464. _z: number;
  84465. /** @hidden */
  84466. _w: number;
  84467. /** @hidden */
  84468. _isDirty: boolean;
  84469. /** Gets or sets the x coordinate */
  84470. get x(): number;
  84471. set x(value: number);
  84472. /** Gets or sets the y coordinate */
  84473. get y(): number;
  84474. set y(value: number);
  84475. /** Gets or sets the z coordinate */
  84476. get z(): number;
  84477. set z(value: number);
  84478. /** Gets or sets the w coordinate */
  84479. get w(): number;
  84480. set w(value: number);
  84481. /**
  84482. * Creates a new Quaternion from the given floats
  84483. * @param x defines the first component (0 by default)
  84484. * @param y defines the second component (0 by default)
  84485. * @param z defines the third component (0 by default)
  84486. * @param w defines the fourth component (1.0 by default)
  84487. */
  84488. constructor(x?: number, y?: number, z?: number, w?: number);
  84489. /**
  84490. * Gets a string representation for the current quaternion
  84491. * @returns a string with the Quaternion coordinates
  84492. */
  84493. toString(): string;
  84494. /**
  84495. * Gets the class name of the quaternion
  84496. * @returns the string "Quaternion"
  84497. */
  84498. getClassName(): string;
  84499. /**
  84500. * Gets a hash code for this quaternion
  84501. * @returns the quaternion hash code
  84502. */
  84503. getHashCode(): number;
  84504. /**
  84505. * Copy the quaternion to an array
  84506. * @returns a new array populated with 4 elements from the quaternion coordinates
  84507. */
  84508. asArray(): number[];
  84509. /**
  84510. * Check if two quaternions are equals
  84511. * @param otherQuaternion defines the second operand
  84512. * @return true if the current quaternion and the given one coordinates are strictly equals
  84513. */
  84514. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84515. /**
  84516. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84517. * @param otherQuaternion defines the other quaternion
  84518. * @param epsilon defines the minimal distance to consider equality
  84519. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84520. */
  84521. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84522. /**
  84523. * Clone the current quaternion
  84524. * @returns a new quaternion copied from the current one
  84525. */
  84526. clone(): Quaternion;
  84527. /**
  84528. * Copy a quaternion to the current one
  84529. * @param other defines the other quaternion
  84530. * @returns the updated current quaternion
  84531. */
  84532. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84533. /**
  84534. * Updates the current quaternion with the given float coordinates
  84535. * @param x defines the x coordinate
  84536. * @param y defines the y coordinate
  84537. * @param z defines the z coordinate
  84538. * @param w defines the w coordinate
  84539. * @returns the updated current quaternion
  84540. */
  84541. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84542. /**
  84543. * Updates the current quaternion from the given float coordinates
  84544. * @param x defines the x coordinate
  84545. * @param y defines the y coordinate
  84546. * @param z defines the z coordinate
  84547. * @param w defines the w coordinate
  84548. * @returns the updated current quaternion
  84549. */
  84550. set(x: number, y: number, z: number, w: number): Quaternion;
  84551. /**
  84552. * Adds two quaternions
  84553. * @param other defines the second operand
  84554. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84555. */
  84556. add(other: DeepImmutable<Quaternion>): Quaternion;
  84557. /**
  84558. * Add a quaternion to the current one
  84559. * @param other defines the quaternion to add
  84560. * @returns the current quaternion
  84561. */
  84562. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84563. /**
  84564. * Subtract two quaternions
  84565. * @param other defines the second operand
  84566. * @returns a new quaternion as the subtraction result of the given one from the current one
  84567. */
  84568. subtract(other: Quaternion): Quaternion;
  84569. /**
  84570. * Multiplies the current quaternion by a scale factor
  84571. * @param value defines the scale factor
  84572. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84573. */
  84574. scale(value: number): Quaternion;
  84575. /**
  84576. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84577. * @param scale defines the scale factor
  84578. * @param result defines the Quaternion object where to store the result
  84579. * @returns the unmodified current quaternion
  84580. */
  84581. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84582. /**
  84583. * Multiplies in place the current quaternion by a scale factor
  84584. * @param value defines the scale factor
  84585. * @returns the current modified quaternion
  84586. */
  84587. scaleInPlace(value: number): Quaternion;
  84588. /**
  84589. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84590. * @param scale defines the scale factor
  84591. * @param result defines the Quaternion object where to store the result
  84592. * @returns the unmodified current quaternion
  84593. */
  84594. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84595. /**
  84596. * Multiplies two quaternions
  84597. * @param q1 defines the second operand
  84598. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84599. */
  84600. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84601. /**
  84602. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84603. * @param q1 defines the second operand
  84604. * @param result defines the target quaternion
  84605. * @returns the current quaternion
  84606. */
  84607. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84608. /**
  84609. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84610. * @param q1 defines the second operand
  84611. * @returns the currentupdated quaternion
  84612. */
  84613. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84614. /**
  84615. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84616. * @param ref defines the target quaternion
  84617. * @returns the current quaternion
  84618. */
  84619. conjugateToRef(ref: Quaternion): Quaternion;
  84620. /**
  84621. * Conjugates in place (1-q) the current quaternion
  84622. * @returns the current updated quaternion
  84623. */
  84624. conjugateInPlace(): Quaternion;
  84625. /**
  84626. * Conjugates in place (1-q) the current quaternion
  84627. * @returns a new quaternion
  84628. */
  84629. conjugate(): Quaternion;
  84630. /**
  84631. * Gets length of current quaternion
  84632. * @returns the quaternion length (float)
  84633. */
  84634. length(): number;
  84635. /**
  84636. * Normalize in place the current quaternion
  84637. * @returns the current updated quaternion
  84638. */
  84639. normalize(): Quaternion;
  84640. /**
  84641. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84642. * @param order is a reserved parameter and is ignored for now
  84643. * @returns a new Vector3 containing the Euler angles
  84644. */
  84645. toEulerAngles(order?: string): Vector3;
  84646. /**
  84647. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84648. * @param result defines the vector which will be filled with the Euler angles
  84649. * @returns the current unchanged quaternion
  84650. */
  84651. toEulerAnglesToRef(result: Vector3): Quaternion;
  84652. /**
  84653. * Updates the given rotation matrix with the current quaternion values
  84654. * @param result defines the target matrix
  84655. * @returns the current unchanged quaternion
  84656. */
  84657. toRotationMatrix(result: Matrix): Quaternion;
  84658. /**
  84659. * Updates the current quaternion from the given rotation matrix values
  84660. * @param matrix defines the source matrix
  84661. * @returns the current updated quaternion
  84662. */
  84663. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84664. /**
  84665. * Creates a new quaternion from a rotation matrix
  84666. * @param matrix defines the source matrix
  84667. * @returns a new quaternion created from the given rotation matrix values
  84668. */
  84669. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84670. /**
  84671. * Updates the given quaternion with the given rotation matrix values
  84672. * @param matrix defines the source matrix
  84673. * @param result defines the target quaternion
  84674. */
  84675. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84676. /**
  84677. * Returns the dot product (float) between the quaternions "left" and "right"
  84678. * @param left defines the left operand
  84679. * @param right defines the right operand
  84680. * @returns the dot product
  84681. */
  84682. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84683. /**
  84684. * Checks if the two quaternions are close to each other
  84685. * @param quat0 defines the first quaternion to check
  84686. * @param quat1 defines the second quaternion to check
  84687. * @returns true if the two quaternions are close to each other
  84688. */
  84689. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84690. /**
  84691. * Creates an empty quaternion
  84692. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84693. */
  84694. static Zero(): Quaternion;
  84695. /**
  84696. * Inverse a given quaternion
  84697. * @param q defines the source quaternion
  84698. * @returns a new quaternion as the inverted current quaternion
  84699. */
  84700. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84701. /**
  84702. * Inverse a given quaternion
  84703. * @param q defines the source quaternion
  84704. * @param result the quaternion the result will be stored in
  84705. * @returns the result quaternion
  84706. */
  84707. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84708. /**
  84709. * Creates an identity quaternion
  84710. * @returns the identity quaternion
  84711. */
  84712. static Identity(): Quaternion;
  84713. /**
  84714. * Gets a boolean indicating if the given quaternion is identity
  84715. * @param quaternion defines the quaternion to check
  84716. * @returns true if the quaternion is identity
  84717. */
  84718. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84719. /**
  84720. * Creates a quaternion from a rotation around an axis
  84721. * @param axis defines the axis to use
  84722. * @param angle defines the angle to use
  84723. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84724. */
  84725. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84726. /**
  84727. * Creates a rotation around an axis and stores it into the given quaternion
  84728. * @param axis defines the axis to use
  84729. * @param angle defines the angle to use
  84730. * @param result defines the target quaternion
  84731. * @returns the target quaternion
  84732. */
  84733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84734. /**
  84735. * Creates a new quaternion from data stored into an array
  84736. * @param array defines the data source
  84737. * @param offset defines the offset in the source array where the data starts
  84738. * @returns a new quaternion
  84739. */
  84740. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84741. /**
  84742. * Updates the given quaternion "result" from the starting index of the given array.
  84743. * @param array the array to pull values from
  84744. * @param offset the offset into the array to start at
  84745. * @param result the quaternion to store the result in
  84746. */
  84747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84748. /**
  84749. * Create a quaternion from Euler rotation angles
  84750. * @param x Pitch
  84751. * @param y Yaw
  84752. * @param z Roll
  84753. * @returns the new Quaternion
  84754. */
  84755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84756. /**
  84757. * Updates a quaternion from Euler rotation angles
  84758. * @param x Pitch
  84759. * @param y Yaw
  84760. * @param z Roll
  84761. * @param result the quaternion to store the result
  84762. * @returns the updated quaternion
  84763. */
  84764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84765. /**
  84766. * Create a quaternion from Euler rotation vector
  84767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84768. * @returns the new Quaternion
  84769. */
  84770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84771. /**
  84772. * Updates a quaternion from Euler rotation vector
  84773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84774. * @param result the quaternion to store the result
  84775. * @returns the updated quaternion
  84776. */
  84777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84778. /**
  84779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84780. * @param yaw defines the rotation around Y axis
  84781. * @param pitch defines the rotation around X axis
  84782. * @param roll defines the rotation around Z axis
  84783. * @returns the new quaternion
  84784. */
  84785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84786. /**
  84787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84788. * @param yaw defines the rotation around Y axis
  84789. * @param pitch defines the rotation around X axis
  84790. * @param roll defines the rotation around Z axis
  84791. * @param result defines the target quaternion
  84792. */
  84793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84794. /**
  84795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84796. * @param alpha defines the rotation around first axis
  84797. * @param beta defines the rotation around second axis
  84798. * @param gamma defines the rotation around third axis
  84799. * @returns the new quaternion
  84800. */
  84801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84802. /**
  84803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84804. * @param alpha defines the rotation around first axis
  84805. * @param beta defines the rotation around second axis
  84806. * @param gamma defines the rotation around third axis
  84807. * @param result defines the target quaternion
  84808. */
  84809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84810. /**
  84811. * 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)
  84812. * @param axis1 defines the first axis
  84813. * @param axis2 defines the second axis
  84814. * @param axis3 defines the third axis
  84815. * @returns the new quaternion
  84816. */
  84817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84818. /**
  84819. * 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
  84820. * @param axis1 defines the first axis
  84821. * @param axis2 defines the second axis
  84822. * @param axis3 defines the third axis
  84823. * @param ref defines the target quaternion
  84824. */
  84825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84826. /**
  84827. * Interpolates between two quaternions
  84828. * @param left defines first quaternion
  84829. * @param right defines second quaternion
  84830. * @param amount defines the gradient to use
  84831. * @returns the new interpolated quaternion
  84832. */
  84833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84834. /**
  84835. * Interpolates between two quaternions and stores it into a target quaternion
  84836. * @param left defines first quaternion
  84837. * @param right defines second quaternion
  84838. * @param amount defines the gradient to use
  84839. * @param result defines the target quaternion
  84840. */
  84841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84842. /**
  84843. * Interpolate between two quaternions using Hermite interpolation
  84844. * @param value1 defines first quaternion
  84845. * @param tangent1 defines the incoming tangent
  84846. * @param value2 defines second quaternion
  84847. * @param tangent2 defines the outgoing tangent
  84848. * @param amount defines the target quaternion
  84849. * @returns the new interpolated quaternion
  84850. */
  84851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84852. }
  84853. /**
  84854. * Class used to store matrix data (4x4)
  84855. */
  84856. export class Matrix {
  84857. /**
  84858. * Gets the precision of matrix computations
  84859. */
  84860. static get Use64Bits(): boolean;
  84861. private static _updateFlagSeed;
  84862. private static _identityReadOnly;
  84863. private _isIdentity;
  84864. private _isIdentityDirty;
  84865. private _isIdentity3x2;
  84866. private _isIdentity3x2Dirty;
  84867. /**
  84868. * Gets the update flag of the matrix which is an unique number for the matrix.
  84869. * It will be incremented every time the matrix data change.
  84870. * You can use it to speed the comparison between two versions of the same matrix.
  84871. */
  84872. updateFlag: number;
  84873. private readonly _m;
  84874. /**
  84875. * Gets the internal data of the matrix
  84876. */
  84877. get m(): DeepImmutable<Float32Array | Array<number>>;
  84878. /** @hidden */
  84879. _markAsUpdated(): void;
  84880. /** @hidden */
  84881. private _updateIdentityStatus;
  84882. /**
  84883. * Creates an empty matrix (filled with zeros)
  84884. */
  84885. constructor();
  84886. /**
  84887. * Check if the current matrix is identity
  84888. * @returns true is the matrix is the identity matrix
  84889. */
  84890. isIdentity(): boolean;
  84891. /**
  84892. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84893. * @returns true is the matrix is the identity matrix
  84894. */
  84895. isIdentityAs3x2(): boolean;
  84896. /**
  84897. * Gets the determinant of the matrix
  84898. * @returns the matrix determinant
  84899. */
  84900. determinant(): number;
  84901. /**
  84902. * Returns the matrix as a Float32Array or Array<number>
  84903. * @returns the matrix underlying array
  84904. */
  84905. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84906. /**
  84907. * Returns the matrix as a Float32Array or Array<number>
  84908. * @returns the matrix underlying array.
  84909. */
  84910. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84911. /**
  84912. * Inverts the current matrix in place
  84913. * @returns the current inverted matrix
  84914. */
  84915. invert(): Matrix;
  84916. /**
  84917. * Sets all the matrix elements to zero
  84918. * @returns the current matrix
  84919. */
  84920. reset(): Matrix;
  84921. /**
  84922. * Adds the current matrix with a second one
  84923. * @param other defines the matrix to add
  84924. * @returns a new matrix as the addition of the current matrix and the given one
  84925. */
  84926. add(other: DeepImmutable<Matrix>): Matrix;
  84927. /**
  84928. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84929. * @param other defines the matrix to add
  84930. * @param result defines the target matrix
  84931. * @returns the current matrix
  84932. */
  84933. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84934. /**
  84935. * Adds in place the given matrix to the current matrix
  84936. * @param other defines the second operand
  84937. * @returns the current updated matrix
  84938. */
  84939. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84940. /**
  84941. * Sets the given matrix to the current inverted Matrix
  84942. * @param other defines the target matrix
  84943. * @returns the unmodified current matrix
  84944. */
  84945. invertToRef(other: Matrix): Matrix;
  84946. /**
  84947. * add a value at the specified position in the current Matrix
  84948. * @param index the index of the value within the matrix. between 0 and 15.
  84949. * @param value the value to be added
  84950. * @returns the current updated matrix
  84951. */
  84952. addAtIndex(index: number, value: number): Matrix;
  84953. /**
  84954. * mutiply the specified position in the current Matrix by a value
  84955. * @param index the index of the value within the matrix. between 0 and 15.
  84956. * @param value the value to be added
  84957. * @returns the current updated matrix
  84958. */
  84959. multiplyAtIndex(index: number, value: number): Matrix;
  84960. /**
  84961. * Inserts the translation vector (using 3 floats) in the current matrix
  84962. * @param x defines the 1st component of the translation
  84963. * @param y defines the 2nd component of the translation
  84964. * @param z defines the 3rd component of the translation
  84965. * @returns the current updated matrix
  84966. */
  84967. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84968. /**
  84969. * Adds the translation vector (using 3 floats) in the current matrix
  84970. * @param x defines the 1st component of the translation
  84971. * @param y defines the 2nd component of the translation
  84972. * @param z defines the 3rd component of the translation
  84973. * @returns the current updated matrix
  84974. */
  84975. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84976. /**
  84977. * Inserts the translation vector in the current matrix
  84978. * @param vector3 defines the translation to insert
  84979. * @returns the current updated matrix
  84980. */
  84981. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84982. /**
  84983. * Gets the translation value of the current matrix
  84984. * @returns a new Vector3 as the extracted translation from the matrix
  84985. */
  84986. getTranslation(): Vector3;
  84987. /**
  84988. * Fill a Vector3 with the extracted translation from the matrix
  84989. * @param result defines the Vector3 where to store the translation
  84990. * @returns the current matrix
  84991. */
  84992. getTranslationToRef(result: Vector3): Matrix;
  84993. /**
  84994. * Remove rotation and scaling part from the matrix
  84995. * @returns the updated matrix
  84996. */
  84997. removeRotationAndScaling(): Matrix;
  84998. /**
  84999. * Multiply two matrices
  85000. * @param other defines the second operand
  85001. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85002. */
  85003. multiply(other: DeepImmutable<Matrix>): Matrix;
  85004. /**
  85005. * Copy the current matrix from the given one
  85006. * @param other defines the source matrix
  85007. * @returns the current updated matrix
  85008. */
  85009. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85010. /**
  85011. * Populates the given array from the starting index with the current matrix values
  85012. * @param array defines the target array
  85013. * @param offset defines the offset in the target array where to start storing values
  85014. * @returns the current matrix
  85015. */
  85016. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85017. /**
  85018. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85019. * @param other defines the second operand
  85020. * @param result defines the matrix where to store the multiplication
  85021. * @returns the current matrix
  85022. */
  85023. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85024. /**
  85025. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85026. * @param other defines the second operand
  85027. * @param result defines the array where to store the multiplication
  85028. * @param offset defines the offset in the target array where to start storing values
  85029. * @returns the current matrix
  85030. */
  85031. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85032. /**
  85033. * Check equality between this matrix and a second one
  85034. * @param value defines the second matrix to compare
  85035. * @returns true is the current matrix and the given one values are strictly equal
  85036. */
  85037. equals(value: DeepImmutable<Matrix>): boolean;
  85038. /**
  85039. * Clone the current matrix
  85040. * @returns a new matrix from the current matrix
  85041. */
  85042. clone(): Matrix;
  85043. /**
  85044. * Returns the name of the current matrix class
  85045. * @returns the string "Matrix"
  85046. */
  85047. getClassName(): string;
  85048. /**
  85049. * Gets the hash code of the current matrix
  85050. * @returns the hash code
  85051. */
  85052. getHashCode(): number;
  85053. /**
  85054. * Decomposes the current Matrix into a translation, rotation and scaling components
  85055. * @param scale defines the scale vector3 given as a reference to update
  85056. * @param rotation defines the rotation quaternion given as a reference to update
  85057. * @param translation defines the translation vector3 given as a reference to update
  85058. * @returns true if operation was successful
  85059. */
  85060. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85061. /**
  85062. * Gets specific row of the matrix
  85063. * @param index defines the number of the row to get
  85064. * @returns the index-th row of the current matrix as a new Vector4
  85065. */
  85066. getRow(index: number): Nullable<Vector4>;
  85067. /**
  85068. * Sets the index-th row of the current matrix to the vector4 values
  85069. * @param index defines the number of the row to set
  85070. * @param row defines the target vector4
  85071. * @returns the updated current matrix
  85072. */
  85073. setRow(index: number, row: Vector4): Matrix;
  85074. /**
  85075. * Compute the transpose of the matrix
  85076. * @returns the new transposed matrix
  85077. */
  85078. transpose(): Matrix;
  85079. /**
  85080. * Compute the transpose of the matrix and store it in a given matrix
  85081. * @param result defines the target matrix
  85082. * @returns the current matrix
  85083. */
  85084. transposeToRef(result: Matrix): Matrix;
  85085. /**
  85086. * Sets the index-th row of the current matrix with the given 4 x float values
  85087. * @param index defines the row index
  85088. * @param x defines the x component to set
  85089. * @param y defines the y component to set
  85090. * @param z defines the z component to set
  85091. * @param w defines the w component to set
  85092. * @returns the updated current matrix
  85093. */
  85094. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85095. /**
  85096. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85097. * @param scale defines the scale factor
  85098. * @returns a new matrix
  85099. */
  85100. scale(scale: number): Matrix;
  85101. /**
  85102. * Scale the current matrix values by a factor to a given result matrix
  85103. * @param scale defines the scale factor
  85104. * @param result defines the matrix to store the result
  85105. * @returns the current matrix
  85106. */
  85107. scaleToRef(scale: number, result: Matrix): Matrix;
  85108. /**
  85109. * Scale the current matrix values by a factor and add the result to a given matrix
  85110. * @param scale defines the scale factor
  85111. * @param result defines the Matrix to store the result
  85112. * @returns the current matrix
  85113. */
  85114. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85115. /**
  85116. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85117. * @param ref matrix to store the result
  85118. */
  85119. toNormalMatrix(ref: Matrix): void;
  85120. /**
  85121. * Gets only rotation part of the current matrix
  85122. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85123. */
  85124. getRotationMatrix(): Matrix;
  85125. /**
  85126. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85127. * @param result defines the target matrix to store data to
  85128. * @returns the current matrix
  85129. */
  85130. getRotationMatrixToRef(result: Matrix): Matrix;
  85131. /**
  85132. * Toggles model matrix from being right handed to left handed in place and vice versa
  85133. */
  85134. toggleModelMatrixHandInPlace(): void;
  85135. /**
  85136. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85137. */
  85138. toggleProjectionMatrixHandInPlace(): void;
  85139. /**
  85140. * Creates a matrix from an array
  85141. * @param array defines the source array
  85142. * @param offset defines an offset in the source array
  85143. * @returns a new Matrix set from the starting index of the given array
  85144. */
  85145. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85146. /**
  85147. * Copy the content of an array into a given matrix
  85148. * @param array defines the source array
  85149. * @param offset defines an offset in the source array
  85150. * @param result defines the target matrix
  85151. */
  85152. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85153. /**
  85154. * Stores an array into a matrix after having multiplied each component by a given factor
  85155. * @param array defines the source array
  85156. * @param offset defines the offset in the source array
  85157. * @param scale defines the scaling factor
  85158. * @param result defines the target matrix
  85159. */
  85160. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85161. /**
  85162. * Gets an identity matrix that must not be updated
  85163. */
  85164. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85165. /**
  85166. * Stores a list of values (16) inside a given matrix
  85167. * @param initialM11 defines 1st value of 1st row
  85168. * @param initialM12 defines 2nd value of 1st row
  85169. * @param initialM13 defines 3rd value of 1st row
  85170. * @param initialM14 defines 4th value of 1st row
  85171. * @param initialM21 defines 1st value of 2nd row
  85172. * @param initialM22 defines 2nd value of 2nd row
  85173. * @param initialM23 defines 3rd value of 2nd row
  85174. * @param initialM24 defines 4th value of 2nd row
  85175. * @param initialM31 defines 1st value of 3rd row
  85176. * @param initialM32 defines 2nd value of 3rd row
  85177. * @param initialM33 defines 3rd value of 3rd row
  85178. * @param initialM34 defines 4th value of 3rd row
  85179. * @param initialM41 defines 1st value of 4th row
  85180. * @param initialM42 defines 2nd value of 4th row
  85181. * @param initialM43 defines 3rd value of 4th row
  85182. * @param initialM44 defines 4th value of 4th row
  85183. * @param result defines the target matrix
  85184. */
  85185. 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;
  85186. /**
  85187. * Creates new matrix from a list of values (16)
  85188. * @param initialM11 defines 1st value of 1st row
  85189. * @param initialM12 defines 2nd value of 1st row
  85190. * @param initialM13 defines 3rd value of 1st row
  85191. * @param initialM14 defines 4th value of 1st row
  85192. * @param initialM21 defines 1st value of 2nd row
  85193. * @param initialM22 defines 2nd value of 2nd row
  85194. * @param initialM23 defines 3rd value of 2nd row
  85195. * @param initialM24 defines 4th value of 2nd row
  85196. * @param initialM31 defines 1st value of 3rd row
  85197. * @param initialM32 defines 2nd value of 3rd row
  85198. * @param initialM33 defines 3rd value of 3rd row
  85199. * @param initialM34 defines 4th value of 3rd row
  85200. * @param initialM41 defines 1st value of 4th row
  85201. * @param initialM42 defines 2nd value of 4th row
  85202. * @param initialM43 defines 3rd value of 4th row
  85203. * @param initialM44 defines 4th value of 4th row
  85204. * @returns the new matrix
  85205. */
  85206. 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;
  85207. /**
  85208. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85209. * @param scale defines the scale vector3
  85210. * @param rotation defines the rotation quaternion
  85211. * @param translation defines the translation vector3
  85212. * @returns a new matrix
  85213. */
  85214. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85215. /**
  85216. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85217. * @param scale defines the scale vector3
  85218. * @param rotation defines the rotation quaternion
  85219. * @param translation defines the translation vector3
  85220. * @param result defines the target matrix
  85221. */
  85222. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85223. /**
  85224. * Creates a new identity matrix
  85225. * @returns a new identity matrix
  85226. */
  85227. static Identity(): Matrix;
  85228. /**
  85229. * Creates a new identity matrix and stores the result in a given matrix
  85230. * @param result defines the target matrix
  85231. */
  85232. static IdentityToRef(result: Matrix): void;
  85233. /**
  85234. * Creates a new zero matrix
  85235. * @returns a new zero matrix
  85236. */
  85237. static Zero(): Matrix;
  85238. /**
  85239. * Creates a new rotation matrix for "angle" radians around the X axis
  85240. * @param angle defines the angle (in radians) to use
  85241. * @return the new matrix
  85242. */
  85243. static RotationX(angle: number): Matrix;
  85244. /**
  85245. * Creates a new matrix as the invert of a given matrix
  85246. * @param source defines the source matrix
  85247. * @returns the new matrix
  85248. */
  85249. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85250. /**
  85251. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85252. * @param angle defines the angle (in radians) to use
  85253. * @param result defines the target matrix
  85254. */
  85255. static RotationXToRef(angle: number, result: Matrix): void;
  85256. /**
  85257. * Creates a new rotation matrix for "angle" radians around the Y axis
  85258. * @param angle defines the angle (in radians) to use
  85259. * @return the new matrix
  85260. */
  85261. static RotationY(angle: number): Matrix;
  85262. /**
  85263. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85264. * @param angle defines the angle (in radians) to use
  85265. * @param result defines the target matrix
  85266. */
  85267. static RotationYToRef(angle: number, result: Matrix): void;
  85268. /**
  85269. * Creates a new rotation matrix for "angle" radians around the Z axis
  85270. * @param angle defines the angle (in radians) to use
  85271. * @return the new matrix
  85272. */
  85273. static RotationZ(angle: number): Matrix;
  85274. /**
  85275. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85276. * @param angle defines the angle (in radians) to use
  85277. * @param result defines the target matrix
  85278. */
  85279. static RotationZToRef(angle: number, result: Matrix): void;
  85280. /**
  85281. * Creates a new rotation matrix for "angle" radians around the given axis
  85282. * @param axis defines the axis to use
  85283. * @param angle defines the angle (in radians) to use
  85284. * @return the new matrix
  85285. */
  85286. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85287. /**
  85288. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85289. * @param axis defines the axis to use
  85290. * @param angle defines the angle (in radians) to use
  85291. * @param result defines the target matrix
  85292. */
  85293. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85294. /**
  85295. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85296. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85297. * @param from defines the vector to align
  85298. * @param to defines the vector to align to
  85299. * @param result defines the target matrix
  85300. */
  85301. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85302. /**
  85303. * Creates a rotation matrix
  85304. * @param yaw defines the yaw angle in radians (Y axis)
  85305. * @param pitch defines the pitch angle in radians (X axis)
  85306. * @param roll defines the roll angle in radians (Z axis)
  85307. * @returns the new rotation matrix
  85308. */
  85309. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85310. /**
  85311. * Creates a rotation matrix and stores it in a given matrix
  85312. * @param yaw defines the yaw angle in radians (Y axis)
  85313. * @param pitch defines the pitch angle in radians (X axis)
  85314. * @param roll defines the roll angle in radians (Z axis)
  85315. * @param result defines the target matrix
  85316. */
  85317. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85318. /**
  85319. * Creates a scaling matrix
  85320. * @param x defines the scale factor on X axis
  85321. * @param y defines the scale factor on Y axis
  85322. * @param z defines the scale factor on Z axis
  85323. * @returns the new matrix
  85324. */
  85325. static Scaling(x: number, y: number, z: number): Matrix;
  85326. /**
  85327. * Creates a scaling matrix and stores it in a given matrix
  85328. * @param x defines the scale factor on X axis
  85329. * @param y defines the scale factor on Y axis
  85330. * @param z defines the scale factor on Z axis
  85331. * @param result defines the target matrix
  85332. */
  85333. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85334. /**
  85335. * Creates a translation matrix
  85336. * @param x defines the translation on X axis
  85337. * @param y defines the translation on Y axis
  85338. * @param z defines the translationon Z axis
  85339. * @returns the new matrix
  85340. */
  85341. static Translation(x: number, y: number, z: number): Matrix;
  85342. /**
  85343. * Creates a translation matrix and stores it in a given matrix
  85344. * @param x defines the translation on X axis
  85345. * @param y defines the translation on Y axis
  85346. * @param z defines the translationon Z axis
  85347. * @param result defines the target matrix
  85348. */
  85349. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85350. /**
  85351. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85352. * @param startValue defines the start value
  85353. * @param endValue defines the end value
  85354. * @param gradient defines the gradient factor
  85355. * @returns the new matrix
  85356. */
  85357. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85358. /**
  85359. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85360. * @param startValue defines the start value
  85361. * @param endValue defines the end value
  85362. * @param gradient defines the gradient factor
  85363. * @param result defines the Matrix object where to store data
  85364. */
  85365. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85366. /**
  85367. * Builds a new matrix whose values are computed by:
  85368. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85369. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85370. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85371. * @param startValue defines the first matrix
  85372. * @param endValue defines the second matrix
  85373. * @param gradient defines the gradient between the two matrices
  85374. * @returns the new matrix
  85375. */
  85376. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85377. /**
  85378. * Update a matrix to values which are computed by:
  85379. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85380. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85381. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85382. * @param startValue defines the first matrix
  85383. * @param endValue defines the second matrix
  85384. * @param gradient defines the gradient between the two matrices
  85385. * @param result defines the target matrix
  85386. */
  85387. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85388. /**
  85389. * 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"
  85390. * This function works in left handed mode
  85391. * @param eye defines the final position of the entity
  85392. * @param target defines where the entity should look at
  85393. * @param up defines the up vector for the entity
  85394. * @returns the new matrix
  85395. */
  85396. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85397. /**
  85398. * 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".
  85399. * This function works in left handed mode
  85400. * @param eye defines the final position of the entity
  85401. * @param target defines where the entity should look at
  85402. * @param up defines the up vector for the entity
  85403. * @param result defines the target matrix
  85404. */
  85405. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85406. /**
  85407. * 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"
  85408. * This function works in right handed mode
  85409. * @param eye defines the final position of the entity
  85410. * @param target defines where the entity should look at
  85411. * @param up defines the up vector for the entity
  85412. * @returns the new matrix
  85413. */
  85414. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85415. /**
  85416. * 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".
  85417. * This function works in right handed mode
  85418. * @param eye defines the final position of the entity
  85419. * @param target defines where the entity should look at
  85420. * @param up defines the up vector for the entity
  85421. * @param result defines the target matrix
  85422. */
  85423. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85424. /**
  85425. * Create a left-handed orthographic projection matrix
  85426. * @param width defines the viewport width
  85427. * @param height defines the viewport height
  85428. * @param znear defines the near clip plane
  85429. * @param zfar defines the far clip plane
  85430. * @returns a new matrix as a left-handed orthographic projection matrix
  85431. */
  85432. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85433. /**
  85434. * Store a left-handed orthographic projection to a given matrix
  85435. * @param width defines the viewport width
  85436. * @param height defines the viewport height
  85437. * @param znear defines the near clip plane
  85438. * @param zfar defines the far clip plane
  85439. * @param result defines the target matrix
  85440. */
  85441. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85442. /**
  85443. * Create a left-handed orthographic projection matrix
  85444. * @param left defines the viewport left coordinate
  85445. * @param right defines the viewport right coordinate
  85446. * @param bottom defines the viewport bottom coordinate
  85447. * @param top defines the viewport top coordinate
  85448. * @param znear defines the near clip plane
  85449. * @param zfar defines the far clip plane
  85450. * @returns a new matrix as a left-handed orthographic projection matrix
  85451. */
  85452. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85453. /**
  85454. * Stores a left-handed orthographic projection into a given matrix
  85455. * @param left defines the viewport left coordinate
  85456. * @param right defines the viewport right coordinate
  85457. * @param bottom defines the viewport bottom coordinate
  85458. * @param top defines the viewport top coordinate
  85459. * @param znear defines the near clip plane
  85460. * @param zfar defines the far clip plane
  85461. * @param result defines the target matrix
  85462. */
  85463. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85464. /**
  85465. * Creates a right-handed orthographic projection matrix
  85466. * @param left defines the viewport left coordinate
  85467. * @param right defines the viewport right coordinate
  85468. * @param bottom defines the viewport bottom coordinate
  85469. * @param top defines the viewport top coordinate
  85470. * @param znear defines the near clip plane
  85471. * @param zfar defines the far clip plane
  85472. * @returns a new matrix as a right-handed orthographic projection matrix
  85473. */
  85474. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85475. /**
  85476. * Stores a right-handed orthographic projection into a given matrix
  85477. * @param left defines the viewport left coordinate
  85478. * @param right defines the viewport right coordinate
  85479. * @param bottom defines the viewport bottom coordinate
  85480. * @param top defines the viewport top coordinate
  85481. * @param znear defines the near clip plane
  85482. * @param zfar defines the far clip plane
  85483. * @param result defines the target matrix
  85484. */
  85485. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85486. /**
  85487. * Creates a left-handed perspective projection matrix
  85488. * @param width defines the viewport width
  85489. * @param height defines the viewport height
  85490. * @param znear defines the near clip plane
  85491. * @param zfar defines the far clip plane
  85492. * @returns a new matrix as a left-handed perspective projection matrix
  85493. */
  85494. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85495. /**
  85496. * Creates a left-handed perspective projection matrix
  85497. * @param fov defines the horizontal field of view
  85498. * @param aspect defines the aspect ratio
  85499. * @param znear defines the near clip plane
  85500. * @param zfar defines the far clip plane
  85501. * @returns a new matrix as a left-handed perspective projection matrix
  85502. */
  85503. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85504. /**
  85505. * Stores a left-handed perspective projection into a given matrix
  85506. * @param fov defines the horizontal field of view
  85507. * @param aspect defines the aspect ratio
  85508. * @param znear defines the near clip plane
  85509. * @param zfar defines the far clip plane
  85510. * @param result defines the target matrix
  85511. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85512. */
  85513. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85514. /**
  85515. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85516. * @param fov defines the horizontal field of view
  85517. * @param aspect defines the aspect ratio
  85518. * @param znear defines the near clip plane
  85519. * @param zfar not used as infinity is used as far clip
  85520. * @param result defines the target matrix
  85521. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85522. */
  85523. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85524. /**
  85525. * Creates a right-handed perspective projection matrix
  85526. * @param fov defines the horizontal field of view
  85527. * @param aspect defines the aspect ratio
  85528. * @param znear defines the near clip plane
  85529. * @param zfar defines the far clip plane
  85530. * @returns a new matrix as a right-handed perspective projection matrix
  85531. */
  85532. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85533. /**
  85534. * Stores a right-handed perspective projection into a given matrix
  85535. * @param fov defines the horizontal field of view
  85536. * @param aspect defines the aspect ratio
  85537. * @param znear defines the near clip plane
  85538. * @param zfar defines the far clip plane
  85539. * @param result defines the target matrix
  85540. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85541. */
  85542. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85543. /**
  85544. * Stores a right-handed perspective projection into a given matrix
  85545. * @param fov defines the horizontal field of view
  85546. * @param aspect defines the aspect ratio
  85547. * @param znear defines the near clip plane
  85548. * @param zfar not used as infinity is used as far clip
  85549. * @param result defines the target matrix
  85550. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85551. */
  85552. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85553. /**
  85554. * Stores a perspective projection for WebVR info a given matrix
  85555. * @param fov defines the field of view
  85556. * @param znear defines the near clip plane
  85557. * @param zfar defines the far clip plane
  85558. * @param result defines the target matrix
  85559. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85560. */
  85561. static PerspectiveFovWebVRToRef(fov: {
  85562. upDegrees: number;
  85563. downDegrees: number;
  85564. leftDegrees: number;
  85565. rightDegrees: number;
  85566. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85567. /**
  85568. * Computes a complete transformation matrix
  85569. * @param viewport defines the viewport to use
  85570. * @param world defines the world matrix
  85571. * @param view defines the view matrix
  85572. * @param projection defines the projection matrix
  85573. * @param zmin defines the near clip plane
  85574. * @param zmax defines the far clip plane
  85575. * @returns the transformation matrix
  85576. */
  85577. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85578. /**
  85579. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85580. * @param matrix defines the matrix to use
  85581. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85582. */
  85583. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85584. /**
  85585. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85586. * @param matrix defines the matrix to use
  85587. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85588. */
  85589. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85590. /**
  85591. * Compute the transpose of a given matrix
  85592. * @param matrix defines the matrix to transpose
  85593. * @returns the new matrix
  85594. */
  85595. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85596. /**
  85597. * Compute the transpose of a matrix and store it in a target matrix
  85598. * @param matrix defines the matrix to transpose
  85599. * @param result defines the target matrix
  85600. */
  85601. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85602. /**
  85603. * Computes a reflection matrix from a plane
  85604. * @param plane defines the reflection plane
  85605. * @returns a new matrix
  85606. */
  85607. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85608. /**
  85609. * Computes a reflection matrix from a plane
  85610. * @param plane defines the reflection plane
  85611. * @param result defines the target matrix
  85612. */
  85613. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85614. /**
  85615. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85616. * @param xaxis defines the value of the 1st axis
  85617. * @param yaxis defines the value of the 2nd axis
  85618. * @param zaxis defines the value of the 3rd axis
  85619. * @param result defines the target matrix
  85620. */
  85621. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85622. /**
  85623. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85624. * @param quat defines the quaternion to use
  85625. * @param result defines the target matrix
  85626. */
  85627. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85628. }
  85629. /**
  85630. * @hidden
  85631. */
  85632. export class TmpVectors {
  85633. static Vector2: Vector2[];
  85634. static Vector3: Vector3[];
  85635. static Vector4: Vector4[];
  85636. static Quaternion: Quaternion[];
  85637. static Matrix: Matrix[];
  85638. }
  85639. }
  85640. declare module BABYLON {
  85641. /**
  85642. * Defines potential orientation for back face culling
  85643. */
  85644. export enum Orientation {
  85645. /**
  85646. * Clockwise
  85647. */
  85648. CW = 0,
  85649. /** Counter clockwise */
  85650. CCW = 1
  85651. }
  85652. /** Class used to represent a Bezier curve */
  85653. export class BezierCurve {
  85654. /**
  85655. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85656. * @param t defines the time
  85657. * @param x1 defines the left coordinate on X axis
  85658. * @param y1 defines the left coordinate on Y axis
  85659. * @param x2 defines the right coordinate on X axis
  85660. * @param y2 defines the right coordinate on Y axis
  85661. * @returns the interpolated value
  85662. */
  85663. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85664. }
  85665. /**
  85666. * Defines angle representation
  85667. */
  85668. export class Angle {
  85669. private _radians;
  85670. /**
  85671. * Creates an Angle object of "radians" radians (float).
  85672. * @param radians the angle in radians
  85673. */
  85674. constructor(radians: number);
  85675. /**
  85676. * Get value in degrees
  85677. * @returns the Angle value in degrees (float)
  85678. */
  85679. degrees(): number;
  85680. /**
  85681. * Get value in radians
  85682. * @returns the Angle value in radians (float)
  85683. */
  85684. radians(): number;
  85685. /**
  85686. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85687. * @param a defines first point as the origin
  85688. * @param b defines point
  85689. * @returns a new Angle
  85690. */
  85691. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85692. /**
  85693. * Gets a new Angle object from the given float in radians
  85694. * @param radians defines the angle value in radians
  85695. * @returns a new Angle
  85696. */
  85697. static FromRadians(radians: number): Angle;
  85698. /**
  85699. * Gets a new Angle object from the given float in degrees
  85700. * @param degrees defines the angle value in degrees
  85701. * @returns a new Angle
  85702. */
  85703. static FromDegrees(degrees: number): Angle;
  85704. }
  85705. /**
  85706. * This represents an arc in a 2d space.
  85707. */
  85708. export class Arc2 {
  85709. /** Defines the start point of the arc */
  85710. startPoint: Vector2;
  85711. /** Defines the mid point of the arc */
  85712. midPoint: Vector2;
  85713. /** Defines the end point of the arc */
  85714. endPoint: Vector2;
  85715. /**
  85716. * Defines the center point of the arc.
  85717. */
  85718. centerPoint: Vector2;
  85719. /**
  85720. * Defines the radius of the arc.
  85721. */
  85722. radius: number;
  85723. /**
  85724. * Defines the angle of the arc (from mid point to end point).
  85725. */
  85726. angle: Angle;
  85727. /**
  85728. * Defines the start angle of the arc (from start point to middle point).
  85729. */
  85730. startAngle: Angle;
  85731. /**
  85732. * Defines the orientation of the arc (clock wise/counter clock wise).
  85733. */
  85734. orientation: Orientation;
  85735. /**
  85736. * Creates an Arc object from the three given points : start, middle and end.
  85737. * @param startPoint Defines the start point of the arc
  85738. * @param midPoint Defines the midlle point of the arc
  85739. * @param endPoint Defines the end point of the arc
  85740. */
  85741. constructor(
  85742. /** Defines the start point of the arc */
  85743. startPoint: Vector2,
  85744. /** Defines the mid point of the arc */
  85745. midPoint: Vector2,
  85746. /** Defines the end point of the arc */
  85747. endPoint: Vector2);
  85748. }
  85749. /**
  85750. * Represents a 2D path made up of multiple 2D points
  85751. */
  85752. export class Path2 {
  85753. private _points;
  85754. private _length;
  85755. /**
  85756. * If the path start and end point are the same
  85757. */
  85758. closed: boolean;
  85759. /**
  85760. * Creates a Path2 object from the starting 2D coordinates x and y.
  85761. * @param x the starting points x value
  85762. * @param y the starting points y value
  85763. */
  85764. constructor(x: number, y: number);
  85765. /**
  85766. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85767. * @param x the added points x value
  85768. * @param y the added points y value
  85769. * @returns the updated Path2.
  85770. */
  85771. addLineTo(x: number, y: number): Path2;
  85772. /**
  85773. * 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.
  85774. * @param midX middle point x value
  85775. * @param midY middle point y value
  85776. * @param endX end point x value
  85777. * @param endY end point y value
  85778. * @param numberOfSegments (default: 36)
  85779. * @returns the updated Path2.
  85780. */
  85781. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85782. /**
  85783. * Closes the Path2.
  85784. * @returns the Path2.
  85785. */
  85786. close(): Path2;
  85787. /**
  85788. * Gets the sum of the distance between each sequential point in the path
  85789. * @returns the Path2 total length (float).
  85790. */
  85791. length(): number;
  85792. /**
  85793. * Gets the points which construct the path
  85794. * @returns the Path2 internal array of points.
  85795. */
  85796. getPoints(): Vector2[];
  85797. /**
  85798. * Retreives the point at the distance aways from the starting point
  85799. * @param normalizedLengthPosition the length along the path to retreive the point from
  85800. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85801. */
  85802. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85803. /**
  85804. * Creates a new path starting from an x and y position
  85805. * @param x starting x value
  85806. * @param y starting y value
  85807. * @returns a new Path2 starting at the coordinates (x, y).
  85808. */
  85809. static StartingAt(x: number, y: number): Path2;
  85810. }
  85811. /**
  85812. * Represents a 3D path made up of multiple 3D points
  85813. */
  85814. export class Path3D {
  85815. /**
  85816. * an array of Vector3, the curve axis of the Path3D
  85817. */
  85818. path: Vector3[];
  85819. private _curve;
  85820. private _distances;
  85821. private _tangents;
  85822. private _normals;
  85823. private _binormals;
  85824. private _raw;
  85825. private _alignTangentsWithPath;
  85826. private readonly _pointAtData;
  85827. /**
  85828. * new Path3D(path, normal, raw)
  85829. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85830. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85831. * @param path an array of Vector3, the curve axis of the Path3D
  85832. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85833. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85834. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85835. */
  85836. constructor(
  85837. /**
  85838. * an array of Vector3, the curve axis of the Path3D
  85839. */
  85840. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85841. /**
  85842. * Returns the Path3D array of successive Vector3 designing its curve.
  85843. * @returns the Path3D array of successive Vector3 designing its curve.
  85844. */
  85845. getCurve(): Vector3[];
  85846. /**
  85847. * Returns the Path3D array of successive Vector3 designing its curve.
  85848. * @returns the Path3D array of successive Vector3 designing its curve.
  85849. */
  85850. getPoints(): Vector3[];
  85851. /**
  85852. * @returns the computed length (float) of the path.
  85853. */
  85854. length(): number;
  85855. /**
  85856. * Returns an array populated with tangent vectors on each Path3D curve point.
  85857. * @returns an array populated with tangent vectors on each Path3D curve point.
  85858. */
  85859. getTangents(): Vector3[];
  85860. /**
  85861. * Returns an array populated with normal vectors on each Path3D curve point.
  85862. * @returns an array populated with normal vectors on each Path3D curve point.
  85863. */
  85864. getNormals(): Vector3[];
  85865. /**
  85866. * Returns an array populated with binormal vectors on each Path3D curve point.
  85867. * @returns an array populated with binormal vectors on each Path3D curve point.
  85868. */
  85869. getBinormals(): Vector3[];
  85870. /**
  85871. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85872. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85873. */
  85874. getDistances(): number[];
  85875. /**
  85876. * Returns an interpolated point along this path
  85877. * @param position the position of the point along this path, from 0.0 to 1.0
  85878. * @returns a new Vector3 as the point
  85879. */
  85880. getPointAt(position: number): Vector3;
  85881. /**
  85882. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85883. * @param position the position of the point along this path, from 0.0 to 1.0
  85884. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85885. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85886. */
  85887. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85888. /**
  85889. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85890. * @param position the position of the point along this path, from 0.0 to 1.0
  85891. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85892. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85893. */
  85894. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85895. /**
  85896. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85897. * @param position the position of the point along this path, from 0.0 to 1.0
  85898. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85899. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85900. */
  85901. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85902. /**
  85903. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85904. * @param position the position of the point along this path, from 0.0 to 1.0
  85905. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85906. */
  85907. getDistanceAt(position: number): number;
  85908. /**
  85909. * Returns the array index of the previous point of an interpolated point along this path
  85910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85911. * @returns the array index
  85912. */
  85913. getPreviousPointIndexAt(position: number): number;
  85914. /**
  85915. * 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)
  85916. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85917. * @returns the sub position
  85918. */
  85919. getSubPositionAt(position: number): number;
  85920. /**
  85921. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85922. * @param target the vector of which to get the closest position to
  85923. * @returns the position of the closest virtual point on this path to the target vector
  85924. */
  85925. getClosestPositionTo(target: Vector3): number;
  85926. /**
  85927. * Returns a sub path (slice) of this path
  85928. * @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
  85929. * @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
  85930. * @returns a sub path (slice) of this path
  85931. */
  85932. slice(start?: number, end?: number): Path3D;
  85933. /**
  85934. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85935. * @param path path which all values are copied into the curves points
  85936. * @param firstNormal which should be projected onto the curve
  85937. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85938. * @returns the same object updated.
  85939. */
  85940. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85941. private _compute;
  85942. private _getFirstNonNullVector;
  85943. private _getLastNonNullVector;
  85944. private _normalVector;
  85945. /**
  85946. * Updates the point at data for an interpolated point along this curve
  85947. * @param position the position of the point along this curve, from 0.0 to 1.0
  85948. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85949. * @returns the (updated) point at data
  85950. */
  85951. private _updatePointAtData;
  85952. /**
  85953. * Updates the point at data from the specified parameters
  85954. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85955. * @param point the interpolated point
  85956. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85957. */
  85958. private _setPointAtData;
  85959. /**
  85960. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85961. */
  85962. private _updateInterpolationMatrix;
  85963. }
  85964. /**
  85965. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85966. * A Curve3 is designed from a series of successive Vector3.
  85967. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85968. */
  85969. export class Curve3 {
  85970. private _points;
  85971. private _length;
  85972. /**
  85973. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85974. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85975. * @param v1 (Vector3) the control point
  85976. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85977. * @param nbPoints (integer) the wanted number of points in the curve
  85978. * @returns the created Curve3
  85979. */
  85980. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85981. /**
  85982. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85983. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85984. * @param v1 (Vector3) the first control point
  85985. * @param v2 (Vector3) the second control point
  85986. * @param v3 (Vector3) the end point of the Cubic Bezier
  85987. * @param nbPoints (integer) the wanted number of points in the curve
  85988. * @returns the created Curve3
  85989. */
  85990. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85991. /**
  85992. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85993. * @param p1 (Vector3) the origin point of the Hermite Spline
  85994. * @param t1 (Vector3) the tangent vector at the origin point
  85995. * @param p2 (Vector3) the end point of the Hermite Spline
  85996. * @param t2 (Vector3) the tangent vector at the end point
  85997. * @param nbPoints (integer) the wanted number of points in the curve
  85998. * @returns the created Curve3
  85999. */
  86000. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86001. /**
  86002. * Returns a Curve3 object along a CatmullRom Spline curve :
  86003. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86004. * @param nbPoints (integer) the wanted number of points between each curve control points
  86005. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86006. * @returns the created Curve3
  86007. */
  86008. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86009. /**
  86010. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86011. * A Curve3 is designed from a series of successive Vector3.
  86012. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86013. * @param points points which make up the curve
  86014. */
  86015. constructor(points: Vector3[]);
  86016. /**
  86017. * @returns the Curve3 stored array of successive Vector3
  86018. */
  86019. getPoints(): Vector3[];
  86020. /**
  86021. * @returns the computed length (float) of the curve.
  86022. */
  86023. length(): number;
  86024. /**
  86025. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86026. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86027. * curveA and curveB keep unchanged.
  86028. * @param curve the curve to continue from this curve
  86029. * @returns the newly constructed curve
  86030. */
  86031. continue(curve: DeepImmutable<Curve3>): Curve3;
  86032. private _computeLength;
  86033. }
  86034. }
  86035. declare module BABYLON {
  86036. /**
  86037. * This represents the main contract an easing function should follow.
  86038. * Easing functions are used throughout the animation system.
  86039. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86040. */
  86041. export interface IEasingFunction {
  86042. /**
  86043. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86044. * of the easing function.
  86045. * The link below provides some of the most common examples of easing functions.
  86046. * @see https://easings.net/
  86047. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86048. * @returns the corresponding value on the curve defined by the easing function
  86049. */
  86050. ease(gradient: number): number;
  86051. }
  86052. /**
  86053. * Base class used for every default easing function.
  86054. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86055. */
  86056. export class EasingFunction implements IEasingFunction {
  86057. /**
  86058. * Interpolation follows the mathematical formula associated with the easing function.
  86059. */
  86060. static readonly EASINGMODE_EASEIN: number;
  86061. /**
  86062. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86063. */
  86064. static readonly EASINGMODE_EASEOUT: number;
  86065. /**
  86066. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86067. */
  86068. static readonly EASINGMODE_EASEINOUT: number;
  86069. private _easingMode;
  86070. /**
  86071. * Sets the easing mode of the current function.
  86072. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86073. */
  86074. setEasingMode(easingMode: number): void;
  86075. /**
  86076. * Gets the current easing mode.
  86077. * @returns the easing mode
  86078. */
  86079. getEasingMode(): number;
  86080. /**
  86081. * @hidden
  86082. */
  86083. easeInCore(gradient: number): number;
  86084. /**
  86085. * Given an input gradient between 0 and 1, this returns the corresponding value
  86086. * of the easing function.
  86087. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86088. * @returns the corresponding value on the curve defined by the easing function
  86089. */
  86090. ease(gradient: number): number;
  86091. }
  86092. /**
  86093. * Easing function with a circle shape (see link below).
  86094. * @see https://easings.net/#easeInCirc
  86095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86096. */
  86097. export class CircleEase extends EasingFunction implements IEasingFunction {
  86098. /** @hidden */
  86099. easeInCore(gradient: number): number;
  86100. }
  86101. /**
  86102. * Easing function with a ease back shape (see link below).
  86103. * @see https://easings.net/#easeInBack
  86104. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86105. */
  86106. export class BackEase extends EasingFunction implements IEasingFunction {
  86107. /** Defines the amplitude of the function */
  86108. amplitude: number;
  86109. /**
  86110. * Instantiates a back ease easing
  86111. * @see https://easings.net/#easeInBack
  86112. * @param amplitude Defines the amplitude of the function
  86113. */
  86114. constructor(
  86115. /** Defines the amplitude of the function */
  86116. amplitude?: number);
  86117. /** @hidden */
  86118. easeInCore(gradient: number): number;
  86119. }
  86120. /**
  86121. * Easing function with a bouncing shape (see link below).
  86122. * @see https://easings.net/#easeInBounce
  86123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86124. */
  86125. export class BounceEase extends EasingFunction implements IEasingFunction {
  86126. /** Defines the number of bounces */
  86127. bounces: number;
  86128. /** Defines the amplitude of the bounce */
  86129. bounciness: number;
  86130. /**
  86131. * Instantiates a bounce easing
  86132. * @see https://easings.net/#easeInBounce
  86133. * @param bounces Defines the number of bounces
  86134. * @param bounciness Defines the amplitude of the bounce
  86135. */
  86136. constructor(
  86137. /** Defines the number of bounces */
  86138. bounces?: number,
  86139. /** Defines the amplitude of the bounce */
  86140. bounciness?: number);
  86141. /** @hidden */
  86142. easeInCore(gradient: number): number;
  86143. }
  86144. /**
  86145. * Easing function with a power of 3 shape (see link below).
  86146. * @see https://easings.net/#easeInCubic
  86147. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86148. */
  86149. export class CubicEase extends EasingFunction implements IEasingFunction {
  86150. /** @hidden */
  86151. easeInCore(gradient: number): number;
  86152. }
  86153. /**
  86154. * Easing function with an elastic shape (see link below).
  86155. * @see https://easings.net/#easeInElastic
  86156. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86157. */
  86158. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86159. /** Defines the number of oscillations*/
  86160. oscillations: number;
  86161. /** Defines the amplitude of the oscillations*/
  86162. springiness: number;
  86163. /**
  86164. * Instantiates an elastic easing function
  86165. * @see https://easings.net/#easeInElastic
  86166. * @param oscillations Defines the number of oscillations
  86167. * @param springiness Defines the amplitude of the oscillations
  86168. */
  86169. constructor(
  86170. /** Defines the number of oscillations*/
  86171. oscillations?: number,
  86172. /** Defines the amplitude of the oscillations*/
  86173. springiness?: number);
  86174. /** @hidden */
  86175. easeInCore(gradient: number): number;
  86176. }
  86177. /**
  86178. * Easing function with an exponential shape (see link below).
  86179. * @see https://easings.net/#easeInExpo
  86180. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86181. */
  86182. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86183. /** Defines the exponent of the function */
  86184. exponent: number;
  86185. /**
  86186. * Instantiates an exponential easing function
  86187. * @see https://easings.net/#easeInExpo
  86188. * @param exponent Defines the exponent of the function
  86189. */
  86190. constructor(
  86191. /** Defines the exponent of the function */
  86192. exponent?: number);
  86193. /** @hidden */
  86194. easeInCore(gradient: number): number;
  86195. }
  86196. /**
  86197. * Easing function with a power shape (see link below).
  86198. * @see https://easings.net/#easeInQuad
  86199. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86200. */
  86201. export class PowerEase extends EasingFunction implements IEasingFunction {
  86202. /** Defines the power of the function */
  86203. power: number;
  86204. /**
  86205. * Instantiates an power base easing function
  86206. * @see https://easings.net/#easeInQuad
  86207. * @param power Defines the power of the function
  86208. */
  86209. constructor(
  86210. /** Defines the power of the function */
  86211. power?: number);
  86212. /** @hidden */
  86213. easeInCore(gradient: number): number;
  86214. }
  86215. /**
  86216. * Easing function with a power of 2 shape (see link below).
  86217. * @see https://easings.net/#easeInQuad
  86218. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86219. */
  86220. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86221. /** @hidden */
  86222. easeInCore(gradient: number): number;
  86223. }
  86224. /**
  86225. * Easing function with a power of 4 shape (see link below).
  86226. * @see https://easings.net/#easeInQuart
  86227. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86228. */
  86229. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86230. /** @hidden */
  86231. easeInCore(gradient: number): number;
  86232. }
  86233. /**
  86234. * Easing function with a power of 5 shape (see link below).
  86235. * @see https://easings.net/#easeInQuint
  86236. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86237. */
  86238. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86239. /** @hidden */
  86240. easeInCore(gradient: number): number;
  86241. }
  86242. /**
  86243. * Easing function with a sin shape (see link below).
  86244. * @see https://easings.net/#easeInSine
  86245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86246. */
  86247. export class SineEase extends EasingFunction implements IEasingFunction {
  86248. /** @hidden */
  86249. easeInCore(gradient: number): number;
  86250. }
  86251. /**
  86252. * Easing function with a bezier shape (see link below).
  86253. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86254. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86255. */
  86256. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86257. /** Defines the x component of the start tangent in the bezier curve */
  86258. x1: number;
  86259. /** Defines the y component of the start tangent in the bezier curve */
  86260. y1: number;
  86261. /** Defines the x component of the end tangent in the bezier curve */
  86262. x2: number;
  86263. /** Defines the y component of the end tangent in the bezier curve */
  86264. y2: number;
  86265. /**
  86266. * Instantiates a bezier function
  86267. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86268. * @param x1 Defines the x component of the start tangent in the bezier curve
  86269. * @param y1 Defines the y component of the start tangent in the bezier curve
  86270. * @param x2 Defines the x component of the end tangent in the bezier curve
  86271. * @param y2 Defines the y component of the end tangent in the bezier curve
  86272. */
  86273. constructor(
  86274. /** Defines the x component of the start tangent in the bezier curve */
  86275. x1?: number,
  86276. /** Defines the y component of the start tangent in the bezier curve */
  86277. y1?: number,
  86278. /** Defines the x component of the end tangent in the bezier curve */
  86279. x2?: number,
  86280. /** Defines the y component of the end tangent in the bezier curve */
  86281. y2?: number);
  86282. /** @hidden */
  86283. easeInCore(gradient: number): number;
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. /**
  86288. * Class used to hold a RBG color
  86289. */
  86290. export class Color3 {
  86291. /**
  86292. * Defines the red component (between 0 and 1, default is 0)
  86293. */
  86294. r: number;
  86295. /**
  86296. * Defines the green component (between 0 and 1, default is 0)
  86297. */
  86298. g: number;
  86299. /**
  86300. * Defines the blue component (between 0 and 1, default is 0)
  86301. */
  86302. b: number;
  86303. /**
  86304. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86305. * @param r defines the red component (between 0 and 1, default is 0)
  86306. * @param g defines the green component (between 0 and 1, default is 0)
  86307. * @param b defines the blue component (between 0 and 1, default is 0)
  86308. */
  86309. constructor(
  86310. /**
  86311. * Defines the red component (between 0 and 1, default is 0)
  86312. */
  86313. r?: number,
  86314. /**
  86315. * Defines the green component (between 0 and 1, default is 0)
  86316. */
  86317. g?: number,
  86318. /**
  86319. * Defines the blue component (between 0 and 1, default is 0)
  86320. */
  86321. b?: number);
  86322. /**
  86323. * Creates a string with the Color3 current values
  86324. * @returns the string representation of the Color3 object
  86325. */
  86326. toString(): string;
  86327. /**
  86328. * Returns the string "Color3"
  86329. * @returns "Color3"
  86330. */
  86331. getClassName(): string;
  86332. /**
  86333. * Compute the Color3 hash code
  86334. * @returns an unique number that can be used to hash Color3 objects
  86335. */
  86336. getHashCode(): number;
  86337. /**
  86338. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86339. * @param array defines the array where to store the r,g,b components
  86340. * @param index defines an optional index in the target array to define where to start storing values
  86341. * @returns the current Color3 object
  86342. */
  86343. toArray(array: FloatArray, index?: number): Color3;
  86344. /**
  86345. * Update the current color with values stored in an array from the starting index of the given array
  86346. * @param array defines the source array
  86347. * @param offset defines an offset in the source array
  86348. * @returns the current Color3 object
  86349. */
  86350. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86351. /**
  86352. * Returns a new Color4 object from the current Color3 and the given alpha
  86353. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86354. * @returns a new Color4 object
  86355. */
  86356. toColor4(alpha?: number): Color4;
  86357. /**
  86358. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86359. * @returns the new array
  86360. */
  86361. asArray(): number[];
  86362. /**
  86363. * Returns the luminance value
  86364. * @returns a float value
  86365. */
  86366. toLuminance(): number;
  86367. /**
  86368. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86369. * @param otherColor defines the second operand
  86370. * @returns the new Color3 object
  86371. */
  86372. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86373. /**
  86374. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86375. * @param otherColor defines the second operand
  86376. * @param result defines the Color3 object where to store the result
  86377. * @returns the current Color3
  86378. */
  86379. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86380. /**
  86381. * Determines equality between Color3 objects
  86382. * @param otherColor defines the second operand
  86383. * @returns true if the rgb values are equal to the given ones
  86384. */
  86385. equals(otherColor: DeepImmutable<Color3>): boolean;
  86386. /**
  86387. * Determines equality between the current Color3 object and a set of r,b,g values
  86388. * @param r defines the red component to check
  86389. * @param g defines the green component to check
  86390. * @param b defines the blue component to check
  86391. * @returns true if the rgb values are equal to the given ones
  86392. */
  86393. equalsFloats(r: number, g: number, b: number): boolean;
  86394. /**
  86395. * Multiplies in place each rgb value by scale
  86396. * @param scale defines the scaling factor
  86397. * @returns the updated Color3
  86398. */
  86399. scale(scale: number): Color3;
  86400. /**
  86401. * Multiplies the rgb values by scale and stores the result into "result"
  86402. * @param scale defines the scaling factor
  86403. * @param result defines the Color3 object where to store the result
  86404. * @returns the unmodified current Color3
  86405. */
  86406. scaleToRef(scale: number, result: Color3): Color3;
  86407. /**
  86408. * Scale the current Color3 values by a factor and add the result to a given Color3
  86409. * @param scale defines the scale factor
  86410. * @param result defines color to store the result into
  86411. * @returns the unmodified current Color3
  86412. */
  86413. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86414. /**
  86415. * Clamps the rgb values by the min and max values and stores the result into "result"
  86416. * @param min defines minimum clamping value (default is 0)
  86417. * @param max defines maximum clamping value (default is 1)
  86418. * @param result defines color to store the result into
  86419. * @returns the original Color3
  86420. */
  86421. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86422. /**
  86423. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86424. * @param otherColor defines the second operand
  86425. * @returns the new Color3
  86426. */
  86427. add(otherColor: DeepImmutable<Color3>): Color3;
  86428. /**
  86429. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86430. * @param otherColor defines the second operand
  86431. * @param result defines Color3 object to store the result into
  86432. * @returns the unmodified current Color3
  86433. */
  86434. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86435. /**
  86436. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86437. * @param otherColor defines the second operand
  86438. * @returns the new Color3
  86439. */
  86440. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86441. /**
  86442. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86443. * @param otherColor defines the second operand
  86444. * @param result defines Color3 object to store the result into
  86445. * @returns the unmodified current Color3
  86446. */
  86447. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86448. /**
  86449. * Copy the current object
  86450. * @returns a new Color3 copied the current one
  86451. */
  86452. clone(): Color3;
  86453. /**
  86454. * Copies the rgb values from the source in the current Color3
  86455. * @param source defines the source Color3 object
  86456. * @returns the updated Color3 object
  86457. */
  86458. copyFrom(source: DeepImmutable<Color3>): Color3;
  86459. /**
  86460. * Updates the Color3 rgb values from the given floats
  86461. * @param r defines the red component to read from
  86462. * @param g defines the green component to read from
  86463. * @param b defines the blue component to read from
  86464. * @returns the current Color3 object
  86465. */
  86466. copyFromFloats(r: number, g: number, b: number): Color3;
  86467. /**
  86468. * Updates the Color3 rgb values from the given floats
  86469. * @param r defines the red component to read from
  86470. * @param g defines the green component to read from
  86471. * @param b defines the blue component to read from
  86472. * @returns the current Color3 object
  86473. */
  86474. set(r: number, g: number, b: number): Color3;
  86475. /**
  86476. * Compute the Color3 hexadecimal code as a string
  86477. * @returns a string containing the hexadecimal representation of the Color3 object
  86478. */
  86479. toHexString(): string;
  86480. /**
  86481. * Computes a new Color3 converted from the current one to linear space
  86482. * @returns a new Color3 object
  86483. */
  86484. toLinearSpace(): Color3;
  86485. /**
  86486. * Converts current color in rgb space to HSV values
  86487. * @returns a new color3 representing the HSV values
  86488. */
  86489. toHSV(): Color3;
  86490. /**
  86491. * Converts current color in rgb space to HSV values
  86492. * @param result defines the Color3 where to store the HSV values
  86493. */
  86494. toHSVToRef(result: Color3): void;
  86495. /**
  86496. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86497. * @param convertedColor defines the Color3 object where to store the linear space version
  86498. * @returns the unmodified Color3
  86499. */
  86500. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86501. /**
  86502. * Computes a new Color3 converted from the current one to gamma space
  86503. * @returns a new Color3 object
  86504. */
  86505. toGammaSpace(): Color3;
  86506. /**
  86507. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86508. * @param convertedColor defines the Color3 object where to store the gamma space version
  86509. * @returns the unmodified Color3
  86510. */
  86511. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86512. private static _BlackReadOnly;
  86513. /**
  86514. * Convert Hue, saturation and value to a Color3 (RGB)
  86515. * @param hue defines the hue
  86516. * @param saturation defines the saturation
  86517. * @param value defines the value
  86518. * @param result defines the Color3 where to store the RGB values
  86519. */
  86520. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86521. /**
  86522. * Creates a new Color3 from the string containing valid hexadecimal values
  86523. * @param hex defines a string containing valid hexadecimal values
  86524. * @returns a new Color3 object
  86525. */
  86526. static FromHexString(hex: string): Color3;
  86527. /**
  86528. * Creates a new Color3 from the starting index of the given array
  86529. * @param array defines the source array
  86530. * @param offset defines an offset in the source array
  86531. * @returns a new Color3 object
  86532. */
  86533. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86534. /**
  86535. * Creates a new Color3 from the starting index element of the given array
  86536. * @param array defines the source array to read from
  86537. * @param offset defines the offset in the source array
  86538. * @param result defines the target Color3 object
  86539. */
  86540. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86541. /**
  86542. * Creates a new Color3 from integer values (< 256)
  86543. * @param r defines the red component to read from (value between 0 and 255)
  86544. * @param g defines the green component to read from (value between 0 and 255)
  86545. * @param b defines the blue component to read from (value between 0 and 255)
  86546. * @returns a new Color3 object
  86547. */
  86548. static FromInts(r: number, g: number, b: number): Color3;
  86549. /**
  86550. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86551. * @param start defines the start Color3 value
  86552. * @param end defines the end Color3 value
  86553. * @param amount defines the gradient value between start and end
  86554. * @returns a new Color3 object
  86555. */
  86556. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86557. /**
  86558. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86559. * @param left defines the start value
  86560. * @param right defines the end value
  86561. * @param amount defines the gradient factor
  86562. * @param result defines the Color3 object where to store the result
  86563. */
  86564. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86565. /**
  86566. * Returns a Color3 value containing a red color
  86567. * @returns a new Color3 object
  86568. */
  86569. static Red(): Color3;
  86570. /**
  86571. * Returns a Color3 value containing a green color
  86572. * @returns a new Color3 object
  86573. */
  86574. static Green(): Color3;
  86575. /**
  86576. * Returns a Color3 value containing a blue color
  86577. * @returns a new Color3 object
  86578. */
  86579. static Blue(): Color3;
  86580. /**
  86581. * Returns a Color3 value containing a black color
  86582. * @returns a new Color3 object
  86583. */
  86584. static Black(): Color3;
  86585. /**
  86586. * Gets a Color3 value containing a black color that must not be updated
  86587. */
  86588. static get BlackReadOnly(): DeepImmutable<Color3>;
  86589. /**
  86590. * Returns a Color3 value containing a white color
  86591. * @returns a new Color3 object
  86592. */
  86593. static White(): Color3;
  86594. /**
  86595. * Returns a Color3 value containing a purple color
  86596. * @returns a new Color3 object
  86597. */
  86598. static Purple(): Color3;
  86599. /**
  86600. * Returns a Color3 value containing a magenta color
  86601. * @returns a new Color3 object
  86602. */
  86603. static Magenta(): Color3;
  86604. /**
  86605. * Returns a Color3 value containing a yellow color
  86606. * @returns a new Color3 object
  86607. */
  86608. static Yellow(): Color3;
  86609. /**
  86610. * Returns a Color3 value containing a gray color
  86611. * @returns a new Color3 object
  86612. */
  86613. static Gray(): Color3;
  86614. /**
  86615. * Returns a Color3 value containing a teal color
  86616. * @returns a new Color3 object
  86617. */
  86618. static Teal(): Color3;
  86619. /**
  86620. * Returns a Color3 value containing a random color
  86621. * @returns a new Color3 object
  86622. */
  86623. static Random(): Color3;
  86624. }
  86625. /**
  86626. * Class used to hold a RBGA color
  86627. */
  86628. export class Color4 {
  86629. /**
  86630. * Defines the red component (between 0 and 1, default is 0)
  86631. */
  86632. r: number;
  86633. /**
  86634. * Defines the green component (between 0 and 1, default is 0)
  86635. */
  86636. g: number;
  86637. /**
  86638. * Defines the blue component (between 0 and 1, default is 0)
  86639. */
  86640. b: number;
  86641. /**
  86642. * Defines the alpha component (between 0 and 1, default is 1)
  86643. */
  86644. a: number;
  86645. /**
  86646. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86647. * @param r defines the red component (between 0 and 1, default is 0)
  86648. * @param g defines the green component (between 0 and 1, default is 0)
  86649. * @param b defines the blue component (between 0 and 1, default is 0)
  86650. * @param a defines the alpha component (between 0 and 1, default is 1)
  86651. */
  86652. constructor(
  86653. /**
  86654. * Defines the red component (between 0 and 1, default is 0)
  86655. */
  86656. r?: number,
  86657. /**
  86658. * Defines the green component (between 0 and 1, default is 0)
  86659. */
  86660. g?: number,
  86661. /**
  86662. * Defines the blue component (between 0 and 1, default is 0)
  86663. */
  86664. b?: number,
  86665. /**
  86666. * Defines the alpha component (between 0 and 1, default is 1)
  86667. */
  86668. a?: number);
  86669. /**
  86670. * Adds in place the given Color4 values to the current Color4 object
  86671. * @param right defines the second operand
  86672. * @returns the current updated Color4 object
  86673. */
  86674. addInPlace(right: DeepImmutable<Color4>): Color4;
  86675. /**
  86676. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86677. * @returns the new array
  86678. */
  86679. asArray(): number[];
  86680. /**
  86681. * Stores from the starting index in the given array the Color4 successive values
  86682. * @param array defines the array where to store the r,g,b components
  86683. * @param index defines an optional index in the target array to define where to start storing values
  86684. * @returns the current Color4 object
  86685. */
  86686. toArray(array: number[], index?: number): Color4;
  86687. /**
  86688. * Update the current color with values stored in an array from the starting index of the given array
  86689. * @param array defines the source array
  86690. * @param offset defines an offset in the source array
  86691. * @returns the current Color4 object
  86692. */
  86693. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86694. /**
  86695. * Determines equality between Color4 objects
  86696. * @param otherColor defines the second operand
  86697. * @returns true if the rgba values are equal to the given ones
  86698. */
  86699. equals(otherColor: DeepImmutable<Color4>): boolean;
  86700. /**
  86701. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86702. * @param right defines the second operand
  86703. * @returns a new Color4 object
  86704. */
  86705. add(right: DeepImmutable<Color4>): Color4;
  86706. /**
  86707. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86708. * @param right defines the second operand
  86709. * @returns a new Color4 object
  86710. */
  86711. subtract(right: DeepImmutable<Color4>): Color4;
  86712. /**
  86713. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86714. * @param right defines the second operand
  86715. * @param result defines the Color4 object where to store the result
  86716. * @returns the current Color4 object
  86717. */
  86718. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86719. /**
  86720. * Creates a new Color4 with the current Color4 values multiplied by scale
  86721. * @param scale defines the scaling factor to apply
  86722. * @returns a new Color4 object
  86723. */
  86724. scale(scale: number): Color4;
  86725. /**
  86726. * Multiplies the current Color4 values by scale and stores the result in "result"
  86727. * @param scale defines the scaling factor to apply
  86728. * @param result defines the Color4 object where to store the result
  86729. * @returns the current unmodified Color4
  86730. */
  86731. scaleToRef(scale: number, result: Color4): Color4;
  86732. /**
  86733. * Scale the current Color4 values by a factor and add the result to a given Color4
  86734. * @param scale defines the scale factor
  86735. * @param result defines the Color4 object where to store the result
  86736. * @returns the unmodified current Color4
  86737. */
  86738. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86739. /**
  86740. * Clamps the rgb values by the min and max values and stores the result into "result"
  86741. * @param min defines minimum clamping value (default is 0)
  86742. * @param max defines maximum clamping value (default is 1)
  86743. * @param result defines color to store the result into.
  86744. * @returns the cuurent Color4
  86745. */
  86746. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86747. /**
  86748. * Multipy an Color4 value by another and return a new Color4 object
  86749. * @param color defines the Color4 value to multiply by
  86750. * @returns a new Color4 object
  86751. */
  86752. multiply(color: Color4): Color4;
  86753. /**
  86754. * Multipy a Color4 value by another and push the result in a reference value
  86755. * @param color defines the Color4 value to multiply by
  86756. * @param result defines the Color4 to fill the result in
  86757. * @returns the result Color4
  86758. */
  86759. multiplyToRef(color: Color4, result: Color4): Color4;
  86760. /**
  86761. * Creates a string with the Color4 current values
  86762. * @returns the string representation of the Color4 object
  86763. */
  86764. toString(): string;
  86765. /**
  86766. * Returns the string "Color4"
  86767. * @returns "Color4"
  86768. */
  86769. getClassName(): string;
  86770. /**
  86771. * Compute the Color4 hash code
  86772. * @returns an unique number that can be used to hash Color4 objects
  86773. */
  86774. getHashCode(): number;
  86775. /**
  86776. * Creates a new Color4 copied from the current one
  86777. * @returns a new Color4 object
  86778. */
  86779. clone(): Color4;
  86780. /**
  86781. * Copies the given Color4 values into the current one
  86782. * @param source defines the source Color4 object
  86783. * @returns the current updated Color4 object
  86784. */
  86785. copyFrom(source: Color4): Color4;
  86786. /**
  86787. * Copies the given float values into the current one
  86788. * @param r defines the red component to read from
  86789. * @param g defines the green component to read from
  86790. * @param b defines the blue component to read from
  86791. * @param a defines the alpha component to read from
  86792. * @returns the current updated Color4 object
  86793. */
  86794. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86795. /**
  86796. * Copies the given float values into the current one
  86797. * @param r defines the red component to read from
  86798. * @param g defines the green component to read from
  86799. * @param b defines the blue component to read from
  86800. * @param a defines the alpha component to read from
  86801. * @returns the current updated Color4 object
  86802. */
  86803. set(r: number, g: number, b: number, a: number): Color4;
  86804. /**
  86805. * Compute the Color4 hexadecimal code as a string
  86806. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86807. * @returns a string containing the hexadecimal representation of the Color4 object
  86808. */
  86809. toHexString(returnAsColor3?: boolean): string;
  86810. /**
  86811. * Computes a new Color4 converted from the current one to linear space
  86812. * @returns a new Color4 object
  86813. */
  86814. toLinearSpace(): Color4;
  86815. /**
  86816. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86817. * @param convertedColor defines the Color4 object where to store the linear space version
  86818. * @returns the unmodified Color4
  86819. */
  86820. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86821. /**
  86822. * Computes a new Color4 converted from the current one to gamma space
  86823. * @returns a new Color4 object
  86824. */
  86825. toGammaSpace(): Color4;
  86826. /**
  86827. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86828. * @param convertedColor defines the Color4 object where to store the gamma space version
  86829. * @returns the unmodified Color4
  86830. */
  86831. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86832. /**
  86833. * Creates a new Color4 from the string containing valid hexadecimal values
  86834. * @param hex defines a string containing valid hexadecimal values
  86835. * @returns a new Color4 object
  86836. */
  86837. static FromHexString(hex: string): Color4;
  86838. /**
  86839. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86840. * @param left defines the start value
  86841. * @param right defines the end value
  86842. * @param amount defines the gradient factor
  86843. * @returns a new Color4 object
  86844. */
  86845. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86846. /**
  86847. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86848. * @param left defines the start value
  86849. * @param right defines the end value
  86850. * @param amount defines the gradient factor
  86851. * @param result defines the Color4 object where to store data
  86852. */
  86853. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86854. /**
  86855. * Creates a new Color4 from a Color3 and an alpha value
  86856. * @param color3 defines the source Color3 to read from
  86857. * @param alpha defines the alpha component (1.0 by default)
  86858. * @returns a new Color4 object
  86859. */
  86860. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86861. /**
  86862. * Creates a new Color4 from the starting index element of the given array
  86863. * @param array defines the source array to read from
  86864. * @param offset defines the offset in the source array
  86865. * @returns a new Color4 object
  86866. */
  86867. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86868. /**
  86869. * Creates a new Color4 from the starting index element of the given array
  86870. * @param array defines the source array to read from
  86871. * @param offset defines the offset in the source array
  86872. * @param result defines the target Color4 object
  86873. */
  86874. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86875. /**
  86876. * Creates a new Color3 from integer values (< 256)
  86877. * @param r defines the red component to read from (value between 0 and 255)
  86878. * @param g defines the green component to read from (value between 0 and 255)
  86879. * @param b defines the blue component to read from (value between 0 and 255)
  86880. * @param a defines the alpha component to read from (value between 0 and 255)
  86881. * @returns a new Color3 object
  86882. */
  86883. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86884. /**
  86885. * Check the content of a given array and convert it to an array containing RGBA data
  86886. * If the original array was already containing count * 4 values then it is returned directly
  86887. * @param colors defines the array to check
  86888. * @param count defines the number of RGBA data to expect
  86889. * @returns an array containing count * 4 values (RGBA)
  86890. */
  86891. static CheckColors4(colors: number[], count: number): number[];
  86892. }
  86893. /**
  86894. * @hidden
  86895. */
  86896. export class TmpColors {
  86897. static Color3: Color3[];
  86898. static Color4: Color4[];
  86899. }
  86900. }
  86901. declare module BABYLON {
  86902. /**
  86903. * Defines an interface which represents an animation key frame
  86904. */
  86905. export interface IAnimationKey {
  86906. /**
  86907. * Frame of the key frame
  86908. */
  86909. frame: number;
  86910. /**
  86911. * Value at the specifies key frame
  86912. */
  86913. value: any;
  86914. /**
  86915. * The input tangent for the cubic hermite spline
  86916. */
  86917. inTangent?: any;
  86918. /**
  86919. * The output tangent for the cubic hermite spline
  86920. */
  86921. outTangent?: any;
  86922. /**
  86923. * The animation interpolation type
  86924. */
  86925. interpolation?: AnimationKeyInterpolation;
  86926. }
  86927. /**
  86928. * Enum for the animation key frame interpolation type
  86929. */
  86930. export enum AnimationKeyInterpolation {
  86931. /**
  86932. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86933. */
  86934. STEP = 1
  86935. }
  86936. }
  86937. declare module BABYLON {
  86938. /**
  86939. * Represents the range of an animation
  86940. */
  86941. export class AnimationRange {
  86942. /**The name of the animation range**/
  86943. name: string;
  86944. /**The starting frame of the animation */
  86945. from: number;
  86946. /**The ending frame of the animation*/
  86947. to: number;
  86948. /**
  86949. * Initializes the range of an animation
  86950. * @param name The name of the animation range
  86951. * @param from The starting frame of the animation
  86952. * @param to The ending frame of the animation
  86953. */
  86954. constructor(
  86955. /**The name of the animation range**/
  86956. name: string,
  86957. /**The starting frame of the animation */
  86958. from: number,
  86959. /**The ending frame of the animation*/
  86960. to: number);
  86961. /**
  86962. * Makes a copy of the animation range
  86963. * @returns A copy of the animation range
  86964. */
  86965. clone(): AnimationRange;
  86966. }
  86967. }
  86968. declare module BABYLON {
  86969. /**
  86970. * Composed of a frame, and an action function
  86971. */
  86972. export class AnimationEvent {
  86973. /** The frame for which the event is triggered **/
  86974. frame: number;
  86975. /** The event to perform when triggered **/
  86976. action: (currentFrame: number) => void;
  86977. /** Specifies if the event should be triggered only once**/
  86978. onlyOnce?: boolean | undefined;
  86979. /**
  86980. * Specifies if the animation event is done
  86981. */
  86982. isDone: boolean;
  86983. /**
  86984. * Initializes the animation event
  86985. * @param frame The frame for which the event is triggered
  86986. * @param action The event to perform when triggered
  86987. * @param onlyOnce Specifies if the event should be triggered only once
  86988. */
  86989. constructor(
  86990. /** The frame for which the event is triggered **/
  86991. frame: number,
  86992. /** The event to perform when triggered **/
  86993. action: (currentFrame: number) => void,
  86994. /** Specifies if the event should be triggered only once**/
  86995. onlyOnce?: boolean | undefined);
  86996. /** @hidden */
  86997. _clone(): AnimationEvent;
  86998. }
  86999. }
  87000. declare module BABYLON {
  87001. /**
  87002. * Interface used to define a behavior
  87003. */
  87004. export interface Behavior<T> {
  87005. /** gets or sets behavior's name */
  87006. name: string;
  87007. /**
  87008. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87009. */
  87010. init(): void;
  87011. /**
  87012. * Called when the behavior is attached to a target
  87013. * @param target defines the target where the behavior is attached to
  87014. */
  87015. attach(target: T): void;
  87016. /**
  87017. * Called when the behavior is detached from its target
  87018. */
  87019. detach(): void;
  87020. }
  87021. /**
  87022. * Interface implemented by classes supporting behaviors
  87023. */
  87024. export interface IBehaviorAware<T> {
  87025. /**
  87026. * Attach a behavior
  87027. * @param behavior defines the behavior to attach
  87028. * @returns the current host
  87029. */
  87030. addBehavior(behavior: Behavior<T>): T;
  87031. /**
  87032. * Remove a behavior from the current object
  87033. * @param behavior defines the behavior to detach
  87034. * @returns the current host
  87035. */
  87036. removeBehavior(behavior: Behavior<T>): T;
  87037. /**
  87038. * Gets a behavior using its name to search
  87039. * @param name defines the name to search
  87040. * @returns the behavior or null if not found
  87041. */
  87042. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87043. }
  87044. }
  87045. declare module BABYLON {
  87046. /**
  87047. * Defines an array and its length.
  87048. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87049. */
  87050. export interface ISmartArrayLike<T> {
  87051. /**
  87052. * The data of the array.
  87053. */
  87054. data: Array<T>;
  87055. /**
  87056. * The active length of the array.
  87057. */
  87058. length: number;
  87059. }
  87060. /**
  87061. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87062. */
  87063. export class SmartArray<T> implements ISmartArrayLike<T> {
  87064. /**
  87065. * The full set of data from the array.
  87066. */
  87067. data: Array<T>;
  87068. /**
  87069. * The active length of the array.
  87070. */
  87071. length: number;
  87072. protected _id: number;
  87073. /**
  87074. * Instantiates a Smart Array.
  87075. * @param capacity defines the default capacity of the array.
  87076. */
  87077. constructor(capacity: number);
  87078. /**
  87079. * Pushes a value at the end of the active data.
  87080. * @param value defines the object to push in the array.
  87081. */
  87082. push(value: T): void;
  87083. /**
  87084. * Iterates over the active data and apply the lambda to them.
  87085. * @param func defines the action to apply on each value.
  87086. */
  87087. forEach(func: (content: T) => void): void;
  87088. /**
  87089. * Sorts the full sets of data.
  87090. * @param compareFn defines the comparison function to apply.
  87091. */
  87092. sort(compareFn: (a: T, b: T) => number): void;
  87093. /**
  87094. * Resets the active data to an empty array.
  87095. */
  87096. reset(): void;
  87097. /**
  87098. * Releases all the data from the array as well as the array.
  87099. */
  87100. dispose(): void;
  87101. /**
  87102. * Concats the active data with a given array.
  87103. * @param array defines the data to concatenate with.
  87104. */
  87105. concat(array: any): void;
  87106. /**
  87107. * Returns the position of a value in the active data.
  87108. * @param value defines the value to find the index for
  87109. * @returns the index if found in the active data otherwise -1
  87110. */
  87111. indexOf(value: T): number;
  87112. /**
  87113. * Returns whether an element is part of the active data.
  87114. * @param value defines the value to look for
  87115. * @returns true if found in the active data otherwise false
  87116. */
  87117. contains(value: T): boolean;
  87118. private static _GlobalId;
  87119. }
  87120. /**
  87121. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87122. * The data in this array can only be present once
  87123. */
  87124. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87125. private _duplicateId;
  87126. /**
  87127. * Pushes a value at the end of the active data.
  87128. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87129. * @param value defines the object to push in the array.
  87130. */
  87131. push(value: T): void;
  87132. /**
  87133. * Pushes a value at the end of the active data.
  87134. * If the data is already present, it won t be added again
  87135. * @param value defines the object to push in the array.
  87136. * @returns true if added false if it was already present
  87137. */
  87138. pushNoDuplicate(value: T): boolean;
  87139. /**
  87140. * Resets the active data to an empty array.
  87141. */
  87142. reset(): void;
  87143. /**
  87144. * Concats the active data with a given array.
  87145. * This ensures no dupplicate will be present in the result.
  87146. * @param array defines the data to concatenate with.
  87147. */
  87148. concatWithNoDuplicate(array: any): void;
  87149. }
  87150. }
  87151. declare module BABYLON {
  87152. /**
  87153. * @ignore
  87154. * This is a list of all the different input types that are available in the application.
  87155. * Fo instance: ArcRotateCameraGamepadInput...
  87156. */
  87157. export var CameraInputTypes: {};
  87158. /**
  87159. * This is the contract to implement in order to create a new input class.
  87160. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87161. */
  87162. export interface ICameraInput<TCamera extends Camera> {
  87163. /**
  87164. * Defines the camera the input is attached to.
  87165. */
  87166. camera: Nullable<TCamera>;
  87167. /**
  87168. * Gets the class name of the current intput.
  87169. * @returns the class name
  87170. */
  87171. getClassName(): string;
  87172. /**
  87173. * Get the friendly name associated with the input class.
  87174. * @returns the input friendly name
  87175. */
  87176. getSimpleName(): string;
  87177. /**
  87178. * Attach the input controls to a specific dom element to get the input from.
  87179. * @param element Defines the element the controls should be listened from
  87180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87181. */
  87182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87183. /**
  87184. * Detach the current controls from the specified dom element.
  87185. * @param element Defines the element to stop listening the inputs from
  87186. */
  87187. detachControl(element: Nullable<HTMLElement>): void;
  87188. /**
  87189. * Update the current camera state depending on the inputs that have been used this frame.
  87190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87191. */
  87192. checkInputs?: () => void;
  87193. }
  87194. /**
  87195. * Represents a map of input types to input instance or input index to input instance.
  87196. */
  87197. export interface CameraInputsMap<TCamera extends Camera> {
  87198. /**
  87199. * Accessor to the input by input type.
  87200. */
  87201. [name: string]: ICameraInput<TCamera>;
  87202. /**
  87203. * Accessor to the input by input index.
  87204. */
  87205. [idx: number]: ICameraInput<TCamera>;
  87206. }
  87207. /**
  87208. * This represents the input manager used within a camera.
  87209. * It helps dealing with all the different kind of input attached to a camera.
  87210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87211. */
  87212. export class CameraInputsManager<TCamera extends Camera> {
  87213. /**
  87214. * Defines the list of inputs attahed to the camera.
  87215. */
  87216. attached: CameraInputsMap<TCamera>;
  87217. /**
  87218. * Defines the dom element the camera is collecting inputs from.
  87219. * This is null if the controls have not been attached.
  87220. */
  87221. attachedElement: Nullable<HTMLElement>;
  87222. /**
  87223. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87224. */
  87225. noPreventDefault: boolean;
  87226. /**
  87227. * Defined the camera the input manager belongs to.
  87228. */
  87229. camera: TCamera;
  87230. /**
  87231. * Update the current camera state depending on the inputs that have been used this frame.
  87232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87233. */
  87234. checkInputs: () => void;
  87235. /**
  87236. * Instantiate a new Camera Input Manager.
  87237. * @param camera Defines the camera the input manager blongs to
  87238. */
  87239. constructor(camera: TCamera);
  87240. /**
  87241. * Add an input method to a camera
  87242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87243. * @param input camera input method
  87244. */
  87245. add(input: ICameraInput<TCamera>): void;
  87246. /**
  87247. * Remove a specific input method from a camera
  87248. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87249. * @param inputToRemove camera input method
  87250. */
  87251. remove(inputToRemove: ICameraInput<TCamera>): void;
  87252. /**
  87253. * Remove a specific input type from a camera
  87254. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87255. * @param inputType the type of the input to remove
  87256. */
  87257. removeByType(inputType: string): void;
  87258. private _addCheckInputs;
  87259. /**
  87260. * Attach the input controls to the currently attached dom element to listen the events from.
  87261. * @param input Defines the input to attach
  87262. */
  87263. attachInput(input: ICameraInput<TCamera>): void;
  87264. /**
  87265. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87266. * @param element Defines the dom element to collect the events from
  87267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87268. */
  87269. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87270. /**
  87271. * Detach the current manager inputs controls from a specific dom element.
  87272. * @param element Defines the dom element to collect the events from
  87273. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87274. */
  87275. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87276. /**
  87277. * Rebuild the dynamic inputCheck function from the current list of
  87278. * defined inputs in the manager.
  87279. */
  87280. rebuildInputCheck(): void;
  87281. /**
  87282. * Remove all attached input methods from a camera
  87283. */
  87284. clear(): void;
  87285. /**
  87286. * Serialize the current input manager attached to a camera.
  87287. * This ensures than once parsed,
  87288. * the input associated to the camera will be identical to the current ones
  87289. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87290. */
  87291. serialize(serializedCamera: any): void;
  87292. /**
  87293. * Parses an input manager serialized JSON to restore the previous list of inputs
  87294. * and states associated to a camera.
  87295. * @param parsedCamera Defines the JSON to parse
  87296. */
  87297. parse(parsedCamera: any): void;
  87298. }
  87299. }
  87300. declare module BABYLON {
  87301. /**
  87302. * Class used to store data that will be store in GPU memory
  87303. */
  87304. export class Buffer {
  87305. private _engine;
  87306. private _buffer;
  87307. /** @hidden */
  87308. _data: Nullable<DataArray>;
  87309. private _updatable;
  87310. private _instanced;
  87311. private _divisor;
  87312. /**
  87313. * Gets the byte stride.
  87314. */
  87315. readonly byteStride: number;
  87316. /**
  87317. * Constructor
  87318. * @param engine the engine
  87319. * @param data the data to use for this buffer
  87320. * @param updatable whether the data is updatable
  87321. * @param stride the stride (optional)
  87322. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87323. * @param instanced whether the buffer is instanced (optional)
  87324. * @param useBytes set to true if the stride in in bytes (optional)
  87325. * @param divisor sets an optional divisor for instances (1 by default)
  87326. */
  87327. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87328. /**
  87329. * Create a new VertexBuffer based on the current buffer
  87330. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87331. * @param offset defines offset in the buffer (0 by default)
  87332. * @param size defines the size in floats of attributes (position is 3 for instance)
  87333. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87334. * @param instanced defines if the vertex buffer contains indexed data
  87335. * @param useBytes defines if the offset and stride are in bytes *
  87336. * @param divisor sets an optional divisor for instances (1 by default)
  87337. * @returns the new vertex buffer
  87338. */
  87339. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87340. /**
  87341. * Gets a boolean indicating if the Buffer is updatable?
  87342. * @returns true if the buffer is updatable
  87343. */
  87344. isUpdatable(): boolean;
  87345. /**
  87346. * Gets current buffer's data
  87347. * @returns a DataArray or null
  87348. */
  87349. getData(): Nullable<DataArray>;
  87350. /**
  87351. * Gets underlying native buffer
  87352. * @returns underlying native buffer
  87353. */
  87354. getBuffer(): Nullable<DataBuffer>;
  87355. /**
  87356. * Gets the stride in float32 units (i.e. byte stride / 4).
  87357. * May not be an integer if the byte stride is not divisible by 4.
  87358. * @returns the stride in float32 units
  87359. * @deprecated Please use byteStride instead.
  87360. */
  87361. getStrideSize(): number;
  87362. /**
  87363. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87364. * @param data defines the data to store
  87365. */
  87366. create(data?: Nullable<DataArray>): void;
  87367. /** @hidden */
  87368. _rebuild(): void;
  87369. /**
  87370. * Update current buffer data
  87371. * @param data defines the data to store
  87372. */
  87373. update(data: DataArray): void;
  87374. /**
  87375. * Updates the data directly.
  87376. * @param data the new data
  87377. * @param offset the new offset
  87378. * @param vertexCount the vertex count (optional)
  87379. * @param useBytes set to true if the offset is in bytes
  87380. */
  87381. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87382. /**
  87383. * Release all resources
  87384. */
  87385. dispose(): void;
  87386. }
  87387. /**
  87388. * Specialized buffer used to store vertex data
  87389. */
  87390. export class VertexBuffer {
  87391. /** @hidden */
  87392. _buffer: Buffer;
  87393. private _kind;
  87394. private _size;
  87395. private _ownsBuffer;
  87396. private _instanced;
  87397. private _instanceDivisor;
  87398. /**
  87399. * The byte type.
  87400. */
  87401. static readonly BYTE: number;
  87402. /**
  87403. * The unsigned byte type.
  87404. */
  87405. static readonly UNSIGNED_BYTE: number;
  87406. /**
  87407. * The short type.
  87408. */
  87409. static readonly SHORT: number;
  87410. /**
  87411. * The unsigned short type.
  87412. */
  87413. static readonly UNSIGNED_SHORT: number;
  87414. /**
  87415. * The integer type.
  87416. */
  87417. static readonly INT: number;
  87418. /**
  87419. * The unsigned integer type.
  87420. */
  87421. static readonly UNSIGNED_INT: number;
  87422. /**
  87423. * The float type.
  87424. */
  87425. static readonly FLOAT: number;
  87426. /**
  87427. * Gets or sets the instance divisor when in instanced mode
  87428. */
  87429. get instanceDivisor(): number;
  87430. set instanceDivisor(value: number);
  87431. /**
  87432. * Gets the byte stride.
  87433. */
  87434. readonly byteStride: number;
  87435. /**
  87436. * Gets the byte offset.
  87437. */
  87438. readonly byteOffset: number;
  87439. /**
  87440. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87441. */
  87442. readonly normalized: boolean;
  87443. /**
  87444. * Gets the data type of each component in the array.
  87445. */
  87446. readonly type: number;
  87447. /**
  87448. * Constructor
  87449. * @param engine the engine
  87450. * @param data the data to use for this vertex buffer
  87451. * @param kind the vertex buffer kind
  87452. * @param updatable whether the data is updatable
  87453. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87454. * @param stride the stride (optional)
  87455. * @param instanced whether the buffer is instanced (optional)
  87456. * @param offset the offset of the data (optional)
  87457. * @param size the number of components (optional)
  87458. * @param type the type of the component (optional)
  87459. * @param normalized whether the data contains normalized data (optional)
  87460. * @param useBytes set to true if stride and offset are in bytes (optional)
  87461. * @param divisor defines the instance divisor to use (1 by default)
  87462. */
  87463. 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);
  87464. /** @hidden */
  87465. _rebuild(): void;
  87466. /**
  87467. * Returns the kind of the VertexBuffer (string)
  87468. * @returns a string
  87469. */
  87470. getKind(): string;
  87471. /**
  87472. * Gets a boolean indicating if the VertexBuffer is updatable?
  87473. * @returns true if the buffer is updatable
  87474. */
  87475. isUpdatable(): boolean;
  87476. /**
  87477. * Gets current buffer's data
  87478. * @returns a DataArray or null
  87479. */
  87480. getData(): Nullable<DataArray>;
  87481. /**
  87482. * Gets underlying native buffer
  87483. * @returns underlying native buffer
  87484. */
  87485. getBuffer(): Nullable<DataBuffer>;
  87486. /**
  87487. * Gets the stride in float32 units (i.e. byte stride / 4).
  87488. * May not be an integer if the byte stride is not divisible by 4.
  87489. * @returns the stride in float32 units
  87490. * @deprecated Please use byteStride instead.
  87491. */
  87492. getStrideSize(): number;
  87493. /**
  87494. * Returns the offset as a multiple of the type byte length.
  87495. * @returns the offset in bytes
  87496. * @deprecated Please use byteOffset instead.
  87497. */
  87498. getOffset(): number;
  87499. /**
  87500. * Returns the number of components per vertex attribute (integer)
  87501. * @returns the size in float
  87502. */
  87503. getSize(): number;
  87504. /**
  87505. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87506. * @returns true if this buffer is instanced
  87507. */
  87508. getIsInstanced(): boolean;
  87509. /**
  87510. * Returns the instancing divisor, zero for non-instanced (integer).
  87511. * @returns a number
  87512. */
  87513. getInstanceDivisor(): number;
  87514. /**
  87515. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87516. * @param data defines the data to store
  87517. */
  87518. create(data?: DataArray): void;
  87519. /**
  87520. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87521. * This function will create a new buffer if the current one is not updatable
  87522. * @param data defines the data to store
  87523. */
  87524. update(data: DataArray): void;
  87525. /**
  87526. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87527. * Returns the directly updated WebGLBuffer.
  87528. * @param data the new data
  87529. * @param offset the new offset
  87530. * @param useBytes set to true if the offset is in bytes
  87531. */
  87532. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87533. /**
  87534. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87535. */
  87536. dispose(): void;
  87537. /**
  87538. * Enumerates each value of this vertex buffer as numbers.
  87539. * @param count the number of values to enumerate
  87540. * @param callback the callback function called for each value
  87541. */
  87542. forEach(count: number, callback: (value: number, index: number) => void): void;
  87543. /**
  87544. * Positions
  87545. */
  87546. static readonly PositionKind: string;
  87547. /**
  87548. * Normals
  87549. */
  87550. static readonly NormalKind: string;
  87551. /**
  87552. * Tangents
  87553. */
  87554. static readonly TangentKind: string;
  87555. /**
  87556. * Texture coordinates
  87557. */
  87558. static readonly UVKind: string;
  87559. /**
  87560. * Texture coordinates 2
  87561. */
  87562. static readonly UV2Kind: string;
  87563. /**
  87564. * Texture coordinates 3
  87565. */
  87566. static readonly UV3Kind: string;
  87567. /**
  87568. * Texture coordinates 4
  87569. */
  87570. static readonly UV4Kind: string;
  87571. /**
  87572. * Texture coordinates 5
  87573. */
  87574. static readonly UV5Kind: string;
  87575. /**
  87576. * Texture coordinates 6
  87577. */
  87578. static readonly UV6Kind: string;
  87579. /**
  87580. * Colors
  87581. */
  87582. static readonly ColorKind: string;
  87583. /**
  87584. * Matrix indices (for bones)
  87585. */
  87586. static readonly MatricesIndicesKind: string;
  87587. /**
  87588. * Matrix weights (for bones)
  87589. */
  87590. static readonly MatricesWeightsKind: string;
  87591. /**
  87592. * Additional matrix indices (for bones)
  87593. */
  87594. static readonly MatricesIndicesExtraKind: string;
  87595. /**
  87596. * Additional matrix weights (for bones)
  87597. */
  87598. static readonly MatricesWeightsExtraKind: string;
  87599. /**
  87600. * Deduces the stride given a kind.
  87601. * @param kind The kind string to deduce
  87602. * @returns The deduced stride
  87603. */
  87604. static DeduceStride(kind: string): number;
  87605. /**
  87606. * Gets the byte length of the given type.
  87607. * @param type the type
  87608. * @returns the number of bytes
  87609. */
  87610. static GetTypeByteLength(type: number): number;
  87611. /**
  87612. * Enumerates each value of the given parameters as numbers.
  87613. * @param data the data to enumerate
  87614. * @param byteOffset the byte offset of the data
  87615. * @param byteStride the byte stride of the data
  87616. * @param componentCount the number of components per element
  87617. * @param componentType the type of the component
  87618. * @param count the number of values to enumerate
  87619. * @param normalized whether the data is normalized
  87620. * @param callback the callback function called for each value
  87621. */
  87622. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87623. private static _GetFloatValue;
  87624. }
  87625. }
  87626. declare module BABYLON {
  87627. /**
  87628. * The options Interface for creating a Capsule Mesh
  87629. */
  87630. export interface ICreateCapsuleOptions {
  87631. /** The Orientation of the capsule. Default : Vector3.Up() */
  87632. orientation?: Vector3;
  87633. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87634. subdivisions: number;
  87635. /** Number of cylindrical segments on the capsule. */
  87636. tessellation: number;
  87637. /** Height or Length of the capsule. */
  87638. height: number;
  87639. /** Radius of the capsule. */
  87640. radius: number;
  87641. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87642. capSubdivisions: number;
  87643. /** Overwrite for the top radius. */
  87644. radiusTop?: number;
  87645. /** Overwrite for the bottom radius. */
  87646. radiusBottom?: number;
  87647. /** Overwrite for the top capSubdivisions. */
  87648. topCapSubdivisions?: number;
  87649. /** Overwrite for the bottom capSubdivisions. */
  87650. bottomCapSubdivisions?: number;
  87651. }
  87652. /**
  87653. * Class containing static functions to help procedurally build meshes
  87654. */
  87655. export class CapsuleBuilder {
  87656. /**
  87657. * Creates a capsule or a pill mesh
  87658. * @param name defines the name of the mesh
  87659. * @param options The constructors options.
  87660. * @param scene The scene the mesh is scoped to.
  87661. * @returns Capsule Mesh
  87662. */
  87663. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87664. }
  87665. }
  87666. declare module BABYLON {
  87667. /**
  87668. * @hidden
  87669. */
  87670. export class IntersectionInfo {
  87671. bu: Nullable<number>;
  87672. bv: Nullable<number>;
  87673. distance: number;
  87674. faceId: number;
  87675. subMeshId: number;
  87676. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87677. }
  87678. }
  87679. declare module BABYLON {
  87680. /**
  87681. * Class used to store bounding sphere information
  87682. */
  87683. export class BoundingSphere {
  87684. /**
  87685. * Gets the center of the bounding sphere in local space
  87686. */
  87687. readonly center: Vector3;
  87688. /**
  87689. * Radius of the bounding sphere in local space
  87690. */
  87691. radius: number;
  87692. /**
  87693. * Gets the center of the bounding sphere in world space
  87694. */
  87695. readonly centerWorld: Vector3;
  87696. /**
  87697. * Radius of the bounding sphere in world space
  87698. */
  87699. radiusWorld: number;
  87700. /**
  87701. * Gets the minimum vector in local space
  87702. */
  87703. readonly minimum: Vector3;
  87704. /**
  87705. * Gets the maximum vector in local space
  87706. */
  87707. readonly maximum: Vector3;
  87708. private _worldMatrix;
  87709. private static readonly TmpVector3;
  87710. /**
  87711. * Creates a new bounding sphere
  87712. * @param min defines the minimum vector (in local space)
  87713. * @param max defines the maximum vector (in local space)
  87714. * @param worldMatrix defines the new world matrix
  87715. */
  87716. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87717. /**
  87718. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87719. * @param min defines the new minimum vector (in local space)
  87720. * @param max defines the new maximum vector (in local space)
  87721. * @param worldMatrix defines the new world matrix
  87722. */
  87723. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87724. /**
  87725. * Scale the current bounding sphere by applying a scale factor
  87726. * @param factor defines the scale factor to apply
  87727. * @returns the current bounding box
  87728. */
  87729. scale(factor: number): BoundingSphere;
  87730. /**
  87731. * Gets the world matrix of the bounding box
  87732. * @returns a matrix
  87733. */
  87734. getWorldMatrix(): DeepImmutable<Matrix>;
  87735. /** @hidden */
  87736. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87737. /**
  87738. * Tests if the bounding sphere is intersecting the frustum planes
  87739. * @param frustumPlanes defines the frustum planes to test
  87740. * @returns true if there is an intersection
  87741. */
  87742. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87743. /**
  87744. * Tests if the bounding sphere center is in between the frustum planes.
  87745. * Used for optimistic fast inclusion.
  87746. * @param frustumPlanes defines the frustum planes to test
  87747. * @returns true if the sphere center is in between the frustum planes
  87748. */
  87749. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87750. /**
  87751. * Tests if a point is inside the bounding sphere
  87752. * @param point defines the point to test
  87753. * @returns true if the point is inside the bounding sphere
  87754. */
  87755. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87756. /**
  87757. * Checks if two sphere intersct
  87758. * @param sphere0 sphere 0
  87759. * @param sphere1 sphere 1
  87760. * @returns true if the speres intersect
  87761. */
  87762. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87763. }
  87764. }
  87765. declare module BABYLON {
  87766. /**
  87767. * Class used to store bounding box information
  87768. */
  87769. export class BoundingBox implements ICullable {
  87770. /**
  87771. * Gets the 8 vectors representing the bounding box in local space
  87772. */
  87773. readonly vectors: Vector3[];
  87774. /**
  87775. * Gets the center of the bounding box in local space
  87776. */
  87777. readonly center: Vector3;
  87778. /**
  87779. * Gets the center of the bounding box in world space
  87780. */
  87781. readonly centerWorld: Vector3;
  87782. /**
  87783. * Gets the extend size in local space
  87784. */
  87785. readonly extendSize: Vector3;
  87786. /**
  87787. * Gets the extend size in world space
  87788. */
  87789. readonly extendSizeWorld: Vector3;
  87790. /**
  87791. * Gets the OBB (object bounding box) directions
  87792. */
  87793. readonly directions: Vector3[];
  87794. /**
  87795. * Gets the 8 vectors representing the bounding box in world space
  87796. */
  87797. readonly vectorsWorld: Vector3[];
  87798. /**
  87799. * Gets the minimum vector in world space
  87800. */
  87801. readonly minimumWorld: Vector3;
  87802. /**
  87803. * Gets the maximum vector in world space
  87804. */
  87805. readonly maximumWorld: Vector3;
  87806. /**
  87807. * Gets the minimum vector in local space
  87808. */
  87809. readonly minimum: Vector3;
  87810. /**
  87811. * Gets the maximum vector in local space
  87812. */
  87813. readonly maximum: Vector3;
  87814. private _worldMatrix;
  87815. private static readonly TmpVector3;
  87816. /**
  87817. * @hidden
  87818. */
  87819. _tag: number;
  87820. /**
  87821. * Creates a new bounding box
  87822. * @param min defines the minimum vector (in local space)
  87823. * @param max defines the maximum vector (in local space)
  87824. * @param worldMatrix defines the new world matrix
  87825. */
  87826. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87827. /**
  87828. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87829. * @param min defines the new minimum vector (in local space)
  87830. * @param max defines the new maximum vector (in local space)
  87831. * @param worldMatrix defines the new world matrix
  87832. */
  87833. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87834. /**
  87835. * Scale the current bounding box by applying a scale factor
  87836. * @param factor defines the scale factor to apply
  87837. * @returns the current bounding box
  87838. */
  87839. scale(factor: number): BoundingBox;
  87840. /**
  87841. * Gets the world matrix of the bounding box
  87842. * @returns a matrix
  87843. */
  87844. getWorldMatrix(): DeepImmutable<Matrix>;
  87845. /** @hidden */
  87846. _update(world: DeepImmutable<Matrix>): void;
  87847. /**
  87848. * Tests if the bounding box is intersecting the frustum planes
  87849. * @param frustumPlanes defines the frustum planes to test
  87850. * @returns true if there is an intersection
  87851. */
  87852. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87853. /**
  87854. * Tests if the bounding box is entirely inside the frustum planes
  87855. * @param frustumPlanes defines the frustum planes to test
  87856. * @returns true if there is an inclusion
  87857. */
  87858. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87859. /**
  87860. * Tests if a point is inside the bounding box
  87861. * @param point defines the point to test
  87862. * @returns true if the point is inside the bounding box
  87863. */
  87864. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87865. /**
  87866. * Tests if the bounding box intersects with a bounding sphere
  87867. * @param sphere defines the sphere to test
  87868. * @returns true if there is an intersection
  87869. */
  87870. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87871. /**
  87872. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87873. * @param min defines the min vector to use
  87874. * @param max defines the max vector to use
  87875. * @returns true if there is an intersection
  87876. */
  87877. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87878. /**
  87879. * Tests if two bounding boxes are intersections
  87880. * @param box0 defines the first box to test
  87881. * @param box1 defines the second box to test
  87882. * @returns true if there is an intersection
  87883. */
  87884. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87885. /**
  87886. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87887. * @param minPoint defines the minimum vector of the bounding box
  87888. * @param maxPoint defines the maximum vector of the bounding box
  87889. * @param sphereCenter defines the sphere center
  87890. * @param sphereRadius defines the sphere radius
  87891. * @returns true if there is an intersection
  87892. */
  87893. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87894. /**
  87895. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87896. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87897. * @param frustumPlanes defines the frustum planes to test
  87898. * @return true if there is an inclusion
  87899. */
  87900. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87901. /**
  87902. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87903. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87904. * @param frustumPlanes defines the frustum planes to test
  87905. * @return true if there is an intersection
  87906. */
  87907. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87908. }
  87909. }
  87910. declare module BABYLON {
  87911. /** @hidden */
  87912. export class Collider {
  87913. /** Define if a collision was found */
  87914. collisionFound: boolean;
  87915. /**
  87916. * Define last intersection point in local space
  87917. */
  87918. intersectionPoint: Vector3;
  87919. /**
  87920. * Define last collided mesh
  87921. */
  87922. collidedMesh: Nullable<AbstractMesh>;
  87923. private _collisionPoint;
  87924. private _planeIntersectionPoint;
  87925. private _tempVector;
  87926. private _tempVector2;
  87927. private _tempVector3;
  87928. private _tempVector4;
  87929. private _edge;
  87930. private _baseToVertex;
  87931. private _destinationPoint;
  87932. private _slidePlaneNormal;
  87933. private _displacementVector;
  87934. /** @hidden */
  87935. _radius: Vector3;
  87936. /** @hidden */
  87937. _retry: number;
  87938. private _velocity;
  87939. private _basePoint;
  87940. private _epsilon;
  87941. /** @hidden */
  87942. _velocityWorldLength: number;
  87943. /** @hidden */
  87944. _basePointWorld: Vector3;
  87945. private _velocityWorld;
  87946. private _normalizedVelocity;
  87947. /** @hidden */
  87948. _initialVelocity: Vector3;
  87949. /** @hidden */
  87950. _initialPosition: Vector3;
  87951. private _nearestDistance;
  87952. private _collisionMask;
  87953. get collisionMask(): number;
  87954. set collisionMask(mask: number);
  87955. /**
  87956. * Gets the plane normal used to compute the sliding response (in local space)
  87957. */
  87958. get slidePlaneNormal(): Vector3;
  87959. /** @hidden */
  87960. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87961. /** @hidden */
  87962. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87963. /** @hidden */
  87964. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87965. /** @hidden */
  87966. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87967. /** @hidden */
  87968. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87969. /** @hidden */
  87970. _getResponse(pos: Vector3, vel: Vector3): void;
  87971. }
  87972. }
  87973. declare module BABYLON {
  87974. /**
  87975. * Interface for cullable objects
  87976. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87977. */
  87978. export interface ICullable {
  87979. /**
  87980. * Checks if the object or part of the object is in the frustum
  87981. * @param frustumPlanes Camera near/planes
  87982. * @returns true if the object is in frustum otherwise false
  87983. */
  87984. isInFrustum(frustumPlanes: Plane[]): boolean;
  87985. /**
  87986. * Checks if a cullable object (mesh...) is in the camera frustum
  87987. * Unlike isInFrustum this cheks the full bounding box
  87988. * @param frustumPlanes Camera near/planes
  87989. * @returns true if the object is in frustum otherwise false
  87990. */
  87991. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87992. }
  87993. /**
  87994. * Info for a bounding data of a mesh
  87995. */
  87996. export class BoundingInfo implements ICullable {
  87997. /**
  87998. * Bounding box for the mesh
  87999. */
  88000. readonly boundingBox: BoundingBox;
  88001. /**
  88002. * Bounding sphere for the mesh
  88003. */
  88004. readonly boundingSphere: BoundingSphere;
  88005. private _isLocked;
  88006. private static readonly TmpVector3;
  88007. /**
  88008. * Constructs bounding info
  88009. * @param minimum min vector of the bounding box/sphere
  88010. * @param maximum max vector of the bounding box/sphere
  88011. * @param worldMatrix defines the new world matrix
  88012. */
  88013. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88014. /**
  88015. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88016. * @param min defines the new minimum vector (in local space)
  88017. * @param max defines the new maximum vector (in local space)
  88018. * @param worldMatrix defines the new world matrix
  88019. */
  88020. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88021. /**
  88022. * min vector of the bounding box/sphere
  88023. */
  88024. get minimum(): Vector3;
  88025. /**
  88026. * max vector of the bounding box/sphere
  88027. */
  88028. get maximum(): Vector3;
  88029. /**
  88030. * If the info is locked and won't be updated to avoid perf overhead
  88031. */
  88032. get isLocked(): boolean;
  88033. set isLocked(value: boolean);
  88034. /**
  88035. * Updates the bounding sphere and box
  88036. * @param world world matrix to be used to update
  88037. */
  88038. update(world: DeepImmutable<Matrix>): void;
  88039. /**
  88040. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88041. * @param center New center of the bounding info
  88042. * @param extend New extend of the bounding info
  88043. * @returns the current bounding info
  88044. */
  88045. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88046. /**
  88047. * Scale the current bounding info by applying a scale factor
  88048. * @param factor defines the scale factor to apply
  88049. * @returns the current bounding info
  88050. */
  88051. scale(factor: number): BoundingInfo;
  88052. /**
  88053. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88054. * @param frustumPlanes defines the frustum to test
  88055. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88056. * @returns true if the bounding info is in the frustum planes
  88057. */
  88058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88059. /**
  88060. * Gets the world distance between the min and max points of the bounding box
  88061. */
  88062. get diagonalLength(): number;
  88063. /**
  88064. * Checks if a cullable object (mesh...) is in the camera frustum
  88065. * Unlike isInFrustum this cheks the full bounding box
  88066. * @param frustumPlanes Camera near/planes
  88067. * @returns true if the object is in frustum otherwise false
  88068. */
  88069. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88070. /** @hidden */
  88071. _checkCollision(collider: Collider): boolean;
  88072. /**
  88073. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88074. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88075. * @param point the point to check intersection with
  88076. * @returns if the point intersects
  88077. */
  88078. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88079. /**
  88080. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88081. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88082. * @param boundingInfo the bounding info to check intersection with
  88083. * @param precise if the intersection should be done using OBB
  88084. * @returns if the bounding info intersects
  88085. */
  88086. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88087. }
  88088. }
  88089. declare module BABYLON {
  88090. /**
  88091. * Extracts minimum and maximum values from a list of indexed positions
  88092. * @param positions defines the positions to use
  88093. * @param indices defines the indices to the positions
  88094. * @param indexStart defines the start index
  88095. * @param indexCount defines the end index
  88096. * @param bias defines bias value to add to the result
  88097. * @return minimum and maximum values
  88098. */
  88099. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88100. minimum: Vector3;
  88101. maximum: Vector3;
  88102. };
  88103. /**
  88104. * Extracts minimum and maximum values from a list of positions
  88105. * @param positions defines the positions to use
  88106. * @param start defines the start index in the positions array
  88107. * @param count defines the number of positions to handle
  88108. * @param bias defines bias value to add to the result
  88109. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88110. * @return minimum and maximum values
  88111. */
  88112. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88113. minimum: Vector3;
  88114. maximum: Vector3;
  88115. };
  88116. }
  88117. declare module BABYLON {
  88118. /** @hidden */
  88119. export class WebGLDataBuffer extends DataBuffer {
  88120. private _buffer;
  88121. constructor(resource: WebGLBuffer);
  88122. get underlyingResource(): any;
  88123. }
  88124. }
  88125. declare module BABYLON {
  88126. /** @hidden */
  88127. export class WebGLPipelineContext implements IPipelineContext {
  88128. engine: ThinEngine;
  88129. program: Nullable<WebGLProgram>;
  88130. context?: WebGLRenderingContext;
  88131. vertexShader?: WebGLShader;
  88132. fragmentShader?: WebGLShader;
  88133. isParallelCompiled: boolean;
  88134. onCompiled?: () => void;
  88135. transformFeedback?: WebGLTransformFeedback | null;
  88136. vertexCompilationError: Nullable<string>;
  88137. fragmentCompilationError: Nullable<string>;
  88138. programLinkError: Nullable<string>;
  88139. programValidationError: Nullable<string>;
  88140. get isAsync(): boolean;
  88141. get isReady(): boolean;
  88142. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88143. _getVertexShaderCode(): string | null;
  88144. _getFragmentShaderCode(): string | null;
  88145. }
  88146. }
  88147. declare module BABYLON {
  88148. interface ThinEngine {
  88149. /**
  88150. * Create an uniform buffer
  88151. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88152. * @param elements defines the content of the uniform buffer
  88153. * @returns the webGL uniform buffer
  88154. */
  88155. createUniformBuffer(elements: FloatArray): DataBuffer;
  88156. /**
  88157. * Create a dynamic uniform buffer
  88158. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88159. * @param elements defines the content of the uniform buffer
  88160. * @returns the webGL uniform buffer
  88161. */
  88162. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88163. /**
  88164. * Update an existing uniform buffer
  88165. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88166. * @param uniformBuffer defines the target uniform buffer
  88167. * @param elements defines the content to update
  88168. * @param offset defines the offset in the uniform buffer where update should start
  88169. * @param count defines the size of the data to update
  88170. */
  88171. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88172. /**
  88173. * Bind an uniform buffer to the current webGL context
  88174. * @param buffer defines the buffer to bind
  88175. */
  88176. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88177. /**
  88178. * Bind a buffer to the current webGL context at a given location
  88179. * @param buffer defines the buffer to bind
  88180. * @param location defines the index where to bind the buffer
  88181. */
  88182. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88183. /**
  88184. * Bind a specific block at a given index in a specific shader program
  88185. * @param pipelineContext defines the pipeline context to use
  88186. * @param blockName defines the block name
  88187. * @param index defines the index where to bind the block
  88188. */
  88189. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88190. }
  88191. }
  88192. declare module BABYLON {
  88193. /**
  88194. * Uniform buffer objects.
  88195. *
  88196. * Handles blocks of uniform on the GPU.
  88197. *
  88198. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88199. *
  88200. * For more information, please refer to :
  88201. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88202. */
  88203. export class UniformBuffer {
  88204. private _engine;
  88205. private _buffer;
  88206. private _data;
  88207. private _bufferData;
  88208. private _dynamic?;
  88209. private _uniformLocations;
  88210. private _uniformSizes;
  88211. private _uniformLocationPointer;
  88212. private _needSync;
  88213. private _noUBO;
  88214. private _currentEffect;
  88215. /** @hidden */
  88216. _alreadyBound: boolean;
  88217. private static _MAX_UNIFORM_SIZE;
  88218. private static _tempBuffer;
  88219. /**
  88220. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88221. * This is dynamic to allow compat with webgl 1 and 2.
  88222. * You will need to pass the name of the uniform as well as the value.
  88223. */
  88224. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88225. /**
  88226. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88227. * This is dynamic to allow compat with webgl 1 and 2.
  88228. * You will need to pass the name of the uniform as well as the value.
  88229. */
  88230. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88231. /**
  88232. * Lambda to Update a single float in a uniform buffer.
  88233. * This is dynamic to allow compat with webgl 1 and 2.
  88234. * You will need to pass the name of the uniform as well as the value.
  88235. */
  88236. updateFloat: (name: string, x: number) => void;
  88237. /**
  88238. * Lambda to Update a vec2 of float in a uniform buffer.
  88239. * This is dynamic to allow compat with webgl 1 and 2.
  88240. * You will need to pass the name of the uniform as well as the value.
  88241. */
  88242. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88243. /**
  88244. * Lambda to Update a vec3 of float in a uniform buffer.
  88245. * This is dynamic to allow compat with webgl 1 and 2.
  88246. * You will need to pass the name of the uniform as well as the value.
  88247. */
  88248. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88249. /**
  88250. * Lambda to Update a vec4 of float in a uniform buffer.
  88251. * This is dynamic to allow compat with webgl 1 and 2.
  88252. * You will need to pass the name of the uniform as well as the value.
  88253. */
  88254. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88255. /**
  88256. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88257. * This is dynamic to allow compat with webgl 1 and 2.
  88258. * You will need to pass the name of the uniform as well as the value.
  88259. */
  88260. updateMatrix: (name: string, mat: Matrix) => void;
  88261. /**
  88262. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88263. * This is dynamic to allow compat with webgl 1 and 2.
  88264. * You will need to pass the name of the uniform as well as the value.
  88265. */
  88266. updateVector3: (name: string, vector: Vector3) => void;
  88267. /**
  88268. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88269. * This is dynamic to allow compat with webgl 1 and 2.
  88270. * You will need to pass the name of the uniform as well as the value.
  88271. */
  88272. updateVector4: (name: string, vector: Vector4) => void;
  88273. /**
  88274. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88275. * This is dynamic to allow compat with webgl 1 and 2.
  88276. * You will need to pass the name of the uniform as well as the value.
  88277. */
  88278. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88279. /**
  88280. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88281. * This is dynamic to allow compat with webgl 1 and 2.
  88282. * You will need to pass the name of the uniform as well as the value.
  88283. */
  88284. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88285. /**
  88286. * Instantiates a new Uniform buffer objects.
  88287. *
  88288. * Handles blocks of uniform on the GPU.
  88289. *
  88290. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88291. *
  88292. * For more information, please refer to :
  88293. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88294. * @param engine Define the engine the buffer is associated with
  88295. * @param data Define the data contained in the buffer
  88296. * @param dynamic Define if the buffer is updatable
  88297. */
  88298. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88299. /**
  88300. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88301. * or just falling back on setUniformXXX calls.
  88302. */
  88303. get useUbo(): boolean;
  88304. /**
  88305. * Indicates if the WebGL underlying uniform buffer is in sync
  88306. * with the javascript cache data.
  88307. */
  88308. get isSync(): boolean;
  88309. /**
  88310. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88311. * Also, a dynamic UniformBuffer will disable cache verification and always
  88312. * update the underlying WebGL uniform buffer to the GPU.
  88313. * @returns if Dynamic, otherwise false
  88314. */
  88315. isDynamic(): boolean;
  88316. /**
  88317. * The data cache on JS side.
  88318. * @returns the underlying data as a float array
  88319. */
  88320. getData(): Float32Array;
  88321. /**
  88322. * The underlying WebGL Uniform buffer.
  88323. * @returns the webgl buffer
  88324. */
  88325. getBuffer(): Nullable<DataBuffer>;
  88326. /**
  88327. * std140 layout specifies how to align data within an UBO structure.
  88328. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88329. * for specs.
  88330. */
  88331. private _fillAlignment;
  88332. /**
  88333. * Adds an uniform in the buffer.
  88334. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88335. * for the layout to be correct !
  88336. * @param name Name of the uniform, as used in the uniform block in the shader.
  88337. * @param size Data size, or data directly.
  88338. */
  88339. addUniform(name: string, size: number | number[]): void;
  88340. /**
  88341. * Adds a Matrix 4x4 to the uniform buffer.
  88342. * @param name Name of the uniform, as used in the uniform block in the shader.
  88343. * @param mat A 4x4 matrix.
  88344. */
  88345. addMatrix(name: string, mat: Matrix): void;
  88346. /**
  88347. * Adds a vec2 to the uniform buffer.
  88348. * @param name Name of the uniform, as used in the uniform block in the shader.
  88349. * @param x Define the x component value of the vec2
  88350. * @param y Define the y component value of the vec2
  88351. */
  88352. addFloat2(name: string, x: number, y: number): void;
  88353. /**
  88354. * Adds a vec3 to the uniform buffer.
  88355. * @param name Name of the uniform, as used in the uniform block in the shader.
  88356. * @param x Define the x component value of the vec3
  88357. * @param y Define the y component value of the vec3
  88358. * @param z Define the z component value of the vec3
  88359. */
  88360. addFloat3(name: string, x: number, y: number, z: number): void;
  88361. /**
  88362. * Adds a vec3 to the uniform buffer.
  88363. * @param name Name of the uniform, as used in the uniform block in the shader.
  88364. * @param color Define the vec3 from a Color
  88365. */
  88366. addColor3(name: string, color: Color3): void;
  88367. /**
  88368. * Adds a vec4 to the uniform buffer.
  88369. * @param name Name of the uniform, as used in the uniform block in the shader.
  88370. * @param color Define the rgb components from a Color
  88371. * @param alpha Define the a component of the vec4
  88372. */
  88373. addColor4(name: string, color: Color3, alpha: number): void;
  88374. /**
  88375. * Adds a vec3 to the uniform buffer.
  88376. * @param name Name of the uniform, as used in the uniform block in the shader.
  88377. * @param vector Define the vec3 components from a Vector
  88378. */
  88379. addVector3(name: string, vector: Vector3): void;
  88380. /**
  88381. * Adds a Matrix 3x3 to the uniform buffer.
  88382. * @param name Name of the uniform, as used in the uniform block in the shader.
  88383. */
  88384. addMatrix3x3(name: string): void;
  88385. /**
  88386. * Adds a Matrix 2x2 to the uniform buffer.
  88387. * @param name Name of the uniform, as used in the uniform block in the shader.
  88388. */
  88389. addMatrix2x2(name: string): void;
  88390. /**
  88391. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88392. */
  88393. create(): void;
  88394. /** @hidden */
  88395. _rebuild(): void;
  88396. /**
  88397. * Updates the WebGL Uniform Buffer on the GPU.
  88398. * If the `dynamic` flag is set to true, no cache comparison is done.
  88399. * Otherwise, the buffer will be updated only if the cache differs.
  88400. */
  88401. update(): void;
  88402. /**
  88403. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88404. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88405. * @param data Define the flattened data
  88406. * @param size Define the size of the data.
  88407. */
  88408. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88409. private _valueCache;
  88410. private _cacheMatrix;
  88411. private _updateMatrix3x3ForUniform;
  88412. private _updateMatrix3x3ForEffect;
  88413. private _updateMatrix2x2ForEffect;
  88414. private _updateMatrix2x2ForUniform;
  88415. private _updateFloatForEffect;
  88416. private _updateFloatForUniform;
  88417. private _updateFloat2ForEffect;
  88418. private _updateFloat2ForUniform;
  88419. private _updateFloat3ForEffect;
  88420. private _updateFloat3ForUniform;
  88421. private _updateFloat4ForEffect;
  88422. private _updateFloat4ForUniform;
  88423. private _updateMatrixForEffect;
  88424. private _updateMatrixForUniform;
  88425. private _updateVector3ForEffect;
  88426. private _updateVector3ForUniform;
  88427. private _updateVector4ForEffect;
  88428. private _updateVector4ForUniform;
  88429. private _updateColor3ForEffect;
  88430. private _updateColor3ForUniform;
  88431. private _updateColor4ForEffect;
  88432. private _updateColor4ForUniform;
  88433. /**
  88434. * Sets a sampler uniform on the effect.
  88435. * @param name Define the name of the sampler.
  88436. * @param texture Define the texture to set in the sampler
  88437. */
  88438. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88439. /**
  88440. * Directly updates the value of the uniform in the cache AND on the GPU.
  88441. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88442. * @param data Define the flattened data
  88443. */
  88444. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88445. /**
  88446. * Binds this uniform buffer to an effect.
  88447. * @param effect Define the effect to bind the buffer to
  88448. * @param name Name of the uniform block in the shader.
  88449. */
  88450. bindToEffect(effect: Effect, name: string): void;
  88451. /**
  88452. * Disposes the uniform buffer.
  88453. */
  88454. dispose(): void;
  88455. }
  88456. }
  88457. declare module BABYLON {
  88458. /**
  88459. * Enum that determines the text-wrapping mode to use.
  88460. */
  88461. export enum InspectableType {
  88462. /**
  88463. * Checkbox for booleans
  88464. */
  88465. Checkbox = 0,
  88466. /**
  88467. * Sliders for numbers
  88468. */
  88469. Slider = 1,
  88470. /**
  88471. * Vector3
  88472. */
  88473. Vector3 = 2,
  88474. /**
  88475. * Quaternions
  88476. */
  88477. Quaternion = 3,
  88478. /**
  88479. * Color3
  88480. */
  88481. Color3 = 4,
  88482. /**
  88483. * String
  88484. */
  88485. String = 5
  88486. }
  88487. /**
  88488. * Interface used to define custom inspectable properties.
  88489. * This interface is used by the inspector to display custom property grids
  88490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88491. */
  88492. export interface IInspectable {
  88493. /**
  88494. * Gets the label to display
  88495. */
  88496. label: string;
  88497. /**
  88498. * Gets the name of the property to edit
  88499. */
  88500. propertyName: string;
  88501. /**
  88502. * Gets the type of the editor to use
  88503. */
  88504. type: InspectableType;
  88505. /**
  88506. * Gets the minimum value of the property when using in "slider" mode
  88507. */
  88508. min?: number;
  88509. /**
  88510. * Gets the maximum value of the property when using in "slider" mode
  88511. */
  88512. max?: number;
  88513. /**
  88514. * Gets the setp to use when using in "slider" mode
  88515. */
  88516. step?: number;
  88517. }
  88518. }
  88519. declare module BABYLON {
  88520. /**
  88521. * Class used to provide helper for timing
  88522. */
  88523. export class TimingTools {
  88524. /**
  88525. * Polyfill for setImmediate
  88526. * @param action defines the action to execute after the current execution block
  88527. */
  88528. static SetImmediate(action: () => void): void;
  88529. }
  88530. }
  88531. declare module BABYLON {
  88532. /**
  88533. * Class used to enable instatition of objects by class name
  88534. */
  88535. export class InstantiationTools {
  88536. /**
  88537. * Use this object to register external classes like custom textures or material
  88538. * to allow the laoders to instantiate them
  88539. */
  88540. static RegisteredExternalClasses: {
  88541. [key: string]: Object;
  88542. };
  88543. /**
  88544. * Tries to instantiate a new object from a given class name
  88545. * @param className defines the class name to instantiate
  88546. * @returns the new object or null if the system was not able to do the instantiation
  88547. */
  88548. static Instantiate(className: string): any;
  88549. }
  88550. }
  88551. declare module BABYLON {
  88552. /**
  88553. * Define options used to create a depth texture
  88554. */
  88555. export class DepthTextureCreationOptions {
  88556. /** Specifies whether or not a stencil should be allocated in the texture */
  88557. generateStencil?: boolean;
  88558. /** Specifies whether or not bilinear filtering is enable on the texture */
  88559. bilinearFiltering?: boolean;
  88560. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88561. comparisonFunction?: number;
  88562. /** Specifies if the created texture is a cube texture */
  88563. isCube?: boolean;
  88564. }
  88565. }
  88566. declare module BABYLON {
  88567. interface ThinEngine {
  88568. /**
  88569. * Creates a depth stencil cube texture.
  88570. * This is only available in WebGL 2.
  88571. * @param size The size of face edge in the cube texture.
  88572. * @param options The options defining the cube texture.
  88573. * @returns The cube texture
  88574. */
  88575. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88576. /**
  88577. * Creates a cube texture
  88578. * @param rootUrl defines the url where the files to load is located
  88579. * @param scene defines the current scene
  88580. * @param files defines the list of files to load (1 per face)
  88581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88582. * @param onLoad defines an optional callback raised when the texture is loaded
  88583. * @param onError defines an optional callback raised if there is an issue to load the texture
  88584. * @param format defines the format of the data
  88585. * @param forcedExtension defines the extension to use to pick the right loader
  88586. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88587. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88588. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88589. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88590. * @returns the cube texture as an InternalTexture
  88591. */
  88592. 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;
  88593. /**
  88594. * Creates a cube texture
  88595. * @param rootUrl defines the url where the files to load is located
  88596. * @param scene defines the current scene
  88597. * @param files defines the list of files to load (1 per face)
  88598. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88599. * @param onLoad defines an optional callback raised when the texture is loaded
  88600. * @param onError defines an optional callback raised if there is an issue to load the texture
  88601. * @param format defines the format of the data
  88602. * @param forcedExtension defines the extension to use to pick the right loader
  88603. * @returns the cube texture as an InternalTexture
  88604. */
  88605. 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;
  88606. /**
  88607. * Creates a cube texture
  88608. * @param rootUrl defines the url where the files to load is located
  88609. * @param scene defines the current scene
  88610. * @param files defines the list of files to load (1 per face)
  88611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88612. * @param onLoad defines an optional callback raised when the texture is loaded
  88613. * @param onError defines an optional callback raised if there is an issue to load the texture
  88614. * @param format defines the format of the data
  88615. * @param forcedExtension defines the extension to use to pick the right loader
  88616. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88617. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88618. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88619. * @returns the cube texture as an InternalTexture
  88620. */
  88621. 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;
  88622. /** @hidden */
  88623. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88624. /** @hidden */
  88625. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88626. /** @hidden */
  88627. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88628. /** @hidden */
  88629. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88630. /**
  88631. * @hidden
  88632. */
  88633. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88634. }
  88635. }
  88636. declare module BABYLON {
  88637. /**
  88638. * Class for creating a cube texture
  88639. */
  88640. export class CubeTexture extends BaseTexture {
  88641. private _delayedOnLoad;
  88642. /**
  88643. * Observable triggered once the texture has been loaded.
  88644. */
  88645. onLoadObservable: Observable<CubeTexture>;
  88646. /**
  88647. * The url of the texture
  88648. */
  88649. url: string;
  88650. /**
  88651. * Gets or sets the center of the bounding box associated with the cube texture.
  88652. * It must define where the camera used to render the texture was set
  88653. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88654. */
  88655. boundingBoxPosition: Vector3;
  88656. private _boundingBoxSize;
  88657. /**
  88658. * Gets or sets the size of the bounding box associated with the cube texture
  88659. * When defined, the cubemap will switch to local mode
  88660. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88661. * @example https://www.babylonjs-playground.com/#RNASML
  88662. */
  88663. set boundingBoxSize(value: Vector3);
  88664. /**
  88665. * Returns the bounding box size
  88666. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88667. */
  88668. get boundingBoxSize(): Vector3;
  88669. protected _rotationY: number;
  88670. /**
  88671. * Sets texture matrix rotation angle around Y axis in radians.
  88672. */
  88673. set rotationY(value: number);
  88674. /**
  88675. * Gets texture matrix rotation angle around Y axis radians.
  88676. */
  88677. get rotationY(): number;
  88678. /**
  88679. * Are mip maps generated for this texture or not.
  88680. */
  88681. get noMipmap(): boolean;
  88682. private _noMipmap;
  88683. private _files;
  88684. protected _forcedExtension: Nullable<string>;
  88685. private _extensions;
  88686. private _textureMatrix;
  88687. private _format;
  88688. private _createPolynomials;
  88689. /**
  88690. * Creates a cube texture from an array of image urls
  88691. * @param files defines an array of image urls
  88692. * @param scene defines the hosting scene
  88693. * @param noMipmap specifies if mip maps are not used
  88694. * @returns a cube texture
  88695. */
  88696. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88697. /**
  88698. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88699. * @param url defines the url of the prefiltered texture
  88700. * @param scene defines the scene the texture is attached to
  88701. * @param forcedExtension defines the extension of the file if different from the url
  88702. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88703. * @return the prefiltered texture
  88704. */
  88705. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88706. /**
  88707. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88708. * as prefiltered data.
  88709. * @param rootUrl defines the url of the texture or the root name of the six images
  88710. * @param null defines the scene or engine the texture is attached to
  88711. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88712. * @param noMipmap defines if mipmaps should be created or not
  88713. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88714. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88715. * @param onError defines a callback triggered in case of error during load
  88716. * @param format defines the internal format to use for the texture once loaded
  88717. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88718. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88719. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88722. * @return the cube texture
  88723. */
  88724. 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);
  88725. /**
  88726. * Get the current class name of the texture useful for serialization or dynamic coding.
  88727. * @returns "CubeTexture"
  88728. */
  88729. getClassName(): string;
  88730. /**
  88731. * Update the url (and optional buffer) of this texture if url was null during construction.
  88732. * @param url the url of the texture
  88733. * @param forcedExtension defines the extension to use
  88734. * @param onLoad callback called when the texture is loaded (defaults to null)
  88735. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88736. */
  88737. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88738. /**
  88739. * Delays loading of the cube texture
  88740. * @param forcedExtension defines the extension to use
  88741. */
  88742. delayLoad(forcedExtension?: string): void;
  88743. /**
  88744. * Returns the reflection texture matrix
  88745. * @returns the reflection texture matrix
  88746. */
  88747. getReflectionTextureMatrix(): Matrix;
  88748. /**
  88749. * Sets the reflection texture matrix
  88750. * @param value Reflection texture matrix
  88751. */
  88752. setReflectionTextureMatrix(value: Matrix): void;
  88753. /**
  88754. * Parses text to create a cube texture
  88755. * @param parsedTexture define the serialized text to read from
  88756. * @param scene defines the hosting scene
  88757. * @param rootUrl defines the root url of the cube texture
  88758. * @returns a cube texture
  88759. */
  88760. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88761. /**
  88762. * Makes a clone, or deep copy, of the cube texture
  88763. * @returns a new cube texture
  88764. */
  88765. clone(): CubeTexture;
  88766. }
  88767. }
  88768. declare module BABYLON {
  88769. /**
  88770. * Manages the defines for the Material
  88771. */
  88772. export class MaterialDefines {
  88773. /** @hidden */
  88774. protected _keys: string[];
  88775. private _isDirty;
  88776. /** @hidden */
  88777. _renderId: number;
  88778. /** @hidden */
  88779. _areLightsDirty: boolean;
  88780. /** @hidden */
  88781. _areLightsDisposed: boolean;
  88782. /** @hidden */
  88783. _areAttributesDirty: boolean;
  88784. /** @hidden */
  88785. _areTexturesDirty: boolean;
  88786. /** @hidden */
  88787. _areFresnelDirty: boolean;
  88788. /** @hidden */
  88789. _areMiscDirty: boolean;
  88790. /** @hidden */
  88791. _arePrePassDirty: boolean;
  88792. /** @hidden */
  88793. _areImageProcessingDirty: boolean;
  88794. /** @hidden */
  88795. _normals: boolean;
  88796. /** @hidden */
  88797. _uvs: boolean;
  88798. /** @hidden */
  88799. _needNormals: boolean;
  88800. /** @hidden */
  88801. _needUVs: boolean;
  88802. [id: string]: any;
  88803. /**
  88804. * Specifies if the material needs to be re-calculated
  88805. */
  88806. get isDirty(): boolean;
  88807. /**
  88808. * Marks the material to indicate that it has been re-calculated
  88809. */
  88810. markAsProcessed(): void;
  88811. /**
  88812. * Marks the material to indicate that it needs to be re-calculated
  88813. */
  88814. markAsUnprocessed(): void;
  88815. /**
  88816. * Marks the material to indicate all of its defines need to be re-calculated
  88817. */
  88818. markAllAsDirty(): void;
  88819. /**
  88820. * Marks the material to indicate that image processing needs to be re-calculated
  88821. */
  88822. markAsImageProcessingDirty(): void;
  88823. /**
  88824. * Marks the material to indicate the lights need to be re-calculated
  88825. * @param disposed Defines whether the light is dirty due to dispose or not
  88826. */
  88827. markAsLightDirty(disposed?: boolean): void;
  88828. /**
  88829. * Marks the attribute state as changed
  88830. */
  88831. markAsAttributesDirty(): void;
  88832. /**
  88833. * Marks the texture state as changed
  88834. */
  88835. markAsTexturesDirty(): void;
  88836. /**
  88837. * Marks the fresnel state as changed
  88838. */
  88839. markAsFresnelDirty(): void;
  88840. /**
  88841. * Marks the misc state as changed
  88842. */
  88843. markAsMiscDirty(): void;
  88844. /**
  88845. * Marks the prepass state as changed
  88846. */
  88847. markAsPrePassDirty(): void;
  88848. /**
  88849. * Rebuilds the material defines
  88850. */
  88851. rebuild(): void;
  88852. /**
  88853. * Specifies if two material defines are equal
  88854. * @param other - A material define instance to compare to
  88855. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88856. */
  88857. isEqual(other: MaterialDefines): boolean;
  88858. /**
  88859. * Clones this instance's defines to another instance
  88860. * @param other - material defines to clone values to
  88861. */
  88862. cloneTo(other: MaterialDefines): void;
  88863. /**
  88864. * Resets the material define values
  88865. */
  88866. reset(): void;
  88867. /**
  88868. * Converts the material define values to a string
  88869. * @returns - String of material define information
  88870. */
  88871. toString(): string;
  88872. }
  88873. }
  88874. declare module BABYLON {
  88875. /**
  88876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88878. * 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;
  88879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88880. */
  88881. export class ColorCurves {
  88882. private _dirty;
  88883. private _tempColor;
  88884. private _globalCurve;
  88885. private _highlightsCurve;
  88886. private _midtonesCurve;
  88887. private _shadowsCurve;
  88888. private _positiveCurve;
  88889. private _negativeCurve;
  88890. private _globalHue;
  88891. private _globalDensity;
  88892. private _globalSaturation;
  88893. private _globalExposure;
  88894. /**
  88895. * Gets the global Hue value.
  88896. * 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).
  88897. */
  88898. get globalHue(): number;
  88899. /**
  88900. * Sets the global Hue value.
  88901. * 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).
  88902. */
  88903. set globalHue(value: number);
  88904. /**
  88905. * Gets the global Density value.
  88906. * 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.
  88907. * Values less than zero provide a filter of opposite hue.
  88908. */
  88909. get globalDensity(): number;
  88910. /**
  88911. * Sets the global Density value.
  88912. * 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.
  88913. * Values less than zero provide a filter of opposite hue.
  88914. */
  88915. set globalDensity(value: number);
  88916. /**
  88917. * Gets the global Saturation value.
  88918. * 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.
  88919. */
  88920. get globalSaturation(): number;
  88921. /**
  88922. * Sets the global Saturation value.
  88923. * 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.
  88924. */
  88925. set globalSaturation(value: number);
  88926. /**
  88927. * Gets the global Exposure value.
  88928. * 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.
  88929. */
  88930. get globalExposure(): number;
  88931. /**
  88932. * Sets the global Exposure value.
  88933. * 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.
  88934. */
  88935. set globalExposure(value: number);
  88936. private _highlightsHue;
  88937. private _highlightsDensity;
  88938. private _highlightsSaturation;
  88939. private _highlightsExposure;
  88940. /**
  88941. * Gets the highlights Hue value.
  88942. * 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).
  88943. */
  88944. get highlightsHue(): number;
  88945. /**
  88946. * Sets the highlights Hue value.
  88947. * 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).
  88948. */
  88949. set highlightsHue(value: number);
  88950. /**
  88951. * Gets the highlights Density value.
  88952. * 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.
  88953. * Values less than zero provide a filter of opposite hue.
  88954. */
  88955. get highlightsDensity(): number;
  88956. /**
  88957. * Sets the highlights Density value.
  88958. * 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.
  88959. * Values less than zero provide a filter of opposite hue.
  88960. */
  88961. set highlightsDensity(value: number);
  88962. /**
  88963. * Gets the highlights Saturation value.
  88964. * 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.
  88965. */
  88966. get highlightsSaturation(): number;
  88967. /**
  88968. * Sets the highlights Saturation value.
  88969. * 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.
  88970. */
  88971. set highlightsSaturation(value: number);
  88972. /**
  88973. * Gets the highlights Exposure value.
  88974. * 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.
  88975. */
  88976. get highlightsExposure(): number;
  88977. /**
  88978. * Sets the highlights Exposure value.
  88979. * 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.
  88980. */
  88981. set highlightsExposure(value: number);
  88982. private _midtonesHue;
  88983. private _midtonesDensity;
  88984. private _midtonesSaturation;
  88985. private _midtonesExposure;
  88986. /**
  88987. * Gets the midtones Hue value.
  88988. * 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).
  88989. */
  88990. get midtonesHue(): number;
  88991. /**
  88992. * Sets the midtones Hue value.
  88993. * 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).
  88994. */
  88995. set midtonesHue(value: number);
  88996. /**
  88997. * Gets the midtones Density value.
  88998. * 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.
  88999. * Values less than zero provide a filter of opposite hue.
  89000. */
  89001. get midtonesDensity(): number;
  89002. /**
  89003. * Sets the midtones Density value.
  89004. * 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.
  89005. * Values less than zero provide a filter of opposite hue.
  89006. */
  89007. set midtonesDensity(value: number);
  89008. /**
  89009. * Gets the midtones Saturation value.
  89010. * 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.
  89011. */
  89012. get midtonesSaturation(): number;
  89013. /**
  89014. * Sets the midtones Saturation value.
  89015. * 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.
  89016. */
  89017. set midtonesSaturation(value: number);
  89018. /**
  89019. * Gets the midtones Exposure value.
  89020. * 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.
  89021. */
  89022. get midtonesExposure(): number;
  89023. /**
  89024. * Sets the midtones Exposure value.
  89025. * 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.
  89026. */
  89027. set midtonesExposure(value: number);
  89028. private _shadowsHue;
  89029. private _shadowsDensity;
  89030. private _shadowsSaturation;
  89031. private _shadowsExposure;
  89032. /**
  89033. * Gets the shadows Hue value.
  89034. * 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).
  89035. */
  89036. get shadowsHue(): number;
  89037. /**
  89038. * Sets the shadows Hue value.
  89039. * 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).
  89040. */
  89041. set shadowsHue(value: number);
  89042. /**
  89043. * Gets the shadows Density value.
  89044. * 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.
  89045. * Values less than zero provide a filter of opposite hue.
  89046. */
  89047. get shadowsDensity(): number;
  89048. /**
  89049. * Sets the shadows Density value.
  89050. * 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.
  89051. * Values less than zero provide a filter of opposite hue.
  89052. */
  89053. set shadowsDensity(value: number);
  89054. /**
  89055. * Gets the shadows Saturation value.
  89056. * 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.
  89057. */
  89058. get shadowsSaturation(): number;
  89059. /**
  89060. * Sets the shadows Saturation value.
  89061. * 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.
  89062. */
  89063. set shadowsSaturation(value: number);
  89064. /**
  89065. * Gets the shadows Exposure value.
  89066. * 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.
  89067. */
  89068. get shadowsExposure(): number;
  89069. /**
  89070. * Sets the shadows Exposure value.
  89071. * 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.
  89072. */
  89073. set shadowsExposure(value: number);
  89074. /**
  89075. * Returns the class name
  89076. * @returns The class name
  89077. */
  89078. getClassName(): string;
  89079. /**
  89080. * Binds the color curves to the shader.
  89081. * @param colorCurves The color curve to bind
  89082. * @param effect The effect to bind to
  89083. * @param positiveUniform The positive uniform shader parameter
  89084. * @param neutralUniform The neutral uniform shader parameter
  89085. * @param negativeUniform The negative uniform shader parameter
  89086. */
  89087. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89088. /**
  89089. * Prepare the list of uniforms associated with the ColorCurves effects.
  89090. * @param uniformsList The list of uniforms used in the effect
  89091. */
  89092. static PrepareUniforms(uniformsList: string[]): void;
  89093. /**
  89094. * Returns color grading data based on a hue, density, saturation and exposure value.
  89095. * @param filterHue The hue of the color filter.
  89096. * @param filterDensity The density of the color filter.
  89097. * @param saturation The saturation.
  89098. * @param exposure The exposure.
  89099. * @param result The result data container.
  89100. */
  89101. private getColorGradingDataToRef;
  89102. /**
  89103. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89104. * @param value The input slider value in range [-100,100].
  89105. * @returns Adjusted value.
  89106. */
  89107. private static applyColorGradingSliderNonlinear;
  89108. /**
  89109. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89110. * @param hue The hue (H) input.
  89111. * @param saturation The saturation (S) input.
  89112. * @param brightness The brightness (B) input.
  89113. * @result An RGBA color represented as Vector4.
  89114. */
  89115. private static fromHSBToRef;
  89116. /**
  89117. * Returns a value clamped between min and max
  89118. * @param value The value to clamp
  89119. * @param min The minimum of value
  89120. * @param max The maximum of value
  89121. * @returns The clamped value.
  89122. */
  89123. private static clamp;
  89124. /**
  89125. * Clones the current color curve instance.
  89126. * @return The cloned curves
  89127. */
  89128. clone(): ColorCurves;
  89129. /**
  89130. * Serializes the current color curve instance to a json representation.
  89131. * @return a JSON representation
  89132. */
  89133. serialize(): any;
  89134. /**
  89135. * Parses the color curve from a json representation.
  89136. * @param source the JSON source to parse
  89137. * @return The parsed curves
  89138. */
  89139. static Parse(source: any): ColorCurves;
  89140. }
  89141. }
  89142. declare module BABYLON {
  89143. /**
  89144. * Interface to follow in your material defines to integrate easily the
  89145. * Image proccessing functions.
  89146. * @hidden
  89147. */
  89148. export interface IImageProcessingConfigurationDefines {
  89149. IMAGEPROCESSING: boolean;
  89150. VIGNETTE: boolean;
  89151. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89152. VIGNETTEBLENDMODEOPAQUE: boolean;
  89153. TONEMAPPING: boolean;
  89154. TONEMAPPING_ACES: boolean;
  89155. CONTRAST: boolean;
  89156. EXPOSURE: boolean;
  89157. COLORCURVES: boolean;
  89158. COLORGRADING: boolean;
  89159. COLORGRADING3D: boolean;
  89160. SAMPLER3DGREENDEPTH: boolean;
  89161. SAMPLER3DBGRMAP: boolean;
  89162. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89163. }
  89164. /**
  89165. * @hidden
  89166. */
  89167. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89168. IMAGEPROCESSING: boolean;
  89169. VIGNETTE: boolean;
  89170. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89171. VIGNETTEBLENDMODEOPAQUE: boolean;
  89172. TONEMAPPING: boolean;
  89173. TONEMAPPING_ACES: boolean;
  89174. CONTRAST: boolean;
  89175. COLORCURVES: boolean;
  89176. COLORGRADING: boolean;
  89177. COLORGRADING3D: boolean;
  89178. SAMPLER3DGREENDEPTH: boolean;
  89179. SAMPLER3DBGRMAP: boolean;
  89180. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89181. EXPOSURE: boolean;
  89182. constructor();
  89183. }
  89184. /**
  89185. * This groups together the common properties used for image processing either in direct forward pass
  89186. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89187. * or not.
  89188. */
  89189. export class ImageProcessingConfiguration {
  89190. /**
  89191. * Default tone mapping applied in BabylonJS.
  89192. */
  89193. static readonly TONEMAPPING_STANDARD: number;
  89194. /**
  89195. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89196. * to other engines rendering to increase portability.
  89197. */
  89198. static readonly TONEMAPPING_ACES: number;
  89199. /**
  89200. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89201. */
  89202. colorCurves: Nullable<ColorCurves>;
  89203. private _colorCurvesEnabled;
  89204. /**
  89205. * Gets wether the color curves effect is enabled.
  89206. */
  89207. get colorCurvesEnabled(): boolean;
  89208. /**
  89209. * Sets wether the color curves effect is enabled.
  89210. */
  89211. set colorCurvesEnabled(value: boolean);
  89212. private _colorGradingTexture;
  89213. /**
  89214. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89215. */
  89216. get colorGradingTexture(): Nullable<BaseTexture>;
  89217. /**
  89218. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89219. */
  89220. set colorGradingTexture(value: Nullable<BaseTexture>);
  89221. private _colorGradingEnabled;
  89222. /**
  89223. * Gets wether the color grading effect is enabled.
  89224. */
  89225. get colorGradingEnabled(): boolean;
  89226. /**
  89227. * Sets wether the color grading effect is enabled.
  89228. */
  89229. set colorGradingEnabled(value: boolean);
  89230. private _colorGradingWithGreenDepth;
  89231. /**
  89232. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89233. */
  89234. get colorGradingWithGreenDepth(): boolean;
  89235. /**
  89236. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89237. */
  89238. set colorGradingWithGreenDepth(value: boolean);
  89239. private _colorGradingBGR;
  89240. /**
  89241. * Gets wether the color grading texture contains BGR values.
  89242. */
  89243. get colorGradingBGR(): boolean;
  89244. /**
  89245. * Sets wether the color grading texture contains BGR values.
  89246. */
  89247. set colorGradingBGR(value: boolean);
  89248. /** @hidden */
  89249. _exposure: number;
  89250. /**
  89251. * Gets the Exposure used in the effect.
  89252. */
  89253. get exposure(): number;
  89254. /**
  89255. * Sets the Exposure used in the effect.
  89256. */
  89257. set exposure(value: number);
  89258. private _toneMappingEnabled;
  89259. /**
  89260. * Gets wether the tone mapping effect is enabled.
  89261. */
  89262. get toneMappingEnabled(): boolean;
  89263. /**
  89264. * Sets wether the tone mapping effect is enabled.
  89265. */
  89266. set toneMappingEnabled(value: boolean);
  89267. private _toneMappingType;
  89268. /**
  89269. * Gets the type of tone mapping effect.
  89270. */
  89271. get toneMappingType(): number;
  89272. /**
  89273. * Sets the type of tone mapping effect used in BabylonJS.
  89274. */
  89275. set toneMappingType(value: number);
  89276. protected _contrast: number;
  89277. /**
  89278. * Gets the contrast used in the effect.
  89279. */
  89280. get contrast(): number;
  89281. /**
  89282. * Sets the contrast used in the effect.
  89283. */
  89284. set contrast(value: number);
  89285. /**
  89286. * Vignette stretch size.
  89287. */
  89288. vignetteStretch: number;
  89289. /**
  89290. * Vignette centre X Offset.
  89291. */
  89292. vignetteCentreX: number;
  89293. /**
  89294. * Vignette centre Y Offset.
  89295. */
  89296. vignetteCentreY: number;
  89297. /**
  89298. * Vignette weight or intensity of the vignette effect.
  89299. */
  89300. vignetteWeight: number;
  89301. /**
  89302. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89303. * if vignetteEnabled is set to true.
  89304. */
  89305. vignetteColor: Color4;
  89306. /**
  89307. * Camera field of view used by the Vignette effect.
  89308. */
  89309. vignetteCameraFov: number;
  89310. private _vignetteBlendMode;
  89311. /**
  89312. * Gets the vignette blend mode allowing different kind of effect.
  89313. */
  89314. get vignetteBlendMode(): number;
  89315. /**
  89316. * Sets the vignette blend mode allowing different kind of effect.
  89317. */
  89318. set vignetteBlendMode(value: number);
  89319. private _vignetteEnabled;
  89320. /**
  89321. * Gets wether the vignette effect is enabled.
  89322. */
  89323. get vignetteEnabled(): boolean;
  89324. /**
  89325. * Sets wether the vignette effect is enabled.
  89326. */
  89327. set vignetteEnabled(value: boolean);
  89328. private _applyByPostProcess;
  89329. /**
  89330. * Gets wether the image processing is applied through a post process or not.
  89331. */
  89332. get applyByPostProcess(): boolean;
  89333. /**
  89334. * Sets wether the image processing is applied through a post process or not.
  89335. */
  89336. set applyByPostProcess(value: boolean);
  89337. private _isEnabled;
  89338. /**
  89339. * Gets wether the image processing is enabled or not.
  89340. */
  89341. get isEnabled(): boolean;
  89342. /**
  89343. * Sets wether the image processing is enabled or not.
  89344. */
  89345. set isEnabled(value: boolean);
  89346. /**
  89347. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89348. */
  89349. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89350. /**
  89351. * Method called each time the image processing information changes requires to recompile the effect.
  89352. */
  89353. protected _updateParameters(): void;
  89354. /**
  89355. * Gets the current class name.
  89356. * @return "ImageProcessingConfiguration"
  89357. */
  89358. getClassName(): string;
  89359. /**
  89360. * Prepare the list of uniforms associated with the Image Processing effects.
  89361. * @param uniforms The list of uniforms used in the effect
  89362. * @param defines the list of defines currently in use
  89363. */
  89364. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89365. /**
  89366. * Prepare the list of samplers associated with the Image Processing effects.
  89367. * @param samplersList The list of uniforms used in the effect
  89368. * @param defines the list of defines currently in use
  89369. */
  89370. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89371. /**
  89372. * Prepare the list of defines associated to the shader.
  89373. * @param defines the list of defines to complete
  89374. * @param forPostProcess Define if we are currently in post process mode or not
  89375. */
  89376. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89377. /**
  89378. * Returns true if all the image processing information are ready.
  89379. * @returns True if ready, otherwise, false
  89380. */
  89381. isReady(): boolean;
  89382. /**
  89383. * Binds the image processing to the shader.
  89384. * @param effect The effect to bind to
  89385. * @param overrideAspectRatio Override the aspect ratio of the effect
  89386. */
  89387. bind(effect: Effect, overrideAspectRatio?: number): void;
  89388. /**
  89389. * Clones the current image processing instance.
  89390. * @return The cloned image processing
  89391. */
  89392. clone(): ImageProcessingConfiguration;
  89393. /**
  89394. * Serializes the current image processing instance to a json representation.
  89395. * @return a JSON representation
  89396. */
  89397. serialize(): any;
  89398. /**
  89399. * Parses the image processing from a json representation.
  89400. * @param source the JSON source to parse
  89401. * @return The parsed image processing
  89402. */
  89403. static Parse(source: any): ImageProcessingConfiguration;
  89404. private static _VIGNETTEMODE_MULTIPLY;
  89405. private static _VIGNETTEMODE_OPAQUE;
  89406. /**
  89407. * Used to apply the vignette as a mix with the pixel color.
  89408. */
  89409. static get VIGNETTEMODE_MULTIPLY(): number;
  89410. /**
  89411. * Used to apply the vignette as a replacement of the pixel color.
  89412. */
  89413. static get VIGNETTEMODE_OPAQUE(): number;
  89414. }
  89415. }
  89416. declare module BABYLON {
  89417. /** @hidden */
  89418. export var postprocessVertexShader: {
  89419. name: string;
  89420. shader: string;
  89421. };
  89422. }
  89423. declare module BABYLON {
  89424. /**
  89425. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89426. */
  89427. export type RenderTargetTextureSize = number | {
  89428. width: number;
  89429. height: number;
  89430. layers?: number;
  89431. };
  89432. interface ThinEngine {
  89433. /**
  89434. * Creates a new render target texture
  89435. * @param size defines the size of the texture
  89436. * @param options defines the options used to create the texture
  89437. * @returns a new render target texture stored in an InternalTexture
  89438. */
  89439. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89440. /**
  89441. * Creates a depth stencil texture.
  89442. * This is only available in WebGL 2 or with the depth texture extension available.
  89443. * @param size The size of face edge in the texture.
  89444. * @param options The options defining the texture.
  89445. * @returns The texture
  89446. */
  89447. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89448. /** @hidden */
  89449. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89450. }
  89451. }
  89452. declare module BABYLON {
  89453. /**
  89454. * Defines the kind of connection point for node based material
  89455. */
  89456. export enum NodeMaterialBlockConnectionPointTypes {
  89457. /** Float */
  89458. Float = 1,
  89459. /** Int */
  89460. Int = 2,
  89461. /** Vector2 */
  89462. Vector2 = 4,
  89463. /** Vector3 */
  89464. Vector3 = 8,
  89465. /** Vector4 */
  89466. Vector4 = 16,
  89467. /** Color3 */
  89468. Color3 = 32,
  89469. /** Color4 */
  89470. Color4 = 64,
  89471. /** Matrix */
  89472. Matrix = 128,
  89473. /** Custom object */
  89474. Object = 256,
  89475. /** Detect type based on connection */
  89476. AutoDetect = 1024,
  89477. /** Output type that will be defined by input type */
  89478. BasedOnInput = 2048
  89479. }
  89480. }
  89481. declare module BABYLON {
  89482. /**
  89483. * Enum used to define the target of a block
  89484. */
  89485. export enum NodeMaterialBlockTargets {
  89486. /** Vertex shader */
  89487. Vertex = 1,
  89488. /** Fragment shader */
  89489. Fragment = 2,
  89490. /** Neutral */
  89491. Neutral = 4,
  89492. /** Vertex and Fragment */
  89493. VertexAndFragment = 3
  89494. }
  89495. }
  89496. declare module BABYLON {
  89497. /**
  89498. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89499. */
  89500. export enum NodeMaterialBlockConnectionPointMode {
  89501. /** Value is an uniform */
  89502. Uniform = 0,
  89503. /** Value is a mesh attribute */
  89504. Attribute = 1,
  89505. /** Value is a varying between vertex and fragment shaders */
  89506. Varying = 2,
  89507. /** Mode is undefined */
  89508. Undefined = 3
  89509. }
  89510. }
  89511. declare module BABYLON {
  89512. /**
  89513. * Enum used to define system values e.g. values automatically provided by the system
  89514. */
  89515. export enum NodeMaterialSystemValues {
  89516. /** World */
  89517. World = 1,
  89518. /** View */
  89519. View = 2,
  89520. /** Projection */
  89521. Projection = 3,
  89522. /** ViewProjection */
  89523. ViewProjection = 4,
  89524. /** WorldView */
  89525. WorldView = 5,
  89526. /** WorldViewProjection */
  89527. WorldViewProjection = 6,
  89528. /** CameraPosition */
  89529. CameraPosition = 7,
  89530. /** Fog Color */
  89531. FogColor = 8,
  89532. /** Delta time */
  89533. DeltaTime = 9
  89534. }
  89535. }
  89536. declare module BABYLON {
  89537. /** Defines supported spaces */
  89538. export enum Space {
  89539. /** Local (object) space */
  89540. LOCAL = 0,
  89541. /** World space */
  89542. WORLD = 1,
  89543. /** Bone space */
  89544. BONE = 2
  89545. }
  89546. /** Defines the 3 main axes */
  89547. export class Axis {
  89548. /** X axis */
  89549. static X: Vector3;
  89550. /** Y axis */
  89551. static Y: Vector3;
  89552. /** Z axis */
  89553. static Z: Vector3;
  89554. }
  89555. }
  89556. declare module BABYLON {
  89557. /**
  89558. * Represents a camera frustum
  89559. */
  89560. export class Frustum {
  89561. /**
  89562. * Gets the planes representing the frustum
  89563. * @param transform matrix to be applied to the returned planes
  89564. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89565. */
  89566. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89567. /**
  89568. * Gets the near frustum plane transformed by the transform matrix
  89569. * @param transform transformation matrix to be applied to the resulting frustum plane
  89570. * @param frustumPlane the resuling frustum plane
  89571. */
  89572. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89573. /**
  89574. * Gets the far frustum plane transformed by the transform matrix
  89575. * @param transform transformation matrix to be applied to the resulting frustum plane
  89576. * @param frustumPlane the resuling frustum plane
  89577. */
  89578. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89579. /**
  89580. * Gets the left frustum plane transformed by the transform matrix
  89581. * @param transform transformation matrix to be applied to the resulting frustum plane
  89582. * @param frustumPlane the resuling frustum plane
  89583. */
  89584. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89585. /**
  89586. * Gets the right frustum plane transformed by the transform matrix
  89587. * @param transform transformation matrix to be applied to the resulting frustum plane
  89588. * @param frustumPlane the resuling frustum plane
  89589. */
  89590. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89591. /**
  89592. * Gets the top frustum plane transformed by the transform matrix
  89593. * @param transform transformation matrix to be applied to the resulting frustum plane
  89594. * @param frustumPlane the resuling frustum plane
  89595. */
  89596. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89597. /**
  89598. * Gets the bottom frustum plane transformed by the transform matrix
  89599. * @param transform transformation matrix to be applied to the resulting frustum plane
  89600. * @param frustumPlane the resuling frustum plane
  89601. */
  89602. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89603. /**
  89604. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89605. * @param transform transformation matrix to be applied to the resulting frustum planes
  89606. * @param frustumPlanes the resuling frustum planes
  89607. */
  89608. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89609. }
  89610. }
  89611. declare module BABYLON {
  89612. /**
  89613. * Interface for the size containing width and height
  89614. */
  89615. export interface ISize {
  89616. /**
  89617. * Width
  89618. */
  89619. width: number;
  89620. /**
  89621. * Heighht
  89622. */
  89623. height: number;
  89624. }
  89625. /**
  89626. * Size containing widht and height
  89627. */
  89628. export class Size implements ISize {
  89629. /**
  89630. * Width
  89631. */
  89632. width: number;
  89633. /**
  89634. * Height
  89635. */
  89636. height: number;
  89637. /**
  89638. * Creates a Size object from the given width and height (floats).
  89639. * @param width width of the new size
  89640. * @param height height of the new size
  89641. */
  89642. constructor(width: number, height: number);
  89643. /**
  89644. * Returns a string with the Size width and height
  89645. * @returns a string with the Size width and height
  89646. */
  89647. toString(): string;
  89648. /**
  89649. * "Size"
  89650. * @returns the string "Size"
  89651. */
  89652. getClassName(): string;
  89653. /**
  89654. * Returns the Size hash code.
  89655. * @returns a hash code for a unique width and height
  89656. */
  89657. getHashCode(): number;
  89658. /**
  89659. * Updates the current size from the given one.
  89660. * @param src the given size
  89661. */
  89662. copyFrom(src: Size): void;
  89663. /**
  89664. * Updates in place the current Size from the given floats.
  89665. * @param width width of the new size
  89666. * @param height height of the new size
  89667. * @returns the updated Size.
  89668. */
  89669. copyFromFloats(width: number, height: number): Size;
  89670. /**
  89671. * Updates in place the current Size from the given floats.
  89672. * @param width width to set
  89673. * @param height height to set
  89674. * @returns the updated Size.
  89675. */
  89676. set(width: number, height: number): Size;
  89677. /**
  89678. * Multiplies the width and height by numbers
  89679. * @param w factor to multiple the width by
  89680. * @param h factor to multiple the height by
  89681. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89682. */
  89683. multiplyByFloats(w: number, h: number): Size;
  89684. /**
  89685. * Clones the size
  89686. * @returns a new Size copied from the given one.
  89687. */
  89688. clone(): Size;
  89689. /**
  89690. * True if the current Size and the given one width and height are strictly equal.
  89691. * @param other the other size to compare against
  89692. * @returns True if the current Size and the given one width and height are strictly equal.
  89693. */
  89694. equals(other: Size): boolean;
  89695. /**
  89696. * The surface of the Size : width * height (float).
  89697. */
  89698. get surface(): number;
  89699. /**
  89700. * Create a new size of zero
  89701. * @returns a new Size set to (0.0, 0.0)
  89702. */
  89703. static Zero(): Size;
  89704. /**
  89705. * Sums the width and height of two sizes
  89706. * @param otherSize size to add to this size
  89707. * @returns a new Size set as the addition result of the current Size and the given one.
  89708. */
  89709. add(otherSize: Size): Size;
  89710. /**
  89711. * Subtracts the width and height of two
  89712. * @param otherSize size to subtract to this size
  89713. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89714. */
  89715. subtract(otherSize: Size): Size;
  89716. /**
  89717. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89718. * @param start starting size to lerp between
  89719. * @param end end size to lerp between
  89720. * @param amount amount to lerp between the start and end values
  89721. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89722. */
  89723. static Lerp(start: Size, end: Size, amount: number): Size;
  89724. }
  89725. }
  89726. declare module BABYLON {
  89727. /**
  89728. * Contains position and normal vectors for a vertex
  89729. */
  89730. export class PositionNormalVertex {
  89731. /** the position of the vertex (defaut: 0,0,0) */
  89732. position: Vector3;
  89733. /** the normal of the vertex (defaut: 0,1,0) */
  89734. normal: Vector3;
  89735. /**
  89736. * Creates a PositionNormalVertex
  89737. * @param position the position of the vertex (defaut: 0,0,0)
  89738. * @param normal the normal of the vertex (defaut: 0,1,0)
  89739. */
  89740. constructor(
  89741. /** the position of the vertex (defaut: 0,0,0) */
  89742. position?: Vector3,
  89743. /** the normal of the vertex (defaut: 0,1,0) */
  89744. normal?: Vector3);
  89745. /**
  89746. * Clones the PositionNormalVertex
  89747. * @returns the cloned PositionNormalVertex
  89748. */
  89749. clone(): PositionNormalVertex;
  89750. }
  89751. /**
  89752. * Contains position, normal and uv vectors for a vertex
  89753. */
  89754. export class PositionNormalTextureVertex {
  89755. /** the position of the vertex (defaut: 0,0,0) */
  89756. position: Vector3;
  89757. /** the normal of the vertex (defaut: 0,1,0) */
  89758. normal: Vector3;
  89759. /** the uv of the vertex (default: 0,0) */
  89760. uv: Vector2;
  89761. /**
  89762. * Creates a PositionNormalTextureVertex
  89763. * @param position the position of the vertex (defaut: 0,0,0)
  89764. * @param normal the normal of the vertex (defaut: 0,1,0)
  89765. * @param uv the uv of the vertex (default: 0,0)
  89766. */
  89767. constructor(
  89768. /** the position of the vertex (defaut: 0,0,0) */
  89769. position?: Vector3,
  89770. /** the normal of the vertex (defaut: 0,1,0) */
  89771. normal?: Vector3,
  89772. /** the uv of the vertex (default: 0,0) */
  89773. uv?: Vector2);
  89774. /**
  89775. * Clones the PositionNormalTextureVertex
  89776. * @returns the cloned PositionNormalTextureVertex
  89777. */
  89778. clone(): PositionNormalTextureVertex;
  89779. }
  89780. }
  89781. declare module BABYLON {
  89782. /**
  89783. * Enum defining the type of animations supported by InputBlock
  89784. */
  89785. export enum AnimatedInputBlockTypes {
  89786. /** No animation */
  89787. None = 0,
  89788. /** Time based animation. Will only work for floats */
  89789. Time = 1
  89790. }
  89791. }
  89792. declare module BABYLON {
  89793. /**
  89794. * Interface describing all the common properties and methods a shadow light needs to implement.
  89795. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89796. * as well as binding the different shadow properties to the effects.
  89797. */
  89798. export interface IShadowLight extends Light {
  89799. /**
  89800. * The light id in the scene (used in scene.findLighById for instance)
  89801. */
  89802. id: string;
  89803. /**
  89804. * The position the shdow will be casted from.
  89805. */
  89806. position: Vector3;
  89807. /**
  89808. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89809. */
  89810. direction: Vector3;
  89811. /**
  89812. * The transformed position. Position of the light in world space taking parenting in account.
  89813. */
  89814. transformedPosition: Vector3;
  89815. /**
  89816. * The transformed direction. Direction of the light in world space taking parenting in account.
  89817. */
  89818. transformedDirection: Vector3;
  89819. /**
  89820. * The friendly name of the light in the scene.
  89821. */
  89822. name: string;
  89823. /**
  89824. * Defines the shadow projection clipping minimum z value.
  89825. */
  89826. shadowMinZ: number;
  89827. /**
  89828. * Defines the shadow projection clipping maximum z value.
  89829. */
  89830. shadowMaxZ: number;
  89831. /**
  89832. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89833. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89834. */
  89835. computeTransformedInformation(): boolean;
  89836. /**
  89837. * Gets the scene the light belongs to.
  89838. * @returns The scene
  89839. */
  89840. getScene(): Scene;
  89841. /**
  89842. * Callback defining a custom Projection Matrix Builder.
  89843. * This can be used to override the default projection matrix computation.
  89844. */
  89845. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89846. /**
  89847. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89848. * @param matrix The materix to updated with the projection information
  89849. * @param viewMatrix The transform matrix of the light
  89850. * @param renderList The list of mesh to render in the map
  89851. * @returns The current light
  89852. */
  89853. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89854. /**
  89855. * Gets the current depth scale used in ESM.
  89856. * @returns The scale
  89857. */
  89858. getDepthScale(): number;
  89859. /**
  89860. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89861. * @returns true if a cube texture needs to be use
  89862. */
  89863. needCube(): boolean;
  89864. /**
  89865. * Detects if the projection matrix requires to be recomputed this frame.
  89866. * @returns true if it requires to be recomputed otherwise, false.
  89867. */
  89868. needProjectionMatrixCompute(): boolean;
  89869. /**
  89870. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89871. */
  89872. forceProjectionMatrixCompute(): void;
  89873. /**
  89874. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89875. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89876. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89877. */
  89878. getShadowDirection(faceIndex?: number): Vector3;
  89879. /**
  89880. * Gets the minZ used for shadow according to both the scene and the light.
  89881. * @param activeCamera The camera we are returning the min for
  89882. * @returns the depth min z
  89883. */
  89884. getDepthMinZ(activeCamera: Camera): number;
  89885. /**
  89886. * Gets the maxZ used for shadow according to both the scene and the light.
  89887. * @param activeCamera The camera we are returning the max for
  89888. * @returns the depth max z
  89889. */
  89890. getDepthMaxZ(activeCamera: Camera): number;
  89891. }
  89892. /**
  89893. * Base implementation IShadowLight
  89894. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89895. */
  89896. export abstract class ShadowLight extends Light implements IShadowLight {
  89897. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89898. protected _position: Vector3;
  89899. protected _setPosition(value: Vector3): void;
  89900. /**
  89901. * Sets the position the shadow will be casted from. Also use as the light position for both
  89902. * point and spot lights.
  89903. */
  89904. get position(): Vector3;
  89905. /**
  89906. * Sets the position the shadow will be casted from. Also use as the light position for both
  89907. * point and spot lights.
  89908. */
  89909. set position(value: Vector3);
  89910. protected _direction: Vector3;
  89911. protected _setDirection(value: Vector3): void;
  89912. /**
  89913. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89914. * Also use as the light direction on spot and directional lights.
  89915. */
  89916. get direction(): Vector3;
  89917. /**
  89918. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89919. * Also use as the light direction on spot and directional lights.
  89920. */
  89921. set direction(value: Vector3);
  89922. protected _shadowMinZ: number;
  89923. /**
  89924. * Gets the shadow projection clipping minimum z value.
  89925. */
  89926. get shadowMinZ(): number;
  89927. /**
  89928. * Sets the shadow projection clipping minimum z value.
  89929. */
  89930. set shadowMinZ(value: number);
  89931. protected _shadowMaxZ: number;
  89932. /**
  89933. * Sets the shadow projection clipping maximum z value.
  89934. */
  89935. get shadowMaxZ(): number;
  89936. /**
  89937. * Gets the shadow projection clipping maximum z value.
  89938. */
  89939. set shadowMaxZ(value: number);
  89940. /**
  89941. * Callback defining a custom Projection Matrix Builder.
  89942. * This can be used to override the default projection matrix computation.
  89943. */
  89944. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89945. /**
  89946. * The transformed position. Position of the light in world space taking parenting in account.
  89947. */
  89948. transformedPosition: Vector3;
  89949. /**
  89950. * The transformed direction. Direction of the light in world space taking parenting in account.
  89951. */
  89952. transformedDirection: Vector3;
  89953. private _needProjectionMatrixCompute;
  89954. /**
  89955. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89956. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89957. */
  89958. computeTransformedInformation(): boolean;
  89959. /**
  89960. * Return the depth scale used for the shadow map.
  89961. * @returns the depth scale.
  89962. */
  89963. getDepthScale(): number;
  89964. /**
  89965. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89966. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89967. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89968. */
  89969. getShadowDirection(faceIndex?: number): Vector3;
  89970. /**
  89971. * Returns the ShadowLight absolute position in the World.
  89972. * @returns the position vector in world space
  89973. */
  89974. getAbsolutePosition(): Vector3;
  89975. /**
  89976. * Sets the ShadowLight direction toward the passed target.
  89977. * @param target The point to target in local space
  89978. * @returns the updated ShadowLight direction
  89979. */
  89980. setDirectionToTarget(target: Vector3): Vector3;
  89981. /**
  89982. * Returns the light rotation in euler definition.
  89983. * @returns the x y z rotation in local space.
  89984. */
  89985. getRotation(): Vector3;
  89986. /**
  89987. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89988. * @returns true if a cube texture needs to be use
  89989. */
  89990. needCube(): boolean;
  89991. /**
  89992. * Detects if the projection matrix requires to be recomputed this frame.
  89993. * @returns true if it requires to be recomputed otherwise, false.
  89994. */
  89995. needProjectionMatrixCompute(): boolean;
  89996. /**
  89997. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89998. */
  89999. forceProjectionMatrixCompute(): void;
  90000. /** @hidden */
  90001. _initCache(): void;
  90002. /** @hidden */
  90003. _isSynchronized(): boolean;
  90004. /**
  90005. * Computes the world matrix of the node
  90006. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90007. * @returns the world matrix
  90008. */
  90009. computeWorldMatrix(force?: boolean): Matrix;
  90010. /**
  90011. * Gets the minZ used for shadow according to both the scene and the light.
  90012. * @param activeCamera The camera we are returning the min for
  90013. * @returns the depth min z
  90014. */
  90015. getDepthMinZ(activeCamera: Camera): number;
  90016. /**
  90017. * Gets the maxZ used for shadow according to both the scene and the light.
  90018. * @param activeCamera The camera we are returning the max for
  90019. * @returns the depth max z
  90020. */
  90021. getDepthMaxZ(activeCamera: Camera): number;
  90022. /**
  90023. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90024. * @param matrix The materix to updated with the projection information
  90025. * @param viewMatrix The transform matrix of the light
  90026. * @param renderList The list of mesh to render in the map
  90027. * @returns The current light
  90028. */
  90029. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90030. }
  90031. }
  90032. declare module BABYLON {
  90033. /** @hidden */
  90034. export var packingFunctions: {
  90035. name: string;
  90036. shader: string;
  90037. };
  90038. }
  90039. declare module BABYLON {
  90040. /** @hidden */
  90041. export var bayerDitherFunctions: {
  90042. name: string;
  90043. shader: string;
  90044. };
  90045. }
  90046. declare module BABYLON {
  90047. /** @hidden */
  90048. export var shadowMapFragmentDeclaration: {
  90049. name: string;
  90050. shader: string;
  90051. };
  90052. }
  90053. declare module BABYLON {
  90054. /** @hidden */
  90055. export var clipPlaneFragmentDeclaration: {
  90056. name: string;
  90057. shader: string;
  90058. };
  90059. }
  90060. declare module BABYLON {
  90061. /** @hidden */
  90062. export var clipPlaneFragment: {
  90063. name: string;
  90064. shader: string;
  90065. };
  90066. }
  90067. declare module BABYLON {
  90068. /** @hidden */
  90069. export var shadowMapFragment: {
  90070. name: string;
  90071. shader: string;
  90072. };
  90073. }
  90074. declare module BABYLON {
  90075. /** @hidden */
  90076. export var shadowMapPixelShader: {
  90077. name: string;
  90078. shader: string;
  90079. };
  90080. }
  90081. declare module BABYLON {
  90082. /** @hidden */
  90083. export var bonesDeclaration: {
  90084. name: string;
  90085. shader: string;
  90086. };
  90087. }
  90088. declare module BABYLON {
  90089. /** @hidden */
  90090. export var morphTargetsVertexGlobalDeclaration: {
  90091. name: string;
  90092. shader: string;
  90093. };
  90094. }
  90095. declare module BABYLON {
  90096. /** @hidden */
  90097. export var morphTargetsVertexDeclaration: {
  90098. name: string;
  90099. shader: string;
  90100. };
  90101. }
  90102. declare module BABYLON {
  90103. /** @hidden */
  90104. export var instancesDeclaration: {
  90105. name: string;
  90106. shader: string;
  90107. };
  90108. }
  90109. declare module BABYLON {
  90110. /** @hidden */
  90111. export var helperFunctions: {
  90112. name: string;
  90113. shader: string;
  90114. };
  90115. }
  90116. declare module BABYLON {
  90117. /** @hidden */
  90118. export var shadowMapVertexDeclaration: {
  90119. name: string;
  90120. shader: string;
  90121. };
  90122. }
  90123. declare module BABYLON {
  90124. /** @hidden */
  90125. export var clipPlaneVertexDeclaration: {
  90126. name: string;
  90127. shader: string;
  90128. };
  90129. }
  90130. declare module BABYLON {
  90131. /** @hidden */
  90132. export var morphTargetsVertex: {
  90133. name: string;
  90134. shader: string;
  90135. };
  90136. }
  90137. declare module BABYLON {
  90138. /** @hidden */
  90139. export var instancesVertex: {
  90140. name: string;
  90141. shader: string;
  90142. };
  90143. }
  90144. declare module BABYLON {
  90145. /** @hidden */
  90146. export var bonesVertex: {
  90147. name: string;
  90148. shader: string;
  90149. };
  90150. }
  90151. declare module BABYLON {
  90152. /** @hidden */
  90153. export var shadowMapVertexNormalBias: {
  90154. name: string;
  90155. shader: string;
  90156. };
  90157. }
  90158. declare module BABYLON {
  90159. /** @hidden */
  90160. export var shadowMapVertexMetric: {
  90161. name: string;
  90162. shader: string;
  90163. };
  90164. }
  90165. declare module BABYLON {
  90166. /** @hidden */
  90167. export var clipPlaneVertex: {
  90168. name: string;
  90169. shader: string;
  90170. };
  90171. }
  90172. declare module BABYLON {
  90173. /** @hidden */
  90174. export var shadowMapVertexShader: {
  90175. name: string;
  90176. shader: string;
  90177. };
  90178. }
  90179. declare module BABYLON {
  90180. /** @hidden */
  90181. export var depthBoxBlurPixelShader: {
  90182. name: string;
  90183. shader: string;
  90184. };
  90185. }
  90186. declare module BABYLON {
  90187. /** @hidden */
  90188. export var shadowMapFragmentSoftTransparentShadow: {
  90189. name: string;
  90190. shader: string;
  90191. };
  90192. }
  90193. declare module BABYLON {
  90194. /**
  90195. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90196. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90197. */
  90198. export class EffectFallbacks implements IEffectFallbacks {
  90199. private _defines;
  90200. private _currentRank;
  90201. private _maxRank;
  90202. private _mesh;
  90203. /**
  90204. * Removes the fallback from the bound mesh.
  90205. */
  90206. unBindMesh(): void;
  90207. /**
  90208. * Adds a fallback on the specified property.
  90209. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90210. * @param define The name of the define in the shader
  90211. */
  90212. addFallback(rank: number, define: string): void;
  90213. /**
  90214. * Sets the mesh to use CPU skinning when needing to fallback.
  90215. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90216. * @param mesh The mesh to use the fallbacks.
  90217. */
  90218. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90219. /**
  90220. * Checks to see if more fallbacks are still availible.
  90221. */
  90222. get hasMoreFallbacks(): boolean;
  90223. /**
  90224. * Removes the defines that should be removed when falling back.
  90225. * @param currentDefines defines the current define statements for the shader.
  90226. * @param effect defines the current effect we try to compile
  90227. * @returns The resulting defines with defines of the current rank removed.
  90228. */
  90229. reduce(currentDefines: string, effect: Effect): string;
  90230. }
  90231. }
  90232. declare module BABYLON {
  90233. /**
  90234. * Interface used to define Action
  90235. */
  90236. export interface IAction {
  90237. /**
  90238. * Trigger for the action
  90239. */
  90240. trigger: number;
  90241. /** Options of the trigger */
  90242. triggerOptions: any;
  90243. /**
  90244. * Gets the trigger parameters
  90245. * @returns the trigger parameters
  90246. */
  90247. getTriggerParameter(): any;
  90248. /**
  90249. * Internal only - executes current action event
  90250. * @hidden
  90251. */
  90252. _executeCurrent(evt?: ActionEvent): void;
  90253. /**
  90254. * Serialize placeholder for child classes
  90255. * @param parent of child
  90256. * @returns the serialized object
  90257. */
  90258. serialize(parent: any): any;
  90259. /**
  90260. * Internal only
  90261. * @hidden
  90262. */
  90263. _prepare(): void;
  90264. /**
  90265. * Internal only - manager for action
  90266. * @hidden
  90267. */
  90268. _actionManager: Nullable<AbstractActionManager>;
  90269. /**
  90270. * Adds action to chain of actions, may be a DoNothingAction
  90271. * @param action defines the next action to execute
  90272. * @returns The action passed in
  90273. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90274. */
  90275. then(action: IAction): IAction;
  90276. }
  90277. /**
  90278. * The action to be carried out following a trigger
  90279. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90280. */
  90281. export class Action implements IAction {
  90282. /** the trigger, with or without parameters, for the action */
  90283. triggerOptions: any;
  90284. /**
  90285. * Trigger for the action
  90286. */
  90287. trigger: number;
  90288. /**
  90289. * Internal only - manager for action
  90290. * @hidden
  90291. */
  90292. _actionManager: ActionManager;
  90293. private _nextActiveAction;
  90294. private _child;
  90295. private _condition?;
  90296. private _triggerParameter;
  90297. /**
  90298. * An event triggered prior to action being executed.
  90299. */
  90300. onBeforeExecuteObservable: Observable<Action>;
  90301. /**
  90302. * Creates a new Action
  90303. * @param triggerOptions the trigger, with or without parameters, for the action
  90304. * @param condition an optional determinant of action
  90305. */
  90306. constructor(
  90307. /** the trigger, with or without parameters, for the action */
  90308. triggerOptions: any, condition?: Condition);
  90309. /**
  90310. * Internal only
  90311. * @hidden
  90312. */
  90313. _prepare(): void;
  90314. /**
  90315. * Gets the trigger parameters
  90316. * @returns the trigger parameters
  90317. */
  90318. getTriggerParameter(): any;
  90319. /**
  90320. * Internal only - executes current action event
  90321. * @hidden
  90322. */
  90323. _executeCurrent(evt?: ActionEvent): void;
  90324. /**
  90325. * Execute placeholder for child classes
  90326. * @param evt optional action event
  90327. */
  90328. execute(evt?: ActionEvent): void;
  90329. /**
  90330. * Skips to next active action
  90331. */
  90332. skipToNextActiveAction(): void;
  90333. /**
  90334. * Adds action to chain of actions, may be a DoNothingAction
  90335. * @param action defines the next action to execute
  90336. * @returns The action passed in
  90337. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90338. */
  90339. then(action: Action): Action;
  90340. /**
  90341. * Internal only
  90342. * @hidden
  90343. */
  90344. _getProperty(propertyPath: string): string;
  90345. /**
  90346. * Internal only
  90347. * @hidden
  90348. */
  90349. _getEffectiveTarget(target: any, propertyPath: string): any;
  90350. /**
  90351. * Serialize placeholder for child classes
  90352. * @param parent of child
  90353. * @returns the serialized object
  90354. */
  90355. serialize(parent: any): any;
  90356. /**
  90357. * Internal only called by serialize
  90358. * @hidden
  90359. */
  90360. protected _serialize(serializedAction: any, parent?: any): any;
  90361. /**
  90362. * Internal only
  90363. * @hidden
  90364. */
  90365. static _SerializeValueAsString: (value: any) => string;
  90366. /**
  90367. * Internal only
  90368. * @hidden
  90369. */
  90370. static _GetTargetProperty: (target: Scene | Node) => {
  90371. name: string;
  90372. targetType: string;
  90373. value: string;
  90374. };
  90375. }
  90376. }
  90377. declare module BABYLON {
  90378. /**
  90379. * A Condition applied to an Action
  90380. */
  90381. export class Condition {
  90382. /**
  90383. * Internal only - manager for action
  90384. * @hidden
  90385. */
  90386. _actionManager: ActionManager;
  90387. /**
  90388. * Internal only
  90389. * @hidden
  90390. */
  90391. _evaluationId: number;
  90392. /**
  90393. * Internal only
  90394. * @hidden
  90395. */
  90396. _currentResult: boolean;
  90397. /**
  90398. * Creates a new Condition
  90399. * @param actionManager the manager of the action the condition is applied to
  90400. */
  90401. constructor(actionManager: ActionManager);
  90402. /**
  90403. * Check if the current condition is valid
  90404. * @returns a boolean
  90405. */
  90406. isValid(): boolean;
  90407. /**
  90408. * Internal only
  90409. * @hidden
  90410. */
  90411. _getProperty(propertyPath: string): string;
  90412. /**
  90413. * Internal only
  90414. * @hidden
  90415. */
  90416. _getEffectiveTarget(target: any, propertyPath: string): any;
  90417. /**
  90418. * Serialize placeholder for child classes
  90419. * @returns the serialized object
  90420. */
  90421. serialize(): any;
  90422. /**
  90423. * Internal only
  90424. * @hidden
  90425. */
  90426. protected _serialize(serializedCondition: any): any;
  90427. }
  90428. /**
  90429. * Defines specific conditional operators as extensions of Condition
  90430. */
  90431. export class ValueCondition extends Condition {
  90432. /** path to specify the property of the target the conditional operator uses */
  90433. propertyPath: string;
  90434. /** the value compared by the conditional operator against the current value of the property */
  90435. value: any;
  90436. /** the conditional operator, default ValueCondition.IsEqual */
  90437. operator: number;
  90438. /**
  90439. * Internal only
  90440. * @hidden
  90441. */
  90442. private static _IsEqual;
  90443. /**
  90444. * Internal only
  90445. * @hidden
  90446. */
  90447. private static _IsDifferent;
  90448. /**
  90449. * Internal only
  90450. * @hidden
  90451. */
  90452. private static _IsGreater;
  90453. /**
  90454. * Internal only
  90455. * @hidden
  90456. */
  90457. private static _IsLesser;
  90458. /**
  90459. * returns the number for IsEqual
  90460. */
  90461. static get IsEqual(): number;
  90462. /**
  90463. * Returns the number for IsDifferent
  90464. */
  90465. static get IsDifferent(): number;
  90466. /**
  90467. * Returns the number for IsGreater
  90468. */
  90469. static get IsGreater(): number;
  90470. /**
  90471. * Returns the number for IsLesser
  90472. */
  90473. static get IsLesser(): number;
  90474. /**
  90475. * Internal only The action manager for the condition
  90476. * @hidden
  90477. */
  90478. _actionManager: ActionManager;
  90479. /**
  90480. * Internal only
  90481. * @hidden
  90482. */
  90483. private _target;
  90484. /**
  90485. * Internal only
  90486. * @hidden
  90487. */
  90488. private _effectiveTarget;
  90489. /**
  90490. * Internal only
  90491. * @hidden
  90492. */
  90493. private _property;
  90494. /**
  90495. * Creates a new ValueCondition
  90496. * @param actionManager manager for the action the condition applies to
  90497. * @param target for the action
  90498. * @param propertyPath path to specify the property of the target the conditional operator uses
  90499. * @param value the value compared by the conditional operator against the current value of the property
  90500. * @param operator the conditional operator, default ValueCondition.IsEqual
  90501. */
  90502. constructor(actionManager: ActionManager, target: any,
  90503. /** path to specify the property of the target the conditional operator uses */
  90504. propertyPath: string,
  90505. /** the value compared by the conditional operator against the current value of the property */
  90506. value: any,
  90507. /** the conditional operator, default ValueCondition.IsEqual */
  90508. operator?: number);
  90509. /**
  90510. * Compares the given value with the property value for the specified conditional operator
  90511. * @returns the result of the comparison
  90512. */
  90513. isValid(): boolean;
  90514. /**
  90515. * Serialize the ValueCondition into a JSON compatible object
  90516. * @returns serialization object
  90517. */
  90518. serialize(): any;
  90519. /**
  90520. * Gets the name of the conditional operator for the ValueCondition
  90521. * @param operator the conditional operator
  90522. * @returns the name
  90523. */
  90524. static GetOperatorName(operator: number): string;
  90525. }
  90526. /**
  90527. * Defines a predicate condition as an extension of Condition
  90528. */
  90529. export class PredicateCondition extends Condition {
  90530. /** defines the predicate function used to validate the condition */
  90531. predicate: () => boolean;
  90532. /**
  90533. * Internal only - manager for action
  90534. * @hidden
  90535. */
  90536. _actionManager: ActionManager;
  90537. /**
  90538. * Creates a new PredicateCondition
  90539. * @param actionManager manager for the action the condition applies to
  90540. * @param predicate defines the predicate function used to validate the condition
  90541. */
  90542. constructor(actionManager: ActionManager,
  90543. /** defines the predicate function used to validate the condition */
  90544. predicate: () => boolean);
  90545. /**
  90546. * @returns the validity of the predicate condition
  90547. */
  90548. isValid(): boolean;
  90549. }
  90550. /**
  90551. * Defines a state condition as an extension of Condition
  90552. */
  90553. export class StateCondition extends Condition {
  90554. /** Value to compare with target state */
  90555. value: string;
  90556. /**
  90557. * Internal only - manager for action
  90558. * @hidden
  90559. */
  90560. _actionManager: ActionManager;
  90561. /**
  90562. * Internal only
  90563. * @hidden
  90564. */
  90565. private _target;
  90566. /**
  90567. * Creates a new StateCondition
  90568. * @param actionManager manager for the action the condition applies to
  90569. * @param target of the condition
  90570. * @param value to compare with target state
  90571. */
  90572. constructor(actionManager: ActionManager, target: any,
  90573. /** Value to compare with target state */
  90574. value: string);
  90575. /**
  90576. * Gets a boolean indicating if the current condition is met
  90577. * @returns the validity of the state
  90578. */
  90579. isValid(): boolean;
  90580. /**
  90581. * Serialize the StateCondition into a JSON compatible object
  90582. * @returns serialization object
  90583. */
  90584. serialize(): any;
  90585. }
  90586. }
  90587. declare module BABYLON {
  90588. /**
  90589. * This defines an action responsible to toggle a boolean once triggered.
  90590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90591. */
  90592. export class SwitchBooleanAction extends Action {
  90593. /**
  90594. * The path to the boolean property in the target object
  90595. */
  90596. propertyPath: string;
  90597. private _target;
  90598. private _effectiveTarget;
  90599. private _property;
  90600. /**
  90601. * Instantiate the action
  90602. * @param triggerOptions defines the trigger options
  90603. * @param target defines the object containing the boolean
  90604. * @param propertyPath defines the path to the boolean property in the target object
  90605. * @param condition defines the trigger related conditions
  90606. */
  90607. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90608. /** @hidden */
  90609. _prepare(): void;
  90610. /**
  90611. * Execute the action toggle the boolean value.
  90612. */
  90613. execute(): void;
  90614. /**
  90615. * Serializes the actions and its related information.
  90616. * @param parent defines the object to serialize in
  90617. * @returns the serialized object
  90618. */
  90619. serialize(parent: any): any;
  90620. }
  90621. /**
  90622. * This defines an action responsible to set a the state field of the target
  90623. * to a desired value once triggered.
  90624. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90625. */
  90626. export class SetStateAction extends Action {
  90627. /**
  90628. * The value to store in the state field.
  90629. */
  90630. value: string;
  90631. private _target;
  90632. /**
  90633. * Instantiate the action
  90634. * @param triggerOptions defines the trigger options
  90635. * @param target defines the object containing the state property
  90636. * @param value defines the value to store in the state field
  90637. * @param condition defines the trigger related conditions
  90638. */
  90639. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90640. /**
  90641. * Execute the action and store the value on the target state property.
  90642. */
  90643. execute(): void;
  90644. /**
  90645. * Serializes the actions and its related information.
  90646. * @param parent defines the object to serialize in
  90647. * @returns the serialized object
  90648. */
  90649. serialize(parent: any): any;
  90650. }
  90651. /**
  90652. * This defines an action responsible to set a property of the target
  90653. * to a desired value once triggered.
  90654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90655. */
  90656. export class SetValueAction extends Action {
  90657. /**
  90658. * The path of the property to set in the target.
  90659. */
  90660. propertyPath: string;
  90661. /**
  90662. * The value to set in the property
  90663. */
  90664. value: any;
  90665. private _target;
  90666. private _effectiveTarget;
  90667. private _property;
  90668. /**
  90669. * Instantiate the action
  90670. * @param triggerOptions defines the trigger options
  90671. * @param target defines the object containing the property
  90672. * @param propertyPath defines the path of the property to set in the target
  90673. * @param value defines the value to set in the property
  90674. * @param condition defines the trigger related conditions
  90675. */
  90676. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90677. /** @hidden */
  90678. _prepare(): void;
  90679. /**
  90680. * Execute the action and set the targetted property to the desired value.
  90681. */
  90682. execute(): void;
  90683. /**
  90684. * Serializes the actions and its related information.
  90685. * @param parent defines the object to serialize in
  90686. * @returns the serialized object
  90687. */
  90688. serialize(parent: any): any;
  90689. }
  90690. /**
  90691. * This defines an action responsible to increment the target value
  90692. * to a desired value once triggered.
  90693. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90694. */
  90695. export class IncrementValueAction extends Action {
  90696. /**
  90697. * The path of the property to increment in the target.
  90698. */
  90699. propertyPath: string;
  90700. /**
  90701. * The value we should increment the property by.
  90702. */
  90703. value: any;
  90704. private _target;
  90705. private _effectiveTarget;
  90706. private _property;
  90707. /**
  90708. * Instantiate the action
  90709. * @param triggerOptions defines the trigger options
  90710. * @param target defines the object containing the property
  90711. * @param propertyPath defines the path of the property to increment in the target
  90712. * @param value defines the value value we should increment the property by
  90713. * @param condition defines the trigger related conditions
  90714. */
  90715. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90716. /** @hidden */
  90717. _prepare(): void;
  90718. /**
  90719. * Execute the action and increment the target of the value amount.
  90720. */
  90721. execute(): void;
  90722. /**
  90723. * Serializes the actions and its related information.
  90724. * @param parent defines the object to serialize in
  90725. * @returns the serialized object
  90726. */
  90727. serialize(parent: any): any;
  90728. }
  90729. /**
  90730. * This defines an action responsible to start an animation once triggered.
  90731. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90732. */
  90733. export class PlayAnimationAction extends Action {
  90734. /**
  90735. * Where the animation should start (animation frame)
  90736. */
  90737. from: number;
  90738. /**
  90739. * Where the animation should stop (animation frame)
  90740. */
  90741. to: number;
  90742. /**
  90743. * Define if the animation should loop or stop after the first play.
  90744. */
  90745. loop?: boolean;
  90746. private _target;
  90747. /**
  90748. * Instantiate the action
  90749. * @param triggerOptions defines the trigger options
  90750. * @param target defines the target animation or animation name
  90751. * @param from defines from where the animation should start (animation frame)
  90752. * @param end defines where the animation should stop (animation frame)
  90753. * @param loop defines if the animation should loop or stop after the first play
  90754. * @param condition defines the trigger related conditions
  90755. */
  90756. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90757. /** @hidden */
  90758. _prepare(): void;
  90759. /**
  90760. * Execute the action and play the animation.
  90761. */
  90762. execute(): void;
  90763. /**
  90764. * Serializes the actions and its related information.
  90765. * @param parent defines the object to serialize in
  90766. * @returns the serialized object
  90767. */
  90768. serialize(parent: any): any;
  90769. }
  90770. /**
  90771. * This defines an action responsible to stop an animation once triggered.
  90772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90773. */
  90774. export class StopAnimationAction extends Action {
  90775. private _target;
  90776. /**
  90777. * Instantiate the action
  90778. * @param triggerOptions defines the trigger options
  90779. * @param target defines the target animation or animation name
  90780. * @param condition defines the trigger related conditions
  90781. */
  90782. constructor(triggerOptions: any, target: any, condition?: Condition);
  90783. /** @hidden */
  90784. _prepare(): void;
  90785. /**
  90786. * Execute the action and stop the animation.
  90787. */
  90788. execute(): void;
  90789. /**
  90790. * Serializes the actions and its related information.
  90791. * @param parent defines the object to serialize in
  90792. * @returns the serialized object
  90793. */
  90794. serialize(parent: any): any;
  90795. }
  90796. /**
  90797. * This defines an action responsible that does nothing once triggered.
  90798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90799. */
  90800. export class DoNothingAction extends Action {
  90801. /**
  90802. * Instantiate the action
  90803. * @param triggerOptions defines the trigger options
  90804. * @param condition defines the trigger related conditions
  90805. */
  90806. constructor(triggerOptions?: any, condition?: Condition);
  90807. /**
  90808. * Execute the action and do nothing.
  90809. */
  90810. execute(): void;
  90811. /**
  90812. * Serializes the actions and its related information.
  90813. * @param parent defines the object to serialize in
  90814. * @returns the serialized object
  90815. */
  90816. serialize(parent: any): any;
  90817. }
  90818. /**
  90819. * This defines an action responsible to trigger several actions once triggered.
  90820. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90821. */
  90822. export class CombineAction extends Action {
  90823. /**
  90824. * The list of aggregated animations to run.
  90825. */
  90826. children: Action[];
  90827. /**
  90828. * Instantiate the action
  90829. * @param triggerOptions defines the trigger options
  90830. * @param children defines the list of aggregated animations to run
  90831. * @param condition defines the trigger related conditions
  90832. */
  90833. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90834. /** @hidden */
  90835. _prepare(): void;
  90836. /**
  90837. * Execute the action and executes all the aggregated actions.
  90838. */
  90839. execute(evt: ActionEvent): void;
  90840. /**
  90841. * Serializes the actions and its related information.
  90842. * @param parent defines the object to serialize in
  90843. * @returns the serialized object
  90844. */
  90845. serialize(parent: any): any;
  90846. }
  90847. /**
  90848. * This defines an action responsible to run code (external event) once triggered.
  90849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90850. */
  90851. export class ExecuteCodeAction extends Action {
  90852. /**
  90853. * The callback function to run.
  90854. */
  90855. func: (evt: ActionEvent) => void;
  90856. /**
  90857. * Instantiate the action
  90858. * @param triggerOptions defines the trigger options
  90859. * @param func defines the callback function to run
  90860. * @param condition defines the trigger related conditions
  90861. */
  90862. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90863. /**
  90864. * Execute the action and run the attached code.
  90865. */
  90866. execute(evt: ActionEvent): void;
  90867. }
  90868. /**
  90869. * This defines an action responsible to set the parent property of the target once triggered.
  90870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90871. */
  90872. export class SetParentAction extends Action {
  90873. private _parent;
  90874. private _target;
  90875. /**
  90876. * Instantiate the action
  90877. * @param triggerOptions defines the trigger options
  90878. * @param target defines the target containing the parent property
  90879. * @param parent defines from where the animation should start (animation frame)
  90880. * @param condition defines the trigger related conditions
  90881. */
  90882. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90883. /** @hidden */
  90884. _prepare(): void;
  90885. /**
  90886. * Execute the action and set the parent property.
  90887. */
  90888. execute(): void;
  90889. /**
  90890. * Serializes the actions and its related information.
  90891. * @param parent defines the object to serialize in
  90892. * @returns the serialized object
  90893. */
  90894. serialize(parent: any): any;
  90895. }
  90896. }
  90897. declare module BABYLON {
  90898. /**
  90899. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90900. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90901. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90902. */
  90903. export class ActionManager extends AbstractActionManager {
  90904. /**
  90905. * Nothing
  90906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90907. */
  90908. static readonly NothingTrigger: number;
  90909. /**
  90910. * On pick
  90911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90912. */
  90913. static readonly OnPickTrigger: number;
  90914. /**
  90915. * On left pick
  90916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90917. */
  90918. static readonly OnLeftPickTrigger: number;
  90919. /**
  90920. * On right pick
  90921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90922. */
  90923. static readonly OnRightPickTrigger: number;
  90924. /**
  90925. * On center pick
  90926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90927. */
  90928. static readonly OnCenterPickTrigger: number;
  90929. /**
  90930. * On pick down
  90931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90932. */
  90933. static readonly OnPickDownTrigger: number;
  90934. /**
  90935. * On double pick
  90936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90937. */
  90938. static readonly OnDoublePickTrigger: number;
  90939. /**
  90940. * On pick up
  90941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90942. */
  90943. static readonly OnPickUpTrigger: number;
  90944. /**
  90945. * On pick out.
  90946. * This trigger will only be raised if you also declared a OnPickDown
  90947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90948. */
  90949. static readonly OnPickOutTrigger: number;
  90950. /**
  90951. * On long press
  90952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90953. */
  90954. static readonly OnLongPressTrigger: number;
  90955. /**
  90956. * On pointer over
  90957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90958. */
  90959. static readonly OnPointerOverTrigger: number;
  90960. /**
  90961. * On pointer out
  90962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90963. */
  90964. static readonly OnPointerOutTrigger: number;
  90965. /**
  90966. * On every frame
  90967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90968. */
  90969. static readonly OnEveryFrameTrigger: number;
  90970. /**
  90971. * On intersection enter
  90972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90973. */
  90974. static readonly OnIntersectionEnterTrigger: number;
  90975. /**
  90976. * On intersection exit
  90977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90978. */
  90979. static readonly OnIntersectionExitTrigger: number;
  90980. /**
  90981. * On key down
  90982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90983. */
  90984. static readonly OnKeyDownTrigger: number;
  90985. /**
  90986. * On key up
  90987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90988. */
  90989. static readonly OnKeyUpTrigger: number;
  90990. private _scene;
  90991. /**
  90992. * Creates a new action manager
  90993. * @param scene defines the hosting scene
  90994. */
  90995. constructor(scene: Scene);
  90996. /**
  90997. * Releases all associated resources
  90998. */
  90999. dispose(): void;
  91000. /**
  91001. * Gets hosting scene
  91002. * @returns the hosting scene
  91003. */
  91004. getScene(): Scene;
  91005. /**
  91006. * Does this action manager handles actions of any of the given triggers
  91007. * @param triggers defines the triggers to be tested
  91008. * @return a boolean indicating whether one (or more) of the triggers is handled
  91009. */
  91010. hasSpecificTriggers(triggers: number[]): boolean;
  91011. /**
  91012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91013. * speed.
  91014. * @param triggerA defines the trigger to be tested
  91015. * @param triggerB defines the trigger to be tested
  91016. * @return a boolean indicating whether one (or more) of the triggers is handled
  91017. */
  91018. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91019. /**
  91020. * Does this action manager handles actions of a given trigger
  91021. * @param trigger defines the trigger to be tested
  91022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91023. * @return whether the trigger is handled
  91024. */
  91025. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91026. /**
  91027. * Does this action manager has pointer triggers
  91028. */
  91029. get hasPointerTriggers(): boolean;
  91030. /**
  91031. * Does this action manager has pick triggers
  91032. */
  91033. get hasPickTriggers(): boolean;
  91034. /**
  91035. * Registers an action to this action manager
  91036. * @param action defines the action to be registered
  91037. * @return the action amended (prepared) after registration
  91038. */
  91039. registerAction(action: IAction): Nullable<IAction>;
  91040. /**
  91041. * Unregisters an action to this action manager
  91042. * @param action defines the action to be unregistered
  91043. * @return a boolean indicating whether the action has been unregistered
  91044. */
  91045. unregisterAction(action: IAction): Boolean;
  91046. /**
  91047. * Process a specific trigger
  91048. * @param trigger defines the trigger to process
  91049. * @param evt defines the event details to be processed
  91050. */
  91051. processTrigger(trigger: number, evt?: IActionEvent): void;
  91052. /** @hidden */
  91053. _getEffectiveTarget(target: any, propertyPath: string): any;
  91054. /** @hidden */
  91055. _getProperty(propertyPath: string): string;
  91056. /**
  91057. * Serialize this manager to a JSON object
  91058. * @param name defines the property name to store this manager
  91059. * @returns a JSON representation of this manager
  91060. */
  91061. serialize(name: string): any;
  91062. /**
  91063. * Creates a new ActionManager from a JSON data
  91064. * @param parsedActions defines the JSON data to read from
  91065. * @param object defines the hosting mesh
  91066. * @param scene defines the hosting scene
  91067. */
  91068. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91069. /**
  91070. * Get a trigger name by index
  91071. * @param trigger defines the trigger index
  91072. * @returns a trigger name
  91073. */
  91074. static GetTriggerName(trigger: number): string;
  91075. }
  91076. }
  91077. declare module BABYLON {
  91078. /**
  91079. * Class used to represent a sprite
  91080. * @see https://doc.babylonjs.com/babylon101/sprites
  91081. */
  91082. export class Sprite implements IAnimatable {
  91083. /** defines the name */
  91084. name: string;
  91085. /** Gets or sets the current world position */
  91086. position: Vector3;
  91087. /** Gets or sets the main color */
  91088. color: Color4;
  91089. /** Gets or sets the width */
  91090. width: number;
  91091. /** Gets or sets the height */
  91092. height: number;
  91093. /** Gets or sets rotation angle */
  91094. angle: number;
  91095. /** Gets or sets the cell index in the sprite sheet */
  91096. cellIndex: number;
  91097. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91098. cellRef: string;
  91099. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91100. invertU: boolean;
  91101. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91102. invertV: boolean;
  91103. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91104. disposeWhenFinishedAnimating: boolean;
  91105. /** Gets the list of attached animations */
  91106. animations: Nullable<Array<Animation>>;
  91107. /** Gets or sets a boolean indicating if the sprite can be picked */
  91108. isPickable: boolean;
  91109. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91110. useAlphaForPicking: boolean;
  91111. /** @hidden */
  91112. _xOffset: number;
  91113. /** @hidden */
  91114. _yOffset: number;
  91115. /** @hidden */
  91116. _xSize: number;
  91117. /** @hidden */
  91118. _ySize: number;
  91119. /**
  91120. * Gets or sets the associated action manager
  91121. */
  91122. actionManager: Nullable<ActionManager>;
  91123. /**
  91124. * An event triggered when the control has been disposed
  91125. */
  91126. onDisposeObservable: Observable<Sprite>;
  91127. private _animationStarted;
  91128. private _loopAnimation;
  91129. private _fromIndex;
  91130. private _toIndex;
  91131. private _delay;
  91132. private _direction;
  91133. private _manager;
  91134. private _time;
  91135. private _onAnimationEnd;
  91136. /**
  91137. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91138. */
  91139. isVisible: boolean;
  91140. /**
  91141. * Gets or sets the sprite size
  91142. */
  91143. get size(): number;
  91144. set size(value: number);
  91145. /**
  91146. * Returns a boolean indicating if the animation is started
  91147. */
  91148. get animationStarted(): boolean;
  91149. /**
  91150. * Gets or sets the unique id of the sprite
  91151. */
  91152. uniqueId: number;
  91153. /**
  91154. * Gets the manager of this sprite
  91155. */
  91156. get manager(): ISpriteManager;
  91157. /**
  91158. * Creates a new Sprite
  91159. * @param name defines the name
  91160. * @param manager defines the manager
  91161. */
  91162. constructor(
  91163. /** defines the name */
  91164. name: string, manager: ISpriteManager);
  91165. /**
  91166. * Returns the string "Sprite"
  91167. * @returns "Sprite"
  91168. */
  91169. getClassName(): string;
  91170. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91171. get fromIndex(): number;
  91172. set fromIndex(value: number);
  91173. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91174. get toIndex(): number;
  91175. set toIndex(value: number);
  91176. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91177. get loopAnimation(): boolean;
  91178. set loopAnimation(value: boolean);
  91179. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91180. get delay(): number;
  91181. set delay(value: number);
  91182. /**
  91183. * Starts an animation
  91184. * @param from defines the initial key
  91185. * @param to defines the end key
  91186. * @param loop defines if the animation must loop
  91187. * @param delay defines the start delay (in ms)
  91188. * @param onAnimationEnd defines a callback to call when animation ends
  91189. */
  91190. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91191. /** Stops current animation (if any) */
  91192. stopAnimation(): void;
  91193. /** @hidden */
  91194. _animate(deltaTime: number): void;
  91195. /** Release associated resources */
  91196. dispose(): void;
  91197. /**
  91198. * Serializes the sprite to a JSON object
  91199. * @returns the JSON object
  91200. */
  91201. serialize(): any;
  91202. /**
  91203. * Parses a JSON object to create a new sprite
  91204. * @param parsedSprite The JSON object to parse
  91205. * @param manager defines the hosting manager
  91206. * @returns the new sprite
  91207. */
  91208. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91209. }
  91210. }
  91211. declare module BABYLON {
  91212. /**
  91213. * Information about the result of picking within a scene
  91214. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91215. */
  91216. export class PickingInfo {
  91217. /** @hidden */
  91218. _pickingUnavailable: boolean;
  91219. /**
  91220. * If the pick collided with an object
  91221. */
  91222. hit: boolean;
  91223. /**
  91224. * Distance away where the pick collided
  91225. */
  91226. distance: number;
  91227. /**
  91228. * The location of pick collision
  91229. */
  91230. pickedPoint: Nullable<Vector3>;
  91231. /**
  91232. * The mesh corresponding the the pick collision
  91233. */
  91234. pickedMesh: Nullable<AbstractMesh>;
  91235. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91236. bu: number;
  91237. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91238. bv: number;
  91239. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91240. faceId: number;
  91241. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91242. subMeshFaceId: number;
  91243. /** Id of the the submesh that was picked */
  91244. subMeshId: number;
  91245. /** If a sprite was picked, this will be the sprite the pick collided with */
  91246. pickedSprite: Nullable<Sprite>;
  91247. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91248. thinInstanceIndex: number;
  91249. /**
  91250. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91251. */
  91252. originMesh: Nullable<AbstractMesh>;
  91253. /**
  91254. * The ray that was used to perform the picking.
  91255. */
  91256. ray: Nullable<Ray>;
  91257. /**
  91258. * Gets the normal correspodning to the face the pick collided with
  91259. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91260. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91261. * @returns The normal correspodning to the face the pick collided with
  91262. */
  91263. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91264. /**
  91265. * Gets the texture coordinates of where the pick occured
  91266. * @returns the vector containing the coordnates of the texture
  91267. */
  91268. getTextureCoordinates(): Nullable<Vector2>;
  91269. }
  91270. }
  91271. declare module BABYLON {
  91272. /**
  91273. * Class representing a ray with position and direction
  91274. */
  91275. export class Ray {
  91276. /** origin point */
  91277. origin: Vector3;
  91278. /** direction */
  91279. direction: Vector3;
  91280. /** length of the ray */
  91281. length: number;
  91282. private static readonly _TmpVector3;
  91283. private _tmpRay;
  91284. /**
  91285. * Creates a new ray
  91286. * @param origin origin point
  91287. * @param direction direction
  91288. * @param length length of the ray
  91289. */
  91290. constructor(
  91291. /** origin point */
  91292. origin: Vector3,
  91293. /** direction */
  91294. direction: Vector3,
  91295. /** length of the ray */
  91296. length?: number);
  91297. /**
  91298. * Checks if the ray intersects a box
  91299. * This does not account for the ray lenght by design to improve perfs.
  91300. * @param minimum bound of the box
  91301. * @param maximum bound of the box
  91302. * @param intersectionTreshold extra extend to be added to the box in all direction
  91303. * @returns if the box was hit
  91304. */
  91305. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91306. /**
  91307. * Checks if the ray intersects a box
  91308. * This does not account for the ray lenght by design to improve perfs.
  91309. * @param box the bounding box to check
  91310. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91311. * @returns if the box was hit
  91312. */
  91313. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91314. /**
  91315. * If the ray hits a sphere
  91316. * @param sphere the bounding sphere to check
  91317. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91318. * @returns true if it hits the sphere
  91319. */
  91320. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91321. /**
  91322. * If the ray hits a triange
  91323. * @param vertex0 triangle vertex
  91324. * @param vertex1 triangle vertex
  91325. * @param vertex2 triangle vertex
  91326. * @returns intersection information if hit
  91327. */
  91328. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91329. /**
  91330. * Checks if ray intersects a plane
  91331. * @param plane the plane to check
  91332. * @returns the distance away it was hit
  91333. */
  91334. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91335. /**
  91336. * Calculate the intercept of a ray on a given axis
  91337. * @param axis to check 'x' | 'y' | 'z'
  91338. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91339. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91340. */
  91341. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91342. /**
  91343. * Checks if ray intersects a mesh
  91344. * @param mesh the mesh to check
  91345. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91346. * @returns picking info of the intersecton
  91347. */
  91348. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91349. /**
  91350. * Checks if ray intersects a mesh
  91351. * @param meshes the meshes to check
  91352. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91353. * @param results array to store result in
  91354. * @returns Array of picking infos
  91355. */
  91356. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91357. private _comparePickingInfo;
  91358. private static smallnum;
  91359. private static rayl;
  91360. /**
  91361. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91362. * @param sega the first point of the segment to test the intersection against
  91363. * @param segb the second point of the segment to test the intersection against
  91364. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91365. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91366. */
  91367. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91368. /**
  91369. * Update the ray from viewport position
  91370. * @param x position
  91371. * @param y y position
  91372. * @param viewportWidth viewport width
  91373. * @param viewportHeight viewport height
  91374. * @param world world matrix
  91375. * @param view view matrix
  91376. * @param projection projection matrix
  91377. * @returns this ray updated
  91378. */
  91379. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91380. /**
  91381. * Creates a ray with origin and direction of 0,0,0
  91382. * @returns the new ray
  91383. */
  91384. static Zero(): Ray;
  91385. /**
  91386. * Creates a new ray from screen space and viewport
  91387. * @param x position
  91388. * @param y y position
  91389. * @param viewportWidth viewport width
  91390. * @param viewportHeight viewport height
  91391. * @param world world matrix
  91392. * @param view view matrix
  91393. * @param projection projection matrix
  91394. * @returns new ray
  91395. */
  91396. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91397. /**
  91398. * 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
  91399. * transformed to the given world matrix.
  91400. * @param origin The origin point
  91401. * @param end The end point
  91402. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91403. * @returns the new ray
  91404. */
  91405. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91406. /**
  91407. * Transforms a ray by a matrix
  91408. * @param ray ray to transform
  91409. * @param matrix matrix to apply
  91410. * @returns the resulting new ray
  91411. */
  91412. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91413. /**
  91414. * Transforms a ray by a matrix
  91415. * @param ray ray to transform
  91416. * @param matrix matrix to apply
  91417. * @param result ray to store result in
  91418. */
  91419. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91420. /**
  91421. * Unproject a ray from screen space to object space
  91422. * @param sourceX defines the screen space x coordinate to use
  91423. * @param sourceY defines the screen space y coordinate to use
  91424. * @param viewportWidth defines the current width of the viewport
  91425. * @param viewportHeight defines the current height of the viewport
  91426. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91427. * @param view defines the view matrix to use
  91428. * @param projection defines the projection matrix to use
  91429. */
  91430. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91431. }
  91432. /**
  91433. * Type used to define predicate used to select faces when a mesh intersection is detected
  91434. */
  91435. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91436. interface Scene {
  91437. /** @hidden */
  91438. _tempPickingRay: Nullable<Ray>;
  91439. /** @hidden */
  91440. _cachedRayForTransform: Ray;
  91441. /** @hidden */
  91442. _pickWithRayInverseMatrix: Matrix;
  91443. /** @hidden */
  91444. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91445. /** @hidden */
  91446. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91447. /** @hidden */
  91448. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91449. }
  91450. }
  91451. declare module BABYLON {
  91452. /**
  91453. * Groups all the scene component constants in one place to ease maintenance.
  91454. * @hidden
  91455. */
  91456. export class SceneComponentConstants {
  91457. static readonly NAME_EFFECTLAYER: string;
  91458. static readonly NAME_LAYER: string;
  91459. static readonly NAME_LENSFLARESYSTEM: string;
  91460. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91461. static readonly NAME_PARTICLESYSTEM: string;
  91462. static readonly NAME_GAMEPAD: string;
  91463. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91464. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91465. static readonly NAME_PREPASSRENDERER: string;
  91466. static readonly NAME_DEPTHRENDERER: string;
  91467. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91468. static readonly NAME_SPRITE: string;
  91469. static readonly NAME_SUBSURFACE: string;
  91470. static readonly NAME_OUTLINERENDERER: string;
  91471. static readonly NAME_PROCEDURALTEXTURE: string;
  91472. static readonly NAME_SHADOWGENERATOR: string;
  91473. static readonly NAME_OCTREE: string;
  91474. static readonly NAME_PHYSICSENGINE: string;
  91475. static readonly NAME_AUDIO: string;
  91476. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91477. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91478. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91479. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91480. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91481. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91482. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91483. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91484. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91485. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91486. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91487. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91488. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91489. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91490. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91491. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91492. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91493. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91494. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91495. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91496. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91497. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91498. static readonly STEP_AFTERRENDER_AUDIO: number;
  91499. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91500. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91501. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91502. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91503. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91504. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91505. static readonly STEP_POINTERMOVE_SPRITE: number;
  91506. static readonly STEP_POINTERDOWN_SPRITE: number;
  91507. static readonly STEP_POINTERUP_SPRITE: number;
  91508. }
  91509. /**
  91510. * This represents a scene component.
  91511. *
  91512. * This is used to decouple the dependency the scene is having on the different workloads like
  91513. * layers, post processes...
  91514. */
  91515. export interface ISceneComponent {
  91516. /**
  91517. * The name of the component. Each component must have a unique name.
  91518. */
  91519. name: string;
  91520. /**
  91521. * The scene the component belongs to.
  91522. */
  91523. scene: Scene;
  91524. /**
  91525. * Register the component to one instance of a scene.
  91526. */
  91527. register(): void;
  91528. /**
  91529. * Rebuilds the elements related to this component in case of
  91530. * context lost for instance.
  91531. */
  91532. rebuild(): void;
  91533. /**
  91534. * Disposes the component and the associated ressources.
  91535. */
  91536. dispose(): void;
  91537. }
  91538. /**
  91539. * This represents a SERIALIZABLE scene component.
  91540. *
  91541. * This extends Scene Component to add Serialization methods on top.
  91542. */
  91543. export interface ISceneSerializableComponent extends ISceneComponent {
  91544. /**
  91545. * Adds all the elements from the container to the scene
  91546. * @param container the container holding the elements
  91547. */
  91548. addFromContainer(container: AbstractScene): void;
  91549. /**
  91550. * Removes all the elements in the container from the scene
  91551. * @param container contains the elements to remove
  91552. * @param dispose if the removed element should be disposed (default: false)
  91553. */
  91554. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91555. /**
  91556. * Serializes the component data to the specified json object
  91557. * @param serializationObject The object to serialize to
  91558. */
  91559. serialize(serializationObject: any): void;
  91560. }
  91561. /**
  91562. * Strong typing of a Mesh related stage step action
  91563. */
  91564. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91565. /**
  91566. * Strong typing of a Evaluate Sub Mesh related stage step action
  91567. */
  91568. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91569. /**
  91570. * Strong typing of a Active Mesh related stage step action
  91571. */
  91572. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91573. /**
  91574. * Strong typing of a Camera related stage step action
  91575. */
  91576. export type CameraStageAction = (camera: Camera) => void;
  91577. /**
  91578. * Strong typing of a Camera Frame buffer related stage step action
  91579. */
  91580. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91581. /**
  91582. * Strong typing of a Render Target related stage step action
  91583. */
  91584. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91585. /**
  91586. * Strong typing of a RenderingGroup related stage step action
  91587. */
  91588. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91589. /**
  91590. * Strong typing of a Mesh Render related stage step action
  91591. */
  91592. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91593. /**
  91594. * Strong typing of a simple stage step action
  91595. */
  91596. export type SimpleStageAction = () => void;
  91597. /**
  91598. * Strong typing of a render target action.
  91599. */
  91600. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91601. /**
  91602. * Strong typing of a pointer move action.
  91603. */
  91604. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91605. /**
  91606. * Strong typing of a pointer up/down action.
  91607. */
  91608. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91609. /**
  91610. * Representation of a stage in the scene (Basically a list of ordered steps)
  91611. * @hidden
  91612. */
  91613. export class Stage<T extends Function> extends Array<{
  91614. index: number;
  91615. component: ISceneComponent;
  91616. action: T;
  91617. }> {
  91618. /**
  91619. * Hide ctor from the rest of the world.
  91620. * @param items The items to add.
  91621. */
  91622. private constructor();
  91623. /**
  91624. * Creates a new Stage.
  91625. * @returns A new instance of a Stage
  91626. */
  91627. static Create<T extends Function>(): Stage<T>;
  91628. /**
  91629. * Registers a step in an ordered way in the targeted stage.
  91630. * @param index Defines the position to register the step in
  91631. * @param component Defines the component attached to the step
  91632. * @param action Defines the action to launch during the step
  91633. */
  91634. registerStep(index: number, component: ISceneComponent, action: T): void;
  91635. /**
  91636. * Clears all the steps from the stage.
  91637. */
  91638. clear(): void;
  91639. }
  91640. }
  91641. declare module BABYLON {
  91642. interface Scene {
  91643. /** @hidden */
  91644. _pointerOverSprite: Nullable<Sprite>;
  91645. /** @hidden */
  91646. _pickedDownSprite: Nullable<Sprite>;
  91647. /** @hidden */
  91648. _tempSpritePickingRay: Nullable<Ray>;
  91649. /**
  91650. * All of the sprite managers added to this scene
  91651. * @see https://doc.babylonjs.com/babylon101/sprites
  91652. */
  91653. spriteManagers: Array<ISpriteManager>;
  91654. /**
  91655. * An event triggered when sprites rendering is about to start
  91656. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91657. */
  91658. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91659. /**
  91660. * An event triggered when sprites rendering is done
  91661. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91662. */
  91663. onAfterSpritesRenderingObservable: Observable<Scene>;
  91664. /** @hidden */
  91665. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91666. /** Launch a ray to try to pick a sprite in the scene
  91667. * @param x position on screen
  91668. * @param y position on screen
  91669. * @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
  91670. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91671. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91672. * @returns a PickingInfo
  91673. */
  91674. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91675. /** Use the given ray to pick a sprite in the scene
  91676. * @param ray The ray (in world space) to use to pick meshes
  91677. * @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
  91678. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91679. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91680. * @returns a PickingInfo
  91681. */
  91682. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91683. /** @hidden */
  91684. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91685. /** Launch a ray to try to pick sprites in the scene
  91686. * @param x position on screen
  91687. * @param y position on screen
  91688. * @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
  91689. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91690. * @returns a PickingInfo array
  91691. */
  91692. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91693. /** Use the given ray to pick sprites in the scene
  91694. * @param ray The ray (in world space) to use to pick meshes
  91695. * @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
  91696. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91697. * @returns a PickingInfo array
  91698. */
  91699. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91700. /**
  91701. * Force the sprite under the pointer
  91702. * @param sprite defines the sprite to use
  91703. */
  91704. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91705. /**
  91706. * Gets the sprite under the pointer
  91707. * @returns a Sprite or null if no sprite is under the pointer
  91708. */
  91709. getPointerOverSprite(): Nullable<Sprite>;
  91710. }
  91711. /**
  91712. * Defines the sprite scene component responsible to manage sprites
  91713. * in a given scene.
  91714. */
  91715. export class SpriteSceneComponent implements ISceneComponent {
  91716. /**
  91717. * The component name helpfull to identify the component in the list of scene components.
  91718. */
  91719. readonly name: string;
  91720. /**
  91721. * The scene the component belongs to.
  91722. */
  91723. scene: Scene;
  91724. /** @hidden */
  91725. private _spritePredicate;
  91726. /**
  91727. * Creates a new instance of the component for the given scene
  91728. * @param scene Defines the scene to register the component in
  91729. */
  91730. constructor(scene: Scene);
  91731. /**
  91732. * Registers the component in a given scene
  91733. */
  91734. register(): void;
  91735. /**
  91736. * Rebuilds the elements related to this component in case of
  91737. * context lost for instance.
  91738. */
  91739. rebuild(): void;
  91740. /**
  91741. * Disposes the component and the associated ressources.
  91742. */
  91743. dispose(): void;
  91744. private _pickSpriteButKeepRay;
  91745. private _pointerMove;
  91746. private _pointerDown;
  91747. private _pointerUp;
  91748. }
  91749. }
  91750. declare module BABYLON {
  91751. /** @hidden */
  91752. export var fogFragmentDeclaration: {
  91753. name: string;
  91754. shader: string;
  91755. };
  91756. }
  91757. declare module BABYLON {
  91758. /** @hidden */
  91759. export var fogFragment: {
  91760. name: string;
  91761. shader: string;
  91762. };
  91763. }
  91764. declare module BABYLON {
  91765. /** @hidden */
  91766. export var imageProcessingCompatibility: {
  91767. name: string;
  91768. shader: string;
  91769. };
  91770. }
  91771. declare module BABYLON {
  91772. /** @hidden */
  91773. export var spritesPixelShader: {
  91774. name: string;
  91775. shader: string;
  91776. };
  91777. }
  91778. declare module BABYLON {
  91779. /** @hidden */
  91780. export var fogVertexDeclaration: {
  91781. name: string;
  91782. shader: string;
  91783. };
  91784. }
  91785. declare module BABYLON {
  91786. /** @hidden */
  91787. export var spritesVertexShader: {
  91788. name: string;
  91789. shader: string;
  91790. };
  91791. }
  91792. declare module BABYLON {
  91793. /**
  91794. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91795. */
  91796. export interface ISpriteManager extends IDisposable {
  91797. /**
  91798. * Gets manager's name
  91799. */
  91800. name: string;
  91801. /**
  91802. * Restricts the camera to viewing objects with the same layerMask.
  91803. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91804. */
  91805. layerMask: number;
  91806. /**
  91807. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91808. */
  91809. isPickable: boolean;
  91810. /**
  91811. * Gets the hosting scene
  91812. */
  91813. scene: Scene;
  91814. /**
  91815. * Specifies the rendering group id for this mesh (0 by default)
  91816. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91817. */
  91818. renderingGroupId: number;
  91819. /**
  91820. * Defines the list of sprites managed by the manager.
  91821. */
  91822. sprites: Array<Sprite>;
  91823. /**
  91824. * Gets or sets the spritesheet texture
  91825. */
  91826. texture: Texture;
  91827. /** Defines the default width of a cell in the spritesheet */
  91828. cellWidth: number;
  91829. /** Defines the default height of a cell in the spritesheet */
  91830. cellHeight: number;
  91831. /**
  91832. * Tests the intersection of a sprite with a specific ray.
  91833. * @param ray The ray we are sending to test the collision
  91834. * @param camera The camera space we are sending rays in
  91835. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91836. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91837. * @returns picking info or null.
  91838. */
  91839. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91840. /**
  91841. * Intersects the sprites with a ray
  91842. * @param ray defines the ray to intersect with
  91843. * @param camera defines the current active camera
  91844. * @param predicate defines a predicate used to select candidate sprites
  91845. * @returns null if no hit or a PickingInfo array
  91846. */
  91847. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91848. /**
  91849. * Renders the list of sprites on screen.
  91850. */
  91851. render(): void;
  91852. }
  91853. /**
  91854. * Class used to manage multiple sprites on the same spritesheet
  91855. * @see https://doc.babylonjs.com/babylon101/sprites
  91856. */
  91857. export class SpriteManager implements ISpriteManager {
  91858. /** defines the manager's name */
  91859. name: string;
  91860. /** Define the Url to load snippets */
  91861. static SnippetUrl: string;
  91862. /** Snippet ID if the manager was created from the snippet server */
  91863. snippetId: string;
  91864. /** Gets the list of sprites */
  91865. sprites: Sprite[];
  91866. /** Gets or sets the rendering group id (0 by default) */
  91867. renderingGroupId: number;
  91868. /** Gets or sets camera layer mask */
  91869. layerMask: number;
  91870. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91871. fogEnabled: boolean;
  91872. /** Gets or sets a boolean indicating if the sprites are pickable */
  91873. isPickable: boolean;
  91874. /** Defines the default width of a cell in the spritesheet */
  91875. cellWidth: number;
  91876. /** Defines the default height of a cell in the spritesheet */
  91877. cellHeight: number;
  91878. /** Associative array from JSON sprite data file */
  91879. private _cellData;
  91880. /** Array of sprite names from JSON sprite data file */
  91881. private _spriteMap;
  91882. /** True when packed cell data from JSON file is ready*/
  91883. private _packedAndReady;
  91884. private _textureContent;
  91885. private _useInstancing;
  91886. /**
  91887. * An event triggered when the manager is disposed.
  91888. */
  91889. onDisposeObservable: Observable<SpriteManager>;
  91890. private _onDisposeObserver;
  91891. /**
  91892. * Callback called when the manager is disposed
  91893. */
  91894. set onDispose(callback: () => void);
  91895. private _capacity;
  91896. private _fromPacked;
  91897. private _spriteTexture;
  91898. private _epsilon;
  91899. private _scene;
  91900. private _vertexData;
  91901. private _buffer;
  91902. private _vertexBuffers;
  91903. private _spriteBuffer;
  91904. private _indexBuffer;
  91905. private _effectBase;
  91906. private _effectFog;
  91907. private _vertexBufferSize;
  91908. /**
  91909. * Gets or sets the unique id of the sprite
  91910. */
  91911. uniqueId: number;
  91912. /**
  91913. * Gets the array of sprites
  91914. */
  91915. get children(): Sprite[];
  91916. /**
  91917. * Gets the hosting scene
  91918. */
  91919. get scene(): Scene;
  91920. /**
  91921. * Gets the capacity of the manager
  91922. */
  91923. get capacity(): number;
  91924. /**
  91925. * Gets or sets the spritesheet texture
  91926. */
  91927. get texture(): Texture;
  91928. set texture(value: Texture);
  91929. private _blendMode;
  91930. /**
  91931. * Blend mode use to render the particle, it can be any of
  91932. * the static Constants.ALPHA_x properties provided in this class.
  91933. * Default value is Constants.ALPHA_COMBINE
  91934. */
  91935. get blendMode(): number;
  91936. set blendMode(blendMode: number);
  91937. /** Disables writing to the depth buffer when rendering the sprites.
  91938. * It can be handy to disable depth writing when using textures without alpha channel
  91939. * and setting some specific blend modes.
  91940. */
  91941. disableDepthWrite: boolean;
  91942. /**
  91943. * Creates a new sprite manager
  91944. * @param name defines the manager's name
  91945. * @param imgUrl defines the sprite sheet url
  91946. * @param capacity defines the maximum allowed number of sprites
  91947. * @param cellSize defines the size of a sprite cell
  91948. * @param scene defines the hosting scene
  91949. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91950. * @param samplingMode defines the smapling mode to use with spritesheet
  91951. * @param fromPacked set to false; do not alter
  91952. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91953. */
  91954. constructor(
  91955. /** defines the manager's name */
  91956. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91957. /**
  91958. * Returns the string "SpriteManager"
  91959. * @returns "SpriteManager"
  91960. */
  91961. getClassName(): string;
  91962. private _makePacked;
  91963. private _appendSpriteVertex;
  91964. private _checkTextureAlpha;
  91965. /**
  91966. * Intersects the sprites with a ray
  91967. * @param ray defines the ray to intersect with
  91968. * @param camera defines the current active camera
  91969. * @param predicate defines a predicate used to select candidate sprites
  91970. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91971. * @returns null if no hit or a PickingInfo
  91972. */
  91973. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91974. /**
  91975. * Intersects the sprites with a ray
  91976. * @param ray defines the ray to intersect with
  91977. * @param camera defines the current active camera
  91978. * @param predicate defines a predicate used to select candidate sprites
  91979. * @returns null if no hit or a PickingInfo array
  91980. */
  91981. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91982. /**
  91983. * Render all child sprites
  91984. */
  91985. render(): void;
  91986. /**
  91987. * Release associated resources
  91988. */
  91989. dispose(): void;
  91990. /**
  91991. * Serializes the sprite manager to a JSON object
  91992. * @param serializeTexture defines if the texture must be serialized as well
  91993. * @returns the JSON object
  91994. */
  91995. serialize(serializeTexture?: boolean): any;
  91996. /**
  91997. * Parses a JSON object to create a new sprite manager.
  91998. * @param parsedManager The JSON object to parse
  91999. * @param scene The scene to create the sprite managerin
  92000. * @param rootUrl The root url to use to load external dependencies like texture
  92001. * @returns the new sprite manager
  92002. */
  92003. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92004. /**
  92005. * Creates a sprite manager from a snippet saved in a remote file
  92006. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92007. * @param url defines the url to load from
  92008. * @param scene defines the hosting scene
  92009. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92010. * @returns a promise that will resolve to the new sprite manager
  92011. */
  92012. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92013. /**
  92014. * Creates a sprite manager from a snippet saved by the sprite editor
  92015. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92016. * @param scene defines the hosting scene
  92017. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92018. * @returns a promise that will resolve to the new sprite manager
  92019. */
  92020. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92021. }
  92022. }
  92023. declare module BABYLON {
  92024. /** Interface used by value gradients (color, factor, ...) */
  92025. export interface IValueGradient {
  92026. /**
  92027. * Gets or sets the gradient value (between 0 and 1)
  92028. */
  92029. gradient: number;
  92030. }
  92031. /** Class used to store color4 gradient */
  92032. export class ColorGradient implements IValueGradient {
  92033. /**
  92034. * Gets or sets the gradient value (between 0 and 1)
  92035. */
  92036. gradient: number;
  92037. /**
  92038. * Gets or sets first associated color
  92039. */
  92040. color1: Color4;
  92041. /**
  92042. * Gets or sets second associated color
  92043. */
  92044. color2?: Color4 | undefined;
  92045. /**
  92046. * Creates a new color4 gradient
  92047. * @param gradient gets or sets the gradient value (between 0 and 1)
  92048. * @param color1 gets or sets first associated color
  92049. * @param color2 gets or sets first second color
  92050. */
  92051. constructor(
  92052. /**
  92053. * Gets or sets the gradient value (between 0 and 1)
  92054. */
  92055. gradient: number,
  92056. /**
  92057. * Gets or sets first associated color
  92058. */
  92059. color1: Color4,
  92060. /**
  92061. * Gets or sets second associated color
  92062. */
  92063. color2?: Color4 | undefined);
  92064. /**
  92065. * Will get a color picked randomly between color1 and color2.
  92066. * If color2 is undefined then color1 will be used
  92067. * @param result defines the target Color4 to store the result in
  92068. */
  92069. getColorToRef(result: Color4): void;
  92070. }
  92071. /** Class used to store color 3 gradient */
  92072. export class Color3Gradient implements IValueGradient {
  92073. /**
  92074. * Gets or sets the gradient value (between 0 and 1)
  92075. */
  92076. gradient: number;
  92077. /**
  92078. * Gets or sets the associated color
  92079. */
  92080. color: Color3;
  92081. /**
  92082. * Creates a new color3 gradient
  92083. * @param gradient gets or sets the gradient value (between 0 and 1)
  92084. * @param color gets or sets associated color
  92085. */
  92086. constructor(
  92087. /**
  92088. * Gets or sets the gradient value (between 0 and 1)
  92089. */
  92090. gradient: number,
  92091. /**
  92092. * Gets or sets the associated color
  92093. */
  92094. color: Color3);
  92095. }
  92096. /** Class used to store factor gradient */
  92097. export class FactorGradient implements IValueGradient {
  92098. /**
  92099. * Gets or sets the gradient value (between 0 and 1)
  92100. */
  92101. gradient: number;
  92102. /**
  92103. * Gets or sets first associated factor
  92104. */
  92105. factor1: number;
  92106. /**
  92107. * Gets or sets second associated factor
  92108. */
  92109. factor2?: number | undefined;
  92110. /**
  92111. * Creates a new factor gradient
  92112. * @param gradient gets or sets the gradient value (between 0 and 1)
  92113. * @param factor1 gets or sets first associated factor
  92114. * @param factor2 gets or sets second associated factor
  92115. */
  92116. constructor(
  92117. /**
  92118. * Gets or sets the gradient value (between 0 and 1)
  92119. */
  92120. gradient: number,
  92121. /**
  92122. * Gets or sets first associated factor
  92123. */
  92124. factor1: number,
  92125. /**
  92126. * Gets or sets second associated factor
  92127. */
  92128. factor2?: number | undefined);
  92129. /**
  92130. * Will get a number picked randomly between factor1 and factor2.
  92131. * If factor2 is undefined then factor1 will be used
  92132. * @returns the picked number
  92133. */
  92134. getFactor(): number;
  92135. }
  92136. /**
  92137. * Helper used to simplify some generic gradient tasks
  92138. */
  92139. export class GradientHelper {
  92140. /**
  92141. * Gets the current gradient from an array of IValueGradient
  92142. * @param ratio defines the current ratio to get
  92143. * @param gradients defines the array of IValueGradient
  92144. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92145. */
  92146. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92147. }
  92148. }
  92149. declare module BABYLON {
  92150. interface ThinEngine {
  92151. /**
  92152. * Creates a raw texture
  92153. * @param data defines the data to store in the texture
  92154. * @param width defines the width of the texture
  92155. * @param height defines the height of the texture
  92156. * @param format defines the format of the data
  92157. * @param generateMipMaps defines if the engine should generate the mip levels
  92158. * @param invertY defines if data must be stored with Y axis inverted
  92159. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92160. * @param compression defines the compression used (null by default)
  92161. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92162. * @returns the raw texture inside an InternalTexture
  92163. */
  92164. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92165. /**
  92166. * Update a raw texture
  92167. * @param texture defines the texture to update
  92168. * @param data defines the data to store in the texture
  92169. * @param format defines the format of the data
  92170. * @param invertY defines if data must be stored with Y axis inverted
  92171. */
  92172. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92173. /**
  92174. * Update a raw texture
  92175. * @param texture defines the texture to update
  92176. * @param data defines the data to store in the texture
  92177. * @param format defines the format of the data
  92178. * @param invertY defines if data must be stored with Y axis inverted
  92179. * @param compression defines the compression used (null by default)
  92180. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92181. */
  92182. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92183. /**
  92184. * Creates a new raw cube texture
  92185. * @param data defines the array of data to use to create each face
  92186. * @param size defines the size of the textures
  92187. * @param format defines the format of the data
  92188. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92189. * @param generateMipMaps defines if the engine should generate the mip levels
  92190. * @param invertY defines if data must be stored with Y axis inverted
  92191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92192. * @param compression defines the compression used (null by default)
  92193. * @returns the cube texture as an InternalTexture
  92194. */
  92195. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92196. /**
  92197. * Update a raw cube texture
  92198. * @param texture defines the texture to udpdate
  92199. * @param data defines the data to store
  92200. * @param format defines the data format
  92201. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92202. * @param invertY defines if data must be stored with Y axis inverted
  92203. */
  92204. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92205. /**
  92206. * Update a raw cube texture
  92207. * @param texture defines the texture to udpdate
  92208. * @param data defines the data to store
  92209. * @param format defines the data format
  92210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92211. * @param invertY defines if data must be stored with Y axis inverted
  92212. * @param compression defines the compression used (null by default)
  92213. */
  92214. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92215. /**
  92216. * Update a raw cube texture
  92217. * @param texture defines the texture to udpdate
  92218. * @param data defines the data to store
  92219. * @param format defines the data format
  92220. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92221. * @param invertY defines if data must be stored with Y axis inverted
  92222. * @param compression defines the compression used (null by default)
  92223. * @param level defines which level of the texture to update
  92224. */
  92225. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92226. /**
  92227. * Creates a new raw cube texture from a specified url
  92228. * @param url defines the url where the data is located
  92229. * @param scene defines the current scene
  92230. * @param size defines the size of the textures
  92231. * @param format defines the format of the data
  92232. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92233. * @param noMipmap defines if the engine should avoid generating the mip levels
  92234. * @param callback defines a callback used to extract texture data from loaded data
  92235. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92236. * @param onLoad defines a callback called when texture is loaded
  92237. * @param onError defines a callback called if there is an error
  92238. * @returns the cube texture as an InternalTexture
  92239. */
  92240. 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;
  92241. /**
  92242. * Creates a new raw cube texture from a specified url
  92243. * @param url defines the url where the data is located
  92244. * @param scene defines the current scene
  92245. * @param size defines the size of the textures
  92246. * @param format defines the format of the data
  92247. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92248. * @param noMipmap defines if the engine should avoid generating the mip levels
  92249. * @param callback defines a callback used to extract texture data from loaded data
  92250. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92251. * @param onLoad defines a callback called when texture is loaded
  92252. * @param onError defines a callback called if there is an error
  92253. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92254. * @param invertY defines if data must be stored with Y axis inverted
  92255. * @returns the cube texture as an InternalTexture
  92256. */
  92257. 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;
  92258. /**
  92259. * Creates a new raw 3D texture
  92260. * @param data defines the data used to create the texture
  92261. * @param width defines the width of the texture
  92262. * @param height defines the height of the texture
  92263. * @param depth defines the depth of the texture
  92264. * @param format defines the format of the texture
  92265. * @param generateMipMaps defines if the engine must generate mip levels
  92266. * @param invertY defines if data must be stored with Y axis inverted
  92267. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92268. * @param compression defines the compressed used (can be null)
  92269. * @param textureType defines the compressed used (can be null)
  92270. * @returns a new raw 3D texture (stored in an InternalTexture)
  92271. */
  92272. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92273. /**
  92274. * Update a raw 3D texture
  92275. * @param texture defines the texture to update
  92276. * @param data defines the data to store
  92277. * @param format defines the data format
  92278. * @param invertY defines if data must be stored with Y axis inverted
  92279. */
  92280. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92281. /**
  92282. * Update a raw 3D texture
  92283. * @param texture defines the texture to update
  92284. * @param data defines the data to store
  92285. * @param format defines the data format
  92286. * @param invertY defines if data must be stored with Y axis inverted
  92287. * @param compression defines the used compression (can be null)
  92288. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92289. */
  92290. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92291. /**
  92292. * Creates a new raw 2D array texture
  92293. * @param data defines the data used to create the texture
  92294. * @param width defines the width of the texture
  92295. * @param height defines the height of the texture
  92296. * @param depth defines the number of layers of the texture
  92297. * @param format defines the format of the texture
  92298. * @param generateMipMaps defines if the engine must generate mip levels
  92299. * @param invertY defines if data must be stored with Y axis inverted
  92300. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92301. * @param compression defines the compressed used (can be null)
  92302. * @param textureType defines the compressed used (can be null)
  92303. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92304. */
  92305. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92306. /**
  92307. * Update a raw 2D array texture
  92308. * @param texture defines the texture to update
  92309. * @param data defines the data to store
  92310. * @param format defines the data format
  92311. * @param invertY defines if data must be stored with Y axis inverted
  92312. */
  92313. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92314. /**
  92315. * Update a raw 2D array texture
  92316. * @param texture defines the texture to update
  92317. * @param data defines the data to store
  92318. * @param format defines the data format
  92319. * @param invertY defines if data must be stored with Y axis inverted
  92320. * @param compression defines the used compression (can be null)
  92321. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92322. */
  92323. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92324. }
  92325. }
  92326. declare module BABYLON {
  92327. /**
  92328. * Raw texture can help creating a texture directly from an array of data.
  92329. * This can be super useful if you either get the data from an uncompressed source or
  92330. * if you wish to create your texture pixel by pixel.
  92331. */
  92332. export class RawTexture extends Texture {
  92333. /**
  92334. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92335. */
  92336. format: number;
  92337. /**
  92338. * Instantiates a new RawTexture.
  92339. * Raw texture can help creating a texture directly from an array of data.
  92340. * This can be super useful if you either get the data from an uncompressed source or
  92341. * if you wish to create your texture pixel by pixel.
  92342. * @param data define the array of data to use to create the texture
  92343. * @param width define the width of the texture
  92344. * @param height define the height of the texture
  92345. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92346. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92347. * @param generateMipMaps define whether mip maps should be generated or not
  92348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92350. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92351. */
  92352. constructor(data: ArrayBufferView, width: number, height: number,
  92353. /**
  92354. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92355. */
  92356. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92357. /**
  92358. * Updates the texture underlying data.
  92359. * @param data Define the new data of the texture
  92360. */
  92361. update(data: ArrayBufferView): void;
  92362. /**
  92363. * Creates a luminance texture from some data.
  92364. * @param data Define the texture data
  92365. * @param width Define the width of the texture
  92366. * @param height Define the height of the texture
  92367. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92371. * @returns the luminance texture
  92372. */
  92373. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92374. /**
  92375. * Creates a luminance alpha texture from some data.
  92376. * @param data Define the texture data
  92377. * @param width Define the width of the texture
  92378. * @param height Define the height of the texture
  92379. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92383. * @returns the luminance alpha texture
  92384. */
  92385. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92386. /**
  92387. * Creates an alpha texture from some data.
  92388. * @param data Define the texture data
  92389. * @param width Define the width of the texture
  92390. * @param height Define the height of the texture
  92391. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92395. * @returns the alpha texture
  92396. */
  92397. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92398. /**
  92399. * Creates a RGB texture from some data.
  92400. * @param data Define the texture data
  92401. * @param width Define the width of the texture
  92402. * @param height Define the height of the texture
  92403. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92408. * @returns the RGB alpha texture
  92409. */
  92410. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92411. /**
  92412. * Creates a RGBA texture from some data.
  92413. * @param data Define the texture data
  92414. * @param width Define the width of the texture
  92415. * @param height Define the height of the texture
  92416. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92420. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92421. * @returns the RGBA texture
  92422. */
  92423. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92424. /**
  92425. * Creates a R texture from some data.
  92426. * @param data Define the texture data
  92427. * @param width Define the width of the texture
  92428. * @param height Define the height of the texture
  92429. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92433. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92434. * @returns the R texture
  92435. */
  92436. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92437. }
  92438. }
  92439. declare module BABYLON {
  92440. interface ThinEngine {
  92441. /**
  92442. * Update a dynamic index buffer
  92443. * @param indexBuffer defines the target index buffer
  92444. * @param indices defines the data to update
  92445. * @param offset defines the offset in the target index buffer where update should start
  92446. */
  92447. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92448. /**
  92449. * Updates a dynamic vertex buffer.
  92450. * @param vertexBuffer the vertex buffer to update
  92451. * @param data the data used to update the vertex buffer
  92452. * @param byteOffset the byte offset of the data
  92453. * @param byteLength the byte length of the data
  92454. */
  92455. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92456. }
  92457. }
  92458. declare module BABYLON {
  92459. interface AbstractScene {
  92460. /**
  92461. * The list of procedural textures added to the scene
  92462. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92463. */
  92464. proceduralTextures: Array<ProceduralTexture>;
  92465. }
  92466. /**
  92467. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92468. * in a given scene.
  92469. */
  92470. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92471. /**
  92472. * The component name helpfull to identify the component in the list of scene components.
  92473. */
  92474. readonly name: string;
  92475. /**
  92476. * The scene the component belongs to.
  92477. */
  92478. scene: Scene;
  92479. /**
  92480. * Creates a new instance of the component for the given scene
  92481. * @param scene Defines the scene to register the component in
  92482. */
  92483. constructor(scene: Scene);
  92484. /**
  92485. * Registers the component in a given scene
  92486. */
  92487. register(): void;
  92488. /**
  92489. * Rebuilds the elements related to this component in case of
  92490. * context lost for instance.
  92491. */
  92492. rebuild(): void;
  92493. /**
  92494. * Disposes the component and the associated ressources.
  92495. */
  92496. dispose(): void;
  92497. private _beforeClear;
  92498. }
  92499. }
  92500. declare module BABYLON {
  92501. interface ThinEngine {
  92502. /**
  92503. * Creates a new render target cube texture
  92504. * @param size defines the size of the texture
  92505. * @param options defines the options used to create the texture
  92506. * @returns a new render target cube texture stored in an InternalTexture
  92507. */
  92508. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92509. }
  92510. }
  92511. declare module BABYLON {
  92512. /** @hidden */
  92513. export var proceduralVertexShader: {
  92514. name: string;
  92515. shader: string;
  92516. };
  92517. }
  92518. declare module BABYLON {
  92519. /**
  92520. * 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.
  92521. * This is the base class of any Procedural texture and contains most of the shareable code.
  92522. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92523. */
  92524. export class ProceduralTexture extends Texture {
  92525. /**
  92526. * Define if the texture is enabled or not (disabled texture will not render)
  92527. */
  92528. isEnabled: boolean;
  92529. /**
  92530. * Define if the texture must be cleared before rendering (default is true)
  92531. */
  92532. autoClear: boolean;
  92533. /**
  92534. * Callback called when the texture is generated
  92535. */
  92536. onGenerated: () => void;
  92537. /**
  92538. * Event raised when the texture is generated
  92539. */
  92540. onGeneratedObservable: Observable<ProceduralTexture>;
  92541. /**
  92542. * Event raised before the texture is generated
  92543. */
  92544. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92545. /**
  92546. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92547. */
  92548. nodeMaterialSource: Nullable<NodeMaterial>;
  92549. /** @hidden */
  92550. _generateMipMaps: boolean;
  92551. /** @hidden **/
  92552. _effect: Effect;
  92553. /** @hidden */
  92554. _textures: {
  92555. [key: string]: Texture;
  92556. };
  92557. /** @hidden */
  92558. protected _fallbackTexture: Nullable<Texture>;
  92559. private _size;
  92560. private _currentRefreshId;
  92561. private _frameId;
  92562. private _refreshRate;
  92563. private _vertexBuffers;
  92564. private _indexBuffer;
  92565. private _uniforms;
  92566. private _samplers;
  92567. private _fragment;
  92568. private _floats;
  92569. private _ints;
  92570. private _floatsArrays;
  92571. private _colors3;
  92572. private _colors4;
  92573. private _vectors2;
  92574. private _vectors3;
  92575. private _matrices;
  92576. private _fallbackTextureUsed;
  92577. private _fullEngine;
  92578. private _cachedDefines;
  92579. private _contentUpdateId;
  92580. private _contentData;
  92581. /**
  92582. * Instantiates a new procedural texture.
  92583. * 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.
  92584. * This is the base class of any Procedural texture and contains most of the shareable code.
  92585. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92586. * @param name Define the name of the texture
  92587. * @param size Define the size of the texture to create
  92588. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92589. * @param scene Define the scene the texture belongs to
  92590. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92591. * @param generateMipMaps Define if the texture should creates mip maps or not
  92592. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92593. * @param textureType The FBO internal texture type
  92594. */
  92595. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92596. /**
  92597. * The effect that is created when initializing the post process.
  92598. * @returns The created effect corresponding the the postprocess.
  92599. */
  92600. getEffect(): Effect;
  92601. /**
  92602. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92603. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92604. */
  92605. getContent(): Nullable<ArrayBufferView>;
  92606. private _createIndexBuffer;
  92607. /** @hidden */
  92608. _rebuild(): void;
  92609. /**
  92610. * Resets the texture in order to recreate its associated resources.
  92611. * This can be called in case of context loss
  92612. */
  92613. reset(): void;
  92614. protected _getDefines(): string;
  92615. /**
  92616. * Is the texture ready to be used ? (rendered at least once)
  92617. * @returns true if ready, otherwise, false.
  92618. */
  92619. isReady(): boolean;
  92620. /**
  92621. * Resets the refresh counter of the texture and start bak from scratch.
  92622. * Could be useful to regenerate the texture if it is setup to render only once.
  92623. */
  92624. resetRefreshCounter(): void;
  92625. /**
  92626. * Set the fragment shader to use in order to render the texture.
  92627. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92628. */
  92629. setFragment(fragment: any): void;
  92630. /**
  92631. * Define the refresh rate of the texture or the rendering frequency.
  92632. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92633. */
  92634. get refreshRate(): number;
  92635. set refreshRate(value: number);
  92636. /** @hidden */
  92637. _shouldRender(): boolean;
  92638. /**
  92639. * Get the size the texture is rendering at.
  92640. * @returns the size (on cube texture it is always squared)
  92641. */
  92642. getRenderSize(): RenderTargetTextureSize;
  92643. /**
  92644. * Resize the texture to new value.
  92645. * @param size Define the new size the texture should have
  92646. * @param generateMipMaps Define whether the new texture should create mip maps
  92647. */
  92648. resize(size: number, generateMipMaps: boolean): void;
  92649. private _checkUniform;
  92650. /**
  92651. * Set a texture in the shader program used to render.
  92652. * @param name Define the name of the uniform samplers as defined in the shader
  92653. * @param texture Define the texture to bind to this sampler
  92654. * @return the texture itself allowing "fluent" like uniform updates
  92655. */
  92656. setTexture(name: string, texture: Texture): ProceduralTexture;
  92657. /**
  92658. * Set a float in the shader.
  92659. * @param name Define the name of the uniform as defined in the shader
  92660. * @param value Define the value to give to the uniform
  92661. * @return the texture itself allowing "fluent" like uniform updates
  92662. */
  92663. setFloat(name: string, value: number): ProceduralTexture;
  92664. /**
  92665. * Set a int in the shader.
  92666. * @param name Define the name of the uniform as defined in the shader
  92667. * @param value Define the value to give to the uniform
  92668. * @return the texture itself allowing "fluent" like uniform updates
  92669. */
  92670. setInt(name: string, value: number): ProceduralTexture;
  92671. /**
  92672. * Set an array of floats in the shader.
  92673. * @param name Define the name of the uniform as defined in the shader
  92674. * @param value Define the value to give to the uniform
  92675. * @return the texture itself allowing "fluent" like uniform updates
  92676. */
  92677. setFloats(name: string, value: number[]): ProceduralTexture;
  92678. /**
  92679. * Set a vec3 in the shader from a Color3.
  92680. * @param name Define the name of the uniform as defined in the shader
  92681. * @param value Define the value to give to the uniform
  92682. * @return the texture itself allowing "fluent" like uniform updates
  92683. */
  92684. setColor3(name: string, value: Color3): ProceduralTexture;
  92685. /**
  92686. * Set a vec4 in the shader from a Color4.
  92687. * @param name Define the name of the uniform as defined in the shader
  92688. * @param value Define the value to give to the uniform
  92689. * @return the texture itself allowing "fluent" like uniform updates
  92690. */
  92691. setColor4(name: string, value: Color4): ProceduralTexture;
  92692. /**
  92693. * Set a vec2 in the shader from a Vector2.
  92694. * @param name Define the name of the uniform as defined in the shader
  92695. * @param value Define the value to give to the uniform
  92696. * @return the texture itself allowing "fluent" like uniform updates
  92697. */
  92698. setVector2(name: string, value: Vector2): ProceduralTexture;
  92699. /**
  92700. * Set a vec3 in the shader from a Vector3.
  92701. * @param name Define the name of the uniform as defined in the shader
  92702. * @param value Define the value to give to the uniform
  92703. * @return the texture itself allowing "fluent" like uniform updates
  92704. */
  92705. setVector3(name: string, value: Vector3): ProceduralTexture;
  92706. /**
  92707. * Set a mat4 in the shader from a MAtrix.
  92708. * @param name Define the name of the uniform as defined in the shader
  92709. * @param value Define the value to give to the uniform
  92710. * @return the texture itself allowing "fluent" like uniform updates
  92711. */
  92712. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92713. /**
  92714. * Render the texture to its associated render target.
  92715. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92716. */
  92717. render(useCameraPostProcess?: boolean): void;
  92718. /**
  92719. * Clone the texture.
  92720. * @returns the cloned texture
  92721. */
  92722. clone(): ProceduralTexture;
  92723. /**
  92724. * Dispose the texture and release its asoociated resources.
  92725. */
  92726. dispose(): void;
  92727. }
  92728. }
  92729. declare module BABYLON {
  92730. /**
  92731. * This represents the base class for particle system in Babylon.
  92732. * 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.
  92733. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92734. * @example https://doc.babylonjs.com/babylon101/particles
  92735. */
  92736. export class BaseParticleSystem {
  92737. /**
  92738. * Source color is added to the destination color without alpha affecting the result
  92739. */
  92740. static BLENDMODE_ONEONE: number;
  92741. /**
  92742. * Blend current color and particle color using particle’s alpha
  92743. */
  92744. static BLENDMODE_STANDARD: number;
  92745. /**
  92746. * Add current color and particle color multiplied by particle’s alpha
  92747. */
  92748. static BLENDMODE_ADD: number;
  92749. /**
  92750. * Multiply current color with particle color
  92751. */
  92752. static BLENDMODE_MULTIPLY: number;
  92753. /**
  92754. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92755. */
  92756. static BLENDMODE_MULTIPLYADD: number;
  92757. /**
  92758. * List of animations used by the particle system.
  92759. */
  92760. animations: Animation[];
  92761. /**
  92762. * Gets or sets the unique id of the particle system
  92763. */
  92764. uniqueId: number;
  92765. /**
  92766. * The id of the Particle system.
  92767. */
  92768. id: string;
  92769. /**
  92770. * The friendly name of the Particle system.
  92771. */
  92772. name: string;
  92773. /**
  92774. * Snippet ID if the particle system was created from the snippet server
  92775. */
  92776. snippetId: string;
  92777. /**
  92778. * The rendering group used by the Particle system to chose when to render.
  92779. */
  92780. renderingGroupId: number;
  92781. /**
  92782. * The emitter represents the Mesh or position we are attaching the particle system to.
  92783. */
  92784. emitter: Nullable<AbstractMesh | Vector3>;
  92785. /**
  92786. * The maximum number of particles to emit per frame
  92787. */
  92788. emitRate: number;
  92789. /**
  92790. * If you want to launch only a few particles at once, that can be done, as well.
  92791. */
  92792. manualEmitCount: number;
  92793. /**
  92794. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92795. */
  92796. updateSpeed: number;
  92797. /**
  92798. * The amount of time the particle system is running (depends of the overall update speed).
  92799. */
  92800. targetStopDuration: number;
  92801. /**
  92802. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92803. */
  92804. disposeOnStop: boolean;
  92805. /**
  92806. * Minimum power of emitting particles.
  92807. */
  92808. minEmitPower: number;
  92809. /**
  92810. * Maximum power of emitting particles.
  92811. */
  92812. maxEmitPower: number;
  92813. /**
  92814. * Minimum life time of emitting particles.
  92815. */
  92816. minLifeTime: number;
  92817. /**
  92818. * Maximum life time of emitting particles.
  92819. */
  92820. maxLifeTime: number;
  92821. /**
  92822. * Minimum Size of emitting particles.
  92823. */
  92824. minSize: number;
  92825. /**
  92826. * Maximum Size of emitting particles.
  92827. */
  92828. maxSize: number;
  92829. /**
  92830. * Minimum scale of emitting particles on X axis.
  92831. */
  92832. minScaleX: number;
  92833. /**
  92834. * Maximum scale of emitting particles on X axis.
  92835. */
  92836. maxScaleX: number;
  92837. /**
  92838. * Minimum scale of emitting particles on Y axis.
  92839. */
  92840. minScaleY: number;
  92841. /**
  92842. * Maximum scale of emitting particles on Y axis.
  92843. */
  92844. maxScaleY: number;
  92845. /**
  92846. * Gets or sets the minimal initial rotation in radians.
  92847. */
  92848. minInitialRotation: number;
  92849. /**
  92850. * Gets or sets the maximal initial rotation in radians.
  92851. */
  92852. maxInitialRotation: number;
  92853. /**
  92854. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92855. */
  92856. minAngularSpeed: number;
  92857. /**
  92858. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92859. */
  92860. maxAngularSpeed: number;
  92861. /**
  92862. * The texture used to render each particle. (this can be a spritesheet)
  92863. */
  92864. particleTexture: Nullable<BaseTexture>;
  92865. /**
  92866. * The layer mask we are rendering the particles through.
  92867. */
  92868. layerMask: number;
  92869. /**
  92870. * This can help using your own shader to render the particle system.
  92871. * The according effect will be created
  92872. */
  92873. customShader: any;
  92874. /**
  92875. * By default particle system starts as soon as they are created. This prevents the
  92876. * automatic start to happen and let you decide when to start emitting particles.
  92877. */
  92878. preventAutoStart: boolean;
  92879. private _noiseTexture;
  92880. /**
  92881. * Gets or sets a texture used to add random noise to particle positions
  92882. */
  92883. get noiseTexture(): Nullable<ProceduralTexture>;
  92884. set noiseTexture(value: Nullable<ProceduralTexture>);
  92885. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92886. noiseStrength: Vector3;
  92887. /**
  92888. * Callback triggered when the particle animation is ending.
  92889. */
  92890. onAnimationEnd: Nullable<() => void>;
  92891. /**
  92892. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92893. */
  92894. blendMode: number;
  92895. /**
  92896. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92897. * to override the particles.
  92898. */
  92899. forceDepthWrite: boolean;
  92900. /** 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 */
  92901. preWarmCycles: number;
  92902. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92903. preWarmStepOffset: number;
  92904. /**
  92905. * 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)
  92906. */
  92907. spriteCellChangeSpeed: number;
  92908. /**
  92909. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92910. */
  92911. startSpriteCellID: number;
  92912. /**
  92913. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92914. */
  92915. endSpriteCellID: number;
  92916. /**
  92917. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92918. */
  92919. spriteCellWidth: number;
  92920. /**
  92921. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92922. */
  92923. spriteCellHeight: number;
  92924. /**
  92925. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92926. */
  92927. spriteRandomStartCell: boolean;
  92928. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92929. translationPivot: Vector2;
  92930. /** @hidden */
  92931. protected _isAnimationSheetEnabled: boolean;
  92932. /**
  92933. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92934. */
  92935. beginAnimationOnStart: boolean;
  92936. /**
  92937. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92938. */
  92939. beginAnimationFrom: number;
  92940. /**
  92941. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92942. */
  92943. beginAnimationTo: number;
  92944. /**
  92945. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92946. */
  92947. beginAnimationLoop: boolean;
  92948. /**
  92949. * Gets or sets a world offset applied to all particles
  92950. */
  92951. worldOffset: Vector3;
  92952. /**
  92953. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92954. */
  92955. get isAnimationSheetEnabled(): boolean;
  92956. set isAnimationSheetEnabled(value: boolean);
  92957. /**
  92958. * Get hosting scene
  92959. * @returns the scene
  92960. */
  92961. getScene(): Nullable<Scene>;
  92962. /**
  92963. * You can use gravity if you want to give an orientation to your particles.
  92964. */
  92965. gravity: Vector3;
  92966. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92967. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92968. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92969. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92970. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92971. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92972. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92973. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92974. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92975. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92976. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92977. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92978. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92979. /**
  92980. * Defines the delay in milliseconds before starting the system (0 by default)
  92981. */
  92982. startDelay: number;
  92983. /**
  92984. * Gets the current list of drag gradients.
  92985. * You must use addDragGradient and removeDragGradient to udpate this list
  92986. * @returns the list of drag gradients
  92987. */
  92988. getDragGradients(): Nullable<Array<FactorGradient>>;
  92989. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92990. limitVelocityDamping: number;
  92991. /**
  92992. * Gets the current list of limit velocity gradients.
  92993. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92994. * @returns the list of limit velocity gradients
  92995. */
  92996. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92997. /**
  92998. * Gets the current list of color gradients.
  92999. * You must use addColorGradient and removeColorGradient to udpate this list
  93000. * @returns the list of color gradients
  93001. */
  93002. getColorGradients(): Nullable<Array<ColorGradient>>;
  93003. /**
  93004. * Gets the current list of size gradients.
  93005. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93006. * @returns the list of size gradients
  93007. */
  93008. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93009. /**
  93010. * Gets the current list of color remap gradients.
  93011. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93012. * @returns the list of color remap gradients
  93013. */
  93014. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93015. /**
  93016. * Gets the current list of alpha remap gradients.
  93017. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93018. * @returns the list of alpha remap gradients
  93019. */
  93020. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93021. /**
  93022. * Gets the current list of life time gradients.
  93023. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93024. * @returns the list of life time gradients
  93025. */
  93026. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93027. /**
  93028. * Gets the current list of angular speed gradients.
  93029. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93030. * @returns the list of angular speed gradients
  93031. */
  93032. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93033. /**
  93034. * Gets the current list of velocity gradients.
  93035. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93036. * @returns the list of velocity gradients
  93037. */
  93038. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93039. /**
  93040. * Gets the current list of start size gradients.
  93041. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93042. * @returns the list of start size gradients
  93043. */
  93044. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93045. /**
  93046. * Gets the current list of emit rate gradients.
  93047. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93048. * @returns the list of emit rate gradients
  93049. */
  93050. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93051. /**
  93052. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93053. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93054. */
  93055. get direction1(): Vector3;
  93056. set direction1(value: Vector3);
  93057. /**
  93058. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93059. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93060. */
  93061. get direction2(): Vector3;
  93062. set direction2(value: Vector3);
  93063. /**
  93064. * 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.
  93065. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93066. */
  93067. get minEmitBox(): Vector3;
  93068. set minEmitBox(value: Vector3);
  93069. /**
  93070. * 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.
  93071. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93072. */
  93073. get maxEmitBox(): Vector3;
  93074. set maxEmitBox(value: Vector3);
  93075. /**
  93076. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93077. */
  93078. color1: Color4;
  93079. /**
  93080. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93081. */
  93082. color2: Color4;
  93083. /**
  93084. * Color the particle will have at the end of its lifetime
  93085. */
  93086. colorDead: Color4;
  93087. /**
  93088. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93089. */
  93090. textureMask: Color4;
  93091. /**
  93092. * The particle emitter type defines the emitter used by the particle system.
  93093. * It can be for example box, sphere, or cone...
  93094. */
  93095. particleEmitterType: IParticleEmitterType;
  93096. /** @hidden */
  93097. _isSubEmitter: boolean;
  93098. /**
  93099. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93100. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93101. */
  93102. billboardMode: number;
  93103. protected _isBillboardBased: boolean;
  93104. /**
  93105. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93106. */
  93107. get isBillboardBased(): boolean;
  93108. set isBillboardBased(value: boolean);
  93109. /**
  93110. * The scene the particle system belongs to.
  93111. */
  93112. protected _scene: Nullable<Scene>;
  93113. /**
  93114. * The engine the particle system belongs to.
  93115. */
  93116. protected _engine: ThinEngine;
  93117. /**
  93118. * Local cache of defines for image processing.
  93119. */
  93120. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93121. /**
  93122. * Default configuration related to image processing available in the standard Material.
  93123. */
  93124. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93125. /**
  93126. * Gets the image processing configuration used either in this material.
  93127. */
  93128. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93129. /**
  93130. * Sets the Default image processing configuration used either in the this material.
  93131. *
  93132. * If sets to null, the scene one is in use.
  93133. */
  93134. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93135. /**
  93136. * Attaches a new image processing configuration to the Standard Material.
  93137. * @param configuration
  93138. */
  93139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93140. /** @hidden */
  93141. protected _reset(): void;
  93142. /** @hidden */
  93143. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93144. /**
  93145. * Instantiates a particle system.
  93146. * 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.
  93147. * @param name The name of the particle system
  93148. */
  93149. constructor(name: string);
  93150. /**
  93151. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93152. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93153. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93154. * @returns the emitter
  93155. */
  93156. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93157. /**
  93158. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93159. * @param radius The radius of the hemisphere to emit from
  93160. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93161. * @returns the emitter
  93162. */
  93163. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93164. /**
  93165. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93166. * @param radius The radius of the sphere to emit from
  93167. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93168. * @returns the emitter
  93169. */
  93170. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93171. /**
  93172. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93173. * @param radius The radius of the sphere to emit from
  93174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93176. * @returns the emitter
  93177. */
  93178. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93179. /**
  93180. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93181. * @param radius The radius of the emission cylinder
  93182. * @param height The height of the emission cylinder
  93183. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93184. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93185. * @returns the emitter
  93186. */
  93187. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93188. /**
  93189. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93190. * @param radius The radius of the cylinder to emit from
  93191. * @param height The height of the emission cylinder
  93192. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93193. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93194. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93195. * @returns the emitter
  93196. */
  93197. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93198. /**
  93199. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93200. * @param radius The radius of the cone to emit from
  93201. * @param angle The base angle of the cone
  93202. * @returns the emitter
  93203. */
  93204. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93205. /**
  93206. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93209. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93210. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93211. * @returns the emitter
  93212. */
  93213. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93214. }
  93215. }
  93216. declare module BABYLON {
  93217. /**
  93218. * Type of sub emitter
  93219. */
  93220. export enum SubEmitterType {
  93221. /**
  93222. * Attached to the particle over it's lifetime
  93223. */
  93224. ATTACHED = 0,
  93225. /**
  93226. * Created when the particle dies
  93227. */
  93228. END = 1
  93229. }
  93230. /**
  93231. * Sub emitter class used to emit particles from an existing particle
  93232. */
  93233. export class SubEmitter {
  93234. /**
  93235. * the particle system to be used by the sub emitter
  93236. */
  93237. particleSystem: ParticleSystem;
  93238. /**
  93239. * Type of the submitter (Default: END)
  93240. */
  93241. type: SubEmitterType;
  93242. /**
  93243. * 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)
  93244. * Note: This only is supported when using an emitter of type Mesh
  93245. */
  93246. inheritDirection: boolean;
  93247. /**
  93248. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93249. */
  93250. inheritedVelocityAmount: number;
  93251. /**
  93252. * Creates a sub emitter
  93253. * @param particleSystem the particle system to be used by the sub emitter
  93254. */
  93255. constructor(
  93256. /**
  93257. * the particle system to be used by the sub emitter
  93258. */
  93259. particleSystem: ParticleSystem);
  93260. /**
  93261. * Clones the sub emitter
  93262. * @returns the cloned sub emitter
  93263. */
  93264. clone(): SubEmitter;
  93265. /**
  93266. * Serialize current object to a JSON object
  93267. * @returns the serialized object
  93268. */
  93269. serialize(): any;
  93270. /** @hidden */
  93271. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93272. /**
  93273. * Creates a new SubEmitter from a serialized JSON version
  93274. * @param serializationObject defines the JSON object to read from
  93275. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93276. * @param rootUrl defines the rootUrl for data loading
  93277. * @returns a new SubEmitter
  93278. */
  93279. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93280. /** Release associated resources */
  93281. dispose(): void;
  93282. }
  93283. }
  93284. declare module BABYLON {
  93285. /** @hidden */
  93286. export var imageProcessingDeclaration: {
  93287. name: string;
  93288. shader: string;
  93289. };
  93290. }
  93291. declare module BABYLON {
  93292. /** @hidden */
  93293. export var imageProcessingFunctions: {
  93294. name: string;
  93295. shader: string;
  93296. };
  93297. }
  93298. declare module BABYLON {
  93299. /** @hidden */
  93300. export var particlesPixelShader: {
  93301. name: string;
  93302. shader: string;
  93303. };
  93304. }
  93305. declare module BABYLON {
  93306. /** @hidden */
  93307. export var particlesVertexShader: {
  93308. name: string;
  93309. shader: string;
  93310. };
  93311. }
  93312. declare module BABYLON {
  93313. /**
  93314. * Interface used to define entities containing multiple clip planes
  93315. */
  93316. export interface IClipPlanesHolder {
  93317. /**
  93318. * Gets or sets the active clipplane 1
  93319. */
  93320. clipPlane: Nullable<Plane>;
  93321. /**
  93322. * Gets or sets the active clipplane 2
  93323. */
  93324. clipPlane2: Nullable<Plane>;
  93325. /**
  93326. * Gets or sets the active clipplane 3
  93327. */
  93328. clipPlane3: Nullable<Plane>;
  93329. /**
  93330. * Gets or sets the active clipplane 4
  93331. */
  93332. clipPlane4: Nullable<Plane>;
  93333. /**
  93334. * Gets or sets the active clipplane 5
  93335. */
  93336. clipPlane5: Nullable<Plane>;
  93337. /**
  93338. * Gets or sets the active clipplane 6
  93339. */
  93340. clipPlane6: Nullable<Plane>;
  93341. }
  93342. }
  93343. declare module BABYLON {
  93344. /**
  93345. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93346. *
  93347. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93348. *
  93349. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93350. */
  93351. export class ThinMaterialHelper {
  93352. /**
  93353. * Binds the clip plane information from the holder to the effect.
  93354. * @param effect The effect we are binding the data to
  93355. * @param holder The entity containing the clip plane information
  93356. */
  93357. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93358. }
  93359. }
  93360. declare module BABYLON {
  93361. interface ThinEngine {
  93362. /**
  93363. * Sets alpha constants used by some alpha blending modes
  93364. * @param r defines the red component
  93365. * @param g defines the green component
  93366. * @param b defines the blue component
  93367. * @param a defines the alpha component
  93368. */
  93369. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93370. /**
  93371. * Sets the current alpha mode
  93372. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93373. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93374. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93375. */
  93376. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93377. /**
  93378. * Gets the current alpha mode
  93379. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93380. * @returns the current alpha mode
  93381. */
  93382. getAlphaMode(): number;
  93383. /**
  93384. * Sets the current alpha equation
  93385. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93386. */
  93387. setAlphaEquation(equation: number): void;
  93388. /**
  93389. * Gets the current alpha equation.
  93390. * @returns the current alpha equation
  93391. */
  93392. getAlphaEquation(): number;
  93393. }
  93394. }
  93395. declare module BABYLON {
  93396. /**
  93397. * This represents a particle system in Babylon.
  93398. * 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.
  93399. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93400. * @example https://doc.babylonjs.com/babylon101/particles
  93401. */
  93402. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93403. /**
  93404. * Billboard mode will only apply to Y axis
  93405. */
  93406. static readonly BILLBOARDMODE_Y: number;
  93407. /**
  93408. * Billboard mode will apply to all axes
  93409. */
  93410. static readonly BILLBOARDMODE_ALL: number;
  93411. /**
  93412. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93413. */
  93414. static readonly BILLBOARDMODE_STRETCHED: number;
  93415. /**
  93416. * This function can be defined to provide custom update for active particles.
  93417. * This function will be called instead of regular update (age, position, color, etc.).
  93418. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93419. */
  93420. updateFunction: (particles: Particle[]) => void;
  93421. private _emitterWorldMatrix;
  93422. /**
  93423. * This function can be defined to specify initial direction for every new particle.
  93424. * It by default use the emitterType defined function
  93425. */
  93426. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93427. /**
  93428. * This function can be defined to specify initial position for every new particle.
  93429. * It by default use the emitterType defined function
  93430. */
  93431. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93432. /**
  93433. * @hidden
  93434. */
  93435. _inheritedVelocityOffset: Vector3;
  93436. /**
  93437. * An event triggered when the system is disposed
  93438. */
  93439. onDisposeObservable: Observable<IParticleSystem>;
  93440. /**
  93441. * An event triggered when the system is stopped
  93442. */
  93443. onStoppedObservable: Observable<IParticleSystem>;
  93444. private _onDisposeObserver;
  93445. /**
  93446. * Sets a callback that will be triggered when the system is disposed
  93447. */
  93448. set onDispose(callback: () => void);
  93449. private _particles;
  93450. private _epsilon;
  93451. private _capacity;
  93452. private _stockParticles;
  93453. private _newPartsExcess;
  93454. private _vertexData;
  93455. private _vertexBuffer;
  93456. private _vertexBuffers;
  93457. private _spriteBuffer;
  93458. private _indexBuffer;
  93459. private _effect;
  93460. private _customEffect;
  93461. private _cachedDefines;
  93462. private _scaledColorStep;
  93463. private _colorDiff;
  93464. private _scaledDirection;
  93465. private _scaledGravity;
  93466. private _currentRenderId;
  93467. private _alive;
  93468. private _useInstancing;
  93469. private _vertexArrayObject;
  93470. private _started;
  93471. private _stopped;
  93472. private _actualFrame;
  93473. private _scaledUpdateSpeed;
  93474. private _vertexBufferSize;
  93475. /** @hidden */
  93476. _currentEmitRateGradient: Nullable<FactorGradient>;
  93477. /** @hidden */
  93478. _currentEmitRate1: number;
  93479. /** @hidden */
  93480. _currentEmitRate2: number;
  93481. /** @hidden */
  93482. _currentStartSizeGradient: Nullable<FactorGradient>;
  93483. /** @hidden */
  93484. _currentStartSize1: number;
  93485. /** @hidden */
  93486. _currentStartSize2: number;
  93487. private readonly _rawTextureWidth;
  93488. private _rampGradientsTexture;
  93489. private _useRampGradients;
  93490. /** Gets or sets a matrix to use to compute projection */
  93491. defaultProjectionMatrix: Matrix;
  93492. /** Gets or sets a matrix to use to compute view */
  93493. defaultViewMatrix: Matrix;
  93494. /** Gets or sets a boolean indicating that ramp gradients must be used
  93495. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93496. */
  93497. get useRampGradients(): boolean;
  93498. set useRampGradients(value: boolean);
  93499. /**
  93500. * 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.
  93501. * 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: [])
  93502. */
  93503. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93504. private _subEmitters;
  93505. /**
  93506. * @hidden
  93507. * If the particle systems emitter should be disposed when the particle system is disposed
  93508. */
  93509. _disposeEmitterOnDispose: boolean;
  93510. /**
  93511. * The current active Sub-systems, this property is used by the root particle system only.
  93512. */
  93513. activeSubSystems: Array<ParticleSystem>;
  93514. /**
  93515. * Specifies if the particles are updated in emitter local space or world space
  93516. */
  93517. isLocal: boolean;
  93518. private _rootParticleSystem;
  93519. /**
  93520. * Gets the current list of active particles
  93521. */
  93522. get particles(): Particle[];
  93523. /**
  93524. * Gets the number of particles active at the same time.
  93525. * @returns The number of active particles.
  93526. */
  93527. getActiveCount(): number;
  93528. /**
  93529. * Returns the string "ParticleSystem"
  93530. * @returns a string containing the class name
  93531. */
  93532. getClassName(): string;
  93533. /**
  93534. * Gets a boolean indicating that the system is stopping
  93535. * @returns true if the system is currently stopping
  93536. */
  93537. isStopping(): boolean;
  93538. /**
  93539. * Gets the custom effect used to render the particles
  93540. * @param blendMode Blend mode for which the effect should be retrieved
  93541. * @returns The effect
  93542. */
  93543. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93544. /**
  93545. * Sets the custom effect used to render the particles
  93546. * @param effect The effect to set
  93547. * @param blendMode Blend mode for which the effect should be set
  93548. */
  93549. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93550. /** @hidden */
  93551. private _onBeforeDrawParticlesObservable;
  93552. /**
  93553. * Observable that will be called just before the particles are drawn
  93554. */
  93555. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93556. /**
  93557. * Gets the name of the particle vertex shader
  93558. */
  93559. get vertexShaderName(): string;
  93560. /**
  93561. * Instantiates a particle system.
  93562. * 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.
  93563. * @param name The name of the particle system
  93564. * @param capacity The max number of particles alive at the same time
  93565. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93566. * @param customEffect a custom effect used to change the way particles are rendered by default
  93567. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93568. * @param epsilon Offset used to render the particles
  93569. */
  93570. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93571. private _addFactorGradient;
  93572. private _removeFactorGradient;
  93573. /**
  93574. * Adds a new life time gradient
  93575. * @param gradient defines the gradient to use (between 0 and 1)
  93576. * @param factor defines the life time factor to affect to the specified gradient
  93577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93578. * @returns the current particle system
  93579. */
  93580. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93581. /**
  93582. * Remove a specific life time gradient
  93583. * @param gradient defines the gradient to remove
  93584. * @returns the current particle system
  93585. */
  93586. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93587. /**
  93588. * Adds a new size gradient
  93589. * @param gradient defines the gradient to use (between 0 and 1)
  93590. * @param factor defines the size factor to affect to the specified gradient
  93591. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93592. * @returns the current particle system
  93593. */
  93594. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93595. /**
  93596. * Remove a specific size gradient
  93597. * @param gradient defines the gradient to remove
  93598. * @returns the current particle system
  93599. */
  93600. removeSizeGradient(gradient: number): IParticleSystem;
  93601. /**
  93602. * Adds a new color remap gradient
  93603. * @param gradient defines the gradient to use (between 0 and 1)
  93604. * @param min defines the color remap minimal range
  93605. * @param max defines the color remap maximal range
  93606. * @returns the current particle system
  93607. */
  93608. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93609. /**
  93610. * Remove a specific color remap gradient
  93611. * @param gradient defines the gradient to remove
  93612. * @returns the current particle system
  93613. */
  93614. removeColorRemapGradient(gradient: number): IParticleSystem;
  93615. /**
  93616. * Adds a new alpha remap gradient
  93617. * @param gradient defines the gradient to use (between 0 and 1)
  93618. * @param min defines the alpha remap minimal range
  93619. * @param max defines the alpha remap maximal range
  93620. * @returns the current particle system
  93621. */
  93622. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93623. /**
  93624. * Remove a specific alpha remap gradient
  93625. * @param gradient defines the gradient to remove
  93626. * @returns the current particle system
  93627. */
  93628. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93629. /**
  93630. * Adds a new angular speed gradient
  93631. * @param gradient defines the gradient to use (between 0 and 1)
  93632. * @param factor defines the angular speed to affect to the specified gradient
  93633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93634. * @returns the current particle system
  93635. */
  93636. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93637. /**
  93638. * Remove a specific angular speed gradient
  93639. * @param gradient defines the gradient to remove
  93640. * @returns the current particle system
  93641. */
  93642. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93643. /**
  93644. * Adds a new velocity gradient
  93645. * @param gradient defines the gradient to use (between 0 and 1)
  93646. * @param factor defines the velocity to affect to the specified gradient
  93647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93648. * @returns the current particle system
  93649. */
  93650. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93651. /**
  93652. * Remove a specific velocity gradient
  93653. * @param gradient defines the gradient to remove
  93654. * @returns the current particle system
  93655. */
  93656. removeVelocityGradient(gradient: number): IParticleSystem;
  93657. /**
  93658. * Adds a new limit velocity gradient
  93659. * @param gradient defines the gradient to use (between 0 and 1)
  93660. * @param factor defines the limit velocity value to affect to the specified gradient
  93661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93662. * @returns the current particle system
  93663. */
  93664. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93665. /**
  93666. * Remove a specific limit velocity gradient
  93667. * @param gradient defines the gradient to remove
  93668. * @returns the current particle system
  93669. */
  93670. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93671. /**
  93672. * Adds a new drag gradient
  93673. * @param gradient defines the gradient to use (between 0 and 1)
  93674. * @param factor defines the drag value to affect to the specified gradient
  93675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93676. * @returns the current particle system
  93677. */
  93678. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93679. /**
  93680. * Remove a specific drag gradient
  93681. * @param gradient defines the gradient to remove
  93682. * @returns the current particle system
  93683. */
  93684. removeDragGradient(gradient: number): IParticleSystem;
  93685. /**
  93686. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93687. * @param gradient defines the gradient to use (between 0 and 1)
  93688. * @param factor defines the emit rate value to affect to the specified gradient
  93689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93690. * @returns the current particle system
  93691. */
  93692. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93693. /**
  93694. * Remove a specific emit rate gradient
  93695. * @param gradient defines the gradient to remove
  93696. * @returns the current particle system
  93697. */
  93698. removeEmitRateGradient(gradient: number): IParticleSystem;
  93699. /**
  93700. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93701. * @param gradient defines the gradient to use (between 0 and 1)
  93702. * @param factor defines the start size value to affect to the specified gradient
  93703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93704. * @returns the current particle system
  93705. */
  93706. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93707. /**
  93708. * Remove a specific start size gradient
  93709. * @param gradient defines the gradient to remove
  93710. * @returns the current particle system
  93711. */
  93712. removeStartSizeGradient(gradient: number): IParticleSystem;
  93713. private _createRampGradientTexture;
  93714. /**
  93715. * Gets the current list of ramp gradients.
  93716. * You must use addRampGradient and removeRampGradient to udpate this list
  93717. * @returns the list of ramp gradients
  93718. */
  93719. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93720. /** Force the system to rebuild all gradients that need to be resync */
  93721. forceRefreshGradients(): void;
  93722. private _syncRampGradientTexture;
  93723. /**
  93724. * Adds a new ramp gradient used to remap particle colors
  93725. * @param gradient defines the gradient to use (between 0 and 1)
  93726. * @param color defines the color to affect to the specified gradient
  93727. * @returns the current particle system
  93728. */
  93729. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93730. /**
  93731. * Remove a specific ramp gradient
  93732. * @param gradient defines the gradient to remove
  93733. * @returns the current particle system
  93734. */
  93735. removeRampGradient(gradient: number): ParticleSystem;
  93736. /**
  93737. * Adds a new color gradient
  93738. * @param gradient defines the gradient to use (between 0 and 1)
  93739. * @param color1 defines the color to affect to the specified gradient
  93740. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93741. * @returns this particle system
  93742. */
  93743. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93744. /**
  93745. * Remove a specific color gradient
  93746. * @param gradient defines the gradient to remove
  93747. * @returns this particle system
  93748. */
  93749. removeColorGradient(gradient: number): IParticleSystem;
  93750. private _fetchR;
  93751. protected _reset(): void;
  93752. private _resetEffect;
  93753. private _createVertexBuffers;
  93754. private _createIndexBuffer;
  93755. /**
  93756. * Gets the maximum number of particles active at the same time.
  93757. * @returns The max number of active particles.
  93758. */
  93759. getCapacity(): number;
  93760. /**
  93761. * Gets whether there are still active particles in the system.
  93762. * @returns True if it is alive, otherwise false.
  93763. */
  93764. isAlive(): boolean;
  93765. /**
  93766. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93767. * @returns True if it has been started, otherwise false.
  93768. */
  93769. isStarted(): boolean;
  93770. private _prepareSubEmitterInternalArray;
  93771. /**
  93772. * Starts the particle system and begins to emit
  93773. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93774. */
  93775. start(delay?: number): void;
  93776. /**
  93777. * Stops the particle system.
  93778. * @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.
  93779. */
  93780. stop(stopSubEmitters?: boolean): void;
  93781. /**
  93782. * Remove all active particles
  93783. */
  93784. reset(): void;
  93785. /**
  93786. * @hidden (for internal use only)
  93787. */
  93788. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93789. /**
  93790. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93791. * Its lifetime will start back at 0.
  93792. */
  93793. recycleParticle: (particle: Particle) => void;
  93794. private _stopSubEmitters;
  93795. private _createParticle;
  93796. private _removeFromRoot;
  93797. private _emitFromParticle;
  93798. private _update;
  93799. /** @hidden */
  93800. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93801. /** @hidden */
  93802. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93803. /**
  93804. * Fill the defines array according to the current settings of the particle system
  93805. * @param defines Array to be updated
  93806. * @param blendMode blend mode to take into account when updating the array
  93807. */
  93808. fillDefines(defines: Array<string>, blendMode: number): void;
  93809. /**
  93810. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93811. * @param uniforms Uniforms array to fill
  93812. * @param attributes Attributes array to fill
  93813. * @param samplers Samplers array to fill
  93814. */
  93815. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93816. /** @hidden */
  93817. private _getEffect;
  93818. /**
  93819. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93820. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93821. */
  93822. animate(preWarmOnly?: boolean): void;
  93823. private _appendParticleVertices;
  93824. /**
  93825. * Rebuilds the particle system.
  93826. */
  93827. rebuild(): void;
  93828. /**
  93829. * Is this system ready to be used/rendered
  93830. * @return true if the system is ready
  93831. */
  93832. isReady(): boolean;
  93833. private _render;
  93834. /**
  93835. * Renders the particle system in its current state.
  93836. * @returns the current number of particles
  93837. */
  93838. render(): number;
  93839. /**
  93840. * Disposes the particle system and free the associated resources
  93841. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93842. */
  93843. dispose(disposeTexture?: boolean): void;
  93844. /**
  93845. * Clones the particle system.
  93846. * @param name The name of the cloned object
  93847. * @param newEmitter The new emitter to use
  93848. * @returns the cloned particle system
  93849. */
  93850. clone(name: string, newEmitter: any): ParticleSystem;
  93851. /**
  93852. * Serializes the particle system to a JSON object
  93853. * @param serializeTexture defines if the texture must be serialized as well
  93854. * @returns the JSON object
  93855. */
  93856. serialize(serializeTexture?: boolean): any;
  93857. /** @hidden */
  93858. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93859. /** @hidden */
  93860. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93861. /**
  93862. * Parses a JSON object to create a particle system.
  93863. * @param parsedParticleSystem The JSON object to parse
  93864. * @param sceneOrEngine The scene or the engine to create the particle system in
  93865. * @param rootUrl The root url to use to load external dependencies like texture
  93866. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93867. * @returns the Parsed particle system
  93868. */
  93869. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93870. }
  93871. }
  93872. declare module BABYLON {
  93873. /**
  93874. * A particle represents one of the element emitted by a particle system.
  93875. * This is mainly define by its coordinates, direction, velocity and age.
  93876. */
  93877. export class Particle {
  93878. /**
  93879. * The particle system the particle belongs to.
  93880. */
  93881. particleSystem: ParticleSystem;
  93882. private static _Count;
  93883. /**
  93884. * Unique ID of the particle
  93885. */
  93886. id: number;
  93887. /**
  93888. * The world position of the particle in the scene.
  93889. */
  93890. position: Vector3;
  93891. /**
  93892. * The world direction of the particle in the scene.
  93893. */
  93894. direction: Vector3;
  93895. /**
  93896. * The color of the particle.
  93897. */
  93898. color: Color4;
  93899. /**
  93900. * The color change of the particle per step.
  93901. */
  93902. colorStep: Color4;
  93903. /**
  93904. * Defines how long will the life of the particle be.
  93905. */
  93906. lifeTime: number;
  93907. /**
  93908. * The current age of the particle.
  93909. */
  93910. age: number;
  93911. /**
  93912. * The current size of the particle.
  93913. */
  93914. size: number;
  93915. /**
  93916. * The current scale of the particle.
  93917. */
  93918. scale: Vector2;
  93919. /**
  93920. * The current angle of the particle.
  93921. */
  93922. angle: number;
  93923. /**
  93924. * Defines how fast is the angle changing.
  93925. */
  93926. angularSpeed: number;
  93927. /**
  93928. * Defines the cell index used by the particle to be rendered from a sprite.
  93929. */
  93930. cellIndex: number;
  93931. /**
  93932. * The information required to support color remapping
  93933. */
  93934. remapData: Vector4;
  93935. /** @hidden */
  93936. _randomCellOffset?: number;
  93937. /** @hidden */
  93938. _initialDirection: Nullable<Vector3>;
  93939. /** @hidden */
  93940. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93941. /** @hidden */
  93942. _initialStartSpriteCellID: number;
  93943. /** @hidden */
  93944. _initialEndSpriteCellID: number;
  93945. /** @hidden */
  93946. _currentColorGradient: Nullable<ColorGradient>;
  93947. /** @hidden */
  93948. _currentColor1: Color4;
  93949. /** @hidden */
  93950. _currentColor2: Color4;
  93951. /** @hidden */
  93952. _currentSizeGradient: Nullable<FactorGradient>;
  93953. /** @hidden */
  93954. _currentSize1: number;
  93955. /** @hidden */
  93956. _currentSize2: number;
  93957. /** @hidden */
  93958. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93959. /** @hidden */
  93960. _currentAngularSpeed1: number;
  93961. /** @hidden */
  93962. _currentAngularSpeed2: number;
  93963. /** @hidden */
  93964. _currentVelocityGradient: Nullable<FactorGradient>;
  93965. /** @hidden */
  93966. _currentVelocity1: number;
  93967. /** @hidden */
  93968. _currentVelocity2: number;
  93969. /** @hidden */
  93970. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93971. /** @hidden */
  93972. _currentLimitVelocity1: number;
  93973. /** @hidden */
  93974. _currentLimitVelocity2: number;
  93975. /** @hidden */
  93976. _currentDragGradient: Nullable<FactorGradient>;
  93977. /** @hidden */
  93978. _currentDrag1: number;
  93979. /** @hidden */
  93980. _currentDrag2: number;
  93981. /** @hidden */
  93982. _randomNoiseCoordinates1: Vector3;
  93983. /** @hidden */
  93984. _randomNoiseCoordinates2: Vector3;
  93985. /** @hidden */
  93986. _localPosition?: Vector3;
  93987. /**
  93988. * Creates a new instance Particle
  93989. * @param particleSystem the particle system the particle belongs to
  93990. */
  93991. constructor(
  93992. /**
  93993. * The particle system the particle belongs to.
  93994. */
  93995. particleSystem: ParticleSystem);
  93996. private updateCellInfoFromSystem;
  93997. /**
  93998. * Defines how the sprite cell index is updated for the particle
  93999. */
  94000. updateCellIndex(): void;
  94001. /** @hidden */
  94002. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94003. /** @hidden */
  94004. _inheritParticleInfoToSubEmitters(): void;
  94005. /** @hidden */
  94006. _reset(): void;
  94007. /**
  94008. * Copy the properties of particle to another one.
  94009. * @param other the particle to copy the information to.
  94010. */
  94011. copyTo(other: Particle): void;
  94012. }
  94013. }
  94014. declare module BABYLON {
  94015. /**
  94016. * Particle emitter represents a volume emitting particles.
  94017. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94018. */
  94019. export interface IParticleEmitterType {
  94020. /**
  94021. * Called by the particle System when the direction is computed for the created particle.
  94022. * @param worldMatrix is the world matrix of the particle system
  94023. * @param directionToUpdate is the direction vector to update with the result
  94024. * @param particle is the particle we are computed the direction for
  94025. * @param isLocal defines if the direction should be set in local space
  94026. */
  94027. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94028. /**
  94029. * Called by the particle System when the position is computed for the created particle.
  94030. * @param worldMatrix is the world matrix of the particle system
  94031. * @param positionToUpdate is the position vector to update with the result
  94032. * @param particle is the particle we are computed the position for
  94033. * @param isLocal defines if the position should be set in local space
  94034. */
  94035. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94036. /**
  94037. * Clones the current emitter and returns a copy of it
  94038. * @returns the new emitter
  94039. */
  94040. clone(): IParticleEmitterType;
  94041. /**
  94042. * Called by the GPUParticleSystem to setup the update shader
  94043. * @param effect defines the update shader
  94044. */
  94045. applyToShader(effect: Effect): void;
  94046. /**
  94047. * Returns a string to use to update the GPU particles update shader
  94048. * @returns the effect defines string
  94049. */
  94050. getEffectDefines(): string;
  94051. /**
  94052. * Returns a string representing the class name
  94053. * @returns a string containing the class name
  94054. */
  94055. getClassName(): string;
  94056. /**
  94057. * Serializes the particle system to a JSON object.
  94058. * @returns the JSON object
  94059. */
  94060. serialize(): any;
  94061. /**
  94062. * Parse properties from a JSON object
  94063. * @param serializationObject defines the JSON object
  94064. * @param scene defines the hosting scene
  94065. */
  94066. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94067. }
  94068. }
  94069. declare module BABYLON {
  94070. /**
  94071. * Particle emitter emitting particles from the inside of a box.
  94072. * It emits the particles randomly between 2 given directions.
  94073. */
  94074. export class BoxParticleEmitter implements IParticleEmitterType {
  94075. /**
  94076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94077. */
  94078. direction1: Vector3;
  94079. /**
  94080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94081. */
  94082. direction2: Vector3;
  94083. /**
  94084. * 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.
  94085. */
  94086. minEmitBox: Vector3;
  94087. /**
  94088. * 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.
  94089. */
  94090. maxEmitBox: Vector3;
  94091. /**
  94092. * Creates a new instance BoxParticleEmitter
  94093. */
  94094. constructor();
  94095. /**
  94096. * Called by the particle System when the direction is computed for the created particle.
  94097. * @param worldMatrix is the world matrix of the particle system
  94098. * @param directionToUpdate is the direction vector to update with the result
  94099. * @param particle is the particle we are computed the direction for
  94100. * @param isLocal defines if the direction should be set in local space
  94101. */
  94102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94103. /**
  94104. * Called by the particle System when the position is computed for the created particle.
  94105. * @param worldMatrix is the world matrix of the particle system
  94106. * @param positionToUpdate is the position vector to update with the result
  94107. * @param particle is the particle we are computed the position for
  94108. * @param isLocal defines if the position should be set in local space
  94109. */
  94110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94111. /**
  94112. * Clones the current emitter and returns a copy of it
  94113. * @returns the new emitter
  94114. */
  94115. clone(): BoxParticleEmitter;
  94116. /**
  94117. * Called by the GPUParticleSystem to setup the update shader
  94118. * @param effect defines the update shader
  94119. */
  94120. applyToShader(effect: Effect): void;
  94121. /**
  94122. * Returns a string to use to update the GPU particles update shader
  94123. * @returns a string containng the defines string
  94124. */
  94125. getEffectDefines(): string;
  94126. /**
  94127. * Returns the string "BoxParticleEmitter"
  94128. * @returns a string containing the class name
  94129. */
  94130. getClassName(): string;
  94131. /**
  94132. * Serializes the particle system to a JSON object.
  94133. * @returns the JSON object
  94134. */
  94135. serialize(): any;
  94136. /**
  94137. * Parse properties from a JSON object
  94138. * @param serializationObject defines the JSON object
  94139. */
  94140. parse(serializationObject: any): void;
  94141. }
  94142. }
  94143. declare module BABYLON {
  94144. /**
  94145. * Particle emitter emitting particles from the inside of a cone.
  94146. * It emits the particles alongside the cone volume from the base to the particle.
  94147. * The emission direction might be randomized.
  94148. */
  94149. export class ConeParticleEmitter implements IParticleEmitterType {
  94150. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94151. directionRandomizer: number;
  94152. private _radius;
  94153. private _angle;
  94154. private _height;
  94155. /**
  94156. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94157. */
  94158. radiusRange: number;
  94159. /**
  94160. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94161. */
  94162. heightRange: number;
  94163. /**
  94164. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94165. */
  94166. emitFromSpawnPointOnly: boolean;
  94167. /**
  94168. * Gets or sets the radius of the emission cone
  94169. */
  94170. get radius(): number;
  94171. set radius(value: number);
  94172. /**
  94173. * Gets or sets the angle of the emission cone
  94174. */
  94175. get angle(): number;
  94176. set angle(value: number);
  94177. private _buildHeight;
  94178. /**
  94179. * Creates a new instance ConeParticleEmitter
  94180. * @param radius the radius of the emission cone (1 by default)
  94181. * @param angle the cone base angle (PI by default)
  94182. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94183. */
  94184. constructor(radius?: number, angle?: number,
  94185. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94186. directionRandomizer?: number);
  94187. /**
  94188. * Called by the particle System when the direction is computed for the created particle.
  94189. * @param worldMatrix is the world matrix of the particle system
  94190. * @param directionToUpdate is the direction vector to update with the result
  94191. * @param particle is the particle we are computed the direction for
  94192. * @param isLocal defines if the direction should be set in local space
  94193. */
  94194. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94195. /**
  94196. * Called by the particle System when the position is computed for the created particle.
  94197. * @param worldMatrix is the world matrix of the particle system
  94198. * @param positionToUpdate is the position vector to update with the result
  94199. * @param particle is the particle we are computed the position for
  94200. * @param isLocal defines if the position should be set in local space
  94201. */
  94202. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94203. /**
  94204. * Clones the current emitter and returns a copy of it
  94205. * @returns the new emitter
  94206. */
  94207. clone(): ConeParticleEmitter;
  94208. /**
  94209. * Called by the GPUParticleSystem to setup the update shader
  94210. * @param effect defines the update shader
  94211. */
  94212. applyToShader(effect: Effect): void;
  94213. /**
  94214. * Returns a string to use to update the GPU particles update shader
  94215. * @returns a string containng the defines string
  94216. */
  94217. getEffectDefines(): string;
  94218. /**
  94219. * Returns the string "ConeParticleEmitter"
  94220. * @returns a string containing the class name
  94221. */
  94222. getClassName(): string;
  94223. /**
  94224. * Serializes the particle system to a JSON object.
  94225. * @returns the JSON object
  94226. */
  94227. serialize(): any;
  94228. /**
  94229. * Parse properties from a JSON object
  94230. * @param serializationObject defines the JSON object
  94231. */
  94232. parse(serializationObject: any): void;
  94233. }
  94234. }
  94235. declare module BABYLON {
  94236. /**
  94237. * Particle emitter emitting particles from the inside of a cylinder.
  94238. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94239. */
  94240. export class CylinderParticleEmitter implements IParticleEmitterType {
  94241. /**
  94242. * The radius of the emission cylinder.
  94243. */
  94244. radius: number;
  94245. /**
  94246. * The height of the emission cylinder.
  94247. */
  94248. height: number;
  94249. /**
  94250. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94251. */
  94252. radiusRange: number;
  94253. /**
  94254. * How much to randomize the particle direction [0-1].
  94255. */
  94256. directionRandomizer: number;
  94257. /**
  94258. * Creates a new instance CylinderParticleEmitter
  94259. * @param radius the radius of the emission cylinder (1 by default)
  94260. * @param height the height of the emission cylinder (1 by default)
  94261. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94262. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94263. */
  94264. constructor(
  94265. /**
  94266. * The radius of the emission cylinder.
  94267. */
  94268. radius?: number,
  94269. /**
  94270. * The height of the emission cylinder.
  94271. */
  94272. height?: number,
  94273. /**
  94274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94275. */
  94276. radiusRange?: number,
  94277. /**
  94278. * How much to randomize the particle direction [0-1].
  94279. */
  94280. directionRandomizer?: number);
  94281. /**
  94282. * Called by the particle System when the direction is computed for the created particle.
  94283. * @param worldMatrix is the world matrix of the particle system
  94284. * @param directionToUpdate is the direction vector to update with the result
  94285. * @param particle is the particle we are computed the direction for
  94286. * @param isLocal defines if the direction should be set in local space
  94287. */
  94288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94289. /**
  94290. * Called by the particle System when the position is computed for the created particle.
  94291. * @param worldMatrix is the world matrix of the particle system
  94292. * @param positionToUpdate is the position vector to update with the result
  94293. * @param particle is the particle we are computed the position for
  94294. * @param isLocal defines if the position should be set in local space
  94295. */
  94296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94297. /**
  94298. * Clones the current emitter and returns a copy of it
  94299. * @returns the new emitter
  94300. */
  94301. clone(): CylinderParticleEmitter;
  94302. /**
  94303. * Called by the GPUParticleSystem to setup the update shader
  94304. * @param effect defines the update shader
  94305. */
  94306. applyToShader(effect: Effect): void;
  94307. /**
  94308. * Returns a string to use to update the GPU particles update shader
  94309. * @returns a string containng the defines string
  94310. */
  94311. getEffectDefines(): string;
  94312. /**
  94313. * Returns the string "CylinderParticleEmitter"
  94314. * @returns a string containing the class name
  94315. */
  94316. getClassName(): string;
  94317. /**
  94318. * Serializes the particle system to a JSON object.
  94319. * @returns the JSON object
  94320. */
  94321. serialize(): any;
  94322. /**
  94323. * Parse properties from a JSON object
  94324. * @param serializationObject defines the JSON object
  94325. */
  94326. parse(serializationObject: any): void;
  94327. }
  94328. /**
  94329. * Particle emitter emitting particles from the inside of a cylinder.
  94330. * It emits the particles randomly between two vectors.
  94331. */
  94332. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94333. /**
  94334. * The min limit of the emission direction.
  94335. */
  94336. direction1: Vector3;
  94337. /**
  94338. * The max limit of the emission direction.
  94339. */
  94340. direction2: Vector3;
  94341. /**
  94342. * Creates a new instance CylinderDirectedParticleEmitter
  94343. * @param radius the radius of the emission cylinder (1 by default)
  94344. * @param height the height of the emission cylinder (1 by default)
  94345. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94346. * @param direction1 the min limit of the emission direction (up vector by default)
  94347. * @param direction2 the max limit of the emission direction (up vector by default)
  94348. */
  94349. constructor(radius?: number, height?: number, radiusRange?: number,
  94350. /**
  94351. * The min limit of the emission direction.
  94352. */
  94353. direction1?: Vector3,
  94354. /**
  94355. * The max limit of the emission direction.
  94356. */
  94357. direction2?: Vector3);
  94358. /**
  94359. * Called by the particle System when the direction is computed for the created particle.
  94360. * @param worldMatrix is the world matrix of the particle system
  94361. * @param directionToUpdate is the direction vector to update with the result
  94362. * @param particle is the particle we are computed the direction for
  94363. */
  94364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94365. /**
  94366. * Clones the current emitter and returns a copy of it
  94367. * @returns the new emitter
  94368. */
  94369. clone(): CylinderDirectedParticleEmitter;
  94370. /**
  94371. * Called by the GPUParticleSystem to setup the update shader
  94372. * @param effect defines the update shader
  94373. */
  94374. applyToShader(effect: Effect): void;
  94375. /**
  94376. * Returns a string to use to update the GPU particles update shader
  94377. * @returns a string containng the defines string
  94378. */
  94379. getEffectDefines(): string;
  94380. /**
  94381. * Returns the string "CylinderDirectedParticleEmitter"
  94382. * @returns a string containing the class name
  94383. */
  94384. getClassName(): string;
  94385. /**
  94386. * Serializes the particle system to a JSON object.
  94387. * @returns the JSON object
  94388. */
  94389. serialize(): any;
  94390. /**
  94391. * Parse properties from a JSON object
  94392. * @param serializationObject defines the JSON object
  94393. */
  94394. parse(serializationObject: any): void;
  94395. }
  94396. }
  94397. declare module BABYLON {
  94398. /**
  94399. * Particle emitter emitting particles from the inside of a hemisphere.
  94400. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94401. */
  94402. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94403. /**
  94404. * The radius of the emission hemisphere.
  94405. */
  94406. radius: number;
  94407. /**
  94408. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94409. */
  94410. radiusRange: number;
  94411. /**
  94412. * How much to randomize the particle direction [0-1].
  94413. */
  94414. directionRandomizer: number;
  94415. /**
  94416. * Creates a new instance HemisphericParticleEmitter
  94417. * @param radius the radius of the emission hemisphere (1 by default)
  94418. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94419. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94420. */
  94421. constructor(
  94422. /**
  94423. * The radius of the emission hemisphere.
  94424. */
  94425. radius?: number,
  94426. /**
  94427. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94428. */
  94429. radiusRange?: number,
  94430. /**
  94431. * How much to randomize the particle direction [0-1].
  94432. */
  94433. directionRandomizer?: number);
  94434. /**
  94435. * Called by the particle System when the direction is computed for the created particle.
  94436. * @param worldMatrix is the world matrix of the particle system
  94437. * @param directionToUpdate is the direction vector to update with the result
  94438. * @param particle is the particle we are computed the direction for
  94439. * @param isLocal defines if the direction should be set in local space
  94440. */
  94441. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94442. /**
  94443. * Called by the particle System when the position is computed for the created particle.
  94444. * @param worldMatrix is the world matrix of the particle system
  94445. * @param positionToUpdate is the position vector to update with the result
  94446. * @param particle is the particle we are computed the position for
  94447. * @param isLocal defines if the position should be set in local space
  94448. */
  94449. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94450. /**
  94451. * Clones the current emitter and returns a copy of it
  94452. * @returns the new emitter
  94453. */
  94454. clone(): HemisphericParticleEmitter;
  94455. /**
  94456. * Called by the GPUParticleSystem to setup the update shader
  94457. * @param effect defines the update shader
  94458. */
  94459. applyToShader(effect: Effect): void;
  94460. /**
  94461. * Returns a string to use to update the GPU particles update shader
  94462. * @returns a string containng the defines string
  94463. */
  94464. getEffectDefines(): string;
  94465. /**
  94466. * Returns the string "HemisphericParticleEmitter"
  94467. * @returns a string containing the class name
  94468. */
  94469. getClassName(): string;
  94470. /**
  94471. * Serializes the particle system to a JSON object.
  94472. * @returns the JSON object
  94473. */
  94474. serialize(): any;
  94475. /**
  94476. * Parse properties from a JSON object
  94477. * @param serializationObject defines the JSON object
  94478. */
  94479. parse(serializationObject: any): void;
  94480. }
  94481. }
  94482. declare module BABYLON {
  94483. /**
  94484. * Particle emitter emitting particles from a point.
  94485. * It emits the particles randomly between 2 given directions.
  94486. */
  94487. export class PointParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance PointParticleEmitter
  94498. */
  94499. constructor();
  94500. /**
  94501. * Called by the particle System when the direction is computed for the created particle.
  94502. * @param worldMatrix is the world matrix of the particle system
  94503. * @param directionToUpdate is the direction vector to update with the result
  94504. * @param particle is the particle we are computed the direction for
  94505. * @param isLocal defines if the direction should be set in local space
  94506. */
  94507. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94508. /**
  94509. * Called by the particle System when the position is computed for the created particle.
  94510. * @param worldMatrix is the world matrix of the particle system
  94511. * @param positionToUpdate is the position vector to update with the result
  94512. * @param particle is the particle we are computed the position for
  94513. * @param isLocal defines if the position should be set in local space
  94514. */
  94515. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94516. /**
  94517. * Clones the current emitter and returns a copy of it
  94518. * @returns the new emitter
  94519. */
  94520. clone(): PointParticleEmitter;
  94521. /**
  94522. * Called by the GPUParticleSystem to setup the update shader
  94523. * @param effect defines the update shader
  94524. */
  94525. applyToShader(effect: Effect): void;
  94526. /**
  94527. * Returns a string to use to update the GPU particles update shader
  94528. * @returns a string containng the defines string
  94529. */
  94530. getEffectDefines(): string;
  94531. /**
  94532. * Returns the string "PointParticleEmitter"
  94533. * @returns a string containing the class name
  94534. */
  94535. getClassName(): string;
  94536. /**
  94537. * Serializes the particle system to a JSON object.
  94538. * @returns the JSON object
  94539. */
  94540. serialize(): any;
  94541. /**
  94542. * Parse properties from a JSON object
  94543. * @param serializationObject defines the JSON object
  94544. */
  94545. parse(serializationObject: any): void;
  94546. }
  94547. }
  94548. declare module BABYLON {
  94549. /**
  94550. * Particle emitter emitting particles from the inside of a sphere.
  94551. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94552. */
  94553. export class SphereParticleEmitter implements IParticleEmitterType {
  94554. /**
  94555. * The radius of the emission sphere.
  94556. */
  94557. radius: number;
  94558. /**
  94559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94560. */
  94561. radiusRange: number;
  94562. /**
  94563. * How much to randomize the particle direction [0-1].
  94564. */
  94565. directionRandomizer: number;
  94566. /**
  94567. * Creates a new instance SphereParticleEmitter
  94568. * @param radius the radius of the emission sphere (1 by default)
  94569. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94570. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94571. */
  94572. constructor(
  94573. /**
  94574. * The radius of the emission sphere.
  94575. */
  94576. radius?: number,
  94577. /**
  94578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94579. */
  94580. radiusRange?: number,
  94581. /**
  94582. * How much to randomize the particle direction [0-1].
  94583. */
  94584. directionRandomizer?: number);
  94585. /**
  94586. * Called by the particle System when the direction is computed for the created particle.
  94587. * @param worldMatrix is the world matrix of the particle system
  94588. * @param directionToUpdate is the direction vector to update with the result
  94589. * @param particle is the particle we are computed the direction for
  94590. * @param isLocal defines if the direction should be set in local space
  94591. */
  94592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94593. /**
  94594. * Called by the particle System when the position is computed for the created particle.
  94595. * @param worldMatrix is the world matrix of the particle system
  94596. * @param positionToUpdate is the position vector to update with the result
  94597. * @param particle is the particle we are computed the position for
  94598. * @param isLocal defines if the position should be set in local space
  94599. */
  94600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94601. /**
  94602. * Clones the current emitter and returns a copy of it
  94603. * @returns the new emitter
  94604. */
  94605. clone(): SphereParticleEmitter;
  94606. /**
  94607. * Called by the GPUParticleSystem to setup the update shader
  94608. * @param effect defines the update shader
  94609. */
  94610. applyToShader(effect: Effect): void;
  94611. /**
  94612. * Returns a string to use to update the GPU particles update shader
  94613. * @returns a string containng the defines string
  94614. */
  94615. getEffectDefines(): string;
  94616. /**
  94617. * Returns the string "SphereParticleEmitter"
  94618. * @returns a string containing the class name
  94619. */
  94620. getClassName(): string;
  94621. /**
  94622. * Serializes the particle system to a JSON object.
  94623. * @returns the JSON object
  94624. */
  94625. serialize(): any;
  94626. /**
  94627. * Parse properties from a JSON object
  94628. * @param serializationObject defines the JSON object
  94629. */
  94630. parse(serializationObject: any): void;
  94631. }
  94632. /**
  94633. * Particle emitter emitting particles from the inside of a sphere.
  94634. * It emits the particles randomly between two vectors.
  94635. */
  94636. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94637. /**
  94638. * The min limit of the emission direction.
  94639. */
  94640. direction1: Vector3;
  94641. /**
  94642. * The max limit of the emission direction.
  94643. */
  94644. direction2: Vector3;
  94645. /**
  94646. * Creates a new instance SphereDirectedParticleEmitter
  94647. * @param radius the radius of the emission sphere (1 by default)
  94648. * @param direction1 the min limit of the emission direction (up vector by default)
  94649. * @param direction2 the max limit of the emission direction (up vector by default)
  94650. */
  94651. constructor(radius?: number,
  94652. /**
  94653. * The min limit of the emission direction.
  94654. */
  94655. direction1?: Vector3,
  94656. /**
  94657. * The max limit of the emission direction.
  94658. */
  94659. direction2?: Vector3);
  94660. /**
  94661. * Called by the particle System when the direction is computed for the created particle.
  94662. * @param worldMatrix is the world matrix of the particle system
  94663. * @param directionToUpdate is the direction vector to update with the result
  94664. * @param particle is the particle we are computed the direction for
  94665. */
  94666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94667. /**
  94668. * Clones the current emitter and returns a copy of it
  94669. * @returns the new emitter
  94670. */
  94671. clone(): SphereDirectedParticleEmitter;
  94672. /**
  94673. * Called by the GPUParticleSystem to setup the update shader
  94674. * @param effect defines the update shader
  94675. */
  94676. applyToShader(effect: Effect): void;
  94677. /**
  94678. * Returns a string to use to update the GPU particles update shader
  94679. * @returns a string containng the defines string
  94680. */
  94681. getEffectDefines(): string;
  94682. /**
  94683. * Returns the string "SphereDirectedParticleEmitter"
  94684. * @returns a string containing the class name
  94685. */
  94686. getClassName(): string;
  94687. /**
  94688. * Serializes the particle system to a JSON object.
  94689. * @returns the JSON object
  94690. */
  94691. serialize(): any;
  94692. /**
  94693. * Parse properties from a JSON object
  94694. * @param serializationObject defines the JSON object
  94695. */
  94696. parse(serializationObject: any): void;
  94697. }
  94698. }
  94699. declare module BABYLON {
  94700. /**
  94701. * Particle emitter emitting particles from a custom list of positions.
  94702. */
  94703. export class CustomParticleEmitter implements IParticleEmitterType {
  94704. /**
  94705. * Gets or sets the position generator that will create the inital position of each particle.
  94706. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94707. */
  94708. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94709. /**
  94710. * Gets or sets the destination generator that will create the final destination of each particle.
  94711. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94712. */
  94713. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94714. /**
  94715. * Creates a new instance CustomParticleEmitter
  94716. */
  94717. constructor();
  94718. /**
  94719. * Called by the particle System when the direction is computed for the created particle.
  94720. * @param worldMatrix is the world matrix of the particle system
  94721. * @param directionToUpdate is the direction vector to update with the result
  94722. * @param particle is the particle we are computed the direction for
  94723. * @param isLocal defines if the direction should be set in local space
  94724. */
  94725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94726. /**
  94727. * Called by the particle System when the position is computed for the created particle.
  94728. * @param worldMatrix is the world matrix of the particle system
  94729. * @param positionToUpdate is the position vector to update with the result
  94730. * @param particle is the particle we are computed the position for
  94731. * @param isLocal defines if the position should be set in local space
  94732. */
  94733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94734. /**
  94735. * Clones the current emitter and returns a copy of it
  94736. * @returns the new emitter
  94737. */
  94738. clone(): CustomParticleEmitter;
  94739. /**
  94740. * Called by the GPUParticleSystem to setup the update shader
  94741. * @param effect defines the update shader
  94742. */
  94743. applyToShader(effect: Effect): void;
  94744. /**
  94745. * Returns a string to use to update the GPU particles update shader
  94746. * @returns a string containng the defines string
  94747. */
  94748. getEffectDefines(): string;
  94749. /**
  94750. * Returns the string "PointParticleEmitter"
  94751. * @returns a string containing the class name
  94752. */
  94753. getClassName(): string;
  94754. /**
  94755. * Serializes the particle system to a JSON object.
  94756. * @returns the JSON object
  94757. */
  94758. serialize(): any;
  94759. /**
  94760. * Parse properties from a JSON object
  94761. * @param serializationObject defines the JSON object
  94762. */
  94763. parse(serializationObject: any): void;
  94764. }
  94765. }
  94766. declare module BABYLON {
  94767. /**
  94768. * Particle emitter emitting particles from the inside of a box.
  94769. * It emits the particles randomly between 2 given directions.
  94770. */
  94771. export class MeshParticleEmitter implements IParticleEmitterType {
  94772. private _indices;
  94773. private _positions;
  94774. private _normals;
  94775. private _storedNormal;
  94776. private _mesh;
  94777. /**
  94778. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94779. */
  94780. direction1: Vector3;
  94781. /**
  94782. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94783. */
  94784. direction2: Vector3;
  94785. /**
  94786. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94787. */
  94788. useMeshNormalsForDirection: boolean;
  94789. /** Defines the mesh to use as source */
  94790. get mesh(): Nullable<AbstractMesh>;
  94791. set mesh(value: Nullable<AbstractMesh>);
  94792. /**
  94793. * Creates a new instance MeshParticleEmitter
  94794. * @param mesh defines the mesh to use as source
  94795. */
  94796. constructor(mesh?: Nullable<AbstractMesh>);
  94797. /**
  94798. * Called by the particle System when the direction is computed for the created particle.
  94799. * @param worldMatrix is the world matrix of the particle system
  94800. * @param directionToUpdate is the direction vector to update with the result
  94801. * @param particle is the particle we are computed the direction for
  94802. * @param isLocal defines if the direction should be set in local space
  94803. */
  94804. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94805. /**
  94806. * Called by the particle System when the position is computed for the created particle.
  94807. * @param worldMatrix is the world matrix of the particle system
  94808. * @param positionToUpdate is the position vector to update with the result
  94809. * @param particle is the particle we are computed the position for
  94810. * @param isLocal defines if the position should be set in local space
  94811. */
  94812. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94813. /**
  94814. * Clones the current emitter and returns a copy of it
  94815. * @returns the new emitter
  94816. */
  94817. clone(): MeshParticleEmitter;
  94818. /**
  94819. * Called by the GPUParticleSystem to setup the update shader
  94820. * @param effect defines the update shader
  94821. */
  94822. applyToShader(effect: Effect): void;
  94823. /**
  94824. * Returns a string to use to update the GPU particles update shader
  94825. * @returns a string containng the defines string
  94826. */
  94827. getEffectDefines(): string;
  94828. /**
  94829. * Returns the string "BoxParticleEmitter"
  94830. * @returns a string containing the class name
  94831. */
  94832. getClassName(): string;
  94833. /**
  94834. * Serializes the particle system to a JSON object.
  94835. * @returns the JSON object
  94836. */
  94837. serialize(): any;
  94838. /**
  94839. * Parse properties from a JSON object
  94840. * @param serializationObject defines the JSON object
  94841. * @param scene defines the hosting scene
  94842. */
  94843. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94844. }
  94845. }
  94846. declare module BABYLON {
  94847. /**
  94848. * Interface representing a particle system in Babylon.js.
  94849. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94850. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94851. */
  94852. export interface IParticleSystem {
  94853. /**
  94854. * List of animations used by the particle system.
  94855. */
  94856. animations: Animation[];
  94857. /**
  94858. * The id of the Particle system.
  94859. */
  94860. id: string;
  94861. /**
  94862. * The name of the Particle system.
  94863. */
  94864. name: string;
  94865. /**
  94866. * The emitter represents the Mesh or position we are attaching the particle system to.
  94867. */
  94868. emitter: Nullable<AbstractMesh | Vector3>;
  94869. /**
  94870. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94871. */
  94872. isBillboardBased: boolean;
  94873. /**
  94874. * The rendering group used by the Particle system to chose when to render.
  94875. */
  94876. renderingGroupId: number;
  94877. /**
  94878. * The layer mask we are rendering the particles through.
  94879. */
  94880. layerMask: number;
  94881. /**
  94882. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94883. */
  94884. updateSpeed: number;
  94885. /**
  94886. * The amount of time the particle system is running (depends of the overall update speed).
  94887. */
  94888. targetStopDuration: number;
  94889. /**
  94890. * The texture used to render each particle. (this can be a spritesheet)
  94891. */
  94892. particleTexture: Nullable<BaseTexture>;
  94893. /**
  94894. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94895. */
  94896. blendMode: number;
  94897. /**
  94898. * Minimum life time of emitting particles.
  94899. */
  94900. minLifeTime: number;
  94901. /**
  94902. * Maximum life time of emitting particles.
  94903. */
  94904. maxLifeTime: number;
  94905. /**
  94906. * Minimum Size of emitting particles.
  94907. */
  94908. minSize: number;
  94909. /**
  94910. * Maximum Size of emitting particles.
  94911. */
  94912. maxSize: number;
  94913. /**
  94914. * Minimum scale of emitting particles on X axis.
  94915. */
  94916. minScaleX: number;
  94917. /**
  94918. * Maximum scale of emitting particles on X axis.
  94919. */
  94920. maxScaleX: number;
  94921. /**
  94922. * Minimum scale of emitting particles on Y axis.
  94923. */
  94924. minScaleY: number;
  94925. /**
  94926. * Maximum scale of emitting particles on Y axis.
  94927. */
  94928. maxScaleY: number;
  94929. /**
  94930. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94931. */
  94932. color1: Color4;
  94933. /**
  94934. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94935. */
  94936. color2: Color4;
  94937. /**
  94938. * Color the particle will have at the end of its lifetime.
  94939. */
  94940. colorDead: Color4;
  94941. /**
  94942. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94943. */
  94944. emitRate: number;
  94945. /**
  94946. * You can use gravity if you want to give an orientation to your particles.
  94947. */
  94948. gravity: Vector3;
  94949. /**
  94950. * Minimum power of emitting particles.
  94951. */
  94952. minEmitPower: number;
  94953. /**
  94954. * Maximum power of emitting particles.
  94955. */
  94956. maxEmitPower: number;
  94957. /**
  94958. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94959. */
  94960. minAngularSpeed: number;
  94961. /**
  94962. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94963. */
  94964. maxAngularSpeed: number;
  94965. /**
  94966. * Gets or sets the minimal initial rotation in radians.
  94967. */
  94968. minInitialRotation: number;
  94969. /**
  94970. * Gets or sets the maximal initial rotation in radians.
  94971. */
  94972. maxInitialRotation: number;
  94973. /**
  94974. * The particle emitter type defines the emitter used by the particle system.
  94975. * It can be for example box, sphere, or cone...
  94976. */
  94977. particleEmitterType: Nullable<IParticleEmitterType>;
  94978. /**
  94979. * Defines the delay in milliseconds before starting the system (0 by default)
  94980. */
  94981. startDelay: number;
  94982. /**
  94983. * 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
  94984. */
  94985. preWarmCycles: number;
  94986. /**
  94987. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94988. */
  94989. preWarmStepOffset: number;
  94990. /**
  94991. * 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)
  94992. */
  94993. spriteCellChangeSpeed: number;
  94994. /**
  94995. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94996. */
  94997. startSpriteCellID: number;
  94998. /**
  94999. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95000. */
  95001. endSpriteCellID: number;
  95002. /**
  95003. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95004. */
  95005. spriteCellWidth: number;
  95006. /**
  95007. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95008. */
  95009. spriteCellHeight: number;
  95010. /**
  95011. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95012. */
  95013. spriteRandomStartCell: boolean;
  95014. /**
  95015. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95016. */
  95017. isAnimationSheetEnabled: boolean;
  95018. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95019. translationPivot: Vector2;
  95020. /**
  95021. * Gets or sets a texture used to add random noise to particle positions
  95022. */
  95023. noiseTexture: Nullable<BaseTexture>;
  95024. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95025. noiseStrength: Vector3;
  95026. /**
  95027. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95028. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95029. */
  95030. billboardMode: number;
  95031. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95032. limitVelocityDamping: number;
  95033. /**
  95034. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95035. */
  95036. beginAnimationOnStart: boolean;
  95037. /**
  95038. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95039. */
  95040. beginAnimationFrom: number;
  95041. /**
  95042. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95043. */
  95044. beginAnimationTo: number;
  95045. /**
  95046. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95047. */
  95048. beginAnimationLoop: boolean;
  95049. /**
  95050. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95051. */
  95052. disposeOnStop: boolean;
  95053. /**
  95054. * Specifies if the particles are updated in emitter local space or world space
  95055. */
  95056. isLocal: boolean;
  95057. /** Snippet ID if the particle system was created from the snippet server */
  95058. snippetId: string;
  95059. /** Gets or sets a matrix to use to compute projection */
  95060. defaultProjectionMatrix: Matrix;
  95061. /**
  95062. * Gets the maximum number of particles active at the same time.
  95063. * @returns The max number of active particles.
  95064. */
  95065. getCapacity(): number;
  95066. /**
  95067. * Gets the number of particles active at the same time.
  95068. * @returns The number of active particles.
  95069. */
  95070. getActiveCount(): number;
  95071. /**
  95072. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95073. * @returns True if it has been started, otherwise false.
  95074. */
  95075. isStarted(): boolean;
  95076. /**
  95077. * Animates the particle system for this frame.
  95078. */
  95079. animate(): void;
  95080. /**
  95081. * Renders the particle system in its current state.
  95082. * @returns the current number of particles
  95083. */
  95084. render(): number;
  95085. /**
  95086. * Dispose the particle system and frees its associated resources.
  95087. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95088. */
  95089. dispose(disposeTexture?: boolean): void;
  95090. /**
  95091. * An event triggered when the system is disposed
  95092. */
  95093. onDisposeObservable: Observable<IParticleSystem>;
  95094. /**
  95095. * An event triggered when the system is stopped
  95096. */
  95097. onStoppedObservable: Observable<IParticleSystem>;
  95098. /**
  95099. * Clones the particle system.
  95100. * @param name The name of the cloned object
  95101. * @param newEmitter The new emitter to use
  95102. * @returns the cloned particle system
  95103. */
  95104. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95105. /**
  95106. * Serializes the particle system to a JSON object
  95107. * @param serializeTexture defines if the texture must be serialized as well
  95108. * @returns the JSON object
  95109. */
  95110. serialize(serializeTexture: boolean): any;
  95111. /**
  95112. * Rebuild the particle system
  95113. */
  95114. rebuild(): void;
  95115. /** Force the system to rebuild all gradients that need to be resync */
  95116. forceRefreshGradients(): void;
  95117. /**
  95118. * Starts the particle system and begins to emit
  95119. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95120. */
  95121. start(delay?: number): void;
  95122. /**
  95123. * Stops the particle system.
  95124. */
  95125. stop(): void;
  95126. /**
  95127. * Remove all active particles
  95128. */
  95129. reset(): void;
  95130. /**
  95131. * Gets a boolean indicating that the system is stopping
  95132. * @returns true if the system is currently stopping
  95133. */
  95134. isStopping(): boolean;
  95135. /**
  95136. * Is this system ready to be used/rendered
  95137. * @return true if the system is ready
  95138. */
  95139. isReady(): boolean;
  95140. /**
  95141. * Returns the string "ParticleSystem"
  95142. * @returns a string containing the class name
  95143. */
  95144. getClassName(): string;
  95145. /**
  95146. * Gets the custom effect used to render the particles
  95147. * @param blendMode Blend mode for which the effect should be retrieved
  95148. * @returns The effect
  95149. */
  95150. getCustomEffect(blendMode: number): Nullable<Effect>;
  95151. /**
  95152. * Sets the custom effect used to render the particles
  95153. * @param effect The effect to set
  95154. * @param blendMode Blend mode for which the effect should be set
  95155. */
  95156. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95157. /**
  95158. * Fill the defines array according to the current settings of the particle system
  95159. * @param defines Array to be updated
  95160. * @param blendMode blend mode to take into account when updating the array
  95161. */
  95162. fillDefines(defines: Array<string>, blendMode: number): void;
  95163. /**
  95164. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95165. * @param uniforms Uniforms array to fill
  95166. * @param attributes Attributes array to fill
  95167. * @param samplers Samplers array to fill
  95168. */
  95169. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95170. /**
  95171. * Observable that will be called just before the particles are drawn
  95172. */
  95173. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95174. /**
  95175. * Gets the name of the particle vertex shader
  95176. */
  95177. vertexShaderName: string;
  95178. /**
  95179. * Adds a new color gradient
  95180. * @param gradient defines the gradient to use (between 0 and 1)
  95181. * @param color1 defines the color to affect to the specified gradient
  95182. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95183. * @returns the current particle system
  95184. */
  95185. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95186. /**
  95187. * Remove a specific color gradient
  95188. * @param gradient defines the gradient to remove
  95189. * @returns the current particle system
  95190. */
  95191. removeColorGradient(gradient: number): IParticleSystem;
  95192. /**
  95193. * Adds a new size gradient
  95194. * @param gradient defines the gradient to use (between 0 and 1)
  95195. * @param factor defines the size factor to affect to the specified gradient
  95196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95197. * @returns the current particle system
  95198. */
  95199. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95200. /**
  95201. * Remove a specific size gradient
  95202. * @param gradient defines the gradient to remove
  95203. * @returns the current particle system
  95204. */
  95205. removeSizeGradient(gradient: number): IParticleSystem;
  95206. /**
  95207. * Gets the current list of color gradients.
  95208. * You must use addColorGradient and removeColorGradient to udpate this list
  95209. * @returns the list of color gradients
  95210. */
  95211. getColorGradients(): Nullable<Array<ColorGradient>>;
  95212. /**
  95213. * Gets the current list of size gradients.
  95214. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95215. * @returns the list of size gradients
  95216. */
  95217. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95218. /**
  95219. * Gets the current list of angular speed gradients.
  95220. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95221. * @returns the list of angular speed gradients
  95222. */
  95223. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95224. /**
  95225. * Adds a new angular speed gradient
  95226. * @param gradient defines the gradient to use (between 0 and 1)
  95227. * @param factor defines the angular speed to affect to the specified gradient
  95228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95229. * @returns the current particle system
  95230. */
  95231. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95232. /**
  95233. * Remove a specific angular speed gradient
  95234. * @param gradient defines the gradient to remove
  95235. * @returns the current particle system
  95236. */
  95237. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95238. /**
  95239. * Gets the current list of velocity gradients.
  95240. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95241. * @returns the list of velocity gradients
  95242. */
  95243. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95244. /**
  95245. * Adds a new velocity gradient
  95246. * @param gradient defines the gradient to use (between 0 and 1)
  95247. * @param factor defines the velocity to affect to the specified gradient
  95248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95249. * @returns the current particle system
  95250. */
  95251. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95252. /**
  95253. * Remove a specific velocity gradient
  95254. * @param gradient defines the gradient to remove
  95255. * @returns the current particle system
  95256. */
  95257. removeVelocityGradient(gradient: number): IParticleSystem;
  95258. /**
  95259. * Gets the current list of limit velocity gradients.
  95260. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95261. * @returns the list of limit velocity gradients
  95262. */
  95263. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95264. /**
  95265. * Adds a new limit velocity gradient
  95266. * @param gradient defines the gradient to use (between 0 and 1)
  95267. * @param factor defines the limit velocity to affect to the specified gradient
  95268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95269. * @returns the current particle system
  95270. */
  95271. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95272. /**
  95273. * Remove a specific limit velocity gradient
  95274. * @param gradient defines the gradient to remove
  95275. * @returns the current particle system
  95276. */
  95277. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95278. /**
  95279. * Adds a new drag gradient
  95280. * @param gradient defines the gradient to use (between 0 and 1)
  95281. * @param factor defines the drag to affect to the specified gradient
  95282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95283. * @returns the current particle system
  95284. */
  95285. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95286. /**
  95287. * Remove a specific drag gradient
  95288. * @param gradient defines the gradient to remove
  95289. * @returns the current particle system
  95290. */
  95291. removeDragGradient(gradient: number): IParticleSystem;
  95292. /**
  95293. * Gets the current list of drag gradients.
  95294. * You must use addDragGradient and removeDragGradient to udpate this list
  95295. * @returns the list of drag gradients
  95296. */
  95297. getDragGradients(): Nullable<Array<FactorGradient>>;
  95298. /**
  95299. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95300. * @param gradient defines the gradient to use (between 0 and 1)
  95301. * @param factor defines the emit rate to affect to the specified gradient
  95302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95303. * @returns the current particle system
  95304. */
  95305. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95306. /**
  95307. * Remove a specific emit rate gradient
  95308. * @param gradient defines the gradient to remove
  95309. * @returns the current particle system
  95310. */
  95311. removeEmitRateGradient(gradient: number): IParticleSystem;
  95312. /**
  95313. * Gets the current list of emit rate gradients.
  95314. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95315. * @returns the list of emit rate gradients
  95316. */
  95317. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95318. /**
  95319. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95320. * @param gradient defines the gradient to use (between 0 and 1)
  95321. * @param factor defines the start size to affect to the specified gradient
  95322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95323. * @returns the current particle system
  95324. */
  95325. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95326. /**
  95327. * Remove a specific start size gradient
  95328. * @param gradient defines the gradient to remove
  95329. * @returns the current particle system
  95330. */
  95331. removeStartSizeGradient(gradient: number): IParticleSystem;
  95332. /**
  95333. * Gets the current list of start size gradients.
  95334. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95335. * @returns the list of start size gradients
  95336. */
  95337. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95338. /**
  95339. * Adds a new life time gradient
  95340. * @param gradient defines the gradient to use (between 0 and 1)
  95341. * @param factor defines the life time factor to affect to the specified gradient
  95342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95343. * @returns the current particle system
  95344. */
  95345. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95346. /**
  95347. * Remove a specific life time gradient
  95348. * @param gradient defines the gradient to remove
  95349. * @returns the current particle system
  95350. */
  95351. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95352. /**
  95353. * Gets the current list of life time gradients.
  95354. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95355. * @returns the list of life time gradients
  95356. */
  95357. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95358. /**
  95359. * Gets the current list of color gradients.
  95360. * You must use addColorGradient and removeColorGradient to udpate this list
  95361. * @returns the list of color gradients
  95362. */
  95363. getColorGradients(): Nullable<Array<ColorGradient>>;
  95364. /**
  95365. * Adds a new ramp gradient used to remap particle colors
  95366. * @param gradient defines the gradient to use (between 0 and 1)
  95367. * @param color defines the color to affect to the specified gradient
  95368. * @returns the current particle system
  95369. */
  95370. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95371. /**
  95372. * Gets the current list of ramp gradients.
  95373. * You must use addRampGradient and removeRampGradient to udpate this list
  95374. * @returns the list of ramp gradients
  95375. */
  95376. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95377. /** Gets or sets a boolean indicating that ramp gradients must be used
  95378. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95379. */
  95380. useRampGradients: boolean;
  95381. /**
  95382. * Adds a new color remap gradient
  95383. * @param gradient defines the gradient to use (between 0 and 1)
  95384. * @param min defines the color remap minimal range
  95385. * @param max defines the color remap maximal range
  95386. * @returns the current particle system
  95387. */
  95388. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95389. /**
  95390. * Gets the current list of color remap gradients.
  95391. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95392. * @returns the list of color remap gradients
  95393. */
  95394. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95395. /**
  95396. * Adds a new alpha remap gradient
  95397. * @param gradient defines the gradient to use (between 0 and 1)
  95398. * @param min defines the alpha remap minimal range
  95399. * @param max defines the alpha remap maximal range
  95400. * @returns the current particle system
  95401. */
  95402. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95403. /**
  95404. * Gets the current list of alpha remap gradients.
  95405. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95406. * @returns the list of alpha remap gradients
  95407. */
  95408. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95409. /**
  95410. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95413. * @returns the emitter
  95414. */
  95415. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95416. /**
  95417. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95418. * @param radius The radius of the hemisphere to emit from
  95419. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95420. * @returns the emitter
  95421. */
  95422. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95423. /**
  95424. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95425. * @param radius The radius of the sphere to emit from
  95426. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95427. * @returns the emitter
  95428. */
  95429. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95430. /**
  95431. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95432. * @param radius The radius of the sphere to emit from
  95433. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95434. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95435. * @returns the emitter
  95436. */
  95437. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95438. /**
  95439. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95440. * @param radius The radius of the emission cylinder
  95441. * @param height The height of the emission cylinder
  95442. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95443. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95444. * @returns the emitter
  95445. */
  95446. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95447. /**
  95448. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95449. * @param radius The radius of the cylinder to emit from
  95450. * @param height The height of the emission cylinder
  95451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95454. * @returns the emitter
  95455. */
  95456. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95457. /**
  95458. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95459. * @param radius The radius of the cone to emit from
  95460. * @param angle The base angle of the cone
  95461. * @returns the emitter
  95462. */
  95463. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95464. /**
  95465. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95468. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95469. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95470. * @returns the emitter
  95471. */
  95472. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95473. /**
  95474. * Get hosting scene
  95475. * @returns the scene
  95476. */
  95477. getScene(): Nullable<Scene>;
  95478. }
  95479. }
  95480. declare module BABYLON {
  95481. /**
  95482. * 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.
  95483. * @see https://doc.babylonjs.com/how_to/transformnode
  95484. */
  95485. export class TransformNode extends Node {
  95486. /**
  95487. * Object will not rotate to face the camera
  95488. */
  95489. static BILLBOARDMODE_NONE: number;
  95490. /**
  95491. * Object will rotate to face the camera but only on the x axis
  95492. */
  95493. static BILLBOARDMODE_X: number;
  95494. /**
  95495. * Object will rotate to face the camera but only on the y axis
  95496. */
  95497. static BILLBOARDMODE_Y: number;
  95498. /**
  95499. * Object will rotate to face the camera but only on the z axis
  95500. */
  95501. static BILLBOARDMODE_Z: number;
  95502. /**
  95503. * Object will rotate to face the camera
  95504. */
  95505. static BILLBOARDMODE_ALL: number;
  95506. /**
  95507. * Object will rotate to face the camera's position instead of orientation
  95508. */
  95509. static BILLBOARDMODE_USE_POSITION: number;
  95510. private static _TmpRotation;
  95511. private static _TmpScaling;
  95512. private static _TmpTranslation;
  95513. private _forward;
  95514. private _forwardInverted;
  95515. private _up;
  95516. private _right;
  95517. private _rightInverted;
  95518. private _position;
  95519. private _rotation;
  95520. private _rotationQuaternion;
  95521. protected _scaling: Vector3;
  95522. protected _isDirty: boolean;
  95523. private _transformToBoneReferal;
  95524. private _isAbsoluteSynced;
  95525. private _billboardMode;
  95526. /**
  95527. * Gets or sets the billboard mode. Default is 0.
  95528. *
  95529. * | Value | Type | Description |
  95530. * | --- | --- | --- |
  95531. * | 0 | BILLBOARDMODE_NONE | |
  95532. * | 1 | BILLBOARDMODE_X | |
  95533. * | 2 | BILLBOARDMODE_Y | |
  95534. * | 4 | BILLBOARDMODE_Z | |
  95535. * | 7 | BILLBOARDMODE_ALL | |
  95536. *
  95537. */
  95538. get billboardMode(): number;
  95539. set billboardMode(value: number);
  95540. private _preserveParentRotationForBillboard;
  95541. /**
  95542. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95543. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95544. */
  95545. get preserveParentRotationForBillboard(): boolean;
  95546. set preserveParentRotationForBillboard(value: boolean);
  95547. /**
  95548. * 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
  95549. */
  95550. scalingDeterminant: number;
  95551. private _infiniteDistance;
  95552. /**
  95553. * Gets or sets the distance of the object to max, often used by skybox
  95554. */
  95555. get infiniteDistance(): boolean;
  95556. set infiniteDistance(value: boolean);
  95557. /**
  95558. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95559. * By default the system will update normals to compensate
  95560. */
  95561. ignoreNonUniformScaling: boolean;
  95562. /**
  95563. * 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
  95564. */
  95565. reIntegrateRotationIntoRotationQuaternion: boolean;
  95566. /** @hidden */
  95567. _poseMatrix: Nullable<Matrix>;
  95568. /** @hidden */
  95569. _localMatrix: Matrix;
  95570. private _usePivotMatrix;
  95571. private _absolutePosition;
  95572. private _absoluteScaling;
  95573. private _absoluteRotationQuaternion;
  95574. private _pivotMatrix;
  95575. private _pivotMatrixInverse;
  95576. /** @hidden */
  95577. _postMultiplyPivotMatrix: boolean;
  95578. protected _isWorldMatrixFrozen: boolean;
  95579. /** @hidden */
  95580. _indexInSceneTransformNodesArray: number;
  95581. /**
  95582. * An event triggered after the world matrix is updated
  95583. */
  95584. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95585. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95586. /**
  95587. * Gets a string identifying the name of the class
  95588. * @returns "TransformNode" string
  95589. */
  95590. getClassName(): string;
  95591. /**
  95592. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95593. */
  95594. get position(): Vector3;
  95595. set position(newPosition: Vector3);
  95596. /**
  95597. * 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)).
  95598. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95599. */
  95600. get rotation(): Vector3;
  95601. set rotation(newRotation: Vector3);
  95602. /**
  95603. * 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)).
  95604. */
  95605. get scaling(): Vector3;
  95606. set scaling(newScaling: Vector3);
  95607. /**
  95608. * 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).
  95609. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95610. */
  95611. get rotationQuaternion(): Nullable<Quaternion>;
  95612. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95613. /**
  95614. * The forward direction of that transform in world space.
  95615. */
  95616. get forward(): Vector3;
  95617. /**
  95618. * The up direction of that transform in world space.
  95619. */
  95620. get up(): Vector3;
  95621. /**
  95622. * The right direction of that transform in world space.
  95623. */
  95624. get right(): Vector3;
  95625. /**
  95626. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95627. * @param matrix the matrix to copy the pose from
  95628. * @returns this TransformNode.
  95629. */
  95630. updatePoseMatrix(matrix: Matrix): TransformNode;
  95631. /**
  95632. * Returns the mesh Pose matrix.
  95633. * @returns the pose matrix
  95634. */
  95635. getPoseMatrix(): Matrix;
  95636. /** @hidden */
  95637. _isSynchronized(): boolean;
  95638. /** @hidden */
  95639. _initCache(): void;
  95640. /**
  95641. * Flag the transform node as dirty (Forcing it to update everything)
  95642. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95643. * @returns this transform node
  95644. */
  95645. markAsDirty(property: string): TransformNode;
  95646. /**
  95647. * Returns the current mesh absolute position.
  95648. * Returns a Vector3.
  95649. */
  95650. get absolutePosition(): Vector3;
  95651. /**
  95652. * Returns the current mesh absolute scaling.
  95653. * Returns a Vector3.
  95654. */
  95655. get absoluteScaling(): Vector3;
  95656. /**
  95657. * Returns the current mesh absolute rotation.
  95658. * Returns a Quaternion.
  95659. */
  95660. get absoluteRotationQuaternion(): Quaternion;
  95661. /**
  95662. * Sets a new matrix to apply before all other transformation
  95663. * @param matrix defines the transform matrix
  95664. * @returns the current TransformNode
  95665. */
  95666. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95667. /**
  95668. * Sets a new pivot matrix to the current node
  95669. * @param matrix defines the new pivot matrix to use
  95670. * @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
  95671. * @returns the current TransformNode
  95672. */
  95673. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95674. /**
  95675. * Returns the mesh pivot matrix.
  95676. * Default : Identity.
  95677. * @returns the matrix
  95678. */
  95679. getPivotMatrix(): Matrix;
  95680. /**
  95681. * Instantiate (when possible) or clone that node with its hierarchy
  95682. * @param newParent defines the new parent to use for the instance (or clone)
  95683. * @param options defines options to configure how copy is done
  95684. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95685. * @returns an instance (or a clone) of the current node with its hiearchy
  95686. */
  95687. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95688. doNotInstantiate: boolean;
  95689. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95690. /**
  95691. * Prevents the World matrix to be computed any longer
  95692. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95693. * @returns the TransformNode.
  95694. */
  95695. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95696. /**
  95697. * Allows back the World matrix computation.
  95698. * @returns the TransformNode.
  95699. */
  95700. unfreezeWorldMatrix(): this;
  95701. /**
  95702. * True if the World matrix has been frozen.
  95703. */
  95704. get isWorldMatrixFrozen(): boolean;
  95705. /**
  95706. * Retuns the mesh absolute position in the World.
  95707. * @returns a Vector3.
  95708. */
  95709. getAbsolutePosition(): Vector3;
  95710. /**
  95711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95712. * @param absolutePosition the absolute position to set
  95713. * @returns the TransformNode.
  95714. */
  95715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95716. /**
  95717. * Sets the mesh position in its local space.
  95718. * @param vector3 the position to set in localspace
  95719. * @returns the TransformNode.
  95720. */
  95721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95722. /**
  95723. * Returns the mesh position in the local space from the current World matrix values.
  95724. * @returns a new Vector3.
  95725. */
  95726. getPositionExpressedInLocalSpace(): Vector3;
  95727. /**
  95728. * Translates the mesh along the passed Vector3 in its local space.
  95729. * @param vector3 the distance to translate in localspace
  95730. * @returns the TransformNode.
  95731. */
  95732. locallyTranslate(vector3: Vector3): TransformNode;
  95733. private static _lookAtVectorCache;
  95734. /**
  95735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95736. * @param targetPoint the position (must be in same space as current mesh) to look at
  95737. * @param yawCor optional yaw (y-axis) correction in radians
  95738. * @param pitchCor optional pitch (x-axis) correction in radians
  95739. * @param rollCor optional roll (z-axis) correction in radians
  95740. * @param space the choosen space of the target
  95741. * @returns the TransformNode.
  95742. */
  95743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95744. /**
  95745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95746. * This Vector3 is expressed in the World space.
  95747. * @param localAxis axis to rotate
  95748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95749. */
  95750. getDirection(localAxis: Vector3): Vector3;
  95751. /**
  95752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95753. * localAxis is expressed in the mesh local space.
  95754. * result is computed in the Wordl space from the mesh World matrix.
  95755. * @param localAxis axis to rotate
  95756. * @param result the resulting transformnode
  95757. * @returns this TransformNode.
  95758. */
  95759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95760. /**
  95761. * Sets this transform node rotation to the given local axis.
  95762. * @param localAxis the axis in local space
  95763. * @param yawCor optional yaw (y-axis) correction in radians
  95764. * @param pitchCor optional pitch (x-axis) correction in radians
  95765. * @param rollCor optional roll (z-axis) correction in radians
  95766. * @returns this TransformNode
  95767. */
  95768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95769. /**
  95770. * Sets a new pivot point to the current node
  95771. * @param point defines the new pivot point to use
  95772. * @param space defines if the point is in world or local space (local by default)
  95773. * @returns the current TransformNode
  95774. */
  95775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95776. /**
  95777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95778. * @returns the pivot point
  95779. */
  95780. getPivotPoint(): Vector3;
  95781. /**
  95782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95783. * @param result the vector3 to store the result
  95784. * @returns this TransformNode.
  95785. */
  95786. getPivotPointToRef(result: Vector3): TransformNode;
  95787. /**
  95788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95790. */
  95791. getAbsolutePivotPoint(): Vector3;
  95792. /**
  95793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95794. * @param result vector3 to store the result
  95795. * @returns this TransformNode.
  95796. */
  95797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95798. /**
  95799. * Defines the passed node as the parent of the current node.
  95800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95801. * @see https://doc.babylonjs.com/how_to/parenting
  95802. * @param node the node ot set as the parent
  95803. * @returns this TransformNode.
  95804. */
  95805. setParent(node: Nullable<Node>): TransformNode;
  95806. private _nonUniformScaling;
  95807. /**
  95808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95809. */
  95810. get nonUniformScaling(): boolean;
  95811. /** @hidden */
  95812. _updateNonUniformScalingState(value: boolean): boolean;
  95813. /**
  95814. * Attach the current TransformNode to another TransformNode associated with a bone
  95815. * @param bone Bone affecting the TransformNode
  95816. * @param affectedTransformNode TransformNode associated with the bone
  95817. * @returns this object
  95818. */
  95819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95820. /**
  95821. * Detach the transform node if its associated with a bone
  95822. * @returns this object
  95823. */
  95824. detachFromBone(): TransformNode;
  95825. private static _rotationAxisCache;
  95826. /**
  95827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95830. * The passed axis is also normalized.
  95831. * @param axis the axis to rotate around
  95832. * @param amount the amount to rotate in radians
  95833. * @param space Space to rotate in (Default: local)
  95834. * @returns the TransformNode.
  95835. */
  95836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95837. /**
  95838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95840. * The passed axis is also normalized. .
  95841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95842. * @param point the point to rotate around
  95843. * @param axis the axis to rotate around
  95844. * @param amount the amount to rotate in radians
  95845. * @returns the TransformNode
  95846. */
  95847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95848. /**
  95849. * Translates the mesh along the axis vector for the passed distance in the given space.
  95850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95851. * @param axis the axis to translate in
  95852. * @param distance the distance to translate
  95853. * @param space Space to rotate in (Default: local)
  95854. * @returns the TransformNode.
  95855. */
  95856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95857. /**
  95858. * Adds a rotation step to the mesh current rotation.
  95859. * x, y, z are Euler angles expressed in radians.
  95860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95861. * This means this rotation is made in the mesh local space only.
  95862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95864. * ```javascript
  95865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95866. * ```
  95867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95868. * 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.
  95869. * @param x Rotation to add
  95870. * @param y Rotation to add
  95871. * @param z Rotation to add
  95872. * @returns the TransformNode.
  95873. */
  95874. addRotation(x: number, y: number, z: number): TransformNode;
  95875. /**
  95876. * @hidden
  95877. */
  95878. protected _getEffectiveParent(): Nullable<Node>;
  95879. /**
  95880. * Computes the world matrix of the node
  95881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95882. * @returns the world matrix
  95883. */
  95884. computeWorldMatrix(force?: boolean): Matrix;
  95885. /**
  95886. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95887. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95888. */
  95889. resetLocalMatrix(independentOfChildren?: boolean): void;
  95890. protected _afterComputeWorldMatrix(): void;
  95891. /**
  95892. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95893. * @param func callback function to add
  95894. *
  95895. * @returns the TransformNode.
  95896. */
  95897. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95898. /**
  95899. * Removes a registered callback function.
  95900. * @param func callback function to remove
  95901. * @returns the TransformNode.
  95902. */
  95903. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95904. /**
  95905. * Gets the position of the current mesh in camera space
  95906. * @param camera defines the camera to use
  95907. * @returns a position
  95908. */
  95909. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95910. /**
  95911. * Returns the distance from the mesh to the active camera
  95912. * @param camera defines the camera to use
  95913. * @returns the distance
  95914. */
  95915. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95916. /**
  95917. * Clone the current transform node
  95918. * @param name Name of the new clone
  95919. * @param newParent New parent for the clone
  95920. * @param doNotCloneChildren Do not clone children hierarchy
  95921. * @returns the new transform node
  95922. */
  95923. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95924. /**
  95925. * Serializes the objects information.
  95926. * @param currentSerializationObject defines the object to serialize in
  95927. * @returns the serialized object
  95928. */
  95929. serialize(currentSerializationObject?: any): any;
  95930. /**
  95931. * Returns a new TransformNode object parsed from the source provided.
  95932. * @param parsedTransformNode is the source.
  95933. * @param scene the scne the object belongs to
  95934. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95935. * @returns a new TransformNode object parsed from the source provided.
  95936. */
  95937. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95938. /**
  95939. * Get all child-transformNodes of this node
  95940. * @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
  95941. * @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
  95942. * @returns an array of TransformNode
  95943. */
  95944. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95945. /**
  95946. * Releases resources associated with this transform node.
  95947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95949. */
  95950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95951. /**
  95952. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95953. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95954. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95955. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95956. * @returns the current mesh
  95957. */
  95958. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95959. private _syncAbsoluteScalingAndRotation;
  95960. }
  95961. }
  95962. declare module BABYLON {
  95963. /**
  95964. * Class used to override all child animations of a given target
  95965. */
  95966. export class AnimationPropertiesOverride {
  95967. /**
  95968. * Gets or sets a value indicating if animation blending must be used
  95969. */
  95970. enableBlending: boolean;
  95971. /**
  95972. * Gets or sets the blending speed to use when enableBlending is true
  95973. */
  95974. blendingSpeed: number;
  95975. /**
  95976. * Gets or sets the default loop mode to use
  95977. */
  95978. loopMode: number;
  95979. }
  95980. }
  95981. declare module BABYLON {
  95982. /**
  95983. * Class used to store bone information
  95984. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95985. */
  95986. export class Bone extends Node {
  95987. /**
  95988. * defines the bone name
  95989. */
  95990. name: string;
  95991. private static _tmpVecs;
  95992. private static _tmpQuat;
  95993. private static _tmpMats;
  95994. /**
  95995. * Gets the list of child bones
  95996. */
  95997. children: Bone[];
  95998. /** Gets the animations associated with this bone */
  95999. animations: Animation[];
  96000. /**
  96001. * Gets or sets bone length
  96002. */
  96003. length: number;
  96004. /**
  96005. * @hidden Internal only
  96006. * Set this value to map this bone to a different index in the transform matrices
  96007. * Set this value to -1 to exclude the bone from the transform matrices
  96008. */
  96009. _index: Nullable<number>;
  96010. private _skeleton;
  96011. private _localMatrix;
  96012. private _restPose;
  96013. private _bindPose;
  96014. private _baseMatrix;
  96015. private _absoluteTransform;
  96016. private _invertedAbsoluteTransform;
  96017. private _parent;
  96018. private _scalingDeterminant;
  96019. private _worldTransform;
  96020. private _localScaling;
  96021. private _localRotation;
  96022. private _localPosition;
  96023. private _needToDecompose;
  96024. private _needToCompose;
  96025. /** @hidden */
  96026. _linkedTransformNode: Nullable<TransformNode>;
  96027. /** @hidden */
  96028. _waitingTransformNodeId: Nullable<string>;
  96029. /** @hidden */
  96030. get _matrix(): Matrix;
  96031. /** @hidden */
  96032. set _matrix(value: Matrix);
  96033. /**
  96034. * Create a new bone
  96035. * @param name defines the bone name
  96036. * @param skeleton defines the parent skeleton
  96037. * @param parentBone defines the parent (can be null if the bone is the root)
  96038. * @param localMatrix defines the local matrix
  96039. * @param restPose defines the rest pose matrix
  96040. * @param baseMatrix defines the base matrix
  96041. * @param index defines index of the bone in the hiearchy
  96042. */
  96043. constructor(
  96044. /**
  96045. * defines the bone name
  96046. */
  96047. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96048. /**
  96049. * Gets the current object class name.
  96050. * @return the class name
  96051. */
  96052. getClassName(): string;
  96053. /**
  96054. * Gets the parent skeleton
  96055. * @returns a skeleton
  96056. */
  96057. getSkeleton(): Skeleton;
  96058. /**
  96059. * Gets parent bone
  96060. * @returns a bone or null if the bone is the root of the bone hierarchy
  96061. */
  96062. getParent(): Nullable<Bone>;
  96063. /**
  96064. * Returns an array containing the root bones
  96065. * @returns an array containing the root bones
  96066. */
  96067. getChildren(): Array<Bone>;
  96068. /**
  96069. * Gets the node index in matrix array generated for rendering
  96070. * @returns the node index
  96071. */
  96072. getIndex(): number;
  96073. /**
  96074. * Sets the parent bone
  96075. * @param parent defines the parent (can be null if the bone is the root)
  96076. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96077. */
  96078. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96079. /**
  96080. * Gets the local matrix
  96081. * @returns a matrix
  96082. */
  96083. getLocalMatrix(): Matrix;
  96084. /**
  96085. * Gets the base matrix (initial matrix which remains unchanged)
  96086. * @returns a matrix
  96087. */
  96088. getBaseMatrix(): Matrix;
  96089. /**
  96090. * Gets the rest pose matrix
  96091. * @returns a matrix
  96092. */
  96093. getRestPose(): Matrix;
  96094. /**
  96095. * Sets the rest pose matrix
  96096. * @param matrix the local-space rest pose to set for this bone
  96097. */
  96098. setRestPose(matrix: Matrix): void;
  96099. /**
  96100. * Gets the bind pose matrix
  96101. * @returns the bind pose matrix
  96102. */
  96103. getBindPose(): Matrix;
  96104. /**
  96105. * Sets the bind pose matrix
  96106. * @param matrix the local-space bind pose to set for this bone
  96107. */
  96108. setBindPose(matrix: Matrix): void;
  96109. /**
  96110. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96111. */
  96112. getWorldMatrix(): Matrix;
  96113. /**
  96114. * Sets the local matrix to rest pose matrix
  96115. */
  96116. returnToRest(): void;
  96117. /**
  96118. * Gets the inverse of the absolute transform matrix.
  96119. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96120. * @returns a matrix
  96121. */
  96122. getInvertedAbsoluteTransform(): Matrix;
  96123. /**
  96124. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96125. * @returns a matrix
  96126. */
  96127. getAbsoluteTransform(): Matrix;
  96128. /**
  96129. * Links with the given transform node.
  96130. * The local matrix of this bone is copied from the transform node every frame.
  96131. * @param transformNode defines the transform node to link to
  96132. */
  96133. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96134. /**
  96135. * Gets the node used to drive the bone's transformation
  96136. * @returns a transform node or null
  96137. */
  96138. getTransformNode(): Nullable<TransformNode>;
  96139. /** Gets or sets current position (in local space) */
  96140. get position(): Vector3;
  96141. set position(newPosition: Vector3);
  96142. /** Gets or sets current rotation (in local space) */
  96143. get rotation(): Vector3;
  96144. set rotation(newRotation: Vector3);
  96145. /** Gets or sets current rotation quaternion (in local space) */
  96146. get rotationQuaternion(): Quaternion;
  96147. set rotationQuaternion(newRotation: Quaternion);
  96148. /** Gets or sets current scaling (in local space) */
  96149. get scaling(): Vector3;
  96150. set scaling(newScaling: Vector3);
  96151. /**
  96152. * Gets the animation properties override
  96153. */
  96154. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96155. private _decompose;
  96156. private _compose;
  96157. /**
  96158. * Update the base and local matrices
  96159. * @param matrix defines the new base or local matrix
  96160. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96161. * @param updateLocalMatrix defines if the local matrix should be updated
  96162. */
  96163. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96164. /** @hidden */
  96165. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96166. /**
  96167. * Flag the bone as dirty (Forcing it to update everything)
  96168. */
  96169. markAsDirty(): void;
  96170. /** @hidden */
  96171. _markAsDirtyAndCompose(): void;
  96172. private _markAsDirtyAndDecompose;
  96173. /**
  96174. * Translate the bone in local or world space
  96175. * @param vec The amount to translate the bone
  96176. * @param space The space that the translation is in
  96177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96178. */
  96179. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96180. /**
  96181. * Set the postion of the bone in local or world space
  96182. * @param position The position to set the bone
  96183. * @param space The space that the position is in
  96184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96185. */
  96186. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96187. /**
  96188. * Set the absolute position of the bone (world space)
  96189. * @param position The position to set the bone
  96190. * @param mesh The mesh that this bone is attached to
  96191. */
  96192. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96193. /**
  96194. * Scale the bone on the x, y and z axes (in local space)
  96195. * @param x The amount to scale the bone on the x axis
  96196. * @param y The amount to scale the bone on the y axis
  96197. * @param z The amount to scale the bone on the z axis
  96198. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96199. */
  96200. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96201. /**
  96202. * Set the bone scaling in local space
  96203. * @param scale defines the scaling vector
  96204. */
  96205. setScale(scale: Vector3): void;
  96206. /**
  96207. * Gets the current scaling in local space
  96208. * @returns the current scaling vector
  96209. */
  96210. getScale(): Vector3;
  96211. /**
  96212. * Gets the current scaling in local space and stores it in a target vector
  96213. * @param result defines the target vector
  96214. */
  96215. getScaleToRef(result: Vector3): void;
  96216. /**
  96217. * Set the yaw, pitch, and roll of the bone in local or world space
  96218. * @param yaw The rotation of the bone on the y axis
  96219. * @param pitch The rotation of the bone on the x axis
  96220. * @param roll The rotation of the bone on the z axis
  96221. * @param space The space that the axes of rotation are in
  96222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96223. */
  96224. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96225. /**
  96226. * Add a rotation to the bone on an axis in local or world space
  96227. * @param axis The axis to rotate the bone on
  96228. * @param amount The amount to rotate the bone
  96229. * @param space The space that the axis is in
  96230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96231. */
  96232. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96233. /**
  96234. * Set the rotation of the bone to a particular axis angle in local or world space
  96235. * @param axis The axis to rotate the bone on
  96236. * @param angle The angle that the bone should be rotated to
  96237. * @param space The space that the axis is in
  96238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96239. */
  96240. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96241. /**
  96242. * Set the euler rotation of the bone in local or world space
  96243. * @param rotation The euler rotation that the bone should be set to
  96244. * @param space The space that the rotation is in
  96245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96246. */
  96247. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96248. /**
  96249. * Set the quaternion rotation of the bone in local or world space
  96250. * @param quat The quaternion rotation that the bone should be set to
  96251. * @param space The space that the rotation is in
  96252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96253. */
  96254. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96255. /**
  96256. * Set the rotation matrix of the bone in local or world space
  96257. * @param rotMat The rotation matrix that the bone should be set to
  96258. * @param space The space that the rotation is in
  96259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96260. */
  96261. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96262. private _rotateWithMatrix;
  96263. private _getNegativeRotationToRef;
  96264. /**
  96265. * Get the position of the bone in local or world space
  96266. * @param space The space that the returned position is in
  96267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96268. * @returns The position of the bone
  96269. */
  96270. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96271. /**
  96272. * Copy the position of the bone to a vector3 in local or world space
  96273. * @param space The space that the returned position is in
  96274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96275. * @param result The vector3 to copy the position to
  96276. */
  96277. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96278. /**
  96279. * Get the absolute position of the bone (world space)
  96280. * @param mesh The mesh that this bone is attached to
  96281. * @returns The absolute position of the bone
  96282. */
  96283. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96284. /**
  96285. * Copy the absolute position of the bone (world space) to the result param
  96286. * @param mesh The mesh that this bone is attached to
  96287. * @param result The vector3 to copy the absolute position to
  96288. */
  96289. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96290. /**
  96291. * Compute the absolute transforms of this bone and its children
  96292. */
  96293. computeAbsoluteTransforms(): void;
  96294. /**
  96295. * Get the world direction from an axis that is in the local space of the bone
  96296. * @param localAxis The local direction that is used to compute the world direction
  96297. * @param mesh The mesh that this bone is attached to
  96298. * @returns The world direction
  96299. */
  96300. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96301. /**
  96302. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96303. * @param localAxis The local direction that is used to compute the world direction
  96304. * @param mesh The mesh that this bone is attached to
  96305. * @param result The vector3 that the world direction will be copied to
  96306. */
  96307. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96308. /**
  96309. * Get the euler rotation of the bone in local or world space
  96310. * @param space The space that the rotation should be in
  96311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96312. * @returns The euler rotation
  96313. */
  96314. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96315. /**
  96316. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96317. * @param space The space that the rotation should be in
  96318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96319. * @param result The vector3 that the rotation should be copied to
  96320. */
  96321. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96322. /**
  96323. * Get the quaternion rotation of the bone in either local or world space
  96324. * @param space The space that the rotation should be in
  96325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96326. * @returns The quaternion rotation
  96327. */
  96328. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96329. /**
  96330. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96331. * @param space The space that the rotation should be in
  96332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96333. * @param result The quaternion that the rotation should be copied to
  96334. */
  96335. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96336. /**
  96337. * Get the rotation matrix of the bone in local or world space
  96338. * @param space The space that the rotation should be in
  96339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96340. * @returns The rotation matrix
  96341. */
  96342. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96343. /**
  96344. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96345. * @param space The space that the rotation should be in
  96346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96347. * @param result The quaternion that the rotation should be copied to
  96348. */
  96349. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96350. /**
  96351. * Get the world position of a point that is in the local space of the bone
  96352. * @param position The local position
  96353. * @param mesh The mesh that this bone is attached to
  96354. * @returns The world position
  96355. */
  96356. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96357. /**
  96358. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96359. * @param position The local position
  96360. * @param mesh The mesh that this bone is attached to
  96361. * @param result The vector3 that the world position should be copied to
  96362. */
  96363. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96364. /**
  96365. * Get the local position of a point that is in world space
  96366. * @param position The world position
  96367. * @param mesh The mesh that this bone is attached to
  96368. * @returns The local position
  96369. */
  96370. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96371. /**
  96372. * Get the local position of a point that is in world space and copy it to the result param
  96373. * @param position The world position
  96374. * @param mesh The mesh that this bone is attached to
  96375. * @param result The vector3 that the local position should be copied to
  96376. */
  96377. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96378. /**
  96379. * Set the current local matrix as the restPose for this bone.
  96380. */
  96381. setCurrentPoseAsRest(): void;
  96382. }
  96383. }
  96384. declare module BABYLON {
  96385. /**
  96386. * Defines a runtime animation
  96387. */
  96388. export class RuntimeAnimation {
  96389. private _events;
  96390. /**
  96391. * The current frame of the runtime animation
  96392. */
  96393. private _currentFrame;
  96394. /**
  96395. * The animation used by the runtime animation
  96396. */
  96397. private _animation;
  96398. /**
  96399. * The target of the runtime animation
  96400. */
  96401. private _target;
  96402. /**
  96403. * The initiating animatable
  96404. */
  96405. private _host;
  96406. /**
  96407. * The original value of the runtime animation
  96408. */
  96409. private _originalValue;
  96410. /**
  96411. * The original blend value of the runtime animation
  96412. */
  96413. private _originalBlendValue;
  96414. /**
  96415. * The offsets cache of the runtime animation
  96416. */
  96417. private _offsetsCache;
  96418. /**
  96419. * The high limits cache of the runtime animation
  96420. */
  96421. private _highLimitsCache;
  96422. /**
  96423. * Specifies if the runtime animation has been stopped
  96424. */
  96425. private _stopped;
  96426. /**
  96427. * The blending factor of the runtime animation
  96428. */
  96429. private _blendingFactor;
  96430. /**
  96431. * The BabylonJS scene
  96432. */
  96433. private _scene;
  96434. /**
  96435. * The current value of the runtime animation
  96436. */
  96437. private _currentValue;
  96438. /** @hidden */
  96439. _animationState: _IAnimationState;
  96440. /**
  96441. * The active target of the runtime animation
  96442. */
  96443. private _activeTargets;
  96444. private _currentActiveTarget;
  96445. private _directTarget;
  96446. /**
  96447. * The target path of the runtime animation
  96448. */
  96449. private _targetPath;
  96450. /**
  96451. * The weight of the runtime animation
  96452. */
  96453. private _weight;
  96454. /**
  96455. * The ratio offset of the runtime animation
  96456. */
  96457. private _ratioOffset;
  96458. /**
  96459. * The previous delay of the runtime animation
  96460. */
  96461. private _previousDelay;
  96462. /**
  96463. * The previous ratio of the runtime animation
  96464. */
  96465. private _previousRatio;
  96466. private _enableBlending;
  96467. private _keys;
  96468. private _minFrame;
  96469. private _maxFrame;
  96470. private _minValue;
  96471. private _maxValue;
  96472. private _targetIsArray;
  96473. /**
  96474. * Gets the current frame of the runtime animation
  96475. */
  96476. get currentFrame(): number;
  96477. /**
  96478. * Gets the weight of the runtime animation
  96479. */
  96480. get weight(): number;
  96481. /**
  96482. * Gets the current value of the runtime animation
  96483. */
  96484. get currentValue(): any;
  96485. /**
  96486. * Gets the target path of the runtime animation
  96487. */
  96488. get targetPath(): string;
  96489. /**
  96490. * Gets the actual target of the runtime animation
  96491. */
  96492. get target(): any;
  96493. /**
  96494. * Gets the additive state of the runtime animation
  96495. */
  96496. get isAdditive(): boolean;
  96497. /** @hidden */
  96498. _onLoop: () => void;
  96499. /**
  96500. * Create a new RuntimeAnimation object
  96501. * @param target defines the target of the animation
  96502. * @param animation defines the source animation object
  96503. * @param scene defines the hosting scene
  96504. * @param host defines the initiating Animatable
  96505. */
  96506. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96507. private _preparePath;
  96508. /**
  96509. * Gets the animation from the runtime animation
  96510. */
  96511. get animation(): Animation;
  96512. /**
  96513. * Resets the runtime animation to the beginning
  96514. * @param restoreOriginal defines whether to restore the target property to the original value
  96515. */
  96516. reset(restoreOriginal?: boolean): void;
  96517. /**
  96518. * Specifies if the runtime animation is stopped
  96519. * @returns Boolean specifying if the runtime animation is stopped
  96520. */
  96521. isStopped(): boolean;
  96522. /**
  96523. * Disposes of the runtime animation
  96524. */
  96525. dispose(): void;
  96526. /**
  96527. * Apply the interpolated value to the target
  96528. * @param currentValue defines the value computed by the animation
  96529. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96530. */
  96531. setValue(currentValue: any, weight: number): void;
  96532. private _getOriginalValues;
  96533. private _setValue;
  96534. /**
  96535. * Gets the loop pmode of the runtime animation
  96536. * @returns Loop Mode
  96537. */
  96538. private _getCorrectLoopMode;
  96539. /**
  96540. * Move the current animation to a given frame
  96541. * @param frame defines the frame to move to
  96542. */
  96543. goToFrame(frame: number): void;
  96544. /**
  96545. * @hidden Internal use only
  96546. */
  96547. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96548. /**
  96549. * Execute the current animation
  96550. * @param delay defines the delay to add to the current frame
  96551. * @param from defines the lower bound of the animation range
  96552. * @param to defines the upper bound of the animation range
  96553. * @param loop defines if the current animation must loop
  96554. * @param speedRatio defines the current speed ratio
  96555. * @param weight defines the weight of the animation (default is -1 so no weight)
  96556. * @param onLoop optional callback called when animation loops
  96557. * @returns a boolean indicating if the animation is running
  96558. */
  96559. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96560. }
  96561. }
  96562. declare module BABYLON {
  96563. /**
  96564. * Class used to store an actual running animation
  96565. */
  96566. export class Animatable {
  96567. /** defines the target object */
  96568. target: any;
  96569. /** defines the starting frame number (default is 0) */
  96570. fromFrame: number;
  96571. /** defines the ending frame number (default is 100) */
  96572. toFrame: number;
  96573. /** defines if the animation must loop (default is false) */
  96574. loopAnimation: boolean;
  96575. /** defines a callback to call when animation ends if it is not looping */
  96576. onAnimationEnd?: (() => void) | null | undefined;
  96577. /** defines a callback to call when animation loops */
  96578. onAnimationLoop?: (() => void) | null | undefined;
  96579. /** defines whether the animation should be evaluated additively */
  96580. isAdditive: boolean;
  96581. private _localDelayOffset;
  96582. private _pausedDelay;
  96583. private _runtimeAnimations;
  96584. private _paused;
  96585. private _scene;
  96586. private _speedRatio;
  96587. private _weight;
  96588. private _syncRoot;
  96589. /**
  96590. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96591. * This will only apply for non looping animation (default is true)
  96592. */
  96593. disposeOnEnd: boolean;
  96594. /**
  96595. * Gets a boolean indicating if the animation has started
  96596. */
  96597. animationStarted: boolean;
  96598. /**
  96599. * Observer raised when the animation ends
  96600. */
  96601. onAnimationEndObservable: Observable<Animatable>;
  96602. /**
  96603. * Observer raised when the animation loops
  96604. */
  96605. onAnimationLoopObservable: Observable<Animatable>;
  96606. /**
  96607. * Gets the root Animatable used to synchronize and normalize animations
  96608. */
  96609. get syncRoot(): Nullable<Animatable>;
  96610. /**
  96611. * Gets the current frame of the first RuntimeAnimation
  96612. * Used to synchronize Animatables
  96613. */
  96614. get masterFrame(): number;
  96615. /**
  96616. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96617. */
  96618. get weight(): number;
  96619. set weight(value: number);
  96620. /**
  96621. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96622. */
  96623. get speedRatio(): number;
  96624. set speedRatio(value: number);
  96625. /**
  96626. * Creates a new Animatable
  96627. * @param scene defines the hosting scene
  96628. * @param target defines the target object
  96629. * @param fromFrame defines the starting frame number (default is 0)
  96630. * @param toFrame defines the ending frame number (default is 100)
  96631. * @param loopAnimation defines if the animation must loop (default is false)
  96632. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96633. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96634. * @param animations defines a group of animation to add to the new Animatable
  96635. * @param onAnimationLoop defines a callback to call when animation loops
  96636. * @param isAdditive defines whether the animation should be evaluated additively
  96637. */
  96638. constructor(scene: Scene,
  96639. /** defines the target object */
  96640. target: any,
  96641. /** defines the starting frame number (default is 0) */
  96642. fromFrame?: number,
  96643. /** defines the ending frame number (default is 100) */
  96644. toFrame?: number,
  96645. /** defines if the animation must loop (default is false) */
  96646. loopAnimation?: boolean, speedRatio?: number,
  96647. /** defines a callback to call when animation ends if it is not looping */
  96648. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96649. /** defines a callback to call when animation loops */
  96650. onAnimationLoop?: (() => void) | null | undefined,
  96651. /** defines whether the animation should be evaluated additively */
  96652. isAdditive?: boolean);
  96653. /**
  96654. * Synchronize and normalize current Animatable with a source Animatable
  96655. * This is useful when using animation weights and when animations are not of the same length
  96656. * @param root defines the root Animatable to synchronize with
  96657. * @returns the current Animatable
  96658. */
  96659. syncWith(root: Animatable): Animatable;
  96660. /**
  96661. * Gets the list of runtime animations
  96662. * @returns an array of RuntimeAnimation
  96663. */
  96664. getAnimations(): RuntimeAnimation[];
  96665. /**
  96666. * Adds more animations to the current animatable
  96667. * @param target defines the target of the animations
  96668. * @param animations defines the new animations to add
  96669. */
  96670. appendAnimations(target: any, animations: Animation[]): void;
  96671. /**
  96672. * Gets the source animation for a specific property
  96673. * @param property defines the propertyu to look for
  96674. * @returns null or the source animation for the given property
  96675. */
  96676. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96677. /**
  96678. * Gets the runtime animation for a specific property
  96679. * @param property defines the propertyu to look for
  96680. * @returns null or the runtime animation for the given property
  96681. */
  96682. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96683. /**
  96684. * Resets the animatable to its original state
  96685. */
  96686. reset(): void;
  96687. /**
  96688. * Allows the animatable to blend with current running animations
  96689. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96690. * @param blendingSpeed defines the blending speed to use
  96691. */
  96692. enableBlending(blendingSpeed: number): void;
  96693. /**
  96694. * Disable animation blending
  96695. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96696. */
  96697. disableBlending(): void;
  96698. /**
  96699. * Jump directly to a given frame
  96700. * @param frame defines the frame to jump to
  96701. */
  96702. goToFrame(frame: number): void;
  96703. /**
  96704. * Pause the animation
  96705. */
  96706. pause(): void;
  96707. /**
  96708. * Restart the animation
  96709. */
  96710. restart(): void;
  96711. private _raiseOnAnimationEnd;
  96712. /**
  96713. * Stop and delete the current animation
  96714. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96715. * @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)
  96716. */
  96717. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96718. /**
  96719. * Wait asynchronously for the animation to end
  96720. * @returns a promise which will be fullfilled when the animation ends
  96721. */
  96722. waitAsync(): Promise<Animatable>;
  96723. /** @hidden */
  96724. _animate(delay: number): boolean;
  96725. }
  96726. interface Scene {
  96727. /** @hidden */
  96728. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96729. /** @hidden */
  96730. _processLateAnimationBindingsForMatrices(holder: {
  96731. totalWeight: number;
  96732. totalAdditiveWeight: number;
  96733. animations: RuntimeAnimation[];
  96734. additiveAnimations: RuntimeAnimation[];
  96735. originalValue: Matrix;
  96736. }): any;
  96737. /** @hidden */
  96738. _processLateAnimationBindingsForQuaternions(holder: {
  96739. totalWeight: number;
  96740. totalAdditiveWeight: number;
  96741. animations: RuntimeAnimation[];
  96742. additiveAnimations: RuntimeAnimation[];
  96743. originalValue: Quaternion;
  96744. }, refQuaternion: Quaternion): Quaternion;
  96745. /** @hidden */
  96746. _processLateAnimationBindings(): void;
  96747. /**
  96748. * Will start the animation sequence of a given target
  96749. * @param target defines the target
  96750. * @param from defines from which frame should animation start
  96751. * @param to defines until which frame should animation run.
  96752. * @param weight defines the weight to apply to the animation (1.0 by default)
  96753. * @param loop defines if the animation loops
  96754. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96755. * @param onAnimationEnd defines the function to be executed when the animation ends
  96756. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96757. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96758. * @param onAnimationLoop defines the callback to call when an animation loops
  96759. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96760. * @returns the animatable object created for this animation
  96761. */
  96762. 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;
  96763. /**
  96764. * Will start the animation sequence of a given target
  96765. * @param target defines the target
  96766. * @param from defines from which frame should animation start
  96767. * @param to defines until which frame should animation run.
  96768. * @param loop defines if the animation loops
  96769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96770. * @param onAnimationEnd defines the function to be executed when the animation ends
  96771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96772. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96773. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96774. * @param onAnimationLoop defines the callback to call when an animation loops
  96775. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96776. * @returns the animatable object created for this animation
  96777. */
  96778. 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;
  96779. /**
  96780. * Will start the animation sequence of a given target and its hierarchy
  96781. * @param target defines the target
  96782. * @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.
  96783. * @param from defines from which frame should animation start
  96784. * @param to defines until which frame should animation run.
  96785. * @param loop defines if the animation loops
  96786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96787. * @param onAnimationEnd defines the function to be executed when the animation ends
  96788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96791. * @param onAnimationLoop defines the callback to call when an animation loops
  96792. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96793. * @returns the list of created animatables
  96794. */
  96795. 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[];
  96796. /**
  96797. * Begin a new animation on a given node
  96798. * @param target defines the target where the animation will take place
  96799. * @param animations defines the list of animations to start
  96800. * @param from defines the initial value
  96801. * @param to defines the final value
  96802. * @param loop defines if you want animation to loop (off by default)
  96803. * @param speedRatio defines the speed ratio to apply to all animations
  96804. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96805. * @param onAnimationLoop defines the callback to call when an animation loops
  96806. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96807. * @returns the list of created animatables
  96808. */
  96809. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96810. /**
  96811. * Begin a new animation on a given node and its hierarchy
  96812. * @param target defines the root node where the animation will take place
  96813. * @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.
  96814. * @param animations defines the list of animations to start
  96815. * @param from defines the initial value
  96816. * @param to defines the final value
  96817. * @param loop defines if you want animation to loop (off by default)
  96818. * @param speedRatio defines the speed ratio to apply to all animations
  96819. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96820. * @param onAnimationLoop defines the callback to call when an animation loops
  96821. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96822. * @returns the list of animatables created for all nodes
  96823. */
  96824. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96825. /**
  96826. * Gets the animatable associated with a specific target
  96827. * @param target defines the target of the animatable
  96828. * @returns the required animatable if found
  96829. */
  96830. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96831. /**
  96832. * Gets all animatables associated with a given target
  96833. * @param target defines the target to look animatables for
  96834. * @returns an array of Animatables
  96835. */
  96836. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96837. /**
  96838. * Stops and removes all animations that have been applied to the scene
  96839. */
  96840. stopAllAnimations(): void;
  96841. /**
  96842. * Gets the current delta time used by animation engine
  96843. */
  96844. deltaTime: number;
  96845. }
  96846. interface Bone {
  96847. /**
  96848. * Copy an animation range from another bone
  96849. * @param source defines the source bone
  96850. * @param rangeName defines the range name to copy
  96851. * @param frameOffset defines the frame offset
  96852. * @param rescaleAsRequired defines if rescaling must be applied if required
  96853. * @param skelDimensionsRatio defines the scaling ratio
  96854. * @returns true if operation was successful
  96855. */
  96856. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96857. }
  96858. }
  96859. declare module BABYLON {
  96860. /**
  96861. * Class used to handle skinning animations
  96862. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96863. */
  96864. export class Skeleton implements IAnimatable {
  96865. /** defines the skeleton name */
  96866. name: string;
  96867. /** defines the skeleton Id */
  96868. id: string;
  96869. /**
  96870. * Defines the list of child bones
  96871. */
  96872. bones: Bone[];
  96873. /**
  96874. * Defines an estimate of the dimension of the skeleton at rest
  96875. */
  96876. dimensionsAtRest: Vector3;
  96877. /**
  96878. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96879. */
  96880. needInitialSkinMatrix: boolean;
  96881. /**
  96882. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96883. */
  96884. overrideMesh: Nullable<AbstractMesh>;
  96885. /**
  96886. * Gets the list of animations attached to this skeleton
  96887. */
  96888. animations: Array<Animation>;
  96889. private _scene;
  96890. private _isDirty;
  96891. private _transformMatrices;
  96892. private _transformMatrixTexture;
  96893. private _meshesWithPoseMatrix;
  96894. private _animatables;
  96895. private _identity;
  96896. private _synchronizedWithMesh;
  96897. private _ranges;
  96898. private _lastAbsoluteTransformsUpdateId;
  96899. private _canUseTextureForBones;
  96900. private _uniqueId;
  96901. /** @hidden */
  96902. _numBonesWithLinkedTransformNode: number;
  96903. /** @hidden */
  96904. _hasWaitingData: Nullable<boolean>;
  96905. /** @hidden */
  96906. _waitingOverrideMeshId: Nullable<string>;
  96907. /**
  96908. * Specifies if the skeleton should be serialized
  96909. */
  96910. doNotSerialize: boolean;
  96911. private _useTextureToStoreBoneMatrices;
  96912. /**
  96913. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96914. * Please note that this option is not available if the hardware does not support it
  96915. */
  96916. get useTextureToStoreBoneMatrices(): boolean;
  96917. set useTextureToStoreBoneMatrices(value: boolean);
  96918. private _animationPropertiesOverride;
  96919. /**
  96920. * Gets or sets the animation properties override
  96921. */
  96922. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96923. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96924. /**
  96925. * List of inspectable custom properties (used by the Inspector)
  96926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96927. */
  96928. inspectableCustomProperties: IInspectable[];
  96929. /**
  96930. * An observable triggered before computing the skeleton's matrices
  96931. */
  96932. onBeforeComputeObservable: Observable<Skeleton>;
  96933. /**
  96934. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96935. */
  96936. get isUsingTextureForMatrices(): boolean;
  96937. /**
  96938. * Gets the unique ID of this skeleton
  96939. */
  96940. get uniqueId(): number;
  96941. /**
  96942. * Creates a new skeleton
  96943. * @param name defines the skeleton name
  96944. * @param id defines the skeleton Id
  96945. * @param scene defines the hosting scene
  96946. */
  96947. constructor(
  96948. /** defines the skeleton name */
  96949. name: string,
  96950. /** defines the skeleton Id */
  96951. id: string, scene: Scene);
  96952. /**
  96953. * Gets the current object class name.
  96954. * @return the class name
  96955. */
  96956. getClassName(): string;
  96957. /**
  96958. * Returns an array containing the root bones
  96959. * @returns an array containing the root bones
  96960. */
  96961. getChildren(): Array<Bone>;
  96962. /**
  96963. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96964. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96965. * @returns a Float32Array containing matrices data
  96966. */
  96967. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96968. /**
  96969. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96970. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96971. * @returns a raw texture containing the data
  96972. */
  96973. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96974. /**
  96975. * Gets the current hosting scene
  96976. * @returns a scene object
  96977. */
  96978. getScene(): Scene;
  96979. /**
  96980. * Gets a string representing the current skeleton data
  96981. * @param fullDetails defines a boolean indicating if we want a verbose version
  96982. * @returns a string representing the current skeleton data
  96983. */
  96984. toString(fullDetails?: boolean): string;
  96985. /**
  96986. * Get bone's index searching by name
  96987. * @param name defines bone's name to search for
  96988. * @return the indice of the bone. Returns -1 if not found
  96989. */
  96990. getBoneIndexByName(name: string): number;
  96991. /**
  96992. * Creater a new animation range
  96993. * @param name defines the name of the range
  96994. * @param from defines the start key
  96995. * @param to defines the end key
  96996. */
  96997. createAnimationRange(name: string, from: number, to: number): void;
  96998. /**
  96999. * Delete a specific animation range
  97000. * @param name defines the name of the range
  97001. * @param deleteFrames defines if frames must be removed as well
  97002. */
  97003. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97004. /**
  97005. * Gets a specific animation range
  97006. * @param name defines the name of the range to look for
  97007. * @returns the requested animation range or null if not found
  97008. */
  97009. getAnimationRange(name: string): Nullable<AnimationRange>;
  97010. /**
  97011. * Gets the list of all animation ranges defined on this skeleton
  97012. * @returns an array
  97013. */
  97014. getAnimationRanges(): Nullable<AnimationRange>[];
  97015. /**
  97016. * Copy animation range from a source skeleton.
  97017. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97018. * @param source defines the source skeleton
  97019. * @param name defines the name of the range to copy
  97020. * @param rescaleAsRequired defines if rescaling must be applied if required
  97021. * @returns true if operation was successful
  97022. */
  97023. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97024. /**
  97025. * Forces the skeleton to go to rest pose
  97026. */
  97027. returnToRest(): void;
  97028. private _getHighestAnimationFrame;
  97029. /**
  97030. * Begin a specific animation range
  97031. * @param name defines the name of the range to start
  97032. * @param loop defines if looping must be turned on (false by default)
  97033. * @param speedRatio defines the speed ratio to apply (1 by default)
  97034. * @param onAnimationEnd defines a callback which will be called when animation will end
  97035. * @returns a new animatable
  97036. */
  97037. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97038. /**
  97039. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97040. * @param skeleton defines the Skeleton containing the animation range to convert
  97041. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97042. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97043. * @returns the original skeleton
  97044. */
  97045. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97046. /** @hidden */
  97047. _markAsDirty(): void;
  97048. /** @hidden */
  97049. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97050. /** @hidden */
  97051. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97052. private _computeTransformMatrices;
  97053. /**
  97054. * Build all resources required to render a skeleton
  97055. */
  97056. prepare(): void;
  97057. /**
  97058. * Gets the list of animatables currently running for this skeleton
  97059. * @returns an array of animatables
  97060. */
  97061. getAnimatables(): IAnimatable[];
  97062. /**
  97063. * Clone the current skeleton
  97064. * @param name defines the name of the new skeleton
  97065. * @param id defines the id of the new skeleton
  97066. * @returns the new skeleton
  97067. */
  97068. clone(name: string, id?: string): Skeleton;
  97069. /**
  97070. * Enable animation blending for this skeleton
  97071. * @param blendingSpeed defines the blending speed to apply
  97072. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97073. */
  97074. enableBlending(blendingSpeed?: number): void;
  97075. /**
  97076. * Releases all resources associated with the current skeleton
  97077. */
  97078. dispose(): void;
  97079. /**
  97080. * Serialize the skeleton in a JSON object
  97081. * @returns a JSON object
  97082. */
  97083. serialize(): any;
  97084. /**
  97085. * Creates a new skeleton from serialized data
  97086. * @param parsedSkeleton defines the serialized data
  97087. * @param scene defines the hosting scene
  97088. * @returns a new skeleton
  97089. */
  97090. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97091. /**
  97092. * Compute all node absolute transforms
  97093. * @param forceUpdate defines if computation must be done even if cache is up to date
  97094. */
  97095. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97096. /**
  97097. * Gets the root pose matrix
  97098. * @returns a matrix
  97099. */
  97100. getPoseMatrix(): Nullable<Matrix>;
  97101. /**
  97102. * Sorts bones per internal index
  97103. */
  97104. sortBones(): void;
  97105. private _sortBones;
  97106. /**
  97107. * Set the current local matrix as the restPose for all bones in the skeleton.
  97108. */
  97109. setCurrentPoseAsRest(): void;
  97110. }
  97111. }
  97112. declare module BABYLON {
  97113. /**
  97114. * Creates an instance based on a source mesh.
  97115. */
  97116. export class InstancedMesh extends AbstractMesh {
  97117. private _sourceMesh;
  97118. private _currentLOD;
  97119. /** @hidden */
  97120. _indexInSourceMeshInstanceArray: number;
  97121. constructor(name: string, source: Mesh);
  97122. /**
  97123. * Returns the string "InstancedMesh".
  97124. */
  97125. getClassName(): string;
  97126. /** Gets the list of lights affecting that mesh */
  97127. get lightSources(): Light[];
  97128. _resyncLightSources(): void;
  97129. _resyncLightSource(light: Light): void;
  97130. _removeLightSource(light: Light, dispose: boolean): void;
  97131. /**
  97132. * If the source mesh receives shadows
  97133. */
  97134. get receiveShadows(): boolean;
  97135. /**
  97136. * The material of the source mesh
  97137. */
  97138. get material(): Nullable<Material>;
  97139. /**
  97140. * Visibility of the source mesh
  97141. */
  97142. get visibility(): number;
  97143. /**
  97144. * Skeleton of the source mesh
  97145. */
  97146. get skeleton(): Nullable<Skeleton>;
  97147. /**
  97148. * Rendering ground id of the source mesh
  97149. */
  97150. get renderingGroupId(): number;
  97151. set renderingGroupId(value: number);
  97152. /**
  97153. * Returns the total number of vertices (integer).
  97154. */
  97155. getTotalVertices(): number;
  97156. /**
  97157. * Returns a positive integer : the total number of indices in this mesh geometry.
  97158. * @returns the numner of indices or zero if the mesh has no geometry.
  97159. */
  97160. getTotalIndices(): number;
  97161. /**
  97162. * The source mesh of the instance
  97163. */
  97164. get sourceMesh(): Mesh;
  97165. /**
  97166. * Creates a new InstancedMesh object from the mesh model.
  97167. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97168. * @param name defines the name of the new instance
  97169. * @returns a new InstancedMesh
  97170. */
  97171. createInstance(name: string): InstancedMesh;
  97172. /**
  97173. * Is this node ready to be used/rendered
  97174. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97175. * @return {boolean} is it ready
  97176. */
  97177. isReady(completeCheck?: boolean): boolean;
  97178. /**
  97179. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97180. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97181. * @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.
  97182. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97183. */
  97184. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97185. /**
  97186. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97187. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97188. * The `data` are either a numeric array either a Float32Array.
  97189. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97190. * 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).
  97191. * Note that a new underlying VertexBuffer object is created each call.
  97192. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97193. *
  97194. * Possible `kind` values :
  97195. * - VertexBuffer.PositionKind
  97196. * - VertexBuffer.UVKind
  97197. * - VertexBuffer.UV2Kind
  97198. * - VertexBuffer.UV3Kind
  97199. * - VertexBuffer.UV4Kind
  97200. * - VertexBuffer.UV5Kind
  97201. * - VertexBuffer.UV6Kind
  97202. * - VertexBuffer.ColorKind
  97203. * - VertexBuffer.MatricesIndicesKind
  97204. * - VertexBuffer.MatricesIndicesExtraKind
  97205. * - VertexBuffer.MatricesWeightsKind
  97206. * - VertexBuffer.MatricesWeightsExtraKind
  97207. *
  97208. * Returns the Mesh.
  97209. */
  97210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97211. /**
  97212. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97213. * If the mesh has no geometry, it is simply returned as it is.
  97214. * The `data` are either a numeric array either a Float32Array.
  97215. * No new underlying VertexBuffer object is created.
  97216. * 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.
  97217. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97218. *
  97219. * Possible `kind` values :
  97220. * - VertexBuffer.PositionKind
  97221. * - VertexBuffer.UVKind
  97222. * - VertexBuffer.UV2Kind
  97223. * - VertexBuffer.UV3Kind
  97224. * - VertexBuffer.UV4Kind
  97225. * - VertexBuffer.UV5Kind
  97226. * - VertexBuffer.UV6Kind
  97227. * - VertexBuffer.ColorKind
  97228. * - VertexBuffer.MatricesIndicesKind
  97229. * - VertexBuffer.MatricesIndicesExtraKind
  97230. * - VertexBuffer.MatricesWeightsKind
  97231. * - VertexBuffer.MatricesWeightsExtraKind
  97232. *
  97233. * Returns the Mesh.
  97234. */
  97235. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97236. /**
  97237. * Sets the mesh indices.
  97238. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97239. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97240. * This method creates a new index buffer each call.
  97241. * Returns the Mesh.
  97242. */
  97243. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97244. /**
  97245. * Boolean : True if the mesh owns the requested kind of data.
  97246. */
  97247. isVerticesDataPresent(kind: string): boolean;
  97248. /**
  97249. * Returns an array of indices (IndicesArray).
  97250. */
  97251. getIndices(): Nullable<IndicesArray>;
  97252. get _positions(): Nullable<Vector3[]>;
  97253. /**
  97254. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97255. * This means the mesh underlying bounding box and sphere are recomputed.
  97256. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97257. * @returns the current mesh
  97258. */
  97259. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97260. /** @hidden */
  97261. _preActivate(): InstancedMesh;
  97262. /** @hidden */
  97263. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97264. /** @hidden */
  97265. _postActivate(): void;
  97266. getWorldMatrix(): Matrix;
  97267. get isAnInstance(): boolean;
  97268. /**
  97269. * Returns the current associated LOD AbstractMesh.
  97270. */
  97271. getLOD(camera: Camera): AbstractMesh;
  97272. /** @hidden */
  97273. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97274. /** @hidden */
  97275. _syncSubMeshes(): InstancedMesh;
  97276. /** @hidden */
  97277. _generatePointsArray(): boolean;
  97278. /** @hidden */
  97279. _updateBoundingInfo(): AbstractMesh;
  97280. /**
  97281. * Creates a new InstancedMesh from the current mesh.
  97282. * - name (string) : the cloned mesh name
  97283. * - newParent (optional Node) : the optional Node to parent the clone to.
  97284. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97285. *
  97286. * Returns the clone.
  97287. */
  97288. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97289. /**
  97290. * Disposes the InstancedMesh.
  97291. * Returns nothing.
  97292. */
  97293. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97294. }
  97295. interface Mesh {
  97296. /**
  97297. * Register a custom buffer that will be instanced
  97298. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97299. * @param kind defines the buffer kind
  97300. * @param stride defines the stride in floats
  97301. */
  97302. registerInstancedBuffer(kind: string, stride: number): void;
  97303. /**
  97304. * true to use the edge renderer for all instances of this mesh
  97305. */
  97306. edgesShareWithInstances: boolean;
  97307. /** @hidden */
  97308. _userInstancedBuffersStorage: {
  97309. data: {
  97310. [key: string]: Float32Array;
  97311. };
  97312. sizes: {
  97313. [key: string]: number;
  97314. };
  97315. vertexBuffers: {
  97316. [key: string]: Nullable<VertexBuffer>;
  97317. };
  97318. strides: {
  97319. [key: string]: number;
  97320. };
  97321. };
  97322. }
  97323. interface AbstractMesh {
  97324. /**
  97325. * Object used to store instanced buffers defined by user
  97326. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97327. */
  97328. instancedBuffers: {
  97329. [key: string]: any;
  97330. };
  97331. }
  97332. }
  97333. declare module BABYLON {
  97334. /**
  97335. * Defines the options associated with the creation of a shader material.
  97336. */
  97337. export interface IShaderMaterialOptions {
  97338. /**
  97339. * Does the material work in alpha blend mode
  97340. */
  97341. needAlphaBlending: boolean;
  97342. /**
  97343. * Does the material work in alpha test mode
  97344. */
  97345. needAlphaTesting: boolean;
  97346. /**
  97347. * The list of attribute names used in the shader
  97348. */
  97349. attributes: string[];
  97350. /**
  97351. * The list of unifrom names used in the shader
  97352. */
  97353. uniforms: string[];
  97354. /**
  97355. * The list of UBO names used in the shader
  97356. */
  97357. uniformBuffers: string[];
  97358. /**
  97359. * The list of sampler names used in the shader
  97360. */
  97361. samplers: string[];
  97362. /**
  97363. * The list of defines used in the shader
  97364. */
  97365. defines: string[];
  97366. }
  97367. /**
  97368. * 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.
  97369. *
  97370. * This returned material effects how the mesh will look based on the code in the shaders.
  97371. *
  97372. * @see https://doc.babylonjs.com/how_to/shader_material
  97373. */
  97374. export class ShaderMaterial extends Material {
  97375. private _shaderPath;
  97376. private _options;
  97377. private _textures;
  97378. private _textureArrays;
  97379. private _floats;
  97380. private _ints;
  97381. private _floatsArrays;
  97382. private _colors3;
  97383. private _colors3Arrays;
  97384. private _colors4;
  97385. private _colors4Arrays;
  97386. private _vectors2;
  97387. private _vectors3;
  97388. private _vectors4;
  97389. private _matrices;
  97390. private _matrixArrays;
  97391. private _matrices3x3;
  97392. private _matrices2x2;
  97393. private _vectors2Arrays;
  97394. private _vectors3Arrays;
  97395. private _vectors4Arrays;
  97396. private _cachedWorldViewMatrix;
  97397. private _cachedWorldViewProjectionMatrix;
  97398. private _renderId;
  97399. private _multiview;
  97400. private _cachedDefines;
  97401. /** Define the Url to load snippets */
  97402. static SnippetUrl: string;
  97403. /** Snippet ID if the material was created from the snippet server */
  97404. snippetId: string;
  97405. /**
  97406. * Instantiate a new shader material.
  97407. * 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.
  97408. * This returned material effects how the mesh will look based on the code in the shaders.
  97409. * @see https://doc.babylonjs.com/how_to/shader_material
  97410. * @param name Define the name of the material in the scene
  97411. * @param scene Define the scene the material belongs to
  97412. * @param shaderPath Defines the route to the shader code in one of three ways:
  97413. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97414. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97415. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97416. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97417. * @param options Define the options used to create the shader
  97418. */
  97419. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97420. /**
  97421. * Gets the shader path used to define the shader code
  97422. * It can be modified to trigger a new compilation
  97423. */
  97424. get shaderPath(): any;
  97425. /**
  97426. * Sets the shader path used to define the shader code
  97427. * It can be modified to trigger a new compilation
  97428. */
  97429. set shaderPath(shaderPath: any);
  97430. /**
  97431. * Gets the options used to compile the shader.
  97432. * They can be modified to trigger a new compilation
  97433. */
  97434. get options(): IShaderMaterialOptions;
  97435. /**
  97436. * Gets the current class name of the material e.g. "ShaderMaterial"
  97437. * Mainly use in serialization.
  97438. * @returns the class name
  97439. */
  97440. getClassName(): string;
  97441. /**
  97442. * Specifies if the material will require alpha blending
  97443. * @returns a boolean specifying if alpha blending is needed
  97444. */
  97445. needAlphaBlending(): boolean;
  97446. /**
  97447. * Specifies if this material should be rendered in alpha test mode
  97448. * @returns a boolean specifying if an alpha test is needed.
  97449. */
  97450. needAlphaTesting(): boolean;
  97451. private _checkUniform;
  97452. /**
  97453. * Set a texture in the shader.
  97454. * @param name Define the name of the uniform samplers as defined in the shader
  97455. * @param texture Define the texture to bind to this sampler
  97456. * @return the material itself allowing "fluent" like uniform updates
  97457. */
  97458. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97459. /**
  97460. * Set a texture array in the shader.
  97461. * @param name Define the name of the uniform sampler array as defined in the shader
  97462. * @param textures Define the list of textures to bind to this sampler
  97463. * @return the material itself allowing "fluent" like uniform updates
  97464. */
  97465. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97466. /**
  97467. * Set a float in the shader.
  97468. * @param name Define the name of the uniform as defined in the shader
  97469. * @param value Define the value to give to the uniform
  97470. * @return the material itself allowing "fluent" like uniform updates
  97471. */
  97472. setFloat(name: string, value: number): ShaderMaterial;
  97473. /**
  97474. * Set a int in the shader.
  97475. * @param name Define the name of the uniform as defined in the shader
  97476. * @param value Define the value to give to the uniform
  97477. * @return the material itself allowing "fluent" like uniform updates
  97478. */
  97479. setInt(name: string, value: number): ShaderMaterial;
  97480. /**
  97481. * Set an array of floats in the shader.
  97482. * @param name Define the name of the uniform as defined in the shader
  97483. * @param value Define the value to give to the uniform
  97484. * @return the material itself allowing "fluent" like uniform updates
  97485. */
  97486. setFloats(name: string, value: number[]): ShaderMaterial;
  97487. /**
  97488. * Set a vec3 in the shader from a Color3.
  97489. * @param name Define the name of the uniform as defined in the shader
  97490. * @param value Define the value to give to the uniform
  97491. * @return the material itself allowing "fluent" like uniform updates
  97492. */
  97493. setColor3(name: string, value: Color3): ShaderMaterial;
  97494. /**
  97495. * Set a vec3 array in the shader from a Color3 array.
  97496. * @param name Define the name of the uniform as defined in the shader
  97497. * @param value Define the value to give to the uniform
  97498. * @return the material itself allowing "fluent" like uniform updates
  97499. */
  97500. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97501. /**
  97502. * Set a vec4 in the shader from a Color4.
  97503. * @param name Define the name of the uniform as defined in the shader
  97504. * @param value Define the value to give to the uniform
  97505. * @return the material itself allowing "fluent" like uniform updates
  97506. */
  97507. setColor4(name: string, value: Color4): ShaderMaterial;
  97508. /**
  97509. * Set a vec4 array in the shader from a Color4 array.
  97510. * @param name Define the name of the uniform as defined in the shader
  97511. * @param value Define the value to give to the uniform
  97512. * @return the material itself allowing "fluent" like uniform updates
  97513. */
  97514. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97515. /**
  97516. * Set a vec2 in the shader from a Vector2.
  97517. * @param name Define the name of the uniform as defined in the shader
  97518. * @param value Define the value to give to the uniform
  97519. * @return the material itself allowing "fluent" like uniform updates
  97520. */
  97521. setVector2(name: string, value: Vector2): ShaderMaterial;
  97522. /**
  97523. * Set a vec3 in the shader from a Vector3.
  97524. * @param name Define the name of the uniform as defined in the shader
  97525. * @param value Define the value to give to the uniform
  97526. * @return the material itself allowing "fluent" like uniform updates
  97527. */
  97528. setVector3(name: string, value: Vector3): ShaderMaterial;
  97529. /**
  97530. * Set a vec4 in the shader from a Vector4.
  97531. * @param name Define the name of the uniform as defined in the shader
  97532. * @param value Define the value to give to the uniform
  97533. * @return the material itself allowing "fluent" like uniform updates
  97534. */
  97535. setVector4(name: string, value: Vector4): ShaderMaterial;
  97536. /**
  97537. * Set a mat4 in the shader from a Matrix.
  97538. * @param name Define the name of the uniform as defined in the shader
  97539. * @param value Define the value to give to the uniform
  97540. * @return the material itself allowing "fluent" like uniform updates
  97541. */
  97542. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97543. /**
  97544. * Set a float32Array in the shader from a matrix array.
  97545. * @param name Define the name of the uniform as defined in the shader
  97546. * @param value Define the value to give to the uniform
  97547. * @return the material itself allowing "fluent" like uniform updates
  97548. */
  97549. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97550. /**
  97551. * Set a mat3 in the shader from a Float32Array.
  97552. * @param name Define the name of the uniform as defined in the shader
  97553. * @param value Define the value to give to the uniform
  97554. * @return the material itself allowing "fluent" like uniform updates
  97555. */
  97556. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97557. /**
  97558. * Set a mat2 in the shader from a Float32Array.
  97559. * @param name Define the name of the uniform as defined in the shader
  97560. * @param value Define the value to give to the uniform
  97561. * @return the material itself allowing "fluent" like uniform updates
  97562. */
  97563. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97564. /**
  97565. * Set a vec2 array in the shader from a number array.
  97566. * @param name Define the name of the uniform as defined in the shader
  97567. * @param value Define the value to give to the uniform
  97568. * @return the material itself allowing "fluent" like uniform updates
  97569. */
  97570. setArray2(name: string, value: number[]): ShaderMaterial;
  97571. /**
  97572. * Set a vec3 array in the shader from a number array.
  97573. * @param name Define the name of the uniform as defined in the shader
  97574. * @param value Define the value to give to the uniform
  97575. * @return the material itself allowing "fluent" like uniform updates
  97576. */
  97577. setArray3(name: string, value: number[]): ShaderMaterial;
  97578. /**
  97579. * Set a vec4 array in the shader from a number array.
  97580. * @param name Define the name of the uniform as defined in the shader
  97581. * @param value Define the value to give to the uniform
  97582. * @return the material itself allowing "fluent" like uniform updates
  97583. */
  97584. setArray4(name: string, value: number[]): ShaderMaterial;
  97585. private _checkCache;
  97586. /**
  97587. * Specifies that the submesh is ready to be used
  97588. * @param mesh defines the mesh to check
  97589. * @param subMesh defines which submesh to check
  97590. * @param useInstances specifies that instances should be used
  97591. * @returns a boolean indicating that the submesh is ready or not
  97592. */
  97593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97594. /**
  97595. * Checks if the material is ready to render the requested mesh
  97596. * @param mesh Define the mesh to render
  97597. * @param useInstances Define whether or not the material is used with instances
  97598. * @returns true if ready, otherwise false
  97599. */
  97600. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97601. /**
  97602. * Binds the world matrix to the material
  97603. * @param world defines the world transformation matrix
  97604. * @param effectOverride - If provided, use this effect instead of internal effect
  97605. */
  97606. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97607. /**
  97608. * Binds the submesh to this material by preparing the effect and shader to draw
  97609. * @param world defines the world transformation matrix
  97610. * @param mesh defines the mesh containing the submesh
  97611. * @param subMesh defines the submesh to bind the material to
  97612. */
  97613. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97614. /**
  97615. * Binds the material to the mesh
  97616. * @param world defines the world transformation matrix
  97617. * @param mesh defines the mesh to bind the material to
  97618. * @param effectOverride - If provided, use this effect instead of internal effect
  97619. */
  97620. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97621. protected _afterBind(mesh?: Mesh): void;
  97622. /**
  97623. * Gets the active textures from the material
  97624. * @returns an array of textures
  97625. */
  97626. getActiveTextures(): BaseTexture[];
  97627. /**
  97628. * Specifies if the material uses a texture
  97629. * @param texture defines the texture to check against the material
  97630. * @returns a boolean specifying if the material uses the texture
  97631. */
  97632. hasTexture(texture: BaseTexture): boolean;
  97633. /**
  97634. * Makes a duplicate of the material, and gives it a new name
  97635. * @param name defines the new name for the duplicated material
  97636. * @returns the cloned material
  97637. */
  97638. clone(name: string): ShaderMaterial;
  97639. /**
  97640. * Disposes the material
  97641. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97642. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97643. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97644. */
  97645. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97646. /**
  97647. * Serializes this material in a JSON representation
  97648. * @returns the serialized material object
  97649. */
  97650. serialize(): any;
  97651. /**
  97652. * Creates a shader material from parsed shader material data
  97653. * @param source defines the JSON represnetation of the material
  97654. * @param scene defines the hosting scene
  97655. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97656. * @returns a new material
  97657. */
  97658. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97659. /**
  97660. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97661. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97662. * @param url defines the url to load from
  97663. * @param scene defines the hosting scene
  97664. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97665. * @returns a promise that will resolve to the new ShaderMaterial
  97666. */
  97667. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97668. /**
  97669. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97670. * @param snippetId defines the snippet to load
  97671. * @param scene defines the hosting scene
  97672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97673. * @returns a promise that will resolve to the new ShaderMaterial
  97674. */
  97675. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97676. }
  97677. }
  97678. declare module BABYLON {
  97679. /** @hidden */
  97680. export var colorPixelShader: {
  97681. name: string;
  97682. shader: string;
  97683. };
  97684. }
  97685. declare module BABYLON {
  97686. /** @hidden */
  97687. export var colorVertexShader: {
  97688. name: string;
  97689. shader: string;
  97690. };
  97691. }
  97692. declare module BABYLON {
  97693. /**
  97694. * Line mesh
  97695. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97696. */
  97697. export class LinesMesh extends Mesh {
  97698. /**
  97699. * If vertex color should be applied to the mesh
  97700. */
  97701. readonly useVertexColor?: boolean | undefined;
  97702. /**
  97703. * If vertex alpha should be applied to the mesh
  97704. */
  97705. readonly useVertexAlpha?: boolean | undefined;
  97706. /**
  97707. * Color of the line (Default: White)
  97708. */
  97709. color: Color3;
  97710. /**
  97711. * Alpha of the line (Default: 1)
  97712. */
  97713. alpha: number;
  97714. /**
  97715. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97716. * This margin is expressed in world space coordinates, so its value may vary.
  97717. * Default value is 0.1
  97718. */
  97719. intersectionThreshold: number;
  97720. private _colorShader;
  97721. private color4;
  97722. /**
  97723. * Creates a new LinesMesh
  97724. * @param name defines the name
  97725. * @param scene defines the hosting scene
  97726. * @param parent defines the parent mesh if any
  97727. * @param source defines the optional source LinesMesh used to clone data from
  97728. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97729. * When false, achieved by calling a clone(), also passing False.
  97730. * This will make creation of children, recursive.
  97731. * @param useVertexColor defines if this LinesMesh supports vertex color
  97732. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97733. */
  97734. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97735. /**
  97736. * If vertex color should be applied to the mesh
  97737. */
  97738. useVertexColor?: boolean | undefined,
  97739. /**
  97740. * If vertex alpha should be applied to the mesh
  97741. */
  97742. useVertexAlpha?: boolean | undefined);
  97743. private _addClipPlaneDefine;
  97744. private _removeClipPlaneDefine;
  97745. isReady(): boolean;
  97746. /**
  97747. * Returns the string "LineMesh"
  97748. */
  97749. getClassName(): string;
  97750. /**
  97751. * @hidden
  97752. */
  97753. get material(): Material;
  97754. /**
  97755. * @hidden
  97756. */
  97757. set material(value: Material);
  97758. /**
  97759. * @hidden
  97760. */
  97761. get checkCollisions(): boolean;
  97762. /** @hidden */
  97763. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97764. /** @hidden */
  97765. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97766. /**
  97767. * Disposes of the line mesh
  97768. * @param doNotRecurse If children should be disposed
  97769. */
  97770. dispose(doNotRecurse?: boolean): void;
  97771. /**
  97772. * Returns a new LineMesh object cloned from the current one.
  97773. */
  97774. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97775. /**
  97776. * Creates a new InstancedLinesMesh object from the mesh model.
  97777. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97778. * @param name defines the name of the new instance
  97779. * @returns a new InstancedLinesMesh
  97780. */
  97781. createInstance(name: string): InstancedLinesMesh;
  97782. }
  97783. /**
  97784. * Creates an instance based on a source LinesMesh
  97785. */
  97786. export class InstancedLinesMesh extends InstancedMesh {
  97787. /**
  97788. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97789. * This margin is expressed in world space coordinates, so its value may vary.
  97790. * Initilized with the intersectionThreshold value of the source LinesMesh
  97791. */
  97792. intersectionThreshold: number;
  97793. constructor(name: string, source: LinesMesh);
  97794. /**
  97795. * Returns the string "InstancedLinesMesh".
  97796. */
  97797. getClassName(): string;
  97798. }
  97799. }
  97800. declare module BABYLON {
  97801. /** @hidden */
  97802. export var linePixelShader: {
  97803. name: string;
  97804. shader: string;
  97805. };
  97806. }
  97807. declare module BABYLON {
  97808. /** @hidden */
  97809. export var lineVertexShader: {
  97810. name: string;
  97811. shader: string;
  97812. };
  97813. }
  97814. declare module BABYLON {
  97815. interface Scene {
  97816. /** @hidden */
  97817. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97818. }
  97819. interface AbstractMesh {
  97820. /**
  97821. * Gets the edgesRenderer associated with the mesh
  97822. */
  97823. edgesRenderer: Nullable<EdgesRenderer>;
  97824. }
  97825. interface LinesMesh {
  97826. /**
  97827. * Enables the edge rendering mode on the mesh.
  97828. * This mode makes the mesh edges visible
  97829. * @param epsilon defines the maximal distance between two angles to detect a face
  97830. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97831. * @returns the currentAbstractMesh
  97832. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97833. */
  97834. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97835. }
  97836. interface InstancedLinesMesh {
  97837. /**
  97838. * Enables the edge rendering mode on the mesh.
  97839. * This mode makes the mesh edges visible
  97840. * @param epsilon defines the maximal distance between two angles to detect a face
  97841. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97842. * @returns the current InstancedLinesMesh
  97843. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97844. */
  97845. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97846. }
  97847. /**
  97848. * Defines the minimum contract an Edges renderer should follow.
  97849. */
  97850. export interface IEdgesRenderer extends IDisposable {
  97851. /**
  97852. * Gets or sets a boolean indicating if the edgesRenderer is active
  97853. */
  97854. isEnabled: boolean;
  97855. /**
  97856. * Renders the edges of the attached mesh,
  97857. */
  97858. render(): void;
  97859. /**
  97860. * Checks wether or not the edges renderer is ready to render.
  97861. * @return true if ready, otherwise false.
  97862. */
  97863. isReady(): boolean;
  97864. /**
  97865. * List of instances to render in case the source mesh has instances
  97866. */
  97867. customInstances: SmartArray<Matrix>;
  97868. }
  97869. /**
  97870. * Defines the additional options of the edges renderer
  97871. */
  97872. export interface IEdgesRendererOptions {
  97873. /**
  97874. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97875. * If not defined, the default value is true
  97876. */
  97877. useAlternateEdgeFinder?: boolean;
  97878. /**
  97879. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97880. * If not defined, the default value is true.
  97881. * 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)
  97882. * This option is used only if useAlternateEdgeFinder = true
  97883. */
  97884. useFastVertexMerger?: boolean;
  97885. /**
  97886. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97887. * The default value is 1e-6
  97888. * This option is used only if useAlternateEdgeFinder = true
  97889. */
  97890. epsilonVertexMerge?: number;
  97891. /**
  97892. * 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
  97893. * 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.
  97894. * This option is used only if useAlternateEdgeFinder = true
  97895. */
  97896. applyTessellation?: boolean;
  97897. /**
  97898. * 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
  97899. * The default value is 1e-6
  97900. * This option is used only if useAlternateEdgeFinder = true
  97901. */
  97902. epsilonVertexAligned?: number;
  97903. }
  97904. /**
  97905. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97906. */
  97907. export class EdgesRenderer implements IEdgesRenderer {
  97908. /**
  97909. * Define the size of the edges with an orthographic camera
  97910. */
  97911. edgesWidthScalerForOrthographic: number;
  97912. /**
  97913. * Define the size of the edges with a perspective camera
  97914. */
  97915. edgesWidthScalerForPerspective: number;
  97916. protected _source: AbstractMesh;
  97917. protected _linesPositions: number[];
  97918. protected _linesNormals: number[];
  97919. protected _linesIndices: number[];
  97920. protected _epsilon: number;
  97921. protected _indicesCount: number;
  97922. protected _lineShader: ShaderMaterial;
  97923. protected _ib: DataBuffer;
  97924. protected _buffers: {
  97925. [key: string]: Nullable<VertexBuffer>;
  97926. };
  97927. protected _buffersForInstances: {
  97928. [key: string]: Nullable<VertexBuffer>;
  97929. };
  97930. protected _checkVerticesInsteadOfIndices: boolean;
  97931. protected _options: Nullable<IEdgesRendererOptions>;
  97932. private _meshRebuildObserver;
  97933. private _meshDisposeObserver;
  97934. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97935. isEnabled: boolean;
  97936. /**
  97937. * List of instances to render in case the source mesh has instances
  97938. */
  97939. customInstances: SmartArray<Matrix>;
  97940. private static GetShader;
  97941. /**
  97942. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97943. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97944. * @param source Mesh used to create edges
  97945. * @param epsilon sum of angles in adjacency to check for edge
  97946. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97947. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97948. * @param options The options to apply when generating the edges
  97949. */
  97950. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97951. protected _prepareRessources(): void;
  97952. /** @hidden */
  97953. _rebuild(): void;
  97954. /**
  97955. * Releases the required resources for the edges renderer
  97956. */
  97957. dispose(): void;
  97958. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97959. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97960. /**
  97961. * Checks if the pair of p0 and p1 is en edge
  97962. * @param faceIndex
  97963. * @param edge
  97964. * @param faceNormals
  97965. * @param p0
  97966. * @param p1
  97967. * @private
  97968. */
  97969. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97970. /**
  97971. * push line into the position, normal and index buffer
  97972. * @protected
  97973. */
  97974. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97975. /**
  97976. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97977. */
  97978. private _tessellateTriangle;
  97979. private _generateEdgesLinesAlternate;
  97980. /**
  97981. * Generates lines edges from adjacencjes
  97982. * @private
  97983. */
  97984. _generateEdgesLines(): void;
  97985. /**
  97986. * Checks wether or not the edges renderer is ready to render.
  97987. * @return true if ready, otherwise false.
  97988. */
  97989. isReady(): boolean;
  97990. /**
  97991. * Renders the edges of the attached mesh,
  97992. */
  97993. render(): void;
  97994. }
  97995. /**
  97996. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97997. */
  97998. export class LineEdgesRenderer extends EdgesRenderer {
  97999. /**
  98000. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98001. * @param source LineMesh used to generate edges
  98002. * @param epsilon not important (specified angle for edge detection)
  98003. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98004. */
  98005. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98006. /**
  98007. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98008. */
  98009. _generateEdgesLines(): void;
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * This represents the object necessary to create a rendering group.
  98015. * This is exclusively used and created by the rendering manager.
  98016. * To modify the behavior, you use the available helpers in your scene or meshes.
  98017. * @hidden
  98018. */
  98019. export class RenderingGroup {
  98020. index: number;
  98021. private static _zeroVector;
  98022. private _scene;
  98023. private _opaqueSubMeshes;
  98024. private _transparentSubMeshes;
  98025. private _alphaTestSubMeshes;
  98026. private _depthOnlySubMeshes;
  98027. private _particleSystems;
  98028. private _spriteManagers;
  98029. private _opaqueSortCompareFn;
  98030. private _alphaTestSortCompareFn;
  98031. private _transparentSortCompareFn;
  98032. private _renderOpaque;
  98033. private _renderAlphaTest;
  98034. private _renderTransparent;
  98035. /** @hidden */
  98036. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98037. onBeforeTransparentRendering: () => void;
  98038. /**
  98039. * Set the opaque sort comparison function.
  98040. * If null the sub meshes will be render in the order they were created
  98041. */
  98042. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98043. /**
  98044. * Set the alpha test sort comparison function.
  98045. * If null the sub meshes will be render in the order they were created
  98046. */
  98047. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98048. /**
  98049. * Set the transparent sort comparison function.
  98050. * If null the sub meshes will be render in the order they were created
  98051. */
  98052. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98053. /**
  98054. * Creates a new rendering group.
  98055. * @param index The rendering group index
  98056. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98057. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98058. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98059. */
  98060. 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>);
  98061. /**
  98062. * Render all the sub meshes contained in the group.
  98063. * @param customRenderFunction Used to override the default render behaviour of the group.
  98064. * @returns true if rendered some submeshes.
  98065. */
  98066. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98067. /**
  98068. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98069. * @param subMeshes The submeshes to render
  98070. */
  98071. private renderOpaqueSorted;
  98072. /**
  98073. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98074. * @param subMeshes The submeshes to render
  98075. */
  98076. private renderAlphaTestSorted;
  98077. /**
  98078. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98079. * @param subMeshes The submeshes to render
  98080. */
  98081. private renderTransparentSorted;
  98082. /**
  98083. * Renders the submeshes in a specified order.
  98084. * @param subMeshes The submeshes to sort before render
  98085. * @param sortCompareFn The comparison function use to sort
  98086. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98087. * @param transparent Specifies to activate blending if true
  98088. */
  98089. private static renderSorted;
  98090. /**
  98091. * Renders the submeshes in the order they were dispatched (no sort applied).
  98092. * @param subMeshes The submeshes to render
  98093. */
  98094. private static renderUnsorted;
  98095. /**
  98096. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98097. * are rendered back to front if in the same alpha index.
  98098. *
  98099. * @param a The first submesh
  98100. * @param b The second submesh
  98101. * @returns The result of the comparison
  98102. */
  98103. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98104. /**
  98105. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98106. * are rendered back to front.
  98107. *
  98108. * @param a The first submesh
  98109. * @param b The second submesh
  98110. * @returns The result of the comparison
  98111. */
  98112. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98113. /**
  98114. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98115. * are rendered front to back (prevent overdraw).
  98116. *
  98117. * @param a The first submesh
  98118. * @param b The second submesh
  98119. * @returns The result of the comparison
  98120. */
  98121. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98122. /**
  98123. * Resets the different lists of submeshes to prepare a new frame.
  98124. */
  98125. prepare(): void;
  98126. dispose(): void;
  98127. /**
  98128. * Inserts the submesh in its correct queue depending on its material.
  98129. * @param subMesh The submesh to dispatch
  98130. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98131. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98132. */
  98133. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98134. dispatchSprites(spriteManager: ISpriteManager): void;
  98135. dispatchParticles(particleSystem: IParticleSystem): void;
  98136. private _renderParticles;
  98137. private _renderSprites;
  98138. }
  98139. }
  98140. declare module BABYLON {
  98141. /**
  98142. * Interface describing the different options available in the rendering manager
  98143. * regarding Auto Clear between groups.
  98144. */
  98145. export interface IRenderingManagerAutoClearSetup {
  98146. /**
  98147. * Defines whether or not autoclear is enable.
  98148. */
  98149. autoClear: boolean;
  98150. /**
  98151. * Defines whether or not to autoclear the depth buffer.
  98152. */
  98153. depth: boolean;
  98154. /**
  98155. * Defines whether or not to autoclear the stencil buffer.
  98156. */
  98157. stencil: boolean;
  98158. }
  98159. /**
  98160. * This class is used by the onRenderingGroupObservable
  98161. */
  98162. export class RenderingGroupInfo {
  98163. /**
  98164. * The Scene that being rendered
  98165. */
  98166. scene: Scene;
  98167. /**
  98168. * The camera currently used for the rendering pass
  98169. */
  98170. camera: Nullable<Camera>;
  98171. /**
  98172. * The ID of the renderingGroup being processed
  98173. */
  98174. renderingGroupId: number;
  98175. }
  98176. /**
  98177. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98178. * It is enable to manage the different groups as well as the different necessary sort functions.
  98179. * This should not be used directly aside of the few static configurations
  98180. */
  98181. export class RenderingManager {
  98182. /**
  98183. * The max id used for rendering groups (not included)
  98184. */
  98185. static MAX_RENDERINGGROUPS: number;
  98186. /**
  98187. * The min id used for rendering groups (included)
  98188. */
  98189. static MIN_RENDERINGGROUPS: number;
  98190. /**
  98191. * Used to globally prevent autoclearing scenes.
  98192. */
  98193. static AUTOCLEAR: boolean;
  98194. /**
  98195. * @hidden
  98196. */
  98197. _useSceneAutoClearSetup: boolean;
  98198. private _scene;
  98199. private _renderingGroups;
  98200. private _depthStencilBufferAlreadyCleaned;
  98201. private _autoClearDepthStencil;
  98202. private _customOpaqueSortCompareFn;
  98203. private _customAlphaTestSortCompareFn;
  98204. private _customTransparentSortCompareFn;
  98205. private _renderingGroupInfo;
  98206. /**
  98207. * Instantiates a new rendering group for a particular scene
  98208. * @param scene Defines the scene the groups belongs to
  98209. */
  98210. constructor(scene: Scene);
  98211. private _clearDepthStencilBuffer;
  98212. /**
  98213. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98214. * @hidden
  98215. */
  98216. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98217. /**
  98218. * Resets the different information of the group to prepare a new frame
  98219. * @hidden
  98220. */
  98221. reset(): void;
  98222. /**
  98223. * Dispose and release the group and its associated resources.
  98224. * @hidden
  98225. */
  98226. dispose(): void;
  98227. /**
  98228. * Clear the info related to rendering groups preventing retention points during dispose.
  98229. */
  98230. freeRenderingGroups(): void;
  98231. private _prepareRenderingGroup;
  98232. /**
  98233. * Add a sprite manager to the rendering manager in order to render it this frame.
  98234. * @param spriteManager Define the sprite manager to render
  98235. */
  98236. dispatchSprites(spriteManager: ISpriteManager): void;
  98237. /**
  98238. * Add a particle system to the rendering manager in order to render it this frame.
  98239. * @param particleSystem Define the particle system to render
  98240. */
  98241. dispatchParticles(particleSystem: IParticleSystem): void;
  98242. /**
  98243. * Add a submesh to the manager in order to render it this frame
  98244. * @param subMesh The submesh to dispatch
  98245. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98246. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98247. */
  98248. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98249. /**
  98250. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98251. * This allowed control for front to back rendering or reversly depending of the special needs.
  98252. *
  98253. * @param renderingGroupId The rendering group id corresponding to its index
  98254. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98255. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98256. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98257. */
  98258. 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;
  98259. /**
  98260. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98261. *
  98262. * @param renderingGroupId The rendering group id corresponding to its index
  98263. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98264. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98265. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98266. */
  98267. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98268. /**
  98269. * Gets the current auto clear configuration for one rendering group of the rendering
  98270. * manager.
  98271. * @param index the rendering group index to get the information for
  98272. * @returns The auto clear setup for the requested rendering group
  98273. */
  98274. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98275. }
  98276. }
  98277. declare module BABYLON {
  98278. /**
  98279. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98280. */
  98281. export interface ICustomShaderOptions {
  98282. /**
  98283. * Gets or sets the custom shader name to use
  98284. */
  98285. shaderName: string;
  98286. /**
  98287. * The list of attribute names used in the shader
  98288. */
  98289. attributes?: string[];
  98290. /**
  98291. * The list of unifrom names used in the shader
  98292. */
  98293. uniforms?: string[];
  98294. /**
  98295. * The list of sampler names used in the shader
  98296. */
  98297. samplers?: string[];
  98298. /**
  98299. * The list of defines used in the shader
  98300. */
  98301. defines?: string[];
  98302. }
  98303. /**
  98304. * Interface to implement to create a shadow generator compatible with BJS.
  98305. */
  98306. export interface IShadowGenerator {
  98307. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98308. id: string;
  98309. /**
  98310. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98311. * @returns The render target texture if present otherwise, null
  98312. */
  98313. getShadowMap(): Nullable<RenderTargetTexture>;
  98314. /**
  98315. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98316. * @param subMesh The submesh we want to render in the shadow map
  98317. * @param useInstances Defines wether will draw in the map using instances
  98318. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98319. * @returns true if ready otherwise, false
  98320. */
  98321. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98322. /**
  98323. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98324. * @param defines Defines of the material we want to update
  98325. * @param lightIndex Index of the light in the enabled light list of the material
  98326. */
  98327. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98328. /**
  98329. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98330. * defined in the generator but impacting the effect).
  98331. * It implies the unifroms available on the materials are the standard BJS ones.
  98332. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98333. * @param effect The effect we are binfing the information for
  98334. */
  98335. bindShadowLight(lightIndex: string, effect: Effect): void;
  98336. /**
  98337. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98338. * (eq to shadow prjection matrix * light transform matrix)
  98339. * @returns The transform matrix used to create the shadow map
  98340. */
  98341. getTransformMatrix(): Matrix;
  98342. /**
  98343. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98344. * Cube and 2D textures for instance.
  98345. */
  98346. recreateShadowMap(): void;
  98347. /**
  98348. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98349. * @param onCompiled Callback triggered at the and of the effects compilation
  98350. * @param options Sets of optional options forcing the compilation with different modes
  98351. */
  98352. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98353. useInstances: boolean;
  98354. }>): void;
  98355. /**
  98356. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98357. * @param options Sets of optional options forcing the compilation with different modes
  98358. * @returns A promise that resolves when the compilation completes
  98359. */
  98360. forceCompilationAsync(options?: Partial<{
  98361. useInstances: boolean;
  98362. }>): Promise<void>;
  98363. /**
  98364. * Serializes the shadow generator setup to a json object.
  98365. * @returns The serialized JSON object
  98366. */
  98367. serialize(): any;
  98368. /**
  98369. * Disposes the Shadow map and related Textures and effects.
  98370. */
  98371. dispose(): void;
  98372. }
  98373. /**
  98374. * Default implementation IShadowGenerator.
  98375. * This is the main object responsible of generating shadows in the framework.
  98376. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98377. */
  98378. export class ShadowGenerator implements IShadowGenerator {
  98379. /**
  98380. * Name of the shadow generator class
  98381. */
  98382. static CLASSNAME: string;
  98383. /**
  98384. * Shadow generator mode None: no filtering applied.
  98385. */
  98386. static readonly FILTER_NONE: number;
  98387. /**
  98388. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98389. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98390. */
  98391. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98392. /**
  98393. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98394. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98395. */
  98396. static readonly FILTER_POISSONSAMPLING: number;
  98397. /**
  98398. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98399. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98400. */
  98401. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98402. /**
  98403. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98404. * edge artifacts on steep falloff.
  98405. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98406. */
  98407. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98408. /**
  98409. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98410. * edge artifacts on steep falloff.
  98411. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98412. */
  98413. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98414. /**
  98415. * Shadow generator mode PCF: Percentage Closer Filtering
  98416. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98417. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98418. */
  98419. static readonly FILTER_PCF: number;
  98420. /**
  98421. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98422. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98423. * Contact Hardening
  98424. */
  98425. static readonly FILTER_PCSS: number;
  98426. /**
  98427. * Reserved for PCF and PCSS
  98428. * Highest Quality.
  98429. *
  98430. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98431. *
  98432. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98433. */
  98434. static readonly QUALITY_HIGH: number;
  98435. /**
  98436. * Reserved for PCF and PCSS
  98437. * Good tradeoff for quality/perf cross devices
  98438. *
  98439. * Execute PCF on a 3*3 kernel.
  98440. *
  98441. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98442. */
  98443. static readonly QUALITY_MEDIUM: number;
  98444. /**
  98445. * Reserved for PCF and PCSS
  98446. * The lowest quality but the fastest.
  98447. *
  98448. * Execute PCF on a 1*1 kernel.
  98449. *
  98450. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98451. */
  98452. static readonly QUALITY_LOW: number;
  98453. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98454. id: string;
  98455. /** Gets or sets the custom shader name to use */
  98456. customShaderOptions: ICustomShaderOptions;
  98457. /**
  98458. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98459. */
  98460. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98461. /**
  98462. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98463. */
  98464. onAfterShadowMapRenderObservable: Observable<Effect>;
  98465. /**
  98466. * Observable triggered before a mesh is rendered in the shadow map.
  98467. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98468. */
  98469. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98470. /**
  98471. * Observable triggered after a mesh is rendered in the shadow map.
  98472. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98473. */
  98474. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98475. protected _bias: number;
  98476. /**
  98477. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98478. */
  98479. get bias(): number;
  98480. /**
  98481. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98482. */
  98483. set bias(bias: number);
  98484. protected _normalBias: number;
  98485. /**
  98486. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98487. */
  98488. get normalBias(): number;
  98489. /**
  98490. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98491. */
  98492. set normalBias(normalBias: number);
  98493. protected _blurBoxOffset: number;
  98494. /**
  98495. * Gets the blur box offset: offset applied during the blur pass.
  98496. * Only useful if useKernelBlur = false
  98497. */
  98498. get blurBoxOffset(): number;
  98499. /**
  98500. * Sets the blur box offset: offset applied during the blur pass.
  98501. * Only useful if useKernelBlur = false
  98502. */
  98503. set blurBoxOffset(value: number);
  98504. protected _blurScale: number;
  98505. /**
  98506. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98507. * 2 means half of the size.
  98508. */
  98509. get blurScale(): number;
  98510. /**
  98511. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98512. * 2 means half of the size.
  98513. */
  98514. set blurScale(value: number);
  98515. protected _blurKernel: number;
  98516. /**
  98517. * Gets the blur kernel: kernel size of the blur pass.
  98518. * Only useful if useKernelBlur = true
  98519. */
  98520. get blurKernel(): number;
  98521. /**
  98522. * Sets the blur kernel: kernel size of the blur pass.
  98523. * Only useful if useKernelBlur = true
  98524. */
  98525. set blurKernel(value: number);
  98526. protected _useKernelBlur: boolean;
  98527. /**
  98528. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98529. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98530. */
  98531. get useKernelBlur(): boolean;
  98532. /**
  98533. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98534. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98535. */
  98536. set useKernelBlur(value: boolean);
  98537. protected _depthScale: number;
  98538. /**
  98539. * Gets the depth scale used in ESM mode.
  98540. */
  98541. get depthScale(): number;
  98542. /**
  98543. * Sets the depth scale used in ESM mode.
  98544. * This can override the scale stored on the light.
  98545. */
  98546. set depthScale(value: number);
  98547. protected _validateFilter(filter: number): number;
  98548. protected _filter: number;
  98549. /**
  98550. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98551. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98552. */
  98553. get filter(): number;
  98554. /**
  98555. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98556. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98557. */
  98558. set filter(value: number);
  98559. /**
  98560. * Gets if the current filter is set to Poisson Sampling.
  98561. */
  98562. get usePoissonSampling(): boolean;
  98563. /**
  98564. * Sets the current filter to Poisson Sampling.
  98565. */
  98566. set usePoissonSampling(value: boolean);
  98567. /**
  98568. * Gets if the current filter is set to ESM.
  98569. */
  98570. get useExponentialShadowMap(): boolean;
  98571. /**
  98572. * Sets the current filter is to ESM.
  98573. */
  98574. set useExponentialShadowMap(value: boolean);
  98575. /**
  98576. * Gets if the current filter is set to filtered ESM.
  98577. */
  98578. get useBlurExponentialShadowMap(): boolean;
  98579. /**
  98580. * Gets if the current filter is set to filtered ESM.
  98581. */
  98582. set useBlurExponentialShadowMap(value: boolean);
  98583. /**
  98584. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98585. * exponential to prevent steep falloff artifacts).
  98586. */
  98587. get useCloseExponentialShadowMap(): boolean;
  98588. /**
  98589. * Sets the current filter to "close ESM" (using the inverse of the
  98590. * exponential to prevent steep falloff artifacts).
  98591. */
  98592. set useCloseExponentialShadowMap(value: boolean);
  98593. /**
  98594. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98595. * exponential to prevent steep falloff artifacts).
  98596. */
  98597. get useBlurCloseExponentialShadowMap(): boolean;
  98598. /**
  98599. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98600. * exponential to prevent steep falloff artifacts).
  98601. */
  98602. set useBlurCloseExponentialShadowMap(value: boolean);
  98603. /**
  98604. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98605. */
  98606. get usePercentageCloserFiltering(): boolean;
  98607. /**
  98608. * Sets the current filter to "PCF" (percentage closer filtering).
  98609. */
  98610. set usePercentageCloserFiltering(value: boolean);
  98611. protected _filteringQuality: number;
  98612. /**
  98613. * Gets the PCF or PCSS Quality.
  98614. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98615. */
  98616. get filteringQuality(): number;
  98617. /**
  98618. * Sets the PCF or PCSS Quality.
  98619. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98620. */
  98621. set filteringQuality(filteringQuality: number);
  98622. /**
  98623. * Gets if the current filter is set to "PCSS" (contact hardening).
  98624. */
  98625. get useContactHardeningShadow(): boolean;
  98626. /**
  98627. * Sets the current filter to "PCSS" (contact hardening).
  98628. */
  98629. set useContactHardeningShadow(value: boolean);
  98630. protected _contactHardeningLightSizeUVRatio: number;
  98631. /**
  98632. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98633. * Using a ratio helps keeping shape stability independently of the map size.
  98634. *
  98635. * It does not account for the light projection as it was having too much
  98636. * instability during the light setup or during light position changes.
  98637. *
  98638. * Only valid if useContactHardeningShadow is true.
  98639. */
  98640. get contactHardeningLightSizeUVRatio(): number;
  98641. /**
  98642. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98643. * Using a ratio helps keeping shape stability independently of the map size.
  98644. *
  98645. * It does not account for the light projection as it was having too much
  98646. * instability during the light setup or during light position changes.
  98647. *
  98648. * Only valid if useContactHardeningShadow is true.
  98649. */
  98650. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98651. protected _darkness: number;
  98652. /** Gets or sets the actual darkness of a shadow */
  98653. get darkness(): number;
  98654. set darkness(value: number);
  98655. /**
  98656. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98657. * 0 means strongest and 1 would means no shadow.
  98658. * @returns the darkness.
  98659. */
  98660. getDarkness(): number;
  98661. /**
  98662. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98663. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98664. * @returns the shadow generator allowing fluent coding.
  98665. */
  98666. setDarkness(darkness: number): ShadowGenerator;
  98667. protected _transparencyShadow: boolean;
  98668. /** Gets or sets the ability to have transparent shadow */
  98669. get transparencyShadow(): boolean;
  98670. set transparencyShadow(value: boolean);
  98671. /**
  98672. * Sets the ability to have transparent shadow (boolean).
  98673. * @param transparent True if transparent else False
  98674. * @returns the shadow generator allowing fluent coding
  98675. */
  98676. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98677. /**
  98678. * Enables or disables shadows with varying strength based on the transparency
  98679. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98680. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98681. * mesh.visibility * alphaTexture.a
  98682. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98683. */
  98684. enableSoftTransparentShadow: boolean;
  98685. protected _shadowMap: Nullable<RenderTargetTexture>;
  98686. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98687. /**
  98688. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98689. * @returns The render target texture if present otherwise, null
  98690. */
  98691. getShadowMap(): Nullable<RenderTargetTexture>;
  98692. /**
  98693. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98694. * @returns The render target texture if the shadow map is present otherwise, null
  98695. */
  98696. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98697. /**
  98698. * Gets the class name of that object
  98699. * @returns "ShadowGenerator"
  98700. */
  98701. getClassName(): string;
  98702. /**
  98703. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98704. * @param mesh Mesh to add
  98705. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98706. * @returns the Shadow Generator itself
  98707. */
  98708. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98709. /**
  98710. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98711. * @param mesh Mesh to remove
  98712. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98713. * @returns the Shadow Generator itself
  98714. */
  98715. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98716. /**
  98717. * Controls the extent to which the shadows fade out at the edge of the frustum
  98718. */
  98719. frustumEdgeFalloff: number;
  98720. protected _light: IShadowLight;
  98721. /**
  98722. * Returns the associated light object.
  98723. * @returns the light generating the shadow
  98724. */
  98725. getLight(): IShadowLight;
  98726. /**
  98727. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98728. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98729. * It might on the other hand introduce peter panning.
  98730. */
  98731. forceBackFacesOnly: boolean;
  98732. protected _scene: Scene;
  98733. protected _lightDirection: Vector3;
  98734. protected _effect: Effect;
  98735. protected _viewMatrix: Matrix;
  98736. protected _projectionMatrix: Matrix;
  98737. protected _transformMatrix: Matrix;
  98738. protected _cachedPosition: Vector3;
  98739. protected _cachedDirection: Vector3;
  98740. protected _cachedDefines: string;
  98741. protected _currentRenderID: number;
  98742. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98743. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98744. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98745. protected _blurPostProcesses: PostProcess[];
  98746. protected _mapSize: number;
  98747. protected _currentFaceIndex: number;
  98748. protected _currentFaceIndexCache: number;
  98749. protected _textureType: number;
  98750. protected _defaultTextureMatrix: Matrix;
  98751. protected _storedUniqueId: Nullable<number>;
  98752. /** @hidden */
  98753. static _SceneComponentInitialization: (scene: Scene) => void;
  98754. /**
  98755. * Gets or sets the size of the texture what stores the shadows
  98756. */
  98757. get mapSize(): number;
  98758. set mapSize(size: number);
  98759. /**
  98760. * Creates a ShadowGenerator object.
  98761. * A ShadowGenerator is the required tool to use the shadows.
  98762. * Each light casting shadows needs to use its own ShadowGenerator.
  98763. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98764. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98765. * @param light The light object generating the shadows.
  98766. * @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.
  98767. */
  98768. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98769. protected _initializeGenerator(): void;
  98770. protected _createTargetRenderTexture(): void;
  98771. protected _initializeShadowMap(): void;
  98772. protected _initializeBlurRTTAndPostProcesses(): void;
  98773. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98774. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98775. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98776. protected _applyFilterValues(): void;
  98777. /**
  98778. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98779. * @param onCompiled Callback triggered at the and of the effects compilation
  98780. * @param options Sets of optional options forcing the compilation with different modes
  98781. */
  98782. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98783. useInstances: boolean;
  98784. }>): void;
  98785. /**
  98786. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98787. * @param options Sets of optional options forcing the compilation with different modes
  98788. * @returns A promise that resolves when the compilation completes
  98789. */
  98790. forceCompilationAsync(options?: Partial<{
  98791. useInstances: boolean;
  98792. }>): Promise<void>;
  98793. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98794. private _prepareShadowDefines;
  98795. /**
  98796. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98797. * @param subMesh The submesh we want to render in the shadow map
  98798. * @param useInstances Defines wether will draw in the map using instances
  98799. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98800. * @returns true if ready otherwise, false
  98801. */
  98802. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98803. /**
  98804. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98805. * @param defines Defines of the material we want to update
  98806. * @param lightIndex Index of the light in the enabled light list of the material
  98807. */
  98808. prepareDefines(defines: any, lightIndex: number): void;
  98809. /**
  98810. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98811. * defined in the generator but impacting the effect).
  98812. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98813. * @param effect The effect we are binfing the information for
  98814. */
  98815. bindShadowLight(lightIndex: string, effect: Effect): void;
  98816. /**
  98817. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98818. * (eq to shadow prjection matrix * light transform matrix)
  98819. * @returns The transform matrix used to create the shadow map
  98820. */
  98821. getTransformMatrix(): Matrix;
  98822. /**
  98823. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98824. * Cube and 2D textures for instance.
  98825. */
  98826. recreateShadowMap(): void;
  98827. protected _disposeBlurPostProcesses(): void;
  98828. protected _disposeRTTandPostProcesses(): void;
  98829. /**
  98830. * Disposes the ShadowGenerator.
  98831. * Returns nothing.
  98832. */
  98833. dispose(): void;
  98834. /**
  98835. * Serializes the shadow generator setup to a json object.
  98836. * @returns The serialized JSON object
  98837. */
  98838. serialize(): any;
  98839. /**
  98840. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98841. * @param parsedShadowGenerator The JSON object to parse
  98842. * @param scene The scene to create the shadow map for
  98843. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98844. * @returns The parsed shadow generator
  98845. */
  98846. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98847. }
  98848. }
  98849. declare module BABYLON {
  98850. /**
  98851. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98852. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98853. * 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.
  98854. */
  98855. export abstract class Light extends Node {
  98856. /**
  98857. * Falloff Default: light is falling off following the material specification:
  98858. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98859. */
  98860. static readonly FALLOFF_DEFAULT: number;
  98861. /**
  98862. * Falloff Physical: light is falling off following the inverse squared distance law.
  98863. */
  98864. static readonly FALLOFF_PHYSICAL: number;
  98865. /**
  98866. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98867. * to enhance interoperability with other engines.
  98868. */
  98869. static readonly FALLOFF_GLTF: number;
  98870. /**
  98871. * Falloff Standard: light is falling off like in the standard material
  98872. * to enhance interoperability with other materials.
  98873. */
  98874. static readonly FALLOFF_STANDARD: number;
  98875. /**
  98876. * If every light affecting the material is in this lightmapMode,
  98877. * material.lightmapTexture adds or multiplies
  98878. * (depends on material.useLightmapAsShadowmap)
  98879. * after every other light calculations.
  98880. */
  98881. static readonly LIGHTMAP_DEFAULT: number;
  98882. /**
  98883. * material.lightmapTexture as only diffuse lighting from this light
  98884. * adds only specular lighting from this light
  98885. * adds dynamic shadows
  98886. */
  98887. static readonly LIGHTMAP_SPECULAR: number;
  98888. /**
  98889. * material.lightmapTexture as only lighting
  98890. * no light calculation from this light
  98891. * only adds dynamic shadows from this light
  98892. */
  98893. static readonly LIGHTMAP_SHADOWSONLY: number;
  98894. /**
  98895. * Each light type uses the default quantity according to its type:
  98896. * point/spot lights use luminous intensity
  98897. * directional lights use illuminance
  98898. */
  98899. static readonly INTENSITYMODE_AUTOMATIC: number;
  98900. /**
  98901. * lumen (lm)
  98902. */
  98903. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98904. /**
  98905. * candela (lm/sr)
  98906. */
  98907. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98908. /**
  98909. * lux (lm/m^2)
  98910. */
  98911. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98912. /**
  98913. * nit (cd/m^2)
  98914. */
  98915. static readonly INTENSITYMODE_LUMINANCE: number;
  98916. /**
  98917. * Light type const id of the point light.
  98918. */
  98919. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98920. /**
  98921. * Light type const id of the directional light.
  98922. */
  98923. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98924. /**
  98925. * Light type const id of the spot light.
  98926. */
  98927. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98928. /**
  98929. * Light type const id of the hemispheric light.
  98930. */
  98931. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98932. /**
  98933. * Diffuse gives the basic color to an object.
  98934. */
  98935. diffuse: Color3;
  98936. /**
  98937. * Specular produces a highlight color on an object.
  98938. * Note: This is note affecting PBR materials.
  98939. */
  98940. specular: Color3;
  98941. /**
  98942. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98943. * falling off base on range or angle.
  98944. * This can be set to any values in Light.FALLOFF_x.
  98945. *
  98946. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98947. * other types of materials.
  98948. */
  98949. falloffType: number;
  98950. /**
  98951. * Strength of the light.
  98952. * Note: By default it is define in the framework own unit.
  98953. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98954. */
  98955. intensity: number;
  98956. private _range;
  98957. protected _inverseSquaredRange: number;
  98958. /**
  98959. * Defines how far from the source the light is impacting in scene units.
  98960. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98961. */
  98962. get range(): number;
  98963. /**
  98964. * Defines how far from the source the light is impacting in scene units.
  98965. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98966. */
  98967. set range(value: number);
  98968. /**
  98969. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98970. * of light.
  98971. */
  98972. private _photometricScale;
  98973. private _intensityMode;
  98974. /**
  98975. * Gets the photometric scale used to interpret the intensity.
  98976. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98977. */
  98978. get intensityMode(): number;
  98979. /**
  98980. * Sets the photometric scale used to interpret the intensity.
  98981. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98982. */
  98983. set intensityMode(value: number);
  98984. private _radius;
  98985. /**
  98986. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98987. */
  98988. get radius(): number;
  98989. /**
  98990. * sets the light radius used by PBR Materials to simulate soft area lights.
  98991. */
  98992. set radius(value: number);
  98993. private _renderPriority;
  98994. /**
  98995. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98996. * exceeding the number allowed of the materials.
  98997. */
  98998. renderPriority: number;
  98999. private _shadowEnabled;
  99000. /**
  99001. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99002. * the current shadow generator.
  99003. */
  99004. get shadowEnabled(): boolean;
  99005. /**
  99006. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99007. * the current shadow generator.
  99008. */
  99009. set shadowEnabled(value: boolean);
  99010. private _includedOnlyMeshes;
  99011. /**
  99012. * Gets the only meshes impacted by this light.
  99013. */
  99014. get includedOnlyMeshes(): AbstractMesh[];
  99015. /**
  99016. * Sets the only meshes impacted by this light.
  99017. */
  99018. set includedOnlyMeshes(value: AbstractMesh[]);
  99019. private _excludedMeshes;
  99020. /**
  99021. * Gets the meshes not impacted by this light.
  99022. */
  99023. get excludedMeshes(): AbstractMesh[];
  99024. /**
  99025. * Sets the meshes not impacted by this light.
  99026. */
  99027. set excludedMeshes(value: AbstractMesh[]);
  99028. private _excludeWithLayerMask;
  99029. /**
  99030. * Gets the layer id use to find what meshes are not impacted by the light.
  99031. * Inactive if 0
  99032. */
  99033. get excludeWithLayerMask(): number;
  99034. /**
  99035. * Sets the layer id use to find what meshes are not impacted by the light.
  99036. * Inactive if 0
  99037. */
  99038. set excludeWithLayerMask(value: number);
  99039. private _includeOnlyWithLayerMask;
  99040. /**
  99041. * Gets the layer id use to find what meshes are impacted by the light.
  99042. * Inactive if 0
  99043. */
  99044. get includeOnlyWithLayerMask(): number;
  99045. /**
  99046. * Sets the layer id use to find what meshes are impacted by the light.
  99047. * Inactive if 0
  99048. */
  99049. set includeOnlyWithLayerMask(value: number);
  99050. private _lightmapMode;
  99051. /**
  99052. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99053. */
  99054. get lightmapMode(): number;
  99055. /**
  99056. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99057. */
  99058. set lightmapMode(value: number);
  99059. /**
  99060. * Shadow generator associted to the light.
  99061. * @hidden Internal use only.
  99062. */
  99063. _shadowGenerator: Nullable<IShadowGenerator>;
  99064. /**
  99065. * @hidden Internal use only.
  99066. */
  99067. _excludedMeshesIds: string[];
  99068. /**
  99069. * @hidden Internal use only.
  99070. */
  99071. _includedOnlyMeshesIds: string[];
  99072. /**
  99073. * The current light unifom buffer.
  99074. * @hidden Internal use only.
  99075. */
  99076. _uniformBuffer: UniformBuffer;
  99077. /** @hidden */
  99078. _renderId: number;
  99079. /**
  99080. * Creates a Light object in the scene.
  99081. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99082. * @param name The firendly name of the light
  99083. * @param scene The scene the light belongs too
  99084. */
  99085. constructor(name: string, scene: Scene);
  99086. protected abstract _buildUniformLayout(): void;
  99087. /**
  99088. * Sets the passed Effect "effect" with the Light information.
  99089. * @param effect The effect to update
  99090. * @param lightIndex The index of the light in the effect to update
  99091. * @returns The light
  99092. */
  99093. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99094. /**
  99095. * Sets the passed Effect "effect" with the Light textures.
  99096. * @param effect The effect to update
  99097. * @param lightIndex The index of the light in the effect to update
  99098. * @returns The light
  99099. */
  99100. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99101. /**
  99102. * Binds the lights information from the scene to the effect for the given mesh.
  99103. * @param lightIndex Light index
  99104. * @param scene The scene where the light belongs to
  99105. * @param effect The effect we are binding the data to
  99106. * @param useSpecular Defines if specular is supported
  99107. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99108. */
  99109. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99110. /**
  99111. * Sets the passed Effect "effect" with the Light information.
  99112. * @param effect The effect to update
  99113. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99114. * @returns The light
  99115. */
  99116. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99117. /**
  99118. * Returns the string "Light".
  99119. * @returns the class name
  99120. */
  99121. getClassName(): string;
  99122. /** @hidden */
  99123. readonly _isLight: boolean;
  99124. /**
  99125. * Converts the light information to a readable string for debug purpose.
  99126. * @param fullDetails Supports for multiple levels of logging within scene loading
  99127. * @returns the human readable light info
  99128. */
  99129. toString(fullDetails?: boolean): string;
  99130. /** @hidden */
  99131. protected _syncParentEnabledState(): void;
  99132. /**
  99133. * Set the enabled state of this node.
  99134. * @param value - the new enabled state
  99135. */
  99136. setEnabled(value: boolean): void;
  99137. /**
  99138. * Returns the Light associated shadow generator if any.
  99139. * @return the associated shadow generator.
  99140. */
  99141. getShadowGenerator(): Nullable<IShadowGenerator>;
  99142. /**
  99143. * Returns a Vector3, the absolute light position in the World.
  99144. * @returns the world space position of the light
  99145. */
  99146. getAbsolutePosition(): Vector3;
  99147. /**
  99148. * Specifies if the light will affect the passed mesh.
  99149. * @param mesh The mesh to test against the light
  99150. * @return true the mesh is affected otherwise, false.
  99151. */
  99152. canAffectMesh(mesh: AbstractMesh): boolean;
  99153. /**
  99154. * Sort function to order lights for rendering.
  99155. * @param a First Light object to compare to second.
  99156. * @param b Second Light object to compare first.
  99157. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99158. */
  99159. static CompareLightsPriority(a: Light, b: Light): number;
  99160. /**
  99161. * Releases resources associated with this node.
  99162. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99163. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99164. */
  99165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99166. /**
  99167. * Returns the light type ID (integer).
  99168. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99169. */
  99170. getTypeID(): number;
  99171. /**
  99172. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99173. * @returns the scaled intensity in intensity mode unit
  99174. */
  99175. getScaledIntensity(): number;
  99176. /**
  99177. * Returns a new Light object, named "name", from the current one.
  99178. * @param name The name of the cloned light
  99179. * @param newParent The parent of this light, if it has one
  99180. * @returns the new created light
  99181. */
  99182. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99183. /**
  99184. * Serializes the current light into a Serialization object.
  99185. * @returns the serialized object.
  99186. */
  99187. serialize(): any;
  99188. /**
  99189. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99190. * This new light is named "name" and added to the passed scene.
  99191. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99192. * @param name The friendly name of the light
  99193. * @param scene The scene the new light will belong to
  99194. * @returns the constructor function
  99195. */
  99196. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99197. /**
  99198. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99199. * @param parsedLight The JSON representation of the light
  99200. * @param scene The scene to create the parsed light in
  99201. * @returns the created light after parsing
  99202. */
  99203. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99204. private _hookArrayForExcluded;
  99205. private _hookArrayForIncludedOnly;
  99206. private _resyncMeshes;
  99207. /**
  99208. * Forces the meshes to update their light related information in their rendering used effects
  99209. * @hidden Internal Use Only
  99210. */
  99211. _markMeshesAsLightDirty(): void;
  99212. /**
  99213. * Recomputes the cached photometric scale if needed.
  99214. */
  99215. private _computePhotometricScale;
  99216. /**
  99217. * Returns the Photometric Scale according to the light type and intensity mode.
  99218. */
  99219. private _getPhotometricScale;
  99220. /**
  99221. * Reorder the light in the scene according to their defined priority.
  99222. * @hidden Internal Use Only
  99223. */
  99224. _reorderLightsInScene(): void;
  99225. /**
  99226. * Prepares the list of defines specific to the light type.
  99227. * @param defines the list of defines
  99228. * @param lightIndex defines the index of the light for the effect
  99229. */
  99230. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99231. }
  99232. }
  99233. declare module BABYLON {
  99234. /**
  99235. * Configuration needed for prepass-capable materials
  99236. */
  99237. export class PrePassConfiguration {
  99238. /**
  99239. * Previous world matrices of meshes carrying this material
  99240. * Used for computing velocity
  99241. */
  99242. previousWorldMatrices: {
  99243. [index: number]: Matrix;
  99244. };
  99245. /**
  99246. * Previous view project matrix
  99247. * Used for computing velocity
  99248. */
  99249. previousViewProjection: Matrix;
  99250. /**
  99251. * Previous bones of meshes carrying this material
  99252. * Used for computing velocity
  99253. */
  99254. previousBones: {
  99255. [index: number]: Float32Array;
  99256. };
  99257. /**
  99258. * Add the required uniforms to the current list.
  99259. * @param uniforms defines the current uniform list.
  99260. */
  99261. static AddUniforms(uniforms: string[]): void;
  99262. /**
  99263. * Add the required samplers to the current list.
  99264. * @param samplers defines the current sampler list.
  99265. */
  99266. static AddSamplers(samplers: string[]): void;
  99267. /**
  99268. * Binds the material data.
  99269. * @param effect defines the effect to update
  99270. * @param scene defines the scene the material belongs to.
  99271. * @param mesh The mesh
  99272. * @param world World matrix of this mesh
  99273. * @param isFrozen Is the material frozen
  99274. */
  99275. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99276. }
  99277. }
  99278. declare module BABYLON {
  99279. /**
  99280. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99281. * This is the base of the follow, arc rotate cameras and Free camera
  99282. * @see https://doc.babylonjs.com/features/cameras
  99283. */
  99284. export class TargetCamera extends Camera {
  99285. private static _RigCamTransformMatrix;
  99286. private static _TargetTransformMatrix;
  99287. private static _TargetFocalPoint;
  99288. private _tmpUpVector;
  99289. private _tmpTargetVector;
  99290. /**
  99291. * Define the current direction the camera is moving to
  99292. */
  99293. cameraDirection: Vector3;
  99294. /**
  99295. * Define the current rotation the camera is rotating to
  99296. */
  99297. cameraRotation: Vector2;
  99298. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99299. ignoreParentScaling: boolean;
  99300. /**
  99301. * When set, the up vector of the camera will be updated by the rotation of the camera
  99302. */
  99303. updateUpVectorFromRotation: boolean;
  99304. private _tmpQuaternion;
  99305. /**
  99306. * Define the current rotation of the camera
  99307. */
  99308. rotation: Vector3;
  99309. /**
  99310. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99311. */
  99312. rotationQuaternion: Quaternion;
  99313. /**
  99314. * Define the current speed of the camera
  99315. */
  99316. speed: number;
  99317. /**
  99318. * Add constraint to the camera to prevent it to move freely in all directions and
  99319. * around all axis.
  99320. */
  99321. noRotationConstraint: boolean;
  99322. /**
  99323. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99324. * panning
  99325. */
  99326. invertRotation: boolean;
  99327. /**
  99328. * Speed multiplier for inverse camera panning
  99329. */
  99330. inverseRotationSpeed: number;
  99331. /**
  99332. * Define the current target of the camera as an object or a position.
  99333. */
  99334. lockedTarget: any;
  99335. /** @hidden */
  99336. _currentTarget: Vector3;
  99337. /** @hidden */
  99338. _initialFocalDistance: number;
  99339. /** @hidden */
  99340. _viewMatrix: Matrix;
  99341. /** @hidden */
  99342. _camMatrix: Matrix;
  99343. /** @hidden */
  99344. _cameraTransformMatrix: Matrix;
  99345. /** @hidden */
  99346. _cameraRotationMatrix: Matrix;
  99347. /** @hidden */
  99348. _referencePoint: Vector3;
  99349. /** @hidden */
  99350. _transformedReferencePoint: Vector3;
  99351. /** @hidden */
  99352. _reset: () => void;
  99353. private _defaultUp;
  99354. /**
  99355. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99356. * This is the base of the follow, arc rotate cameras and Free camera
  99357. * @see https://doc.babylonjs.com/features/cameras
  99358. * @param name Defines the name of the camera in the scene
  99359. * @param position Defines the start position of the camera in the scene
  99360. * @param scene Defines the scene the camera belongs to
  99361. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99362. */
  99363. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99364. /**
  99365. * Gets the position in front of the camera at a given distance.
  99366. * @param distance The distance from the camera we want the position to be
  99367. * @returns the position
  99368. */
  99369. getFrontPosition(distance: number): Vector3;
  99370. /** @hidden */
  99371. _getLockedTargetPosition(): Nullable<Vector3>;
  99372. private _storedPosition;
  99373. private _storedRotation;
  99374. private _storedRotationQuaternion;
  99375. /**
  99376. * Store current camera state of the camera (fov, position, rotation, etc..)
  99377. * @returns the camera
  99378. */
  99379. storeState(): Camera;
  99380. /**
  99381. * Restored camera state. You must call storeState() first
  99382. * @returns whether it was successful or not
  99383. * @hidden
  99384. */
  99385. _restoreStateValues(): boolean;
  99386. /** @hidden */
  99387. _initCache(): void;
  99388. /** @hidden */
  99389. _updateCache(ignoreParentClass?: boolean): void;
  99390. /** @hidden */
  99391. _isSynchronizedViewMatrix(): boolean;
  99392. /** @hidden */
  99393. _computeLocalCameraSpeed(): number;
  99394. /**
  99395. * Defines the target the camera should look at.
  99396. * @param target Defines the new target as a Vector or a mesh
  99397. */
  99398. setTarget(target: Vector3): void;
  99399. /**
  99400. * Defines the target point of the camera.
  99401. * The camera looks towards it form the radius distance.
  99402. */
  99403. get target(): Vector3;
  99404. set target(value: Vector3);
  99405. /**
  99406. * Return the current target position of the camera. This value is expressed in local space.
  99407. * @returns the target position
  99408. */
  99409. getTarget(): Vector3;
  99410. /** @hidden */
  99411. _decideIfNeedsToMove(): boolean;
  99412. /** @hidden */
  99413. _updatePosition(): void;
  99414. /** @hidden */
  99415. _checkInputs(): void;
  99416. protected _updateCameraRotationMatrix(): void;
  99417. /**
  99418. * 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)
  99419. * @returns the current camera
  99420. */
  99421. private _rotateUpVectorWithCameraRotationMatrix;
  99422. private _cachedRotationZ;
  99423. private _cachedQuaternionRotationZ;
  99424. /** @hidden */
  99425. _getViewMatrix(): Matrix;
  99426. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99427. /**
  99428. * @hidden
  99429. */
  99430. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99431. /**
  99432. * @hidden
  99433. */
  99434. _updateRigCameras(): void;
  99435. private _getRigCamPositionAndTarget;
  99436. /**
  99437. * Gets the current object class name.
  99438. * @return the class name
  99439. */
  99440. getClassName(): string;
  99441. }
  99442. }
  99443. declare module BABYLON {
  99444. /**
  99445. * Gather the list of keyboard event types as constants.
  99446. */
  99447. export class KeyboardEventTypes {
  99448. /**
  99449. * The keydown event is fired when a key becomes active (pressed).
  99450. */
  99451. static readonly KEYDOWN: number;
  99452. /**
  99453. * The keyup event is fired when a key has been released.
  99454. */
  99455. static readonly KEYUP: number;
  99456. }
  99457. /**
  99458. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99459. */
  99460. export class KeyboardInfo {
  99461. /**
  99462. * Defines the type of event (KeyboardEventTypes)
  99463. */
  99464. type: number;
  99465. /**
  99466. * Defines the related dom event
  99467. */
  99468. event: KeyboardEvent;
  99469. /**
  99470. * Instantiates a new keyboard info.
  99471. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99472. * @param type Defines the type of event (KeyboardEventTypes)
  99473. * @param event Defines the related dom event
  99474. */
  99475. constructor(
  99476. /**
  99477. * Defines the type of event (KeyboardEventTypes)
  99478. */
  99479. type: number,
  99480. /**
  99481. * Defines the related dom event
  99482. */
  99483. event: KeyboardEvent);
  99484. }
  99485. /**
  99486. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99487. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99488. */
  99489. export class KeyboardInfoPre extends KeyboardInfo {
  99490. /**
  99491. * Defines the type of event (KeyboardEventTypes)
  99492. */
  99493. type: number;
  99494. /**
  99495. * Defines the related dom event
  99496. */
  99497. event: KeyboardEvent;
  99498. /**
  99499. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99500. */
  99501. skipOnPointerObservable: boolean;
  99502. /**
  99503. * Instantiates a new keyboard pre info.
  99504. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99505. * @param type Defines the type of event (KeyboardEventTypes)
  99506. * @param event Defines the related dom event
  99507. */
  99508. constructor(
  99509. /**
  99510. * Defines the type of event (KeyboardEventTypes)
  99511. */
  99512. type: number,
  99513. /**
  99514. * Defines the related dom event
  99515. */
  99516. event: KeyboardEvent);
  99517. }
  99518. }
  99519. declare module BABYLON {
  99520. /**
  99521. * Manage the keyboard inputs to control the movement of a free camera.
  99522. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99523. */
  99524. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99525. /**
  99526. * Defines the camera the input is attached to.
  99527. */
  99528. camera: FreeCamera;
  99529. /**
  99530. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99531. */
  99532. keysUp: number[];
  99533. /**
  99534. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99535. */
  99536. keysUpward: number[];
  99537. /**
  99538. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99539. */
  99540. keysDown: number[];
  99541. /**
  99542. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99543. */
  99544. keysDownward: number[];
  99545. /**
  99546. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99547. */
  99548. keysLeft: number[];
  99549. /**
  99550. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99551. */
  99552. keysRight: number[];
  99553. private _keys;
  99554. private _onCanvasBlurObserver;
  99555. private _onKeyboardObserver;
  99556. private _engine;
  99557. private _scene;
  99558. /**
  99559. * Attach the input controls to a specific dom element to get the input from.
  99560. * @param element Defines the element the controls should be listened from
  99561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99562. */
  99563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99564. /**
  99565. * Detach the current controls from the specified dom element.
  99566. * @param element Defines the element to stop listening the inputs from
  99567. */
  99568. detachControl(element: Nullable<HTMLElement>): void;
  99569. /**
  99570. * Update the current camera state depending on the inputs that have been used this frame.
  99571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99572. */
  99573. checkInputs(): void;
  99574. /**
  99575. * Gets the class name of the current intput.
  99576. * @returns the class name
  99577. */
  99578. getClassName(): string;
  99579. /** @hidden */
  99580. _onLostFocus(): void;
  99581. /**
  99582. * Get the friendly name associated with the input class.
  99583. * @returns the input friendly name
  99584. */
  99585. getSimpleName(): string;
  99586. }
  99587. }
  99588. declare module BABYLON {
  99589. /**
  99590. * Gather the list of pointer event types as constants.
  99591. */
  99592. export class PointerEventTypes {
  99593. /**
  99594. * 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.
  99595. */
  99596. static readonly POINTERDOWN: number;
  99597. /**
  99598. * The pointerup event is fired when a pointer is no longer active.
  99599. */
  99600. static readonly POINTERUP: number;
  99601. /**
  99602. * The pointermove event is fired when a pointer changes coordinates.
  99603. */
  99604. static readonly POINTERMOVE: number;
  99605. /**
  99606. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99607. */
  99608. static readonly POINTERWHEEL: number;
  99609. /**
  99610. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99611. */
  99612. static readonly POINTERPICK: number;
  99613. /**
  99614. * The pointertap event is fired when a the object has been touched and released without drag.
  99615. */
  99616. static readonly POINTERTAP: number;
  99617. /**
  99618. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99619. */
  99620. static readonly POINTERDOUBLETAP: number;
  99621. }
  99622. /**
  99623. * Base class of pointer info types.
  99624. */
  99625. export class PointerInfoBase {
  99626. /**
  99627. * Defines the type of event (PointerEventTypes)
  99628. */
  99629. type: number;
  99630. /**
  99631. * Defines the related dom event
  99632. */
  99633. event: PointerEvent | MouseWheelEvent;
  99634. /**
  99635. * Instantiates the base class of pointers info.
  99636. * @param type Defines the type of event (PointerEventTypes)
  99637. * @param event Defines the related dom event
  99638. */
  99639. constructor(
  99640. /**
  99641. * Defines the type of event (PointerEventTypes)
  99642. */
  99643. type: number,
  99644. /**
  99645. * Defines the related dom event
  99646. */
  99647. event: PointerEvent | MouseWheelEvent);
  99648. }
  99649. /**
  99650. * This class is used to store pointer related info for the onPrePointerObservable event.
  99651. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99652. */
  99653. export class PointerInfoPre extends PointerInfoBase {
  99654. /**
  99655. * Ray from a pointer if availible (eg. 6dof controller)
  99656. */
  99657. ray: Nullable<Ray>;
  99658. /**
  99659. * Defines the local position of the pointer on the canvas.
  99660. */
  99661. localPosition: Vector2;
  99662. /**
  99663. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99664. */
  99665. skipOnPointerObservable: boolean;
  99666. /**
  99667. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99668. * @param type Defines the type of event (PointerEventTypes)
  99669. * @param event Defines the related dom event
  99670. * @param localX Defines the local x coordinates of the pointer when the event occured
  99671. * @param localY Defines the local y coordinates of the pointer when the event occured
  99672. */
  99673. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99674. }
  99675. /**
  99676. * This type contains all the data related to a pointer event in Babylon.js.
  99677. * 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.
  99678. */
  99679. export class PointerInfo extends PointerInfoBase {
  99680. /**
  99681. * Defines the picking info associated to the info (if any)\
  99682. */
  99683. pickInfo: Nullable<PickingInfo>;
  99684. /**
  99685. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99686. * @param type Defines the type of event (PointerEventTypes)
  99687. * @param event Defines the related dom event
  99688. * @param pickInfo Defines the picking info associated to the info (if any)\
  99689. */
  99690. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99691. /**
  99692. * Defines the picking info associated to the info (if any)\
  99693. */
  99694. pickInfo: Nullable<PickingInfo>);
  99695. }
  99696. /**
  99697. * Data relating to a touch event on the screen.
  99698. */
  99699. export interface PointerTouch {
  99700. /**
  99701. * X coordinate of touch.
  99702. */
  99703. x: number;
  99704. /**
  99705. * Y coordinate of touch.
  99706. */
  99707. y: number;
  99708. /**
  99709. * Id of touch. Unique for each finger.
  99710. */
  99711. pointerId: number;
  99712. /**
  99713. * Event type passed from DOM.
  99714. */
  99715. type: any;
  99716. }
  99717. }
  99718. declare module BABYLON {
  99719. /**
  99720. * Manage the mouse inputs to control the movement of a free camera.
  99721. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99722. */
  99723. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99724. /**
  99725. * Define if touch is enabled in the mouse input
  99726. */
  99727. touchEnabled: boolean;
  99728. /**
  99729. * Defines the camera the input is attached to.
  99730. */
  99731. camera: FreeCamera;
  99732. /**
  99733. * Defines the buttons associated with the input to handle camera move.
  99734. */
  99735. buttons: number[];
  99736. /**
  99737. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99738. */
  99739. angularSensibility: number;
  99740. private _pointerInput;
  99741. private _onMouseMove;
  99742. private _observer;
  99743. private previousPosition;
  99744. /**
  99745. * Observable for when a pointer move event occurs containing the move offset
  99746. */
  99747. onPointerMovedObservable: Observable<{
  99748. offsetX: number;
  99749. offsetY: number;
  99750. }>;
  99751. /**
  99752. * @hidden
  99753. * If the camera should be rotated automatically based on pointer movement
  99754. */
  99755. _allowCameraRotation: boolean;
  99756. /**
  99757. * Manage the mouse inputs to control the movement of a free camera.
  99758. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99759. * @param touchEnabled Defines if touch is enabled or not
  99760. */
  99761. constructor(
  99762. /**
  99763. * Define if touch is enabled in the mouse input
  99764. */
  99765. touchEnabled?: boolean);
  99766. /**
  99767. * Attach the input controls to a specific dom element to get the input from.
  99768. * @param element Defines the element the controls should be listened from
  99769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99770. */
  99771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99772. /**
  99773. * Called on JS contextmenu event.
  99774. * Override this method to provide functionality.
  99775. */
  99776. protected onContextMenu(evt: PointerEvent): void;
  99777. /**
  99778. * Detach the current controls from the specified dom element.
  99779. * @param element Defines the element to stop listening the inputs from
  99780. */
  99781. detachControl(element: Nullable<HTMLElement>): void;
  99782. /**
  99783. * Gets the class name of the current intput.
  99784. * @returns the class name
  99785. */
  99786. getClassName(): string;
  99787. /**
  99788. * Get the friendly name associated with the input class.
  99789. * @returns the input friendly name
  99790. */
  99791. getSimpleName(): string;
  99792. }
  99793. }
  99794. declare module BABYLON {
  99795. /**
  99796. * Manage the touch inputs to control the movement of a free camera.
  99797. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99798. */
  99799. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99800. /**
  99801. * Define if mouse events can be treated as touch events
  99802. */
  99803. allowMouse: boolean;
  99804. /**
  99805. * Defines the camera the input is attached to.
  99806. */
  99807. camera: FreeCamera;
  99808. /**
  99809. * Defines the touch sensibility for rotation.
  99810. * The higher the faster.
  99811. */
  99812. touchAngularSensibility: number;
  99813. /**
  99814. * Defines the touch sensibility for move.
  99815. * The higher the faster.
  99816. */
  99817. touchMoveSensibility: number;
  99818. private _offsetX;
  99819. private _offsetY;
  99820. private _pointerPressed;
  99821. private _pointerInput;
  99822. private _observer;
  99823. private _onLostFocus;
  99824. /**
  99825. * Manage the touch inputs to control the movement of a free camera.
  99826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99827. * @param allowMouse Defines if mouse events can be treated as touch events
  99828. */
  99829. constructor(
  99830. /**
  99831. * Define if mouse events can be treated as touch events
  99832. */
  99833. allowMouse?: boolean);
  99834. /**
  99835. * Attach the input controls to a specific dom element to get the input from.
  99836. * @param element Defines the element the controls should be listened from
  99837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99838. */
  99839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99840. /**
  99841. * Detach the current controls from the specified dom element.
  99842. * @param element Defines the element to stop listening the inputs from
  99843. */
  99844. detachControl(element: Nullable<HTMLElement>): void;
  99845. /**
  99846. * Update the current camera state depending on the inputs that have been used this frame.
  99847. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99848. */
  99849. checkInputs(): void;
  99850. /**
  99851. * Gets the class name of the current intput.
  99852. * @returns the class name
  99853. */
  99854. getClassName(): string;
  99855. /**
  99856. * Get the friendly name associated with the input class.
  99857. * @returns the input friendly name
  99858. */
  99859. getSimpleName(): string;
  99860. }
  99861. }
  99862. declare module BABYLON {
  99863. /**
  99864. * Default Inputs manager for the FreeCamera.
  99865. * It groups all the default supported inputs for ease of use.
  99866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99867. */
  99868. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99869. /**
  99870. * @hidden
  99871. */
  99872. _mouseInput: Nullable<FreeCameraMouseInput>;
  99873. /**
  99874. * Instantiates a new FreeCameraInputsManager.
  99875. * @param camera Defines the camera the inputs belong to
  99876. */
  99877. constructor(camera: FreeCamera);
  99878. /**
  99879. * Add keyboard input support to the input manager.
  99880. * @returns the current input manager
  99881. */
  99882. addKeyboard(): FreeCameraInputsManager;
  99883. /**
  99884. * Add mouse input support to the input manager.
  99885. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99886. * @returns the current input manager
  99887. */
  99888. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99889. /**
  99890. * Removes the mouse input support from the manager
  99891. * @returns the current input manager
  99892. */
  99893. removeMouse(): FreeCameraInputsManager;
  99894. /**
  99895. * Add touch input support to the input manager.
  99896. * @returns the current input manager
  99897. */
  99898. addTouch(): FreeCameraInputsManager;
  99899. /**
  99900. * Remove all attached input methods from a camera
  99901. */
  99902. clear(): void;
  99903. }
  99904. }
  99905. declare module BABYLON {
  99906. /**
  99907. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99908. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99909. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99910. */
  99911. export class FreeCamera extends TargetCamera {
  99912. /**
  99913. * Define the collision ellipsoid of the camera.
  99914. * This is helpful to simulate a camera body like the player body around the camera
  99915. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99916. */
  99917. ellipsoid: Vector3;
  99918. /**
  99919. * Define an offset for the position of the ellipsoid around the camera.
  99920. * This can be helpful to determine the center of the body near the gravity center of the body
  99921. * instead of its head.
  99922. */
  99923. ellipsoidOffset: Vector3;
  99924. /**
  99925. * Enable or disable collisions of the camera with the rest of the scene objects.
  99926. */
  99927. checkCollisions: boolean;
  99928. /**
  99929. * Enable or disable gravity on the camera.
  99930. */
  99931. applyGravity: boolean;
  99932. /**
  99933. * Define the input manager associated to the camera.
  99934. */
  99935. inputs: FreeCameraInputsManager;
  99936. /**
  99937. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99938. * Higher values reduce sensitivity.
  99939. */
  99940. get angularSensibility(): number;
  99941. /**
  99942. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99943. * Higher values reduce sensitivity.
  99944. */
  99945. set angularSensibility(value: number);
  99946. /**
  99947. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99948. */
  99949. get keysUp(): number[];
  99950. set keysUp(value: number[]);
  99951. /**
  99952. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99953. */
  99954. get keysUpward(): number[];
  99955. set keysUpward(value: number[]);
  99956. /**
  99957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99958. */
  99959. get keysDown(): number[];
  99960. set keysDown(value: number[]);
  99961. /**
  99962. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99963. */
  99964. get keysDownward(): number[];
  99965. set keysDownward(value: number[]);
  99966. /**
  99967. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99968. */
  99969. get keysLeft(): number[];
  99970. set keysLeft(value: number[]);
  99971. /**
  99972. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99973. */
  99974. get keysRight(): number[];
  99975. set keysRight(value: number[]);
  99976. /**
  99977. * Event raised when the camera collide with a mesh in the scene.
  99978. */
  99979. onCollide: (collidedMesh: AbstractMesh) => void;
  99980. private _collider;
  99981. private _needMoveForGravity;
  99982. private _oldPosition;
  99983. private _diffPosition;
  99984. private _newPosition;
  99985. /** @hidden */
  99986. _localDirection: Vector3;
  99987. /** @hidden */
  99988. _transformedDirection: Vector3;
  99989. /**
  99990. * Instantiates a Free Camera.
  99991. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99992. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99993. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99994. * @param name Define the name of the camera in the scene
  99995. * @param position Define the start position of the camera in the scene
  99996. * @param scene Define the scene the camera belongs to
  99997. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99998. */
  99999. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100000. /**
  100001. * Attached controls to the current camera.
  100002. * @param element Defines the element the controls should be listened from
  100003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100004. */
  100005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100006. /**
  100007. * Detach the current controls from the camera.
  100008. * The camera will stop reacting to inputs.
  100009. * @param element Defines the element to stop listening the inputs from
  100010. */
  100011. detachControl(element: HTMLElement): void;
  100012. private _collisionMask;
  100013. /**
  100014. * Define a collision mask to limit the list of object the camera can collide with
  100015. */
  100016. get collisionMask(): number;
  100017. set collisionMask(mask: number);
  100018. /** @hidden */
  100019. _collideWithWorld(displacement: Vector3): void;
  100020. private _onCollisionPositionChange;
  100021. /** @hidden */
  100022. _checkInputs(): void;
  100023. /** @hidden */
  100024. _decideIfNeedsToMove(): boolean;
  100025. /** @hidden */
  100026. _updatePosition(): void;
  100027. /**
  100028. * Destroy the camera and release the current resources hold by it.
  100029. */
  100030. dispose(): void;
  100031. /**
  100032. * Gets the current object class name.
  100033. * @return the class name
  100034. */
  100035. getClassName(): string;
  100036. }
  100037. }
  100038. declare module BABYLON {
  100039. /**
  100040. * Represents a gamepad control stick position
  100041. */
  100042. export class StickValues {
  100043. /**
  100044. * The x component of the control stick
  100045. */
  100046. x: number;
  100047. /**
  100048. * The y component of the control stick
  100049. */
  100050. y: number;
  100051. /**
  100052. * Initializes the gamepad x and y control stick values
  100053. * @param x The x component of the gamepad control stick value
  100054. * @param y The y component of the gamepad control stick value
  100055. */
  100056. constructor(
  100057. /**
  100058. * The x component of the control stick
  100059. */
  100060. x: number,
  100061. /**
  100062. * The y component of the control stick
  100063. */
  100064. y: number);
  100065. }
  100066. /**
  100067. * An interface which manages callbacks for gamepad button changes
  100068. */
  100069. export interface GamepadButtonChanges {
  100070. /**
  100071. * Called when a gamepad has been changed
  100072. */
  100073. changed: boolean;
  100074. /**
  100075. * Called when a gamepad press event has been triggered
  100076. */
  100077. pressChanged: boolean;
  100078. /**
  100079. * Called when a touch event has been triggered
  100080. */
  100081. touchChanged: boolean;
  100082. /**
  100083. * Called when a value has changed
  100084. */
  100085. valueChanged: boolean;
  100086. }
  100087. /**
  100088. * Represents a gamepad
  100089. */
  100090. export class Gamepad {
  100091. /**
  100092. * The id of the gamepad
  100093. */
  100094. id: string;
  100095. /**
  100096. * The index of the gamepad
  100097. */
  100098. index: number;
  100099. /**
  100100. * The browser gamepad
  100101. */
  100102. browserGamepad: any;
  100103. /**
  100104. * Specifies what type of gamepad this represents
  100105. */
  100106. type: number;
  100107. private _leftStick;
  100108. private _rightStick;
  100109. /** @hidden */
  100110. _isConnected: boolean;
  100111. private _leftStickAxisX;
  100112. private _leftStickAxisY;
  100113. private _rightStickAxisX;
  100114. private _rightStickAxisY;
  100115. /**
  100116. * Triggered when the left control stick has been changed
  100117. */
  100118. private _onleftstickchanged;
  100119. /**
  100120. * Triggered when the right control stick has been changed
  100121. */
  100122. private _onrightstickchanged;
  100123. /**
  100124. * Represents a gamepad controller
  100125. */
  100126. static GAMEPAD: number;
  100127. /**
  100128. * Represents a generic controller
  100129. */
  100130. static GENERIC: number;
  100131. /**
  100132. * Represents an XBox controller
  100133. */
  100134. static XBOX: number;
  100135. /**
  100136. * Represents a pose-enabled controller
  100137. */
  100138. static POSE_ENABLED: number;
  100139. /**
  100140. * Represents an Dual Shock controller
  100141. */
  100142. static DUALSHOCK: number;
  100143. /**
  100144. * Specifies whether the left control stick should be Y-inverted
  100145. */
  100146. protected _invertLeftStickY: boolean;
  100147. /**
  100148. * Specifies if the gamepad has been connected
  100149. */
  100150. get isConnected(): boolean;
  100151. /**
  100152. * Initializes the gamepad
  100153. * @param id The id of the gamepad
  100154. * @param index The index of the gamepad
  100155. * @param browserGamepad The browser gamepad
  100156. * @param leftStickX The x component of the left joystick
  100157. * @param leftStickY The y component of the left joystick
  100158. * @param rightStickX The x component of the right joystick
  100159. * @param rightStickY The y component of the right joystick
  100160. */
  100161. constructor(
  100162. /**
  100163. * The id of the gamepad
  100164. */
  100165. id: string,
  100166. /**
  100167. * The index of the gamepad
  100168. */
  100169. index: number,
  100170. /**
  100171. * The browser gamepad
  100172. */
  100173. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100174. /**
  100175. * Callback triggered when the left joystick has changed
  100176. * @param callback
  100177. */
  100178. onleftstickchanged(callback: (values: StickValues) => void): void;
  100179. /**
  100180. * Callback triggered when the right joystick has changed
  100181. * @param callback
  100182. */
  100183. onrightstickchanged(callback: (values: StickValues) => void): void;
  100184. /**
  100185. * Gets the left joystick
  100186. */
  100187. get leftStick(): StickValues;
  100188. /**
  100189. * Sets the left joystick values
  100190. */
  100191. set leftStick(newValues: StickValues);
  100192. /**
  100193. * Gets the right joystick
  100194. */
  100195. get rightStick(): StickValues;
  100196. /**
  100197. * Sets the right joystick value
  100198. */
  100199. set rightStick(newValues: StickValues);
  100200. /**
  100201. * Updates the gamepad joystick positions
  100202. */
  100203. update(): void;
  100204. /**
  100205. * Disposes the gamepad
  100206. */
  100207. dispose(): void;
  100208. }
  100209. /**
  100210. * Represents a generic gamepad
  100211. */
  100212. export class GenericPad extends Gamepad {
  100213. private _buttons;
  100214. private _onbuttondown;
  100215. private _onbuttonup;
  100216. /**
  100217. * Observable triggered when a button has been pressed
  100218. */
  100219. onButtonDownObservable: Observable<number>;
  100220. /**
  100221. * Observable triggered when a button has been released
  100222. */
  100223. onButtonUpObservable: Observable<number>;
  100224. /**
  100225. * Callback triggered when a button has been pressed
  100226. * @param callback Called when a button has been pressed
  100227. */
  100228. onbuttondown(callback: (buttonPressed: number) => void): void;
  100229. /**
  100230. * Callback triggered when a button has been released
  100231. * @param callback Called when a button has been released
  100232. */
  100233. onbuttonup(callback: (buttonReleased: number) => void): void;
  100234. /**
  100235. * Initializes the generic gamepad
  100236. * @param id The id of the generic gamepad
  100237. * @param index The index of the generic gamepad
  100238. * @param browserGamepad The browser gamepad
  100239. */
  100240. constructor(id: string, index: number, browserGamepad: any);
  100241. private _setButtonValue;
  100242. /**
  100243. * Updates the generic gamepad
  100244. */
  100245. update(): void;
  100246. /**
  100247. * Disposes the generic gamepad
  100248. */
  100249. dispose(): void;
  100250. }
  100251. }
  100252. declare module BABYLON {
  100253. /**
  100254. * Defines the types of pose enabled controllers that are supported
  100255. */
  100256. export enum PoseEnabledControllerType {
  100257. /**
  100258. * HTC Vive
  100259. */
  100260. VIVE = 0,
  100261. /**
  100262. * Oculus Rift
  100263. */
  100264. OCULUS = 1,
  100265. /**
  100266. * Windows mixed reality
  100267. */
  100268. WINDOWS = 2,
  100269. /**
  100270. * Samsung gear VR
  100271. */
  100272. GEAR_VR = 3,
  100273. /**
  100274. * Google Daydream
  100275. */
  100276. DAYDREAM = 4,
  100277. /**
  100278. * Generic
  100279. */
  100280. GENERIC = 5
  100281. }
  100282. /**
  100283. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100284. */
  100285. export interface MutableGamepadButton {
  100286. /**
  100287. * Value of the button/trigger
  100288. */
  100289. value: number;
  100290. /**
  100291. * If the button/trigger is currently touched
  100292. */
  100293. touched: boolean;
  100294. /**
  100295. * If the button/trigger is currently pressed
  100296. */
  100297. pressed: boolean;
  100298. }
  100299. /**
  100300. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100301. * @hidden
  100302. */
  100303. export interface ExtendedGamepadButton extends GamepadButton {
  100304. /**
  100305. * If the button/trigger is currently pressed
  100306. */
  100307. readonly pressed: boolean;
  100308. /**
  100309. * If the button/trigger is currently touched
  100310. */
  100311. readonly touched: boolean;
  100312. /**
  100313. * Value of the button/trigger
  100314. */
  100315. readonly value: number;
  100316. }
  100317. /** @hidden */
  100318. export interface _GamePadFactory {
  100319. /**
  100320. * Returns whether or not the current gamepad can be created for this type of controller.
  100321. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100322. * @returns true if it can be created, otherwise false
  100323. */
  100324. canCreate(gamepadInfo: any): boolean;
  100325. /**
  100326. * Creates a new instance of the Gamepad.
  100327. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100328. * @returns the new gamepad instance
  100329. */
  100330. create(gamepadInfo: any): Gamepad;
  100331. }
  100332. /**
  100333. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100334. */
  100335. export class PoseEnabledControllerHelper {
  100336. /** @hidden */
  100337. static _ControllerFactories: _GamePadFactory[];
  100338. /** @hidden */
  100339. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100340. /**
  100341. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100342. * @param vrGamepad the gamepad to initialized
  100343. * @returns a vr controller of the type the gamepad identified as
  100344. */
  100345. static InitiateController(vrGamepad: any): Gamepad;
  100346. }
  100347. /**
  100348. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100349. */
  100350. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100351. /**
  100352. * If the controller is used in a webXR session
  100353. */
  100354. isXR: boolean;
  100355. private _deviceRoomPosition;
  100356. private _deviceRoomRotationQuaternion;
  100357. /**
  100358. * The device position in babylon space
  100359. */
  100360. devicePosition: Vector3;
  100361. /**
  100362. * The device rotation in babylon space
  100363. */
  100364. deviceRotationQuaternion: Quaternion;
  100365. /**
  100366. * The scale factor of the device in babylon space
  100367. */
  100368. deviceScaleFactor: number;
  100369. /**
  100370. * (Likely devicePosition should be used instead) The device position in its room space
  100371. */
  100372. position: Vector3;
  100373. /**
  100374. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100375. */
  100376. rotationQuaternion: Quaternion;
  100377. /**
  100378. * The type of controller (Eg. Windows mixed reality)
  100379. */
  100380. controllerType: PoseEnabledControllerType;
  100381. protected _calculatedPosition: Vector3;
  100382. private _calculatedRotation;
  100383. /**
  100384. * The raw pose from the device
  100385. */
  100386. rawPose: DevicePose;
  100387. private _trackPosition;
  100388. private _maxRotationDistFromHeadset;
  100389. private _draggedRoomRotation;
  100390. /**
  100391. * @hidden
  100392. */
  100393. _disableTrackPosition(fixedPosition: Vector3): void;
  100394. /**
  100395. * Internal, the mesh attached to the controller
  100396. * @hidden
  100397. */
  100398. _mesh: Nullable<AbstractMesh>;
  100399. private _poseControlledCamera;
  100400. private _leftHandSystemQuaternion;
  100401. /**
  100402. * Internal, matrix used to convert room space to babylon space
  100403. * @hidden
  100404. */
  100405. _deviceToWorld: Matrix;
  100406. /**
  100407. * Node to be used when casting a ray from the controller
  100408. * @hidden
  100409. */
  100410. _pointingPoseNode: Nullable<TransformNode>;
  100411. /**
  100412. * Name of the child mesh that can be used to cast a ray from the controller
  100413. */
  100414. static readonly POINTING_POSE: string;
  100415. /**
  100416. * Creates a new PoseEnabledController from a gamepad
  100417. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100418. */
  100419. constructor(browserGamepad: any);
  100420. private _workingMatrix;
  100421. /**
  100422. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100423. */
  100424. update(): void;
  100425. /**
  100426. * Updates only the pose device and mesh without doing any button event checking
  100427. */
  100428. protected _updatePoseAndMesh(): void;
  100429. /**
  100430. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100431. * @param poseData raw pose fromthe device
  100432. */
  100433. updateFromDevice(poseData: DevicePose): void;
  100434. /**
  100435. * @hidden
  100436. */
  100437. _meshAttachedObservable: Observable<AbstractMesh>;
  100438. /**
  100439. * Attaches a mesh to the controller
  100440. * @param mesh the mesh to be attached
  100441. */
  100442. attachToMesh(mesh: AbstractMesh): void;
  100443. /**
  100444. * Attaches the controllers mesh to a camera
  100445. * @param camera the camera the mesh should be attached to
  100446. */
  100447. attachToPoseControlledCamera(camera: TargetCamera): void;
  100448. /**
  100449. * Disposes of the controller
  100450. */
  100451. dispose(): void;
  100452. /**
  100453. * The mesh that is attached to the controller
  100454. */
  100455. get mesh(): Nullable<AbstractMesh>;
  100456. /**
  100457. * Gets the ray of the controller in the direction the controller is pointing
  100458. * @param length the length the resulting ray should be
  100459. * @returns a ray in the direction the controller is pointing
  100460. */
  100461. getForwardRay(length?: number): Ray;
  100462. }
  100463. }
  100464. declare module BABYLON {
  100465. /**
  100466. * Defines the WebVRController object that represents controllers tracked in 3D space
  100467. */
  100468. export abstract class WebVRController extends PoseEnabledController {
  100469. /**
  100470. * Internal, the default controller model for the controller
  100471. */
  100472. protected _defaultModel: Nullable<AbstractMesh>;
  100473. /**
  100474. * Fired when the trigger state has changed
  100475. */
  100476. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100477. /**
  100478. * Fired when the main button state has changed
  100479. */
  100480. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100481. /**
  100482. * Fired when the secondary button state has changed
  100483. */
  100484. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100485. /**
  100486. * Fired when the pad state has changed
  100487. */
  100488. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100489. /**
  100490. * Fired when controllers stick values have changed
  100491. */
  100492. onPadValuesChangedObservable: Observable<StickValues>;
  100493. /**
  100494. * Array of button availible on the controller
  100495. */
  100496. protected _buttons: Array<MutableGamepadButton>;
  100497. private _onButtonStateChange;
  100498. /**
  100499. * Fired when a controller button's state has changed
  100500. * @param callback the callback containing the button that was modified
  100501. */
  100502. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100503. /**
  100504. * X and Y axis corresponding to the controllers joystick
  100505. */
  100506. pad: StickValues;
  100507. /**
  100508. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100509. */
  100510. hand: string;
  100511. /**
  100512. * The default controller model for the controller
  100513. */
  100514. get defaultModel(): Nullable<AbstractMesh>;
  100515. /**
  100516. * Creates a new WebVRController from a gamepad
  100517. * @param vrGamepad the gamepad that the WebVRController should be created from
  100518. */
  100519. constructor(vrGamepad: any);
  100520. /**
  100521. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100522. */
  100523. update(): void;
  100524. /**
  100525. * Function to be called when a button is modified
  100526. */
  100527. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100528. /**
  100529. * Loads a mesh and attaches it to the controller
  100530. * @param scene the scene the mesh should be added to
  100531. * @param meshLoaded callback for when the mesh has been loaded
  100532. */
  100533. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100534. private _setButtonValue;
  100535. private _changes;
  100536. private _checkChanges;
  100537. /**
  100538. * Disposes of th webVRCOntroller
  100539. */
  100540. dispose(): void;
  100541. }
  100542. }
  100543. declare module BABYLON {
  100544. /**
  100545. * The HemisphericLight simulates the ambient environment light,
  100546. * so the passed direction is the light reflection direction, not the incoming direction.
  100547. */
  100548. export class HemisphericLight extends Light {
  100549. /**
  100550. * The groundColor is the light in the opposite direction to the one specified during creation.
  100551. * 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.
  100552. */
  100553. groundColor: Color3;
  100554. /**
  100555. * The light reflection direction, not the incoming direction.
  100556. */
  100557. direction: Vector3;
  100558. /**
  100559. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100560. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100561. * The HemisphericLight can't cast shadows.
  100562. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100563. * @param name The friendly name of the light
  100564. * @param direction The direction of the light reflection
  100565. * @param scene The scene the light belongs to
  100566. */
  100567. constructor(name: string, direction: Vector3, scene: Scene);
  100568. protected _buildUniformLayout(): void;
  100569. /**
  100570. * Returns the string "HemisphericLight".
  100571. * @return The class name
  100572. */
  100573. getClassName(): string;
  100574. /**
  100575. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100576. * Returns the updated direction.
  100577. * @param target The target the direction should point to
  100578. * @return The computed direction
  100579. */
  100580. setDirectionToTarget(target: Vector3): Vector3;
  100581. /**
  100582. * Returns the shadow generator associated to the light.
  100583. * @returns Always null for hemispheric lights because it does not support shadows.
  100584. */
  100585. getShadowGenerator(): Nullable<IShadowGenerator>;
  100586. /**
  100587. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100588. * @param effect The effect to update
  100589. * @param lightIndex The index of the light in the effect to update
  100590. * @returns The hemispheric light
  100591. */
  100592. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100593. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100594. /**
  100595. * Computes the world matrix of the node
  100596. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100597. * @param useWasUpdatedFlag defines a reserved property
  100598. * @returns the world matrix
  100599. */
  100600. computeWorldMatrix(): Matrix;
  100601. /**
  100602. * Returns the integer 3.
  100603. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100604. */
  100605. getTypeID(): number;
  100606. /**
  100607. * Prepares the list of defines specific to the light type.
  100608. * @param defines the list of defines
  100609. * @param lightIndex defines the index of the light for the effect
  100610. */
  100611. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100612. }
  100613. }
  100614. declare module BABYLON {
  100615. /** @hidden */
  100616. export var vrMultiviewToSingleviewPixelShader: {
  100617. name: string;
  100618. shader: string;
  100619. };
  100620. }
  100621. declare module BABYLON {
  100622. /**
  100623. * Renders to multiple views with a single draw call
  100624. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100625. */
  100626. export class MultiviewRenderTarget extends RenderTargetTexture {
  100627. /**
  100628. * Creates a multiview render target
  100629. * @param scene scene used with the render target
  100630. * @param size the size of the render target (used for each view)
  100631. */
  100632. constructor(scene: Scene, size?: number | {
  100633. width: number;
  100634. height: number;
  100635. } | {
  100636. ratio: number;
  100637. });
  100638. /**
  100639. * @hidden
  100640. * @param faceIndex the face index, if its a cube texture
  100641. */
  100642. _bindFrameBuffer(faceIndex?: number): void;
  100643. /**
  100644. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100645. * @returns the view count
  100646. */
  100647. getViewCount(): number;
  100648. }
  100649. }
  100650. declare module BABYLON {
  100651. interface Engine {
  100652. /**
  100653. * Creates a new multiview render target
  100654. * @param width defines the width of the texture
  100655. * @param height defines the height of the texture
  100656. * @returns the created multiview texture
  100657. */
  100658. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100659. /**
  100660. * Binds a multiview framebuffer to be drawn to
  100661. * @param multiviewTexture texture to bind
  100662. */
  100663. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100664. }
  100665. interface Camera {
  100666. /**
  100667. * @hidden
  100668. * 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)
  100669. */
  100670. _useMultiviewToSingleView: boolean;
  100671. /**
  100672. * @hidden
  100673. * 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)
  100674. */
  100675. _multiviewTexture: Nullable<RenderTargetTexture>;
  100676. /**
  100677. * @hidden
  100678. * ensures the multiview texture of the camera exists and has the specified width/height
  100679. * @param width height to set on the multiview texture
  100680. * @param height width to set on the multiview texture
  100681. */
  100682. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100683. }
  100684. interface Scene {
  100685. /** @hidden */
  100686. _transformMatrixR: Matrix;
  100687. /** @hidden */
  100688. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100689. /** @hidden */
  100690. _createMultiviewUbo(): void;
  100691. /** @hidden */
  100692. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100693. /** @hidden */
  100694. _renderMultiviewToSingleView(camera: Camera): void;
  100695. }
  100696. }
  100697. declare module BABYLON {
  100698. /**
  100699. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100700. * This will not be used for webXR as it supports displaying texture arrays directly
  100701. */
  100702. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100703. /**
  100704. * Gets a string identifying the name of the class
  100705. * @returns "VRMultiviewToSingleviewPostProcess" string
  100706. */
  100707. getClassName(): string;
  100708. /**
  100709. * Initializes a VRMultiviewToSingleview
  100710. * @param name name of the post process
  100711. * @param camera camera to be applied to
  100712. * @param scaleFactor scaling factor to the size of the output texture
  100713. */
  100714. constructor(name: string, camera: Camera, scaleFactor: number);
  100715. }
  100716. }
  100717. declare module BABYLON {
  100718. /**
  100719. * Interface used to define additional presentation attributes
  100720. */
  100721. export interface IVRPresentationAttributes {
  100722. /**
  100723. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100724. */
  100725. highRefreshRate: boolean;
  100726. /**
  100727. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100728. */
  100729. foveationLevel: number;
  100730. }
  100731. interface Engine {
  100732. /** @hidden */
  100733. _vrDisplay: any;
  100734. /** @hidden */
  100735. _vrSupported: boolean;
  100736. /** @hidden */
  100737. _oldSize: Size;
  100738. /** @hidden */
  100739. _oldHardwareScaleFactor: number;
  100740. /** @hidden */
  100741. _vrExclusivePointerMode: boolean;
  100742. /** @hidden */
  100743. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100744. /** @hidden */
  100745. _onVRDisplayPointerRestricted: () => void;
  100746. /** @hidden */
  100747. _onVRDisplayPointerUnrestricted: () => void;
  100748. /** @hidden */
  100749. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100750. /** @hidden */
  100751. _onVrDisplayDisconnect: Nullable<() => void>;
  100752. /** @hidden */
  100753. _onVrDisplayPresentChange: Nullable<() => void>;
  100754. /**
  100755. * Observable signaled when VR display mode changes
  100756. */
  100757. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100758. /**
  100759. * Observable signaled when VR request present is complete
  100760. */
  100761. onVRRequestPresentComplete: Observable<boolean>;
  100762. /**
  100763. * Observable signaled when VR request present starts
  100764. */
  100765. onVRRequestPresentStart: Observable<Engine>;
  100766. /**
  100767. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100768. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100769. */
  100770. isInVRExclusivePointerMode: boolean;
  100771. /**
  100772. * Gets a boolean indicating if a webVR device was detected
  100773. * @returns true if a webVR device was detected
  100774. */
  100775. isVRDevicePresent(): boolean;
  100776. /**
  100777. * Gets the current webVR device
  100778. * @returns the current webVR device (or null)
  100779. */
  100780. getVRDevice(): any;
  100781. /**
  100782. * Initializes a webVR display and starts listening to display change events
  100783. * The onVRDisplayChangedObservable will be notified upon these changes
  100784. * @returns A promise containing a VRDisplay and if vr is supported
  100785. */
  100786. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100787. /** @hidden */
  100788. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100789. /**
  100790. * Gets or sets the presentation attributes used to configure VR rendering
  100791. */
  100792. vrPresentationAttributes?: IVRPresentationAttributes;
  100793. /**
  100794. * Call this function to switch to webVR mode
  100795. * Will do nothing if webVR is not supported or if there is no webVR device
  100796. * @param options the webvr options provided to the camera. mainly used for multiview
  100797. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100798. */
  100799. enableVR(options: WebVROptions): void;
  100800. /** @hidden */
  100801. _onVRFullScreenTriggered(): void;
  100802. }
  100803. }
  100804. declare module BABYLON {
  100805. /**
  100806. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100807. * IMPORTANT!! The data is right-hand data.
  100808. * @export
  100809. * @interface DevicePose
  100810. */
  100811. export interface DevicePose {
  100812. /**
  100813. * The position of the device, values in array are [x,y,z].
  100814. */
  100815. readonly position: Nullable<Float32Array>;
  100816. /**
  100817. * The linearVelocity of the device, values in array are [x,y,z].
  100818. */
  100819. readonly linearVelocity: Nullable<Float32Array>;
  100820. /**
  100821. * The linearAcceleration of the device, values in array are [x,y,z].
  100822. */
  100823. readonly linearAcceleration: Nullable<Float32Array>;
  100824. /**
  100825. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100826. */
  100827. readonly orientation: Nullable<Float32Array>;
  100828. /**
  100829. * The angularVelocity of the device, values in array are [x,y,z].
  100830. */
  100831. readonly angularVelocity: Nullable<Float32Array>;
  100832. /**
  100833. * The angularAcceleration of the device, values in array are [x,y,z].
  100834. */
  100835. readonly angularAcceleration: Nullable<Float32Array>;
  100836. }
  100837. /**
  100838. * Interface representing a pose controlled object in Babylon.
  100839. * A pose controlled object has both regular pose values as well as pose values
  100840. * from an external device such as a VR head mounted display
  100841. */
  100842. export interface PoseControlled {
  100843. /**
  100844. * The position of the object in babylon space.
  100845. */
  100846. position: Vector3;
  100847. /**
  100848. * The rotation quaternion of the object in babylon space.
  100849. */
  100850. rotationQuaternion: Quaternion;
  100851. /**
  100852. * The position of the device in babylon space.
  100853. */
  100854. devicePosition?: Vector3;
  100855. /**
  100856. * The rotation quaternion of the device in babylon space.
  100857. */
  100858. deviceRotationQuaternion: Quaternion;
  100859. /**
  100860. * The raw pose coming from the device.
  100861. */
  100862. rawPose: Nullable<DevicePose>;
  100863. /**
  100864. * The scale of the device to be used when translating from device space to babylon space.
  100865. */
  100866. deviceScaleFactor: number;
  100867. /**
  100868. * Updates the poseControlled values based on the input device pose.
  100869. * @param poseData the pose data to update the object with
  100870. */
  100871. updateFromDevice(poseData: DevicePose): void;
  100872. }
  100873. /**
  100874. * Set of options to customize the webVRCamera
  100875. */
  100876. export interface WebVROptions {
  100877. /**
  100878. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100879. */
  100880. trackPosition?: boolean;
  100881. /**
  100882. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100883. */
  100884. positionScale?: number;
  100885. /**
  100886. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100887. */
  100888. displayName?: string;
  100889. /**
  100890. * Should the native controller meshes be initialized. (default: true)
  100891. */
  100892. controllerMeshes?: boolean;
  100893. /**
  100894. * Creating a default HemiLight only on controllers. (default: true)
  100895. */
  100896. defaultLightingOnControllers?: boolean;
  100897. /**
  100898. * If you don't want to use the default VR button of the helper. (default: false)
  100899. */
  100900. useCustomVRButton?: boolean;
  100901. /**
  100902. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100903. */
  100904. customVRButton?: HTMLButtonElement;
  100905. /**
  100906. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100907. */
  100908. rayLength?: number;
  100909. /**
  100910. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100911. */
  100912. defaultHeight?: number;
  100913. /**
  100914. * If multiview should be used if availible (default: false)
  100915. */
  100916. useMultiview?: boolean;
  100917. }
  100918. /**
  100919. * This represents a WebVR camera.
  100920. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100921. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100922. */
  100923. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100924. private webVROptions;
  100925. /**
  100926. * @hidden
  100927. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100928. */
  100929. _vrDevice: any;
  100930. /**
  100931. * The rawPose of the vrDevice.
  100932. */
  100933. rawPose: Nullable<DevicePose>;
  100934. private _onVREnabled;
  100935. private _specsVersion;
  100936. private _attached;
  100937. private _frameData;
  100938. protected _descendants: Array<Node>;
  100939. private _deviceRoomPosition;
  100940. /** @hidden */
  100941. _deviceRoomRotationQuaternion: Quaternion;
  100942. private _standingMatrix;
  100943. /**
  100944. * Represents device position in babylon space.
  100945. */
  100946. devicePosition: Vector3;
  100947. /**
  100948. * Represents device rotation in babylon space.
  100949. */
  100950. deviceRotationQuaternion: Quaternion;
  100951. /**
  100952. * The scale of the device to be used when translating from device space to babylon space.
  100953. */
  100954. deviceScaleFactor: number;
  100955. private _deviceToWorld;
  100956. private _worldToDevice;
  100957. /**
  100958. * References to the webVR controllers for the vrDevice.
  100959. */
  100960. controllers: Array<WebVRController>;
  100961. /**
  100962. * Emits an event when a controller is attached.
  100963. */
  100964. onControllersAttachedObservable: Observable<WebVRController[]>;
  100965. /**
  100966. * Emits an event when a controller's mesh has been loaded;
  100967. */
  100968. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100969. /**
  100970. * Emits an event when the HMD's pose has been updated.
  100971. */
  100972. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100973. private _poseSet;
  100974. /**
  100975. * If the rig cameras be used as parent instead of this camera.
  100976. */
  100977. rigParenting: boolean;
  100978. private _lightOnControllers;
  100979. private _defaultHeight?;
  100980. /**
  100981. * Instantiates a WebVRFreeCamera.
  100982. * @param name The name of the WebVRFreeCamera
  100983. * @param position The starting anchor position for the camera
  100984. * @param scene The scene the camera belongs to
  100985. * @param webVROptions a set of customizable options for the webVRCamera
  100986. */
  100987. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100988. /**
  100989. * Gets the device distance from the ground in meters.
  100990. * @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.
  100991. */
  100992. deviceDistanceToRoomGround(): number;
  100993. /**
  100994. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100995. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100996. */
  100997. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100998. /**
  100999. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101000. * @returns A promise with a boolean set to if the standing matrix is supported.
  101001. */
  101002. useStandingMatrixAsync(): Promise<boolean>;
  101003. /**
  101004. * Disposes the camera
  101005. */
  101006. dispose(): void;
  101007. /**
  101008. * Gets a vrController by name.
  101009. * @param name The name of the controller to retreive
  101010. * @returns the controller matching the name specified or null if not found
  101011. */
  101012. getControllerByName(name: string): Nullable<WebVRController>;
  101013. private _leftController;
  101014. /**
  101015. * The controller corresponding to the users left hand.
  101016. */
  101017. get leftController(): Nullable<WebVRController>;
  101018. private _rightController;
  101019. /**
  101020. * The controller corresponding to the users right hand.
  101021. */
  101022. get rightController(): Nullable<WebVRController>;
  101023. /**
  101024. * Casts a ray forward from the vrCamera's gaze.
  101025. * @param length Length of the ray (default: 100)
  101026. * @returns the ray corresponding to the gaze
  101027. */
  101028. getForwardRay(length?: number): Ray;
  101029. /**
  101030. * @hidden
  101031. * Updates the camera based on device's frame data
  101032. */
  101033. _checkInputs(): void;
  101034. /**
  101035. * Updates the poseControlled values based on the input device pose.
  101036. * @param poseData Pose coming from the device
  101037. */
  101038. updateFromDevice(poseData: DevicePose): void;
  101039. private _htmlElementAttached;
  101040. private _detachIfAttached;
  101041. /**
  101042. * WebVR's attach control will start broadcasting frames to the device.
  101043. * Note that in certain browsers (chrome for example) this function must be called
  101044. * within a user-interaction callback. Example:
  101045. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101046. *
  101047. * @param element html element to attach the vrDevice to
  101048. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101049. */
  101050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101051. /**
  101052. * Detaches the camera from the html element and disables VR
  101053. *
  101054. * @param element html element to detach from
  101055. */
  101056. detachControl(element: HTMLElement): void;
  101057. /**
  101058. * @returns the name of this class
  101059. */
  101060. getClassName(): string;
  101061. /**
  101062. * Calls resetPose on the vrDisplay
  101063. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101064. */
  101065. resetToCurrentRotation(): void;
  101066. /**
  101067. * @hidden
  101068. * Updates the rig cameras (left and right eye)
  101069. */
  101070. _updateRigCameras(): void;
  101071. private _workingVector;
  101072. private _oneVector;
  101073. private _workingMatrix;
  101074. private updateCacheCalled;
  101075. private _correctPositionIfNotTrackPosition;
  101076. /**
  101077. * @hidden
  101078. * Updates the cached values of the camera
  101079. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101080. */
  101081. _updateCache(ignoreParentClass?: boolean): void;
  101082. /**
  101083. * @hidden
  101084. * Get current device position in babylon world
  101085. */
  101086. _computeDevicePosition(): void;
  101087. /**
  101088. * Updates the current device position and rotation in the babylon world
  101089. */
  101090. update(): void;
  101091. /**
  101092. * @hidden
  101093. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101094. * @returns an identity matrix
  101095. */
  101096. _getViewMatrix(): Matrix;
  101097. private _tmpMatrix;
  101098. /**
  101099. * This function is called by the two RIG cameras.
  101100. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101101. * @hidden
  101102. */
  101103. _getWebVRViewMatrix(): Matrix;
  101104. /** @hidden */
  101105. _getWebVRProjectionMatrix(): Matrix;
  101106. private _onGamepadConnectedObserver;
  101107. private _onGamepadDisconnectedObserver;
  101108. private _updateCacheWhenTrackingDisabledObserver;
  101109. /**
  101110. * Initializes the controllers and their meshes
  101111. */
  101112. initControllers(): void;
  101113. }
  101114. }
  101115. declare module BABYLON {
  101116. /**
  101117. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101118. *
  101119. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101120. *
  101121. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101122. */
  101123. export class MaterialHelper {
  101124. /**
  101125. * Bind the current view position to an effect.
  101126. * @param effect The effect to be bound
  101127. * @param scene The scene the eyes position is used from
  101128. * @param variableName name of the shader variable that will hold the eye position
  101129. */
  101130. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101131. /**
  101132. * Helps preparing the defines values about the UVs in used in the effect.
  101133. * UVs are shared as much as we can accross channels in the shaders.
  101134. * @param texture The texture we are preparing the UVs for
  101135. * @param defines The defines to update
  101136. * @param key The channel key "diffuse", "specular"... used in the shader
  101137. */
  101138. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101139. /**
  101140. * Binds a texture matrix value to its corrsponding uniform
  101141. * @param texture The texture to bind the matrix for
  101142. * @param uniformBuffer The uniform buffer receivin the data
  101143. * @param key The channel key "diffuse", "specular"... used in the shader
  101144. */
  101145. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101146. /**
  101147. * Gets the current status of the fog (should it be enabled?)
  101148. * @param mesh defines the mesh to evaluate for fog support
  101149. * @param scene defines the hosting scene
  101150. * @returns true if fog must be enabled
  101151. */
  101152. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101153. /**
  101154. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101155. * @param mesh defines the current mesh
  101156. * @param scene defines the current scene
  101157. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101158. * @param pointsCloud defines if point cloud rendering has to be turned on
  101159. * @param fogEnabled defines if fog has to be turned on
  101160. * @param alphaTest defines if alpha testing has to be turned on
  101161. * @param defines defines the current list of defines
  101162. */
  101163. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101164. /**
  101165. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101166. * @param scene defines the current scene
  101167. * @param engine defines the current engine
  101168. * @param defines specifies the list of active defines
  101169. * @param useInstances defines if instances have to be turned on
  101170. * @param useClipPlane defines if clip plane have to be turned on
  101171. * @param useInstances defines if instances have to be turned on
  101172. * @param useThinInstances defines if thin instances have to be turned on
  101173. */
  101174. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101175. /**
  101176. * Prepares the defines for bones
  101177. * @param mesh The mesh containing the geometry data we will draw
  101178. * @param defines The defines to update
  101179. */
  101180. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101181. /**
  101182. * Prepares the defines for morph targets
  101183. * @param mesh The mesh containing the geometry data we will draw
  101184. * @param defines The defines to update
  101185. */
  101186. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101187. /**
  101188. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101189. * @param mesh The mesh containing the geometry data we will draw
  101190. * @param defines The defines to update
  101191. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101192. * @param useBones Precise whether bones should be used or not (override mesh info)
  101193. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101194. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101195. * @returns false if defines are considered not dirty and have not been checked
  101196. */
  101197. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101198. /**
  101199. * Prepares the defines related to multiview
  101200. * @param scene The scene we are intending to draw
  101201. * @param defines The defines to update
  101202. */
  101203. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101204. /**
  101205. * Prepares the defines related to the prepass
  101206. * @param scene The scene we are intending to draw
  101207. * @param defines The defines to update
  101208. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101209. */
  101210. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101211. /**
  101212. * Prepares the defines related to the light information passed in parameter
  101213. * @param scene The scene we are intending to draw
  101214. * @param mesh The mesh the effect is compiling for
  101215. * @param light The light the effect is compiling for
  101216. * @param lightIndex The index of the light
  101217. * @param defines The defines to update
  101218. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101219. * @param state Defines the current state regarding what is needed (normals, etc...)
  101220. */
  101221. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101222. needNormals: boolean;
  101223. needRebuild: boolean;
  101224. shadowEnabled: boolean;
  101225. specularEnabled: boolean;
  101226. lightmapMode: boolean;
  101227. }): void;
  101228. /**
  101229. * Prepares the defines related to the light information passed in parameter
  101230. * @param scene The scene we are intending to draw
  101231. * @param mesh The mesh the effect is compiling for
  101232. * @param defines The defines to update
  101233. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101234. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101235. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101236. * @returns true if normals will be required for the rest of the effect
  101237. */
  101238. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101239. /**
  101240. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101241. * @param lightIndex defines the light index
  101242. * @param uniformsList The uniform list
  101243. * @param samplersList The sampler list
  101244. * @param projectedLightTexture defines if projected texture must be used
  101245. * @param uniformBuffersList defines an optional list of uniform buffers
  101246. */
  101247. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101248. /**
  101249. * Prepares the uniforms and samplers list to be used in the effect
  101250. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101251. * @param samplersList The sampler list
  101252. * @param defines The defines helping in the list generation
  101253. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101254. */
  101255. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101256. /**
  101257. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101258. * @param defines The defines to update while falling back
  101259. * @param fallbacks The authorized effect fallbacks
  101260. * @param maxSimultaneousLights The maximum number of lights allowed
  101261. * @param rank the current rank of the Effect
  101262. * @returns The newly affected rank
  101263. */
  101264. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101265. private static _TmpMorphInfluencers;
  101266. /**
  101267. * Prepares the list of attributes required for morph targets according to the effect defines.
  101268. * @param attribs The current list of supported attribs
  101269. * @param mesh The mesh to prepare the morph targets attributes for
  101270. * @param influencers The number of influencers
  101271. */
  101272. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101273. /**
  101274. * Prepares the list of attributes required for morph targets according to the effect defines.
  101275. * @param attribs The current list of supported attribs
  101276. * @param mesh The mesh to prepare the morph targets attributes for
  101277. * @param defines The current Defines of the effect
  101278. */
  101279. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101280. /**
  101281. * Prepares the list of attributes required for bones according to the effect defines.
  101282. * @param attribs The current list of supported attribs
  101283. * @param mesh The mesh to prepare the bones attributes for
  101284. * @param defines The current Defines of the effect
  101285. * @param fallbacks The current efffect fallback strategy
  101286. */
  101287. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101288. /**
  101289. * Check and prepare the list of attributes required for instances according to the effect defines.
  101290. * @param attribs The current list of supported attribs
  101291. * @param defines The current MaterialDefines of the effect
  101292. */
  101293. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101294. /**
  101295. * Add the list of attributes required for instances to the attribs array.
  101296. * @param attribs The current list of supported attribs
  101297. */
  101298. static PushAttributesForInstances(attribs: string[]): void;
  101299. /**
  101300. * Binds the light information to the effect.
  101301. * @param light The light containing the generator
  101302. * @param effect The effect we are binding the data to
  101303. * @param lightIndex The light index in the effect used to render
  101304. */
  101305. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101306. /**
  101307. * Binds the lights information from the scene to the effect for the given mesh.
  101308. * @param light Light to bind
  101309. * @param lightIndex Light index
  101310. * @param scene The scene where the light belongs to
  101311. * @param effect The effect we are binding the data to
  101312. * @param useSpecular Defines if specular is supported
  101313. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101314. */
  101315. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101316. /**
  101317. * Binds the lights information from the scene to the effect for the given mesh.
  101318. * @param scene The scene the lights belongs to
  101319. * @param mesh The mesh we are binding the information to render
  101320. * @param effect The effect we are binding the data to
  101321. * @param defines The generated defines for the effect
  101322. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101323. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101324. */
  101325. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101326. private static _tempFogColor;
  101327. /**
  101328. * Binds the fog information from the scene to the effect for the given mesh.
  101329. * @param scene The scene the lights belongs to
  101330. * @param mesh The mesh we are binding the information to render
  101331. * @param effect The effect we are binding the data to
  101332. * @param linearSpace Defines if the fog effect is applied in linear space
  101333. */
  101334. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101335. /**
  101336. * Binds the bones information from the mesh to the effect.
  101337. * @param mesh The mesh we are binding the information to render
  101338. * @param effect The effect we are binding the data to
  101339. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101340. */
  101341. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101342. private static _CopyBonesTransformationMatrices;
  101343. /**
  101344. * Binds the morph targets information from the mesh to the effect.
  101345. * @param abstractMesh The mesh we are binding the information to render
  101346. * @param effect The effect we are binding the data to
  101347. */
  101348. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101349. /**
  101350. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101351. * @param defines The generated defines used in the effect
  101352. * @param effect The effect we are binding the data to
  101353. * @param scene The scene we are willing to render with logarithmic scale for
  101354. */
  101355. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101356. /**
  101357. * Binds the clip plane information from the scene to the effect.
  101358. * @param scene The scene the clip plane information are extracted from
  101359. * @param effect The effect we are binding the data to
  101360. */
  101361. static BindClipPlane(effect: Effect, scene: Scene): void;
  101362. }
  101363. }
  101364. declare module BABYLON {
  101365. /**
  101366. * Block used to expose an input value
  101367. */
  101368. export class InputBlock extends NodeMaterialBlock {
  101369. private _mode;
  101370. private _associatedVariableName;
  101371. private _storedValue;
  101372. private _valueCallback;
  101373. private _type;
  101374. private _animationType;
  101375. /** Gets or set a value used to limit the range of float values */
  101376. min: number;
  101377. /** Gets or set a value used to limit the range of float values */
  101378. max: number;
  101379. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101380. isBoolean: boolean;
  101381. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101382. matrixMode: number;
  101383. /** @hidden */
  101384. _systemValue: Nullable<NodeMaterialSystemValues>;
  101385. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101386. isConstant: boolean;
  101387. /** Gets or sets the group to use to display this block in the Inspector */
  101388. groupInInspector: string;
  101389. /** Gets an observable raised when the value is changed */
  101390. onValueChangedObservable: Observable<InputBlock>;
  101391. /**
  101392. * Gets or sets the connection point type (default is float)
  101393. */
  101394. get type(): NodeMaterialBlockConnectionPointTypes;
  101395. /**
  101396. * Creates a new InputBlock
  101397. * @param name defines the block name
  101398. * @param target defines the target of that block (Vertex by default)
  101399. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101400. */
  101401. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101402. /**
  101403. * Validates if a name is a reserve word.
  101404. * @param newName the new name to be given to the node.
  101405. * @returns false if the name is a reserve word, else true.
  101406. */
  101407. validateBlockName(newName: string): boolean;
  101408. /**
  101409. * Gets the output component
  101410. */
  101411. get output(): NodeMaterialConnectionPoint;
  101412. /**
  101413. * Set the source of this connection point to a vertex attribute
  101414. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101415. * @returns the current connection point
  101416. */
  101417. setAsAttribute(attributeName?: string): InputBlock;
  101418. /**
  101419. * Set the source of this connection point to a system value
  101420. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101421. * @returns the current connection point
  101422. */
  101423. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101424. /**
  101425. * Gets or sets the value of that point.
  101426. * Please note that this value will be ignored if valueCallback is defined
  101427. */
  101428. get value(): any;
  101429. set value(value: any);
  101430. /**
  101431. * Gets or sets a callback used to get the value of that point.
  101432. * Please note that setting this value will force the connection point to ignore the value property
  101433. */
  101434. get valueCallback(): () => any;
  101435. set valueCallback(value: () => any);
  101436. /**
  101437. * Gets or sets the associated variable name in the shader
  101438. */
  101439. get associatedVariableName(): string;
  101440. set associatedVariableName(value: string);
  101441. /** Gets or sets the type of animation applied to the input */
  101442. get animationType(): AnimatedInputBlockTypes;
  101443. set animationType(value: AnimatedInputBlockTypes);
  101444. /**
  101445. * Gets a boolean indicating that this connection point not defined yet
  101446. */
  101447. get isUndefined(): boolean;
  101448. /**
  101449. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101450. * In this case the connection point name must be the name of the uniform to use.
  101451. * Can only be set on inputs
  101452. */
  101453. get isUniform(): boolean;
  101454. set isUniform(value: boolean);
  101455. /**
  101456. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101457. * In this case the connection point name must be the name of the attribute to use
  101458. * Can only be set on inputs
  101459. */
  101460. get isAttribute(): boolean;
  101461. set isAttribute(value: boolean);
  101462. /**
  101463. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101464. * Can only be set on exit points
  101465. */
  101466. get isVarying(): boolean;
  101467. set isVarying(value: boolean);
  101468. /**
  101469. * Gets a boolean indicating that the current connection point is a system value
  101470. */
  101471. get isSystemValue(): boolean;
  101472. /**
  101473. * Gets or sets the current well known value or null if not defined as a system value
  101474. */
  101475. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101476. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101477. /**
  101478. * Gets the current class name
  101479. * @returns the class name
  101480. */
  101481. getClassName(): string;
  101482. /**
  101483. * Animate the input if animationType !== None
  101484. * @param scene defines the rendering scene
  101485. */
  101486. animate(scene: Scene): void;
  101487. private _emitDefine;
  101488. initialize(state: NodeMaterialBuildState): void;
  101489. /**
  101490. * Set the input block to its default value (based on its type)
  101491. */
  101492. setDefaultValue(): void;
  101493. private _emitConstant;
  101494. /** @hidden */
  101495. get _noContextSwitch(): boolean;
  101496. private _emit;
  101497. /** @hidden */
  101498. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101499. /** @hidden */
  101500. _transmit(effect: Effect, scene: Scene): void;
  101501. protected _buildBlock(state: NodeMaterialBuildState): void;
  101502. protected _dumpPropertiesCode(): string;
  101503. dispose(): void;
  101504. serialize(): any;
  101505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101506. }
  101507. }
  101508. declare module BABYLON {
  101509. /**
  101510. * Enum used to define the compatibility state between two connection points
  101511. */
  101512. export enum NodeMaterialConnectionPointCompatibilityStates {
  101513. /** Points are compatibles */
  101514. Compatible = 0,
  101515. /** Points are incompatible because of their types */
  101516. TypeIncompatible = 1,
  101517. /** Points are incompatible because of their targets (vertex vs fragment) */
  101518. TargetIncompatible = 2
  101519. }
  101520. /**
  101521. * Defines the direction of a connection point
  101522. */
  101523. export enum NodeMaterialConnectionPointDirection {
  101524. /** Input */
  101525. Input = 0,
  101526. /** Output */
  101527. Output = 1
  101528. }
  101529. /**
  101530. * Defines a connection point for a block
  101531. */
  101532. export class NodeMaterialConnectionPoint {
  101533. /** @hidden */
  101534. _ownerBlock: NodeMaterialBlock;
  101535. /** @hidden */
  101536. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101537. private _endpoints;
  101538. private _associatedVariableName;
  101539. private _direction;
  101540. /** @hidden */
  101541. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101542. /** @hidden */
  101543. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101544. private _type;
  101545. /** @hidden */
  101546. _enforceAssociatedVariableName: boolean;
  101547. /** Gets the direction of the point */
  101548. get direction(): NodeMaterialConnectionPointDirection;
  101549. /** Indicates that this connection point needs dual validation before being connected to another point */
  101550. needDualDirectionValidation: boolean;
  101551. /**
  101552. * Gets or sets the additional types supported by this connection point
  101553. */
  101554. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101555. /**
  101556. * Gets or sets the additional types excluded by this connection point
  101557. */
  101558. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101559. /**
  101560. * Observable triggered when this point is connected
  101561. */
  101562. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101563. /**
  101564. * Gets or sets the associated variable name in the shader
  101565. */
  101566. get associatedVariableName(): string;
  101567. set associatedVariableName(value: string);
  101568. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101569. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101570. /**
  101571. * Gets or sets the connection point type (default is float)
  101572. */
  101573. get type(): NodeMaterialBlockConnectionPointTypes;
  101574. set type(value: NodeMaterialBlockConnectionPointTypes);
  101575. /**
  101576. * Gets or sets the connection point name
  101577. */
  101578. name: string;
  101579. /**
  101580. * Gets or sets the connection point name
  101581. */
  101582. displayName: string;
  101583. /**
  101584. * Gets or sets a boolean indicating that this connection point can be omitted
  101585. */
  101586. isOptional: boolean;
  101587. /**
  101588. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101589. */
  101590. isExposedOnFrame: boolean;
  101591. /**
  101592. * Gets or sets number indicating the position that the port is exposed to on a frame
  101593. */
  101594. exposedPortPosition: number;
  101595. /**
  101596. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101597. */
  101598. define: string;
  101599. /** @hidden */
  101600. _prioritizeVertex: boolean;
  101601. private _target;
  101602. /** Gets or sets the target of that connection point */
  101603. get target(): NodeMaterialBlockTargets;
  101604. set target(value: NodeMaterialBlockTargets);
  101605. /**
  101606. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101607. */
  101608. get isConnected(): boolean;
  101609. /**
  101610. * Gets a boolean indicating that the current point is connected to an input block
  101611. */
  101612. get isConnectedToInputBlock(): boolean;
  101613. /**
  101614. * Gets a the connected input block (if any)
  101615. */
  101616. get connectInputBlock(): Nullable<InputBlock>;
  101617. /** Get the other side of the connection (if any) */
  101618. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101619. /** Get the block that owns this connection point */
  101620. get ownerBlock(): NodeMaterialBlock;
  101621. /** Get the block connected on the other side of this connection (if any) */
  101622. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101623. /** Get the block connected on the endpoints of this connection (if any) */
  101624. get connectedBlocks(): Array<NodeMaterialBlock>;
  101625. /** Gets the list of connected endpoints */
  101626. get endpoints(): NodeMaterialConnectionPoint[];
  101627. /** Gets a boolean indicating if that output point is connected to at least one input */
  101628. get hasEndpoints(): boolean;
  101629. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101630. get isConnectedInVertexShader(): boolean;
  101631. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101632. get isConnectedInFragmentShader(): boolean;
  101633. /**
  101634. * Creates a block suitable to be used as an input for this input point.
  101635. * If null is returned, a block based on the point type will be created.
  101636. * @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
  101637. */
  101638. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101639. /**
  101640. * Creates a new connection point
  101641. * @param name defines the connection point name
  101642. * @param ownerBlock defines the block hosting this connection point
  101643. * @param direction defines the direction of the connection point
  101644. */
  101645. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101646. /**
  101647. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101648. * @returns the class name
  101649. */
  101650. getClassName(): string;
  101651. /**
  101652. * Gets a boolean indicating if the current point can be connected to another point
  101653. * @param connectionPoint defines the other connection point
  101654. * @returns a boolean
  101655. */
  101656. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101657. /**
  101658. * Gets a number indicating if the current point can be connected to another point
  101659. * @param connectionPoint defines the other connection point
  101660. * @returns a number defining the compatibility state
  101661. */
  101662. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101663. /**
  101664. * Connect this point to another connection point
  101665. * @param connectionPoint defines the other connection point
  101666. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101667. * @returns the current connection point
  101668. */
  101669. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101670. /**
  101671. * Disconnect this point from one of his endpoint
  101672. * @param endpoint defines the other connection point
  101673. * @returns the current connection point
  101674. */
  101675. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101676. /**
  101677. * Serializes this point in a JSON representation
  101678. * @param isInput defines if the connection point is an input (default is true)
  101679. * @returns the serialized point object
  101680. */
  101681. serialize(isInput?: boolean): any;
  101682. /**
  101683. * Release resources
  101684. */
  101685. dispose(): void;
  101686. }
  101687. }
  101688. declare module BABYLON {
  101689. /**
  101690. * Enum used to define the material modes
  101691. */
  101692. export enum NodeMaterialModes {
  101693. /** Regular material */
  101694. Material = 0,
  101695. /** For post process */
  101696. PostProcess = 1,
  101697. /** For particle system */
  101698. Particle = 2,
  101699. /** For procedural texture */
  101700. ProceduralTexture = 3
  101701. }
  101702. }
  101703. declare module BABYLON {
  101704. /**
  101705. * Block used to read a texture from a sampler
  101706. */
  101707. export class TextureBlock extends NodeMaterialBlock {
  101708. private _defineName;
  101709. private _linearDefineName;
  101710. private _gammaDefineName;
  101711. private _tempTextureRead;
  101712. private _samplerName;
  101713. private _transformedUVName;
  101714. private _textureTransformName;
  101715. private _textureInfoName;
  101716. private _mainUVName;
  101717. private _mainUVDefineName;
  101718. private _fragmentOnly;
  101719. /**
  101720. * Gets or sets the texture associated with the node
  101721. */
  101722. texture: Nullable<Texture>;
  101723. /**
  101724. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101725. */
  101726. convertToGammaSpace: boolean;
  101727. /**
  101728. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101729. */
  101730. convertToLinearSpace: boolean;
  101731. /**
  101732. * Create a new TextureBlock
  101733. * @param name defines the block name
  101734. */
  101735. constructor(name: string, fragmentOnly?: boolean);
  101736. /**
  101737. * Gets the current class name
  101738. * @returns the class name
  101739. */
  101740. getClassName(): string;
  101741. /**
  101742. * Gets the uv input component
  101743. */
  101744. get uv(): NodeMaterialConnectionPoint;
  101745. /**
  101746. * Gets the rgba output component
  101747. */
  101748. get rgba(): NodeMaterialConnectionPoint;
  101749. /**
  101750. * Gets the rgb output component
  101751. */
  101752. get rgb(): NodeMaterialConnectionPoint;
  101753. /**
  101754. * Gets the r output component
  101755. */
  101756. get r(): NodeMaterialConnectionPoint;
  101757. /**
  101758. * Gets the g output component
  101759. */
  101760. get g(): NodeMaterialConnectionPoint;
  101761. /**
  101762. * Gets the b output component
  101763. */
  101764. get b(): NodeMaterialConnectionPoint;
  101765. /**
  101766. * Gets the a output component
  101767. */
  101768. get a(): NodeMaterialConnectionPoint;
  101769. get target(): NodeMaterialBlockTargets;
  101770. autoConfigure(material: NodeMaterial): void;
  101771. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101773. isReady(): boolean;
  101774. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101775. private get _isMixed();
  101776. private _injectVertexCode;
  101777. private _writeTextureRead;
  101778. private _writeOutput;
  101779. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101780. protected _dumpPropertiesCode(): string;
  101781. serialize(): any;
  101782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101783. }
  101784. }
  101785. declare module BABYLON {
  101786. /** @hidden */
  101787. export var reflectionFunction: {
  101788. name: string;
  101789. shader: string;
  101790. };
  101791. }
  101792. declare module BABYLON {
  101793. /**
  101794. * Base block used to read a reflection texture from a sampler
  101795. */
  101796. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101797. /** @hidden */
  101798. _define3DName: string;
  101799. /** @hidden */
  101800. _defineCubicName: string;
  101801. /** @hidden */
  101802. _defineExplicitName: string;
  101803. /** @hidden */
  101804. _defineProjectionName: string;
  101805. /** @hidden */
  101806. _defineLocalCubicName: string;
  101807. /** @hidden */
  101808. _defineSphericalName: string;
  101809. /** @hidden */
  101810. _definePlanarName: string;
  101811. /** @hidden */
  101812. _defineEquirectangularName: string;
  101813. /** @hidden */
  101814. _defineMirroredEquirectangularFixedName: string;
  101815. /** @hidden */
  101816. _defineEquirectangularFixedName: string;
  101817. /** @hidden */
  101818. _defineSkyboxName: string;
  101819. /** @hidden */
  101820. _defineOppositeZ: string;
  101821. /** @hidden */
  101822. _cubeSamplerName: string;
  101823. /** @hidden */
  101824. _2DSamplerName: string;
  101825. protected _positionUVWName: string;
  101826. protected _directionWName: string;
  101827. protected _reflectionVectorName: string;
  101828. /** @hidden */
  101829. _reflectionCoordsName: string;
  101830. /** @hidden */
  101831. _reflectionMatrixName: string;
  101832. protected _reflectionColorName: string;
  101833. /**
  101834. * Gets or sets the texture associated with the node
  101835. */
  101836. texture: Nullable<BaseTexture>;
  101837. /**
  101838. * Create a new ReflectionTextureBaseBlock
  101839. * @param name defines the block name
  101840. */
  101841. constructor(name: string);
  101842. /**
  101843. * Gets the current class name
  101844. * @returns the class name
  101845. */
  101846. getClassName(): string;
  101847. /**
  101848. * Gets the world position input component
  101849. */
  101850. abstract get position(): NodeMaterialConnectionPoint;
  101851. /**
  101852. * Gets the world position input component
  101853. */
  101854. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101855. /**
  101856. * Gets the world normal input component
  101857. */
  101858. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101859. /**
  101860. * Gets the world input component
  101861. */
  101862. abstract get world(): NodeMaterialConnectionPoint;
  101863. /**
  101864. * Gets the camera (or eye) position component
  101865. */
  101866. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101867. /**
  101868. * Gets the view input component
  101869. */
  101870. abstract get view(): NodeMaterialConnectionPoint;
  101871. protected _getTexture(): Nullable<BaseTexture>;
  101872. autoConfigure(material: NodeMaterial): void;
  101873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101874. isReady(): boolean;
  101875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101876. /**
  101877. * Gets the code to inject in the vertex shader
  101878. * @param state current state of the node material building
  101879. * @returns the shader code
  101880. */
  101881. handleVertexSide(state: NodeMaterialBuildState): string;
  101882. /**
  101883. * Handles the inits for the fragment code path
  101884. * @param state node material build state
  101885. */
  101886. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101887. /**
  101888. * Generates the reflection coords code for the fragment code path
  101889. * @param worldNormalVarName name of the world normal variable
  101890. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101891. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101892. * @returns the shader code
  101893. */
  101894. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101895. /**
  101896. * Generates the reflection color code for the fragment code path
  101897. * @param lodVarName name of the lod variable
  101898. * @param swizzleLookupTexture swizzle to use for the final color variable
  101899. * @returns the shader code
  101900. */
  101901. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101902. /**
  101903. * Generates the code corresponding to the connected output points
  101904. * @param state node material build state
  101905. * @param varName name of the variable to output
  101906. * @returns the shader code
  101907. */
  101908. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101909. protected _buildBlock(state: NodeMaterialBuildState): this;
  101910. protected _dumpPropertiesCode(): string;
  101911. serialize(): any;
  101912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101913. }
  101914. }
  101915. declare module BABYLON {
  101916. /**
  101917. * Defines a connection point to be used for points with a custom object type
  101918. */
  101919. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101920. private _blockType;
  101921. private _blockName;
  101922. private _nameForCheking?;
  101923. /**
  101924. * Creates a new connection point
  101925. * @param name defines the connection point name
  101926. * @param ownerBlock defines the block hosting this connection point
  101927. * @param direction defines the direction of the connection point
  101928. */
  101929. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101930. /**
  101931. * Gets a number indicating if the current point can be connected to another point
  101932. * @param connectionPoint defines the other connection point
  101933. * @returns a number defining the compatibility state
  101934. */
  101935. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101936. /**
  101937. * Creates a block suitable to be used as an input for this input point.
  101938. * If null is returned, a block based on the point type will be created.
  101939. * @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
  101940. */
  101941. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101942. }
  101943. }
  101944. declare module BABYLON {
  101945. /**
  101946. * Enum defining the type of properties that can be edited in the property pages in the NME
  101947. */
  101948. export enum PropertyTypeForEdition {
  101949. /** property is a boolean */
  101950. Boolean = 0,
  101951. /** property is a float */
  101952. Float = 1,
  101953. /** property is a Vector2 */
  101954. Vector2 = 2,
  101955. /** property is a list of values */
  101956. List = 3
  101957. }
  101958. /**
  101959. * Interface that defines an option in a variable of type list
  101960. */
  101961. export interface IEditablePropertyListOption {
  101962. /** label of the option */
  101963. "label": string;
  101964. /** value of the option */
  101965. "value": number;
  101966. }
  101967. /**
  101968. * Interface that defines the options available for an editable property
  101969. */
  101970. export interface IEditablePropertyOption {
  101971. /** min value */
  101972. "min"?: number;
  101973. /** max value */
  101974. "max"?: number;
  101975. /** notifiers: indicates which actions to take when the property is changed */
  101976. "notifiers"?: {
  101977. /** the material should be rebuilt */
  101978. "rebuild"?: boolean;
  101979. /** the preview should be updated */
  101980. "update"?: boolean;
  101981. };
  101982. /** list of the options for a variable of type list */
  101983. "options"?: IEditablePropertyListOption[];
  101984. }
  101985. /**
  101986. * Interface that describes an editable property
  101987. */
  101988. export interface IPropertyDescriptionForEdition {
  101989. /** name of the property */
  101990. "propertyName": string;
  101991. /** display name of the property */
  101992. "displayName": string;
  101993. /** type of the property */
  101994. "type": PropertyTypeForEdition;
  101995. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101996. "groupName": string;
  101997. /** options for the property */
  101998. "options": IEditablePropertyOption;
  101999. }
  102000. /**
  102001. * Decorator that flags a property in a node material block as being editable
  102002. */
  102003. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102004. }
  102005. declare module BABYLON {
  102006. /**
  102007. * Block used to implement the refraction part of the sub surface module of the PBR material
  102008. */
  102009. export class RefractionBlock extends NodeMaterialBlock {
  102010. /** @hidden */
  102011. _define3DName: string;
  102012. /** @hidden */
  102013. _refractionMatrixName: string;
  102014. /** @hidden */
  102015. _defineLODRefractionAlpha: string;
  102016. /** @hidden */
  102017. _defineLinearSpecularRefraction: string;
  102018. /** @hidden */
  102019. _defineOppositeZ: string;
  102020. /** @hidden */
  102021. _cubeSamplerName: string;
  102022. /** @hidden */
  102023. _2DSamplerName: string;
  102024. /** @hidden */
  102025. _vRefractionMicrosurfaceInfosName: string;
  102026. /** @hidden */
  102027. _vRefractionInfosName: string;
  102028. private _scene;
  102029. /**
  102030. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102031. * Materials half opaque for instance using refraction could benefit from this control.
  102032. */
  102033. linkRefractionWithTransparency: boolean;
  102034. /**
  102035. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102036. */
  102037. invertRefractionY: boolean;
  102038. /**
  102039. * Gets or sets the texture associated with the node
  102040. */
  102041. texture: Nullable<BaseTexture>;
  102042. /**
  102043. * Create a new RefractionBlock
  102044. * @param name defines the block name
  102045. */
  102046. constructor(name: string);
  102047. /**
  102048. * Gets the current class name
  102049. * @returns the class name
  102050. */
  102051. getClassName(): string;
  102052. /**
  102053. * Gets the intensity input component
  102054. */
  102055. get intensity(): NodeMaterialConnectionPoint;
  102056. /**
  102057. * Gets the index of refraction input component
  102058. */
  102059. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102060. /**
  102061. * Gets the tint at distance input component
  102062. */
  102063. get tintAtDistance(): NodeMaterialConnectionPoint;
  102064. /**
  102065. * Gets the view input component
  102066. */
  102067. get view(): NodeMaterialConnectionPoint;
  102068. /**
  102069. * Gets the refraction object output component
  102070. */
  102071. get refraction(): NodeMaterialConnectionPoint;
  102072. /**
  102073. * Returns true if the block has a texture
  102074. */
  102075. get hasTexture(): boolean;
  102076. protected _getTexture(): Nullable<BaseTexture>;
  102077. autoConfigure(material: NodeMaterial): void;
  102078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102079. isReady(): boolean;
  102080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102081. /**
  102082. * Gets the main code of the block (fragment side)
  102083. * @param state current state of the node material building
  102084. * @returns the shader code
  102085. */
  102086. getCode(state: NodeMaterialBuildState): string;
  102087. protected _buildBlock(state: NodeMaterialBuildState): this;
  102088. protected _dumpPropertiesCode(): string;
  102089. serialize(): any;
  102090. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102091. }
  102092. }
  102093. declare module BABYLON {
  102094. /**
  102095. * Base block used as input for post process
  102096. */
  102097. export class CurrentScreenBlock extends NodeMaterialBlock {
  102098. private _samplerName;
  102099. private _linearDefineName;
  102100. private _gammaDefineName;
  102101. private _mainUVName;
  102102. private _tempTextureRead;
  102103. /**
  102104. * Gets or sets the texture associated with the node
  102105. */
  102106. texture: Nullable<BaseTexture>;
  102107. /**
  102108. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102109. */
  102110. convertToGammaSpace: boolean;
  102111. /**
  102112. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102113. */
  102114. convertToLinearSpace: boolean;
  102115. /**
  102116. * Create a new CurrentScreenBlock
  102117. * @param name defines the block name
  102118. */
  102119. constructor(name: string);
  102120. /**
  102121. * Gets the current class name
  102122. * @returns the class name
  102123. */
  102124. getClassName(): string;
  102125. /**
  102126. * Gets the uv input component
  102127. */
  102128. get uv(): NodeMaterialConnectionPoint;
  102129. /**
  102130. * Gets the rgba output component
  102131. */
  102132. get rgba(): NodeMaterialConnectionPoint;
  102133. /**
  102134. * Gets the rgb output component
  102135. */
  102136. get rgb(): NodeMaterialConnectionPoint;
  102137. /**
  102138. * Gets the r output component
  102139. */
  102140. get r(): NodeMaterialConnectionPoint;
  102141. /**
  102142. * Gets the g output component
  102143. */
  102144. get g(): NodeMaterialConnectionPoint;
  102145. /**
  102146. * Gets the b output component
  102147. */
  102148. get b(): NodeMaterialConnectionPoint;
  102149. /**
  102150. * Gets the a output component
  102151. */
  102152. get a(): NodeMaterialConnectionPoint;
  102153. /**
  102154. * Initialize the block and prepare the context for build
  102155. * @param state defines the state that will be used for the build
  102156. */
  102157. initialize(state: NodeMaterialBuildState): void;
  102158. get target(): NodeMaterialBlockTargets;
  102159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102160. isReady(): boolean;
  102161. private _injectVertexCode;
  102162. private _writeTextureRead;
  102163. private _writeOutput;
  102164. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102165. serialize(): any;
  102166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102167. }
  102168. }
  102169. declare module BABYLON {
  102170. /**
  102171. * Base block used for the particle texture
  102172. */
  102173. export class ParticleTextureBlock extends NodeMaterialBlock {
  102174. private _samplerName;
  102175. private _linearDefineName;
  102176. private _gammaDefineName;
  102177. private _tempTextureRead;
  102178. /**
  102179. * Gets or sets the texture associated with the node
  102180. */
  102181. texture: Nullable<BaseTexture>;
  102182. /**
  102183. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102184. */
  102185. convertToGammaSpace: boolean;
  102186. /**
  102187. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102188. */
  102189. convertToLinearSpace: boolean;
  102190. /**
  102191. * Create a new ParticleTextureBlock
  102192. * @param name defines the block name
  102193. */
  102194. constructor(name: string);
  102195. /**
  102196. * Gets the current class name
  102197. * @returns the class name
  102198. */
  102199. getClassName(): string;
  102200. /**
  102201. * Gets the uv input component
  102202. */
  102203. get uv(): NodeMaterialConnectionPoint;
  102204. /**
  102205. * Gets the rgba output component
  102206. */
  102207. get rgba(): NodeMaterialConnectionPoint;
  102208. /**
  102209. * Gets the rgb output component
  102210. */
  102211. get rgb(): NodeMaterialConnectionPoint;
  102212. /**
  102213. * Gets the r output component
  102214. */
  102215. get r(): NodeMaterialConnectionPoint;
  102216. /**
  102217. * Gets the g output component
  102218. */
  102219. get g(): NodeMaterialConnectionPoint;
  102220. /**
  102221. * Gets the b output component
  102222. */
  102223. get b(): NodeMaterialConnectionPoint;
  102224. /**
  102225. * Gets the a output component
  102226. */
  102227. get a(): NodeMaterialConnectionPoint;
  102228. /**
  102229. * Initialize the block and prepare the context for build
  102230. * @param state defines the state that will be used for the build
  102231. */
  102232. initialize(state: NodeMaterialBuildState): void;
  102233. autoConfigure(material: NodeMaterial): void;
  102234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102235. isReady(): boolean;
  102236. private _writeOutput;
  102237. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102238. serialize(): any;
  102239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102240. }
  102241. }
  102242. declare module BABYLON {
  102243. /**
  102244. * Class used to store shared data between 2 NodeMaterialBuildState
  102245. */
  102246. export class NodeMaterialBuildStateSharedData {
  102247. /**
  102248. * Gets the list of emitted varyings
  102249. */
  102250. temps: string[];
  102251. /**
  102252. * Gets the list of emitted varyings
  102253. */
  102254. varyings: string[];
  102255. /**
  102256. * Gets the varying declaration string
  102257. */
  102258. varyingDeclaration: string;
  102259. /**
  102260. * Input blocks
  102261. */
  102262. inputBlocks: InputBlock[];
  102263. /**
  102264. * Input blocks
  102265. */
  102266. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102267. /**
  102268. * Bindable blocks (Blocks that need to set data to the effect)
  102269. */
  102270. bindableBlocks: NodeMaterialBlock[];
  102271. /**
  102272. * List of blocks that can provide a compilation fallback
  102273. */
  102274. blocksWithFallbacks: NodeMaterialBlock[];
  102275. /**
  102276. * List of blocks that can provide a define update
  102277. */
  102278. blocksWithDefines: NodeMaterialBlock[];
  102279. /**
  102280. * List of blocks that can provide a repeatable content
  102281. */
  102282. repeatableContentBlocks: NodeMaterialBlock[];
  102283. /**
  102284. * List of blocks that can provide a dynamic list of uniforms
  102285. */
  102286. dynamicUniformBlocks: NodeMaterialBlock[];
  102287. /**
  102288. * List of blocks that can block the isReady function for the material
  102289. */
  102290. blockingBlocks: NodeMaterialBlock[];
  102291. /**
  102292. * Gets the list of animated inputs
  102293. */
  102294. animatedInputs: InputBlock[];
  102295. /**
  102296. * Build Id used to avoid multiple recompilations
  102297. */
  102298. buildId: number;
  102299. /** List of emitted variables */
  102300. variableNames: {
  102301. [key: string]: number;
  102302. };
  102303. /** List of emitted defines */
  102304. defineNames: {
  102305. [key: string]: number;
  102306. };
  102307. /** Should emit comments? */
  102308. emitComments: boolean;
  102309. /** Emit build activity */
  102310. verbose: boolean;
  102311. /** Gets or sets the hosting scene */
  102312. scene: Scene;
  102313. /**
  102314. * Gets the compilation hints emitted at compilation time
  102315. */
  102316. hints: {
  102317. needWorldViewMatrix: boolean;
  102318. needWorldViewProjectionMatrix: boolean;
  102319. needAlphaBlending: boolean;
  102320. needAlphaTesting: boolean;
  102321. };
  102322. /**
  102323. * List of compilation checks
  102324. */
  102325. checks: {
  102326. emitVertex: boolean;
  102327. emitFragment: boolean;
  102328. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102329. };
  102330. /**
  102331. * Is vertex program allowed to be empty?
  102332. */
  102333. allowEmptyVertexProgram: boolean;
  102334. /** Creates a new shared data */
  102335. constructor();
  102336. /**
  102337. * Emits console errors and exceptions if there is a failing check
  102338. */
  102339. emitErrors(): void;
  102340. }
  102341. }
  102342. declare module BABYLON {
  102343. /**
  102344. * Class used to store node based material build state
  102345. */
  102346. export class NodeMaterialBuildState {
  102347. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102348. supportUniformBuffers: boolean;
  102349. /**
  102350. * Gets the list of emitted attributes
  102351. */
  102352. attributes: string[];
  102353. /**
  102354. * Gets the list of emitted uniforms
  102355. */
  102356. uniforms: string[];
  102357. /**
  102358. * Gets the list of emitted constants
  102359. */
  102360. constants: string[];
  102361. /**
  102362. * Gets the list of emitted samplers
  102363. */
  102364. samplers: string[];
  102365. /**
  102366. * Gets the list of emitted functions
  102367. */
  102368. functions: {
  102369. [key: string]: string;
  102370. };
  102371. /**
  102372. * Gets the list of emitted extensions
  102373. */
  102374. extensions: {
  102375. [key: string]: string;
  102376. };
  102377. /**
  102378. * Gets the target of the compilation state
  102379. */
  102380. target: NodeMaterialBlockTargets;
  102381. /**
  102382. * Gets the list of emitted counters
  102383. */
  102384. counters: {
  102385. [key: string]: number;
  102386. };
  102387. /**
  102388. * Shared data between multiple NodeMaterialBuildState instances
  102389. */
  102390. sharedData: NodeMaterialBuildStateSharedData;
  102391. /** @hidden */
  102392. _vertexState: NodeMaterialBuildState;
  102393. /** @hidden */
  102394. _attributeDeclaration: string;
  102395. /** @hidden */
  102396. _uniformDeclaration: string;
  102397. /** @hidden */
  102398. _constantDeclaration: string;
  102399. /** @hidden */
  102400. _samplerDeclaration: string;
  102401. /** @hidden */
  102402. _varyingTransfer: string;
  102403. /** @hidden */
  102404. _injectAtEnd: string;
  102405. private _repeatableContentAnchorIndex;
  102406. /** @hidden */
  102407. _builtCompilationString: string;
  102408. /**
  102409. * Gets the emitted compilation strings
  102410. */
  102411. compilationString: string;
  102412. /**
  102413. * Finalize the compilation strings
  102414. * @param state defines the current compilation state
  102415. */
  102416. finalize(state: NodeMaterialBuildState): void;
  102417. /** @hidden */
  102418. get _repeatableContentAnchor(): string;
  102419. /** @hidden */
  102420. _getFreeVariableName(prefix: string): string;
  102421. /** @hidden */
  102422. _getFreeDefineName(prefix: string): string;
  102423. /** @hidden */
  102424. _excludeVariableName(name: string): void;
  102425. /** @hidden */
  102426. _emit2DSampler(name: string): void;
  102427. /** @hidden */
  102428. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102429. /** @hidden */
  102430. _emitExtension(name: string, extension: string, define?: string): void;
  102431. /** @hidden */
  102432. _emitFunction(name: string, code: string, comments: string): void;
  102433. /** @hidden */
  102434. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102435. replaceStrings?: {
  102436. search: RegExp;
  102437. replace: string;
  102438. }[];
  102439. repeatKey?: string;
  102440. }): string;
  102441. /** @hidden */
  102442. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102443. repeatKey?: string;
  102444. removeAttributes?: boolean;
  102445. removeUniforms?: boolean;
  102446. removeVaryings?: boolean;
  102447. removeIfDef?: boolean;
  102448. replaceStrings?: {
  102449. search: RegExp;
  102450. replace: string;
  102451. }[];
  102452. }, storeKey?: string): void;
  102453. /** @hidden */
  102454. _registerTempVariable(name: string): boolean;
  102455. /** @hidden */
  102456. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102457. /** @hidden */
  102458. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102459. /** @hidden */
  102460. _emitFloat(value: number): string;
  102461. }
  102462. }
  102463. declare module BABYLON {
  102464. /**
  102465. * Helper class used to generate session unique ID
  102466. */
  102467. export class UniqueIdGenerator {
  102468. private static _UniqueIdCounter;
  102469. /**
  102470. * Gets an unique (relatively to the current scene) Id
  102471. */
  102472. static get UniqueId(): number;
  102473. }
  102474. }
  102475. declare module BABYLON {
  102476. /**
  102477. * Defines a block that can be used inside a node based material
  102478. */
  102479. export class NodeMaterialBlock {
  102480. private _buildId;
  102481. private _buildTarget;
  102482. private _target;
  102483. private _isFinalMerger;
  102484. private _isInput;
  102485. private _name;
  102486. protected _isUnique: boolean;
  102487. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102488. inputsAreExclusive: boolean;
  102489. /** @hidden */
  102490. _codeVariableName: string;
  102491. /** @hidden */
  102492. _inputs: NodeMaterialConnectionPoint[];
  102493. /** @hidden */
  102494. _outputs: NodeMaterialConnectionPoint[];
  102495. /** @hidden */
  102496. _preparationId: number;
  102497. /**
  102498. * Gets the name of the block
  102499. */
  102500. get name(): string;
  102501. /**
  102502. * Sets the name of the block. Will check if the name is valid.
  102503. */
  102504. set name(newName: string);
  102505. /**
  102506. * Gets or sets the unique id of the node
  102507. */
  102508. uniqueId: number;
  102509. /**
  102510. * Gets or sets the comments associated with this block
  102511. */
  102512. comments: string;
  102513. /**
  102514. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102515. */
  102516. get isUnique(): boolean;
  102517. /**
  102518. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102519. */
  102520. get isFinalMerger(): boolean;
  102521. /**
  102522. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102523. */
  102524. get isInput(): boolean;
  102525. /**
  102526. * Gets or sets the build Id
  102527. */
  102528. get buildId(): number;
  102529. set buildId(value: number);
  102530. /**
  102531. * Gets or sets the target of the block
  102532. */
  102533. get target(): NodeMaterialBlockTargets;
  102534. set target(value: NodeMaterialBlockTargets);
  102535. /**
  102536. * Gets the list of input points
  102537. */
  102538. get inputs(): NodeMaterialConnectionPoint[];
  102539. /** Gets the list of output points */
  102540. get outputs(): NodeMaterialConnectionPoint[];
  102541. /**
  102542. * Find an input by its name
  102543. * @param name defines the name of the input to look for
  102544. * @returns the input or null if not found
  102545. */
  102546. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102547. /**
  102548. * Find an output by its name
  102549. * @param name defines the name of the outputto look for
  102550. * @returns the output or null if not found
  102551. */
  102552. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102553. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102554. visibleInInspector: boolean;
  102555. /**
  102556. * Creates a new NodeMaterialBlock
  102557. * @param name defines the block name
  102558. * @param target defines the target of that block (Vertex by default)
  102559. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102560. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102561. */
  102562. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102563. /**
  102564. * Initialize the block and prepare the context for build
  102565. * @param state defines the state that will be used for the build
  102566. */
  102567. initialize(state: NodeMaterialBuildState): void;
  102568. /**
  102569. * Bind data to effect. Will only be called for blocks with isBindable === true
  102570. * @param effect defines the effect to bind data to
  102571. * @param nodeMaterial defines the hosting NodeMaterial
  102572. * @param mesh defines the mesh that will be rendered
  102573. * @param subMesh defines the submesh that will be rendered
  102574. */
  102575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102576. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102577. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102578. protected _writeFloat(value: number): string;
  102579. /**
  102580. * Gets the current class name e.g. "NodeMaterialBlock"
  102581. * @returns the class name
  102582. */
  102583. getClassName(): string;
  102584. /**
  102585. * Register a new input. Must be called inside a block constructor
  102586. * @param name defines the connection point name
  102587. * @param type defines the connection point type
  102588. * @param isOptional defines a boolean indicating that this input can be omitted
  102589. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102590. * @param point an already created connection point. If not provided, create a new one
  102591. * @returns the current block
  102592. */
  102593. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102594. /**
  102595. * Register a new output. Must be called inside a block constructor
  102596. * @param name defines the connection point name
  102597. * @param type defines the connection point type
  102598. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102599. * @param point an already created connection point. If not provided, create a new one
  102600. * @returns the current block
  102601. */
  102602. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102603. /**
  102604. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102605. * @param forOutput defines an optional connection point to check compatibility with
  102606. * @returns the first available input or null
  102607. */
  102608. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102609. /**
  102610. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102611. * @param forBlock defines an optional block to check compatibility with
  102612. * @returns the first available input or null
  102613. */
  102614. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102615. /**
  102616. * Gets the sibling of the given output
  102617. * @param current defines the current output
  102618. * @returns the next output in the list or null
  102619. */
  102620. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102621. /**
  102622. * Connect current block with another block
  102623. * @param other defines the block to connect with
  102624. * @param options define the various options to help pick the right connections
  102625. * @returns the current block
  102626. */
  102627. connectTo(other: NodeMaterialBlock, options?: {
  102628. input?: string;
  102629. output?: string;
  102630. outputSwizzle?: string;
  102631. }): this | undefined;
  102632. protected _buildBlock(state: NodeMaterialBuildState): void;
  102633. /**
  102634. * Add uniforms, samplers and uniform buffers at compilation time
  102635. * @param state defines the state to update
  102636. * @param nodeMaterial defines the node material requesting the update
  102637. * @param defines defines the material defines to update
  102638. * @param uniformBuffers defines the list of uniform buffer names
  102639. */
  102640. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102641. /**
  102642. * Add potential fallbacks if shader compilation fails
  102643. * @param mesh defines the mesh to be rendered
  102644. * @param fallbacks defines the current prioritized list of fallbacks
  102645. */
  102646. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102647. /**
  102648. * Initialize defines for shader compilation
  102649. * @param mesh defines the mesh to be rendered
  102650. * @param nodeMaterial defines the node material requesting the update
  102651. * @param defines defines the material defines to update
  102652. * @param useInstances specifies that instances should be used
  102653. */
  102654. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102655. /**
  102656. * Update defines for shader compilation
  102657. * @param mesh defines the mesh to be rendered
  102658. * @param nodeMaterial defines the node material requesting the update
  102659. * @param defines defines the material defines to update
  102660. * @param useInstances specifies that instances should be used
  102661. * @param subMesh defines which submesh to render
  102662. */
  102663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102664. /**
  102665. * Lets the block try to connect some inputs automatically
  102666. * @param material defines the hosting NodeMaterial
  102667. */
  102668. autoConfigure(material: NodeMaterial): void;
  102669. /**
  102670. * Function called when a block is declared as repeatable content generator
  102671. * @param vertexShaderState defines the current compilation state for the vertex shader
  102672. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102673. * @param mesh defines the mesh to be rendered
  102674. * @param defines defines the material defines to update
  102675. */
  102676. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102677. /**
  102678. * Checks if the block is ready
  102679. * @param mesh defines the mesh to be rendered
  102680. * @param nodeMaterial defines the node material requesting the update
  102681. * @param defines defines the material defines to update
  102682. * @param useInstances specifies that instances should be used
  102683. * @returns true if the block is ready
  102684. */
  102685. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102686. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102687. private _processBuild;
  102688. /**
  102689. * Validates the new name for the block node.
  102690. * @param newName the new name to be given to the node.
  102691. * @returns false if the name is a reserve word, else true.
  102692. */
  102693. validateBlockName(newName: string): boolean;
  102694. /**
  102695. * Compile the current node and generate the shader code
  102696. * @param state defines the current compilation state (uniforms, samplers, current string)
  102697. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102698. * @returns true if already built
  102699. */
  102700. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102701. protected _inputRename(name: string): string;
  102702. protected _outputRename(name: string): string;
  102703. protected _dumpPropertiesCode(): string;
  102704. /** @hidden */
  102705. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102706. /** @hidden */
  102707. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102708. /**
  102709. * Clone the current block to a new identical block
  102710. * @param scene defines the hosting scene
  102711. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102712. * @returns a copy of the current block
  102713. */
  102714. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102715. /**
  102716. * Serializes this block in a JSON representation
  102717. * @returns the serialized block object
  102718. */
  102719. serialize(): any;
  102720. /** @hidden */
  102721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102722. private _deserializePortDisplayNamesAndExposedOnFrame;
  102723. /**
  102724. * Release resources
  102725. */
  102726. dispose(): void;
  102727. }
  102728. }
  102729. declare module BABYLON {
  102730. /**
  102731. * Base class of materials working in push mode in babylon JS
  102732. * @hidden
  102733. */
  102734. export class PushMaterial extends Material {
  102735. protected _activeEffect: Effect;
  102736. protected _normalMatrix: Matrix;
  102737. constructor(name: string, scene: Scene);
  102738. getEffect(): Effect;
  102739. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102740. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102741. /**
  102742. * Binds the given world matrix to the active effect
  102743. *
  102744. * @param world the matrix to bind
  102745. */
  102746. bindOnlyWorldMatrix(world: Matrix): void;
  102747. /**
  102748. * Binds the given normal matrix to the active effect
  102749. *
  102750. * @param normalMatrix the matrix to bind
  102751. */
  102752. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102753. bind(world: Matrix, mesh?: Mesh): void;
  102754. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102755. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102756. }
  102757. }
  102758. declare module BABYLON {
  102759. /**
  102760. * Root class for all node material optimizers
  102761. */
  102762. export class NodeMaterialOptimizer {
  102763. /**
  102764. * Function used to optimize a NodeMaterial graph
  102765. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102766. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102767. */
  102768. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102769. }
  102770. }
  102771. declare module BABYLON {
  102772. /**
  102773. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102774. */
  102775. export class TransformBlock extends NodeMaterialBlock {
  102776. /**
  102777. * Defines the value to use to complement W value to transform it to a Vector4
  102778. */
  102779. complementW: number;
  102780. /**
  102781. * Defines the value to use to complement z value to transform it to a Vector4
  102782. */
  102783. complementZ: number;
  102784. /**
  102785. * Creates a new TransformBlock
  102786. * @param name defines the block name
  102787. */
  102788. constructor(name: string);
  102789. /**
  102790. * Gets the current class name
  102791. * @returns the class name
  102792. */
  102793. getClassName(): string;
  102794. /**
  102795. * Gets the vector input
  102796. */
  102797. get vector(): NodeMaterialConnectionPoint;
  102798. /**
  102799. * Gets the output component
  102800. */
  102801. get output(): NodeMaterialConnectionPoint;
  102802. /**
  102803. * Gets the xyz output component
  102804. */
  102805. get xyz(): NodeMaterialConnectionPoint;
  102806. /**
  102807. * Gets the matrix transform input
  102808. */
  102809. get transform(): NodeMaterialConnectionPoint;
  102810. protected _buildBlock(state: NodeMaterialBuildState): this;
  102811. /**
  102812. * Update defines for shader compilation
  102813. * @param mesh defines the mesh to be rendered
  102814. * @param nodeMaterial defines the node material requesting the update
  102815. * @param defines defines the material defines to update
  102816. * @param useInstances specifies that instances should be used
  102817. * @param subMesh defines which submesh to render
  102818. */
  102819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102820. serialize(): any;
  102821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102822. protected _dumpPropertiesCode(): string;
  102823. }
  102824. }
  102825. declare module BABYLON {
  102826. /**
  102827. * Block used to output the vertex position
  102828. */
  102829. export class VertexOutputBlock extends NodeMaterialBlock {
  102830. /**
  102831. * Creates a new VertexOutputBlock
  102832. * @param name defines the block name
  102833. */
  102834. constructor(name: string);
  102835. /**
  102836. * Gets the current class name
  102837. * @returns the class name
  102838. */
  102839. getClassName(): string;
  102840. /**
  102841. * Gets the vector input component
  102842. */
  102843. get vector(): NodeMaterialConnectionPoint;
  102844. protected _buildBlock(state: NodeMaterialBuildState): this;
  102845. }
  102846. }
  102847. declare module BABYLON {
  102848. /**
  102849. * Block used to output the final color
  102850. */
  102851. export class FragmentOutputBlock extends NodeMaterialBlock {
  102852. /**
  102853. * Create a new FragmentOutputBlock
  102854. * @param name defines the block name
  102855. */
  102856. constructor(name: string);
  102857. /**
  102858. * Gets the current class name
  102859. * @returns the class name
  102860. */
  102861. getClassName(): string;
  102862. /**
  102863. * Gets the rgba input component
  102864. */
  102865. get rgba(): NodeMaterialConnectionPoint;
  102866. /**
  102867. * Gets the rgb input component
  102868. */
  102869. get rgb(): NodeMaterialConnectionPoint;
  102870. /**
  102871. * Gets the a input component
  102872. */
  102873. get a(): NodeMaterialConnectionPoint;
  102874. protected _buildBlock(state: NodeMaterialBuildState): this;
  102875. }
  102876. }
  102877. declare module BABYLON {
  102878. /**
  102879. * Block used for the particle ramp gradient section
  102880. */
  102881. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102882. /**
  102883. * Create a new ParticleRampGradientBlock
  102884. * @param name defines the block name
  102885. */
  102886. constructor(name: string);
  102887. /**
  102888. * Gets the current class name
  102889. * @returns the class name
  102890. */
  102891. getClassName(): string;
  102892. /**
  102893. * Gets the color input component
  102894. */
  102895. get color(): NodeMaterialConnectionPoint;
  102896. /**
  102897. * Gets the rampColor output component
  102898. */
  102899. get rampColor(): NodeMaterialConnectionPoint;
  102900. /**
  102901. * Initialize the block and prepare the context for build
  102902. * @param state defines the state that will be used for the build
  102903. */
  102904. initialize(state: NodeMaterialBuildState): void;
  102905. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102906. }
  102907. }
  102908. declare module BABYLON {
  102909. /**
  102910. * Block used for the particle blend multiply section
  102911. */
  102912. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102913. /**
  102914. * Create a new ParticleBlendMultiplyBlock
  102915. * @param name defines the block name
  102916. */
  102917. constructor(name: string);
  102918. /**
  102919. * Gets the current class name
  102920. * @returns the class name
  102921. */
  102922. getClassName(): string;
  102923. /**
  102924. * Gets the color input component
  102925. */
  102926. get color(): NodeMaterialConnectionPoint;
  102927. /**
  102928. * Gets the alphaTexture input component
  102929. */
  102930. get alphaTexture(): NodeMaterialConnectionPoint;
  102931. /**
  102932. * Gets the alphaColor input component
  102933. */
  102934. get alphaColor(): NodeMaterialConnectionPoint;
  102935. /**
  102936. * Gets the blendColor output component
  102937. */
  102938. get blendColor(): NodeMaterialConnectionPoint;
  102939. /**
  102940. * Initialize the block and prepare the context for build
  102941. * @param state defines the state that will be used for the build
  102942. */
  102943. initialize(state: NodeMaterialBuildState): void;
  102944. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102945. }
  102946. }
  102947. declare module BABYLON {
  102948. /**
  102949. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102950. */
  102951. export class VectorMergerBlock extends NodeMaterialBlock {
  102952. /**
  102953. * Create a new VectorMergerBlock
  102954. * @param name defines the block name
  102955. */
  102956. constructor(name: string);
  102957. /**
  102958. * Gets the current class name
  102959. * @returns the class name
  102960. */
  102961. getClassName(): string;
  102962. /**
  102963. * Gets the xyz component (input)
  102964. */
  102965. get xyzIn(): NodeMaterialConnectionPoint;
  102966. /**
  102967. * Gets the xy component (input)
  102968. */
  102969. get xyIn(): NodeMaterialConnectionPoint;
  102970. /**
  102971. * Gets the x component (input)
  102972. */
  102973. get x(): NodeMaterialConnectionPoint;
  102974. /**
  102975. * Gets the y component (input)
  102976. */
  102977. get y(): NodeMaterialConnectionPoint;
  102978. /**
  102979. * Gets the z component (input)
  102980. */
  102981. get z(): NodeMaterialConnectionPoint;
  102982. /**
  102983. * Gets the w component (input)
  102984. */
  102985. get w(): NodeMaterialConnectionPoint;
  102986. /**
  102987. * Gets the xyzw component (output)
  102988. */
  102989. get xyzw(): NodeMaterialConnectionPoint;
  102990. /**
  102991. * Gets the xyz component (output)
  102992. */
  102993. get xyzOut(): NodeMaterialConnectionPoint;
  102994. /**
  102995. * Gets the xy component (output)
  102996. */
  102997. get xyOut(): NodeMaterialConnectionPoint;
  102998. /**
  102999. * Gets the xy component (output)
  103000. * @deprecated Please use xyOut instead.
  103001. */
  103002. get xy(): NodeMaterialConnectionPoint;
  103003. /**
  103004. * Gets the xyz component (output)
  103005. * @deprecated Please use xyzOut instead.
  103006. */
  103007. get xyz(): NodeMaterialConnectionPoint;
  103008. protected _buildBlock(state: NodeMaterialBuildState): this;
  103009. }
  103010. }
  103011. declare module BABYLON {
  103012. /**
  103013. * Block used to remap a float from a range to a new one
  103014. */
  103015. export class RemapBlock extends NodeMaterialBlock {
  103016. /**
  103017. * Gets or sets the source range
  103018. */
  103019. sourceRange: Vector2;
  103020. /**
  103021. * Gets or sets the target range
  103022. */
  103023. targetRange: Vector2;
  103024. /**
  103025. * Creates a new RemapBlock
  103026. * @param name defines the block name
  103027. */
  103028. constructor(name: string);
  103029. /**
  103030. * Gets the current class name
  103031. * @returns the class name
  103032. */
  103033. getClassName(): string;
  103034. /**
  103035. * Gets the input component
  103036. */
  103037. get input(): NodeMaterialConnectionPoint;
  103038. /**
  103039. * Gets the source min input component
  103040. */
  103041. get sourceMin(): NodeMaterialConnectionPoint;
  103042. /**
  103043. * Gets the source max input component
  103044. */
  103045. get sourceMax(): NodeMaterialConnectionPoint;
  103046. /**
  103047. * Gets the target min input component
  103048. */
  103049. get targetMin(): NodeMaterialConnectionPoint;
  103050. /**
  103051. * Gets the target max input component
  103052. */
  103053. get targetMax(): NodeMaterialConnectionPoint;
  103054. /**
  103055. * Gets the output component
  103056. */
  103057. get output(): NodeMaterialConnectionPoint;
  103058. protected _buildBlock(state: NodeMaterialBuildState): this;
  103059. protected _dumpPropertiesCode(): string;
  103060. serialize(): any;
  103061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103062. }
  103063. }
  103064. declare module BABYLON {
  103065. /**
  103066. * Block used to multiply 2 values
  103067. */
  103068. export class MultiplyBlock extends NodeMaterialBlock {
  103069. /**
  103070. * Creates a new MultiplyBlock
  103071. * @param name defines the block name
  103072. */
  103073. constructor(name: string);
  103074. /**
  103075. * Gets the current class name
  103076. * @returns the class name
  103077. */
  103078. getClassName(): string;
  103079. /**
  103080. * Gets the left operand input component
  103081. */
  103082. get left(): NodeMaterialConnectionPoint;
  103083. /**
  103084. * Gets the right operand input component
  103085. */
  103086. get right(): NodeMaterialConnectionPoint;
  103087. /**
  103088. * Gets the output component
  103089. */
  103090. get output(): NodeMaterialConnectionPoint;
  103091. protected _buildBlock(state: NodeMaterialBuildState): this;
  103092. }
  103093. }
  103094. declare module BABYLON {
  103095. /**
  103096. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103097. */
  103098. export class ColorSplitterBlock extends NodeMaterialBlock {
  103099. /**
  103100. * Create a new ColorSplitterBlock
  103101. * @param name defines the block name
  103102. */
  103103. constructor(name: string);
  103104. /**
  103105. * Gets the current class name
  103106. * @returns the class name
  103107. */
  103108. getClassName(): string;
  103109. /**
  103110. * Gets the rgba component (input)
  103111. */
  103112. get rgba(): NodeMaterialConnectionPoint;
  103113. /**
  103114. * Gets the rgb component (input)
  103115. */
  103116. get rgbIn(): NodeMaterialConnectionPoint;
  103117. /**
  103118. * Gets the rgb component (output)
  103119. */
  103120. get rgbOut(): NodeMaterialConnectionPoint;
  103121. /**
  103122. * Gets the r component (output)
  103123. */
  103124. get r(): NodeMaterialConnectionPoint;
  103125. /**
  103126. * Gets the g component (output)
  103127. */
  103128. get g(): NodeMaterialConnectionPoint;
  103129. /**
  103130. * Gets the b component (output)
  103131. */
  103132. get b(): NodeMaterialConnectionPoint;
  103133. /**
  103134. * Gets the a component (output)
  103135. */
  103136. get a(): NodeMaterialConnectionPoint;
  103137. protected _inputRename(name: string): string;
  103138. protected _outputRename(name: string): string;
  103139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /**
  103144. * Operations supported by the Trigonometry block
  103145. */
  103146. export enum TrigonometryBlockOperations {
  103147. /** Cos */
  103148. Cos = 0,
  103149. /** Sin */
  103150. Sin = 1,
  103151. /** Abs */
  103152. Abs = 2,
  103153. /** Exp */
  103154. Exp = 3,
  103155. /** Exp2 */
  103156. Exp2 = 4,
  103157. /** Round */
  103158. Round = 5,
  103159. /** Floor */
  103160. Floor = 6,
  103161. /** Ceiling */
  103162. Ceiling = 7,
  103163. /** Square root */
  103164. Sqrt = 8,
  103165. /** Log */
  103166. Log = 9,
  103167. /** Tangent */
  103168. Tan = 10,
  103169. /** Arc tangent */
  103170. ArcTan = 11,
  103171. /** Arc cosinus */
  103172. ArcCos = 12,
  103173. /** Arc sinus */
  103174. ArcSin = 13,
  103175. /** Fraction */
  103176. Fract = 14,
  103177. /** Sign */
  103178. Sign = 15,
  103179. /** To radians (from degrees) */
  103180. Radians = 16,
  103181. /** To degrees (from radians) */
  103182. Degrees = 17
  103183. }
  103184. /**
  103185. * Block used to apply trigonometry operation to floats
  103186. */
  103187. export class TrigonometryBlock extends NodeMaterialBlock {
  103188. /**
  103189. * Gets or sets the operation applied by the block
  103190. */
  103191. operation: TrigonometryBlockOperations;
  103192. /**
  103193. * Creates a new TrigonometryBlock
  103194. * @param name defines the block name
  103195. */
  103196. constructor(name: string);
  103197. /**
  103198. * Gets the current class name
  103199. * @returns the class name
  103200. */
  103201. getClassName(): string;
  103202. /**
  103203. * Gets the input component
  103204. */
  103205. get input(): NodeMaterialConnectionPoint;
  103206. /**
  103207. * Gets the output component
  103208. */
  103209. get output(): NodeMaterialConnectionPoint;
  103210. protected _buildBlock(state: NodeMaterialBuildState): this;
  103211. serialize(): any;
  103212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103213. protected _dumpPropertiesCode(): string;
  103214. }
  103215. }
  103216. declare module BABYLON {
  103217. /**
  103218. * Interface used to configure the node material editor
  103219. */
  103220. export interface INodeMaterialEditorOptions {
  103221. /** Define the URl to load node editor script */
  103222. editorURL?: string;
  103223. }
  103224. /** @hidden */
  103225. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103226. NORMAL: boolean;
  103227. TANGENT: boolean;
  103228. UV1: boolean;
  103229. /** BONES */
  103230. NUM_BONE_INFLUENCERS: number;
  103231. BonesPerMesh: number;
  103232. BONETEXTURE: boolean;
  103233. /** MORPH TARGETS */
  103234. MORPHTARGETS: boolean;
  103235. MORPHTARGETS_NORMAL: boolean;
  103236. MORPHTARGETS_TANGENT: boolean;
  103237. MORPHTARGETS_UV: boolean;
  103238. NUM_MORPH_INFLUENCERS: number;
  103239. /** IMAGE PROCESSING */
  103240. IMAGEPROCESSING: boolean;
  103241. VIGNETTE: boolean;
  103242. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103243. VIGNETTEBLENDMODEOPAQUE: boolean;
  103244. TONEMAPPING: boolean;
  103245. TONEMAPPING_ACES: boolean;
  103246. CONTRAST: boolean;
  103247. EXPOSURE: boolean;
  103248. COLORCURVES: boolean;
  103249. COLORGRADING: boolean;
  103250. COLORGRADING3D: boolean;
  103251. SAMPLER3DGREENDEPTH: boolean;
  103252. SAMPLER3DBGRMAP: boolean;
  103253. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103254. /** MISC. */
  103255. BUMPDIRECTUV: number;
  103256. constructor();
  103257. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103258. }
  103259. /**
  103260. * Class used to configure NodeMaterial
  103261. */
  103262. export interface INodeMaterialOptions {
  103263. /**
  103264. * Defines if blocks should emit comments
  103265. */
  103266. emitComments: boolean;
  103267. }
  103268. /**
  103269. * Class used to create a node based material built by assembling shader blocks
  103270. */
  103271. export class NodeMaterial extends PushMaterial {
  103272. private static _BuildIdGenerator;
  103273. private _options;
  103274. private _vertexCompilationState;
  103275. private _fragmentCompilationState;
  103276. private _sharedData;
  103277. private _buildId;
  103278. private _buildWasSuccessful;
  103279. private _cachedWorldViewMatrix;
  103280. private _cachedWorldViewProjectionMatrix;
  103281. private _optimizers;
  103282. private _animationFrame;
  103283. /** Define the Url to load node editor script */
  103284. static EditorURL: string;
  103285. /** Define the Url to load snippets */
  103286. static SnippetUrl: string;
  103287. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103288. static IgnoreTexturesAtLoadTime: boolean;
  103289. private BJSNODEMATERIALEDITOR;
  103290. /** Get the inspector from bundle or global */
  103291. private _getGlobalNodeMaterialEditor;
  103292. /**
  103293. * Snippet ID if the material was created from the snippet server
  103294. */
  103295. snippetId: string;
  103296. /**
  103297. * Gets or sets data used by visual editor
  103298. * @see https://nme.babylonjs.com
  103299. */
  103300. editorData: any;
  103301. /**
  103302. * 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)
  103303. */
  103304. ignoreAlpha: boolean;
  103305. /**
  103306. * Defines the maximum number of lights that can be used in the material
  103307. */
  103308. maxSimultaneousLights: number;
  103309. /**
  103310. * Observable raised when the material is built
  103311. */
  103312. onBuildObservable: Observable<NodeMaterial>;
  103313. /**
  103314. * Gets or sets the root nodes of the material vertex shader
  103315. */
  103316. _vertexOutputNodes: NodeMaterialBlock[];
  103317. /**
  103318. * Gets or sets the root nodes of the material fragment (pixel) shader
  103319. */
  103320. _fragmentOutputNodes: NodeMaterialBlock[];
  103321. /** Gets or sets options to control the node material overall behavior */
  103322. get options(): INodeMaterialOptions;
  103323. set options(options: INodeMaterialOptions);
  103324. /**
  103325. * Default configuration related to image processing available in the standard Material.
  103326. */
  103327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103328. /**
  103329. * Gets the image processing configuration used either in this material.
  103330. */
  103331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103332. /**
  103333. * Sets the Default image processing configuration used either in the this material.
  103334. *
  103335. * If sets to null, the scene one is in use.
  103336. */
  103337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103338. /**
  103339. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103340. */
  103341. attachedBlocks: NodeMaterialBlock[];
  103342. /**
  103343. * Specifies the mode of the node material
  103344. * @hidden
  103345. */
  103346. _mode: NodeMaterialModes;
  103347. /**
  103348. * Gets the mode property
  103349. */
  103350. get mode(): NodeMaterialModes;
  103351. /**
  103352. * Create a new node based material
  103353. * @param name defines the material name
  103354. * @param scene defines the hosting scene
  103355. * @param options defines creation option
  103356. */
  103357. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103358. /**
  103359. * Gets the current class name of the material e.g. "NodeMaterial"
  103360. * @returns the class name
  103361. */
  103362. getClassName(): string;
  103363. /**
  103364. * Keep track of the image processing observer to allow dispose and replace.
  103365. */
  103366. private _imageProcessingObserver;
  103367. /**
  103368. * Attaches a new image processing configuration to the Standard Material.
  103369. * @param configuration
  103370. */
  103371. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103372. /**
  103373. * Get a block by its name
  103374. * @param name defines the name of the block to retrieve
  103375. * @returns the required block or null if not found
  103376. */
  103377. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103378. /**
  103379. * Get a block by its name
  103380. * @param predicate defines the predicate used to find the good candidate
  103381. * @returns the required block or null if not found
  103382. */
  103383. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103384. /**
  103385. * Get an input block by its name
  103386. * @param predicate defines the predicate used to find the good candidate
  103387. * @returns the required input block or null if not found
  103388. */
  103389. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103390. /**
  103391. * Gets the list of input blocks attached to this material
  103392. * @returns an array of InputBlocks
  103393. */
  103394. getInputBlocks(): InputBlock[];
  103395. /**
  103396. * Adds a new optimizer to the list of optimizers
  103397. * @param optimizer defines the optimizers to add
  103398. * @returns the current material
  103399. */
  103400. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103401. /**
  103402. * Remove an optimizer from the list of optimizers
  103403. * @param optimizer defines the optimizers to remove
  103404. * @returns the current material
  103405. */
  103406. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103407. /**
  103408. * Add a new block to the list of output nodes
  103409. * @param node defines the node to add
  103410. * @returns the current material
  103411. */
  103412. addOutputNode(node: NodeMaterialBlock): this;
  103413. /**
  103414. * Remove a block from the list of root nodes
  103415. * @param node defines the node to remove
  103416. * @returns the current material
  103417. */
  103418. removeOutputNode(node: NodeMaterialBlock): this;
  103419. private _addVertexOutputNode;
  103420. private _removeVertexOutputNode;
  103421. private _addFragmentOutputNode;
  103422. private _removeFragmentOutputNode;
  103423. /**
  103424. * Specifies if the material will require alpha blending
  103425. * @returns a boolean specifying if alpha blending is needed
  103426. */
  103427. needAlphaBlending(): boolean;
  103428. /**
  103429. * Specifies if this material should be rendered in alpha test mode
  103430. * @returns a boolean specifying if an alpha test is needed.
  103431. */
  103432. needAlphaTesting(): boolean;
  103433. private _initializeBlock;
  103434. private _resetDualBlocks;
  103435. /**
  103436. * Remove a block from the current node material
  103437. * @param block defines the block to remove
  103438. */
  103439. removeBlock(block: NodeMaterialBlock): void;
  103440. /**
  103441. * Build the material and generates the inner effect
  103442. * @param verbose defines if the build should log activity
  103443. */
  103444. build(verbose?: boolean): void;
  103445. /**
  103446. * Runs an otpimization phase to try to improve the shader code
  103447. */
  103448. optimize(): void;
  103449. private _prepareDefinesForAttributes;
  103450. /**
  103451. * Create a post process from the material
  103452. * @param camera The camera to apply the render pass to.
  103453. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103455. * @param engine The engine which the post process will be applied. (default: current engine)
  103456. * @param reusable If the post process can be reused on the same frame. (default: false)
  103457. * @param textureType Type of textures used when performing the post process. (default: 0)
  103458. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103459. * @returns the post process created
  103460. */
  103461. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103462. /**
  103463. * Create the post process effect from the material
  103464. * @param postProcess The post process to create the effect for
  103465. */
  103466. createEffectForPostProcess(postProcess: PostProcess): void;
  103467. private _createEffectForPostProcess;
  103468. /**
  103469. * Create a new procedural texture based on this node material
  103470. * @param size defines the size of the texture
  103471. * @param scene defines the hosting scene
  103472. * @returns the new procedural texture attached to this node material
  103473. */
  103474. createProceduralTexture(size: number | {
  103475. width: number;
  103476. height: number;
  103477. layers?: number;
  103478. }, scene: Scene): Nullable<ProceduralTexture>;
  103479. private _createEffectForParticles;
  103480. private _checkInternals;
  103481. /**
  103482. * Create the effect to be used as the custom effect for a particle system
  103483. * @param particleSystem Particle system to create the effect for
  103484. * @param onCompiled defines a function to call when the effect creation is successful
  103485. * @param onError defines a function to call when the effect creation has failed
  103486. */
  103487. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103488. private _processDefines;
  103489. /**
  103490. * Get if the submesh is ready to be used and all its information available.
  103491. * Child classes can use it to update shaders
  103492. * @param mesh defines the mesh to check
  103493. * @param subMesh defines which submesh to check
  103494. * @param useInstances specifies that instances should be used
  103495. * @returns a boolean indicating that the submesh is ready or not
  103496. */
  103497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103498. /**
  103499. * Get a string representing the shaders built by the current node graph
  103500. */
  103501. get compiledShaders(): string;
  103502. /**
  103503. * Binds the world matrix to the material
  103504. * @param world defines the world transformation matrix
  103505. */
  103506. bindOnlyWorldMatrix(world: Matrix): void;
  103507. /**
  103508. * Binds the submesh to this material by preparing the effect and shader to draw
  103509. * @param world defines the world transformation matrix
  103510. * @param mesh defines the mesh containing the submesh
  103511. * @param subMesh defines the submesh to bind the material to
  103512. */
  103513. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103514. /**
  103515. * Gets the active textures from the material
  103516. * @returns an array of textures
  103517. */
  103518. getActiveTextures(): BaseTexture[];
  103519. /**
  103520. * Gets the list of texture blocks
  103521. * @returns an array of texture blocks
  103522. */
  103523. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103524. /**
  103525. * Specifies if the material uses a texture
  103526. * @param texture defines the texture to check against the material
  103527. * @returns a boolean specifying if the material uses the texture
  103528. */
  103529. hasTexture(texture: BaseTexture): boolean;
  103530. /**
  103531. * Disposes the material
  103532. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103533. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103534. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103535. */
  103536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103537. /** Creates the node editor window. */
  103538. private _createNodeEditor;
  103539. /**
  103540. * Launch the node material editor
  103541. * @param config Define the configuration of the editor
  103542. * @return a promise fulfilled when the node editor is visible
  103543. */
  103544. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103545. /**
  103546. * Clear the current material
  103547. */
  103548. clear(): void;
  103549. /**
  103550. * Clear the current material and set it to a default state
  103551. */
  103552. setToDefault(): void;
  103553. /**
  103554. * Clear the current material and set it to a default state for post process
  103555. */
  103556. setToDefaultPostProcess(): void;
  103557. /**
  103558. * Clear the current material and set it to a default state for procedural texture
  103559. */
  103560. setToDefaultProceduralTexture(): void;
  103561. /**
  103562. * Clear the current material and set it to a default state for particle
  103563. */
  103564. setToDefaultParticle(): void;
  103565. /**
  103566. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103567. * @param url defines the url to load from
  103568. * @returns a promise that will fullfil when the material is fully loaded
  103569. */
  103570. loadAsync(url: string): Promise<void>;
  103571. private _gatherBlocks;
  103572. /**
  103573. * Generate a string containing the code declaration required to create an equivalent of this material
  103574. * @returns a string
  103575. */
  103576. generateCode(): string;
  103577. /**
  103578. * Serializes this material in a JSON representation
  103579. * @returns the serialized material object
  103580. */
  103581. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103582. private _restoreConnections;
  103583. /**
  103584. * Clear the current graph and load a new one from a serialization object
  103585. * @param source defines the JSON representation of the material
  103586. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103587. * @param merge defines whether or not the source must be merged or replace the current content
  103588. */
  103589. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103590. /**
  103591. * Makes a duplicate of the current material.
  103592. * @param name - name to use for the new material.
  103593. */
  103594. clone(name: string): NodeMaterial;
  103595. /**
  103596. * Creates a node material from parsed material data
  103597. * @param source defines the JSON representation of the material
  103598. * @param scene defines the hosting scene
  103599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103600. * @returns a new node material
  103601. */
  103602. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103603. /**
  103604. * Creates a node material from a snippet saved in a remote file
  103605. * @param name defines the name of the material to create
  103606. * @param url defines the url to load from
  103607. * @param scene defines the hosting scene
  103608. * @returns a promise that will resolve to the new node material
  103609. */
  103610. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103611. /**
  103612. * Creates a node material from a snippet saved by the node material editor
  103613. * @param snippetId defines the snippet to load
  103614. * @param scene defines the hosting scene
  103615. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103616. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103617. * @returns a promise that will resolve to the new node material
  103618. */
  103619. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103620. /**
  103621. * Creates a new node material set to default basic configuration
  103622. * @param name defines the name of the material
  103623. * @param scene defines the hosting scene
  103624. * @returns a new NodeMaterial
  103625. */
  103626. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103627. }
  103628. }
  103629. declare module BABYLON {
  103630. interface ThinEngine {
  103631. /**
  103632. * Unbind a list of render target textures from the webGL context
  103633. * This is used only when drawBuffer extension or webGL2 are active
  103634. * @param textures defines the render target textures to unbind
  103635. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103636. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103637. */
  103638. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103639. /**
  103640. * Create a multi render target texture
  103641. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103642. * @param size defines the size of the texture
  103643. * @param options defines the creation options
  103644. * @returns the cube texture as an InternalTexture
  103645. */
  103646. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103647. /**
  103648. * Update the sample count for a given multiple render target texture
  103649. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103650. * @param textures defines the textures to update
  103651. * @param samples defines the sample count to set
  103652. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103653. */
  103654. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103655. /**
  103656. * Select a subsets of attachments to draw to.
  103657. * @param attachments gl attachments
  103658. */
  103659. bindAttachments(attachments: number[]): void;
  103660. /**
  103661. * Creates a layout object to draw/clear on specific textures in a MRT
  103662. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103663. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103664. */
  103665. buildTextureLayout(textureStatus: boolean[]): number[];
  103666. /**
  103667. * Restores the webgl state to only draw on the main color attachment
  103668. */
  103669. restoreSingleAttachment(): void;
  103670. }
  103671. }
  103672. declare module BABYLON {
  103673. /**
  103674. * Creation options of the multi render target texture.
  103675. */
  103676. export interface IMultiRenderTargetOptions {
  103677. /**
  103678. * Define if the texture needs to create mip maps after render.
  103679. */
  103680. generateMipMaps?: boolean;
  103681. /**
  103682. * Define the types of all the draw buffers we want to create
  103683. */
  103684. types?: number[];
  103685. /**
  103686. * Define the sampling modes of all the draw buffers we want to create
  103687. */
  103688. samplingModes?: number[];
  103689. /**
  103690. * Define if a depth buffer is required
  103691. */
  103692. generateDepthBuffer?: boolean;
  103693. /**
  103694. * Define if a stencil buffer is required
  103695. */
  103696. generateStencilBuffer?: boolean;
  103697. /**
  103698. * Define if a depth texture is required instead of a depth buffer
  103699. */
  103700. generateDepthTexture?: boolean;
  103701. /**
  103702. * Define the number of desired draw buffers
  103703. */
  103704. textureCount?: number;
  103705. /**
  103706. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103707. */
  103708. doNotChangeAspectRatio?: boolean;
  103709. /**
  103710. * Define the default type of the buffers we are creating
  103711. */
  103712. defaultType?: number;
  103713. }
  103714. /**
  103715. * A multi render target, like a render target provides the ability to render to a texture.
  103716. * Unlike the render target, it can render to several draw buffers in one draw.
  103717. * This is specially interesting in deferred rendering or for any effects requiring more than
  103718. * just one color from a single pass.
  103719. */
  103720. export class MultiRenderTarget extends RenderTargetTexture {
  103721. private _internalTextures;
  103722. private _textures;
  103723. private _multiRenderTargetOptions;
  103724. private _count;
  103725. /**
  103726. * Get if draw buffers are currently supported by the used hardware and browser.
  103727. */
  103728. get isSupported(): boolean;
  103729. /**
  103730. * Get the list of textures generated by the multi render target.
  103731. */
  103732. get textures(): Texture[];
  103733. /**
  103734. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103735. */
  103736. get count(): number;
  103737. /**
  103738. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103739. */
  103740. get depthTexture(): Texture;
  103741. /**
  103742. * Set the wrapping mode on U of all the textures we are rendering to.
  103743. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103744. */
  103745. set wrapU(wrap: number);
  103746. /**
  103747. * Set the wrapping mode on V of all the textures we are rendering to.
  103748. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103749. */
  103750. set wrapV(wrap: number);
  103751. /**
  103752. * Instantiate a new multi render target texture.
  103753. * A multi render target, like a render target provides the ability to render to a texture.
  103754. * Unlike the render target, it can render to several draw buffers in one draw.
  103755. * This is specially interesting in deferred rendering or for any effects requiring more than
  103756. * just one color from a single pass.
  103757. * @param name Define the name of the texture
  103758. * @param size Define the size of the buffers to render to
  103759. * @param count Define the number of target we are rendering into
  103760. * @param scene Define the scene the texture belongs to
  103761. * @param options Define the options used to create the multi render target
  103762. */
  103763. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103764. private _initTypes;
  103765. /** @hidden */
  103766. _rebuild(forceFullRebuild?: boolean): void;
  103767. private _createInternalTextures;
  103768. private _createTextures;
  103769. /**
  103770. * Replaces a texture within the MRT.
  103771. * @param texture The new texture to insert in the MRT
  103772. * @param index The index of the texture to replace
  103773. */
  103774. replaceTexture(texture: Texture, index: number): void;
  103775. /**
  103776. * Define the number of samples used if MSAA is enabled.
  103777. */
  103778. get samples(): number;
  103779. set samples(value: number);
  103780. /**
  103781. * Resize all the textures in the multi render target.
  103782. * Be careful as it will recreate all the data in the new texture.
  103783. * @param size Define the new size
  103784. */
  103785. resize(size: any): void;
  103786. /**
  103787. * Changes the number of render targets in this MRT
  103788. * Be careful as it will recreate all the data in the new texture.
  103789. * @param count new texture count
  103790. * @param options Specifies texture types and sampling modes for new textures
  103791. */
  103792. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103793. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103794. /**
  103795. * Dispose the render targets and their associated resources
  103796. */
  103797. dispose(): void;
  103798. /**
  103799. * Release all the underlying texture used as draw buffers.
  103800. */
  103801. releaseInternalTextures(): void;
  103802. }
  103803. }
  103804. declare module BABYLON {
  103805. /** @hidden */
  103806. export var imageProcessingPixelShader: {
  103807. name: string;
  103808. shader: string;
  103809. };
  103810. }
  103811. declare module BABYLON {
  103812. /**
  103813. * ImageProcessingPostProcess
  103814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103815. */
  103816. export class ImageProcessingPostProcess extends PostProcess {
  103817. /**
  103818. * Default configuration related to image processing available in the PBR Material.
  103819. */
  103820. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103821. /**
  103822. * Gets the image processing configuration used either in this material.
  103823. */
  103824. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103825. /**
  103826. * Sets the Default image processing configuration used either in the this material.
  103827. *
  103828. * If sets to null, the scene one is in use.
  103829. */
  103830. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103831. /**
  103832. * Keep track of the image processing observer to allow dispose and replace.
  103833. */
  103834. private _imageProcessingObserver;
  103835. /**
  103836. * Attaches a new image processing configuration to the PBR Material.
  103837. * @param configuration
  103838. */
  103839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103840. /**
  103841. * If the post process is supported.
  103842. */
  103843. get isSupported(): boolean;
  103844. /**
  103845. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103846. */
  103847. get colorCurves(): Nullable<ColorCurves>;
  103848. /**
  103849. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103850. */
  103851. set colorCurves(value: Nullable<ColorCurves>);
  103852. /**
  103853. * Gets wether the color curves effect is enabled.
  103854. */
  103855. get colorCurvesEnabled(): boolean;
  103856. /**
  103857. * Sets wether the color curves effect is enabled.
  103858. */
  103859. set colorCurvesEnabled(value: boolean);
  103860. /**
  103861. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103862. */
  103863. get colorGradingTexture(): Nullable<BaseTexture>;
  103864. /**
  103865. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103866. */
  103867. set colorGradingTexture(value: Nullable<BaseTexture>);
  103868. /**
  103869. * Gets wether the color grading effect is enabled.
  103870. */
  103871. get colorGradingEnabled(): boolean;
  103872. /**
  103873. * Gets wether the color grading effect is enabled.
  103874. */
  103875. set colorGradingEnabled(value: boolean);
  103876. /**
  103877. * Gets exposure used in the effect.
  103878. */
  103879. get exposure(): number;
  103880. /**
  103881. * Sets exposure used in the effect.
  103882. */
  103883. set exposure(value: number);
  103884. /**
  103885. * Gets wether tonemapping is enabled or not.
  103886. */
  103887. get toneMappingEnabled(): boolean;
  103888. /**
  103889. * Sets wether tonemapping is enabled or not
  103890. */
  103891. set toneMappingEnabled(value: boolean);
  103892. /**
  103893. * Gets the type of tone mapping effect.
  103894. */
  103895. get toneMappingType(): number;
  103896. /**
  103897. * Sets the type of tone mapping effect.
  103898. */
  103899. set toneMappingType(value: number);
  103900. /**
  103901. * Gets contrast used in the effect.
  103902. */
  103903. get contrast(): number;
  103904. /**
  103905. * Sets contrast used in the effect.
  103906. */
  103907. set contrast(value: number);
  103908. /**
  103909. * Gets Vignette stretch size.
  103910. */
  103911. get vignetteStretch(): number;
  103912. /**
  103913. * Sets Vignette stretch size.
  103914. */
  103915. set vignetteStretch(value: number);
  103916. /**
  103917. * Gets Vignette centre X Offset.
  103918. */
  103919. get vignetteCentreX(): number;
  103920. /**
  103921. * Sets Vignette centre X Offset.
  103922. */
  103923. set vignetteCentreX(value: number);
  103924. /**
  103925. * Gets Vignette centre Y Offset.
  103926. */
  103927. get vignetteCentreY(): number;
  103928. /**
  103929. * Sets Vignette centre Y Offset.
  103930. */
  103931. set vignetteCentreY(value: number);
  103932. /**
  103933. * Gets Vignette weight or intensity of the vignette effect.
  103934. */
  103935. get vignetteWeight(): number;
  103936. /**
  103937. * Sets Vignette weight or intensity of the vignette effect.
  103938. */
  103939. set vignetteWeight(value: number);
  103940. /**
  103941. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103942. * if vignetteEnabled is set to true.
  103943. */
  103944. get vignetteColor(): Color4;
  103945. /**
  103946. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103947. * if vignetteEnabled is set to true.
  103948. */
  103949. set vignetteColor(value: Color4);
  103950. /**
  103951. * Gets Camera field of view used by the Vignette effect.
  103952. */
  103953. get vignetteCameraFov(): number;
  103954. /**
  103955. * Sets Camera field of view used by the Vignette effect.
  103956. */
  103957. set vignetteCameraFov(value: number);
  103958. /**
  103959. * Gets the vignette blend mode allowing different kind of effect.
  103960. */
  103961. get vignetteBlendMode(): number;
  103962. /**
  103963. * Sets the vignette blend mode allowing different kind of effect.
  103964. */
  103965. set vignetteBlendMode(value: number);
  103966. /**
  103967. * Gets wether the vignette effect is enabled.
  103968. */
  103969. get vignetteEnabled(): boolean;
  103970. /**
  103971. * Sets wether the vignette effect is enabled.
  103972. */
  103973. set vignetteEnabled(value: boolean);
  103974. private _fromLinearSpace;
  103975. /**
  103976. * Gets wether the input of the processing is in Gamma or Linear Space.
  103977. */
  103978. get fromLinearSpace(): boolean;
  103979. /**
  103980. * Sets wether the input of the processing is in Gamma or Linear Space.
  103981. */
  103982. set fromLinearSpace(value: boolean);
  103983. /**
  103984. * Defines cache preventing GC.
  103985. */
  103986. private _defines;
  103987. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103988. /**
  103989. * "ImageProcessingPostProcess"
  103990. * @returns "ImageProcessingPostProcess"
  103991. */
  103992. getClassName(): string;
  103993. /**
  103994. * @hidden
  103995. */
  103996. _updateParameters(): void;
  103997. dispose(camera?: Camera): void;
  103998. }
  103999. }
  104000. declare module BABYLON {
  104001. /**
  104002. * Interface for defining prepass effects in the prepass post-process pipeline
  104003. */
  104004. export interface PrePassEffectConfiguration {
  104005. /**
  104006. * Name of the effect
  104007. */
  104008. name: string;
  104009. /**
  104010. * Post process to attach for this effect
  104011. */
  104012. postProcess?: PostProcess;
  104013. /**
  104014. * Textures required in the MRT
  104015. */
  104016. texturesRequired: number[];
  104017. /**
  104018. * Is the effect enabled
  104019. */
  104020. enabled: boolean;
  104021. /**
  104022. * Disposes the effect configuration
  104023. */
  104024. dispose?: () => void;
  104025. /**
  104026. * Creates the associated post process
  104027. */
  104028. createPostProcess?: () => PostProcess;
  104029. }
  104030. }
  104031. declare module BABYLON {
  104032. /**
  104033. * Options to be used when creating a FresnelParameters.
  104034. */
  104035. export type IFresnelParametersCreationOptions = {
  104036. /**
  104037. * Define the color used on edges (grazing angle)
  104038. */
  104039. leftColor?: Color3;
  104040. /**
  104041. * Define the color used on center
  104042. */
  104043. rightColor?: Color3;
  104044. /**
  104045. * Define bias applied to computed fresnel term
  104046. */
  104047. bias?: number;
  104048. /**
  104049. * Defined the power exponent applied to fresnel term
  104050. */
  104051. power?: number;
  104052. /**
  104053. * Define if the fresnel effect is enable or not.
  104054. */
  104055. isEnabled?: boolean;
  104056. };
  104057. /**
  104058. * Serialized format for FresnelParameters.
  104059. */
  104060. export type IFresnelParametersSerialized = {
  104061. /**
  104062. * Define the color used on edges (grazing angle) [as an array]
  104063. */
  104064. leftColor: number[];
  104065. /**
  104066. * Define the color used on center [as an array]
  104067. */
  104068. rightColor: number[];
  104069. /**
  104070. * Define bias applied to computed fresnel term
  104071. */
  104072. bias: number;
  104073. /**
  104074. * Defined the power exponent applied to fresnel term
  104075. */
  104076. power?: number;
  104077. /**
  104078. * Define if the fresnel effect is enable or not.
  104079. */
  104080. isEnabled: boolean;
  104081. };
  104082. /**
  104083. * This represents all the required information to add a fresnel effect on a material:
  104084. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104085. */
  104086. export class FresnelParameters {
  104087. private _isEnabled;
  104088. /**
  104089. * Define if the fresnel effect is enable or not.
  104090. */
  104091. get isEnabled(): boolean;
  104092. set isEnabled(value: boolean);
  104093. /**
  104094. * Define the color used on edges (grazing angle)
  104095. */
  104096. leftColor: Color3;
  104097. /**
  104098. * Define the color used on center
  104099. */
  104100. rightColor: Color3;
  104101. /**
  104102. * Define bias applied to computed fresnel term
  104103. */
  104104. bias: number;
  104105. /**
  104106. * Defined the power exponent applied to fresnel term
  104107. */
  104108. power: number;
  104109. /**
  104110. * Creates a new FresnelParameters object.
  104111. *
  104112. * @param options provide your own settings to optionally to override defaults
  104113. */
  104114. constructor(options?: IFresnelParametersCreationOptions);
  104115. /**
  104116. * Clones the current fresnel and its valuues
  104117. * @returns a clone fresnel configuration
  104118. */
  104119. clone(): FresnelParameters;
  104120. /**
  104121. * Determines equality between FresnelParameters objects
  104122. * @param otherFresnelParameters defines the second operand
  104123. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104124. */
  104125. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104126. /**
  104127. * Serializes the current fresnel parameters to a JSON representation.
  104128. * @return the JSON serialization
  104129. */
  104130. serialize(): IFresnelParametersSerialized;
  104131. /**
  104132. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104133. * @param parsedFresnelParameters Define the JSON representation
  104134. * @returns the parsed parameters
  104135. */
  104136. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104137. }
  104138. }
  104139. declare module BABYLON {
  104140. /**
  104141. * This groups all the flags used to control the materials channel.
  104142. */
  104143. export class MaterialFlags {
  104144. private static _DiffuseTextureEnabled;
  104145. /**
  104146. * Are diffuse textures enabled in the application.
  104147. */
  104148. static get DiffuseTextureEnabled(): boolean;
  104149. static set DiffuseTextureEnabled(value: boolean);
  104150. private static _DetailTextureEnabled;
  104151. /**
  104152. * Are detail textures enabled in the application.
  104153. */
  104154. static get DetailTextureEnabled(): boolean;
  104155. static set DetailTextureEnabled(value: boolean);
  104156. private static _AmbientTextureEnabled;
  104157. /**
  104158. * Are ambient textures enabled in the application.
  104159. */
  104160. static get AmbientTextureEnabled(): boolean;
  104161. static set AmbientTextureEnabled(value: boolean);
  104162. private static _OpacityTextureEnabled;
  104163. /**
  104164. * Are opacity textures enabled in the application.
  104165. */
  104166. static get OpacityTextureEnabled(): boolean;
  104167. static set OpacityTextureEnabled(value: boolean);
  104168. private static _ReflectionTextureEnabled;
  104169. /**
  104170. * Are reflection textures enabled in the application.
  104171. */
  104172. static get ReflectionTextureEnabled(): boolean;
  104173. static set ReflectionTextureEnabled(value: boolean);
  104174. private static _EmissiveTextureEnabled;
  104175. /**
  104176. * Are emissive textures enabled in the application.
  104177. */
  104178. static get EmissiveTextureEnabled(): boolean;
  104179. static set EmissiveTextureEnabled(value: boolean);
  104180. private static _SpecularTextureEnabled;
  104181. /**
  104182. * Are specular textures enabled in the application.
  104183. */
  104184. static get SpecularTextureEnabled(): boolean;
  104185. static set SpecularTextureEnabled(value: boolean);
  104186. private static _BumpTextureEnabled;
  104187. /**
  104188. * Are bump textures enabled in the application.
  104189. */
  104190. static get BumpTextureEnabled(): boolean;
  104191. static set BumpTextureEnabled(value: boolean);
  104192. private static _LightmapTextureEnabled;
  104193. /**
  104194. * Are lightmap textures enabled in the application.
  104195. */
  104196. static get LightmapTextureEnabled(): boolean;
  104197. static set LightmapTextureEnabled(value: boolean);
  104198. private static _RefractionTextureEnabled;
  104199. /**
  104200. * Are refraction textures enabled in the application.
  104201. */
  104202. static get RefractionTextureEnabled(): boolean;
  104203. static set RefractionTextureEnabled(value: boolean);
  104204. private static _ColorGradingTextureEnabled;
  104205. /**
  104206. * Are color grading textures enabled in the application.
  104207. */
  104208. static get ColorGradingTextureEnabled(): boolean;
  104209. static set ColorGradingTextureEnabled(value: boolean);
  104210. private static _FresnelEnabled;
  104211. /**
  104212. * Are fresnels enabled in the application.
  104213. */
  104214. static get FresnelEnabled(): boolean;
  104215. static set FresnelEnabled(value: boolean);
  104216. private static _ClearCoatTextureEnabled;
  104217. /**
  104218. * Are clear coat textures enabled in the application.
  104219. */
  104220. static get ClearCoatTextureEnabled(): boolean;
  104221. static set ClearCoatTextureEnabled(value: boolean);
  104222. private static _ClearCoatBumpTextureEnabled;
  104223. /**
  104224. * Are clear coat bump textures enabled in the application.
  104225. */
  104226. static get ClearCoatBumpTextureEnabled(): boolean;
  104227. static set ClearCoatBumpTextureEnabled(value: boolean);
  104228. private static _ClearCoatTintTextureEnabled;
  104229. /**
  104230. * Are clear coat tint textures enabled in the application.
  104231. */
  104232. static get ClearCoatTintTextureEnabled(): boolean;
  104233. static set ClearCoatTintTextureEnabled(value: boolean);
  104234. private static _SheenTextureEnabled;
  104235. /**
  104236. * Are sheen textures enabled in the application.
  104237. */
  104238. static get SheenTextureEnabled(): boolean;
  104239. static set SheenTextureEnabled(value: boolean);
  104240. private static _AnisotropicTextureEnabled;
  104241. /**
  104242. * Are anisotropic textures enabled in the application.
  104243. */
  104244. static get AnisotropicTextureEnabled(): boolean;
  104245. static set AnisotropicTextureEnabled(value: boolean);
  104246. private static _ThicknessTextureEnabled;
  104247. /**
  104248. * Are thickness textures enabled in the application.
  104249. */
  104250. static get ThicknessTextureEnabled(): boolean;
  104251. static set ThicknessTextureEnabled(value: boolean);
  104252. }
  104253. }
  104254. declare module BABYLON {
  104255. /** @hidden */
  104256. export var defaultFragmentDeclaration: {
  104257. name: string;
  104258. shader: string;
  104259. };
  104260. }
  104261. declare module BABYLON {
  104262. /** @hidden */
  104263. export var defaultUboDeclaration: {
  104264. name: string;
  104265. shader: string;
  104266. };
  104267. }
  104268. declare module BABYLON {
  104269. /** @hidden */
  104270. export var prePassDeclaration: {
  104271. name: string;
  104272. shader: string;
  104273. };
  104274. }
  104275. declare module BABYLON {
  104276. /** @hidden */
  104277. export var lightFragmentDeclaration: {
  104278. name: string;
  104279. shader: string;
  104280. };
  104281. }
  104282. declare module BABYLON {
  104283. /** @hidden */
  104284. export var lightUboDeclaration: {
  104285. name: string;
  104286. shader: string;
  104287. };
  104288. }
  104289. declare module BABYLON {
  104290. /** @hidden */
  104291. export var lightsFragmentFunctions: {
  104292. name: string;
  104293. shader: string;
  104294. };
  104295. }
  104296. declare module BABYLON {
  104297. /** @hidden */
  104298. export var shadowsFragmentFunctions: {
  104299. name: string;
  104300. shader: string;
  104301. };
  104302. }
  104303. declare module BABYLON {
  104304. /** @hidden */
  104305. export var fresnelFunction: {
  104306. name: string;
  104307. shader: string;
  104308. };
  104309. }
  104310. declare module BABYLON {
  104311. /** @hidden */
  104312. export var bumpFragmentMainFunctions: {
  104313. name: string;
  104314. shader: string;
  104315. };
  104316. }
  104317. declare module BABYLON {
  104318. /** @hidden */
  104319. export var bumpFragmentFunctions: {
  104320. name: string;
  104321. shader: string;
  104322. };
  104323. }
  104324. declare module BABYLON {
  104325. /** @hidden */
  104326. export var logDepthDeclaration: {
  104327. name: string;
  104328. shader: string;
  104329. };
  104330. }
  104331. declare module BABYLON {
  104332. /** @hidden */
  104333. export var bumpFragment: {
  104334. name: string;
  104335. shader: string;
  104336. };
  104337. }
  104338. declare module BABYLON {
  104339. /** @hidden */
  104340. export var depthPrePass: {
  104341. name: string;
  104342. shader: string;
  104343. };
  104344. }
  104345. declare module BABYLON {
  104346. /** @hidden */
  104347. export var lightFragment: {
  104348. name: string;
  104349. shader: string;
  104350. };
  104351. }
  104352. declare module BABYLON {
  104353. /** @hidden */
  104354. export var logDepthFragment: {
  104355. name: string;
  104356. shader: string;
  104357. };
  104358. }
  104359. declare module BABYLON {
  104360. /** @hidden */
  104361. export var defaultPixelShader: {
  104362. name: string;
  104363. shader: string;
  104364. };
  104365. }
  104366. declare module BABYLON {
  104367. /** @hidden */
  104368. export var defaultVertexDeclaration: {
  104369. name: string;
  104370. shader: string;
  104371. };
  104372. }
  104373. declare module BABYLON {
  104374. /** @hidden */
  104375. export var prePassVertexDeclaration: {
  104376. name: string;
  104377. shader: string;
  104378. };
  104379. }
  104380. declare module BABYLON {
  104381. /** @hidden */
  104382. export var bumpVertexDeclaration: {
  104383. name: string;
  104384. shader: string;
  104385. };
  104386. }
  104387. declare module BABYLON {
  104388. /** @hidden */
  104389. export var prePassVertex: {
  104390. name: string;
  104391. shader: string;
  104392. };
  104393. }
  104394. declare module BABYLON {
  104395. /** @hidden */
  104396. export var bumpVertex: {
  104397. name: string;
  104398. shader: string;
  104399. };
  104400. }
  104401. declare module BABYLON {
  104402. /** @hidden */
  104403. export var fogVertex: {
  104404. name: string;
  104405. shader: string;
  104406. };
  104407. }
  104408. declare module BABYLON {
  104409. /** @hidden */
  104410. export var shadowsVertex: {
  104411. name: string;
  104412. shader: string;
  104413. };
  104414. }
  104415. declare module BABYLON {
  104416. /** @hidden */
  104417. export var pointCloudVertex: {
  104418. name: string;
  104419. shader: string;
  104420. };
  104421. }
  104422. declare module BABYLON {
  104423. /** @hidden */
  104424. export var logDepthVertex: {
  104425. name: string;
  104426. shader: string;
  104427. };
  104428. }
  104429. declare module BABYLON {
  104430. /** @hidden */
  104431. export var defaultVertexShader: {
  104432. name: string;
  104433. shader: string;
  104434. };
  104435. }
  104436. declare module BABYLON {
  104437. /**
  104438. * @hidden
  104439. */
  104440. export interface IMaterialDetailMapDefines {
  104441. DETAIL: boolean;
  104442. DETAILDIRECTUV: number;
  104443. DETAIL_NORMALBLENDMETHOD: number;
  104444. /** @hidden */
  104445. _areTexturesDirty: boolean;
  104446. }
  104447. /**
  104448. * Define the code related to the detail map parameters of a material
  104449. *
  104450. * Inspired from:
  104451. * 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
  104452. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104453. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104454. */
  104455. export class DetailMapConfiguration {
  104456. private _texture;
  104457. /**
  104458. * The detail texture of the material.
  104459. */
  104460. texture: Nullable<BaseTexture>;
  104461. /**
  104462. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104463. * Bigger values mean stronger blending
  104464. */
  104465. diffuseBlendLevel: number;
  104466. /**
  104467. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104468. * Bigger values mean stronger blending. Only used with PBR materials
  104469. */
  104470. roughnessBlendLevel: number;
  104471. /**
  104472. * Defines how strong the bump effect from the detail map is
  104473. * Bigger values mean stronger effect
  104474. */
  104475. bumpLevel: number;
  104476. private _normalBlendMethod;
  104477. /**
  104478. * The method used to blend the bump and detail normals together
  104479. */
  104480. normalBlendMethod: number;
  104481. private _isEnabled;
  104482. /**
  104483. * Enable or disable the detail map on this material
  104484. */
  104485. isEnabled: boolean;
  104486. /** @hidden */
  104487. private _internalMarkAllSubMeshesAsTexturesDirty;
  104488. /** @hidden */
  104489. _markAllSubMeshesAsTexturesDirty(): void;
  104490. /**
  104491. * Instantiate a new detail map
  104492. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104493. */
  104494. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104495. /**
  104496. * Gets whether the submesh is ready to be used or not.
  104497. * @param defines the list of "defines" to update.
  104498. * @param scene defines the scene the material belongs to.
  104499. * @returns - boolean indicating that the submesh is ready or not.
  104500. */
  104501. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104502. /**
  104503. * Update the defines for detail map usage
  104504. * @param defines the list of "defines" to update.
  104505. * @param scene defines the scene the material belongs to.
  104506. */
  104507. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104508. /**
  104509. * Binds the material data.
  104510. * @param uniformBuffer defines the Uniform buffer to fill in.
  104511. * @param scene defines the scene the material belongs to.
  104512. * @param isFrozen defines whether the material is frozen or not.
  104513. */
  104514. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104515. /**
  104516. * Checks to see if a texture is used in the material.
  104517. * @param texture - Base texture to use.
  104518. * @returns - Boolean specifying if a texture is used in the material.
  104519. */
  104520. hasTexture(texture: BaseTexture): boolean;
  104521. /**
  104522. * Returns an array of the actively used textures.
  104523. * @param activeTextures Array of BaseTextures
  104524. */
  104525. getActiveTextures(activeTextures: BaseTexture[]): void;
  104526. /**
  104527. * Returns the animatable textures.
  104528. * @param animatables Array of animatable textures.
  104529. */
  104530. getAnimatables(animatables: IAnimatable[]): void;
  104531. /**
  104532. * Disposes the resources of the material.
  104533. * @param forceDisposeTextures - Forces the disposal of all textures.
  104534. */
  104535. dispose(forceDisposeTextures?: boolean): void;
  104536. /**
  104537. * Get the current class name useful for serialization or dynamic coding.
  104538. * @returns "DetailMap"
  104539. */
  104540. getClassName(): string;
  104541. /**
  104542. * Add the required uniforms to the current list.
  104543. * @param uniforms defines the current uniform list.
  104544. */
  104545. static AddUniforms(uniforms: string[]): void;
  104546. /**
  104547. * Add the required samplers to the current list.
  104548. * @param samplers defines the current sampler list.
  104549. */
  104550. static AddSamplers(samplers: string[]): void;
  104551. /**
  104552. * Add the required uniforms to the current buffer.
  104553. * @param uniformBuffer defines the current uniform buffer.
  104554. */
  104555. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104556. /**
  104557. * Makes a duplicate of the current instance into another one.
  104558. * @param detailMap define the instance where to copy the info
  104559. */
  104560. copyTo(detailMap: DetailMapConfiguration): void;
  104561. /**
  104562. * Serializes this detail map instance
  104563. * @returns - An object with the serialized instance.
  104564. */
  104565. serialize(): any;
  104566. /**
  104567. * Parses a detail map setting from a serialized object.
  104568. * @param source - Serialized object.
  104569. * @param scene Defines the scene we are parsing for
  104570. * @param rootUrl Defines the rootUrl to load from
  104571. */
  104572. parse(source: any, scene: Scene, rootUrl: string): void;
  104573. }
  104574. }
  104575. declare module BABYLON {
  104576. /** @hidden */
  104577. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104578. MAINUV1: boolean;
  104579. MAINUV2: boolean;
  104580. DIFFUSE: boolean;
  104581. DIFFUSEDIRECTUV: number;
  104582. DETAIL: boolean;
  104583. DETAILDIRECTUV: number;
  104584. DETAIL_NORMALBLENDMETHOD: number;
  104585. AMBIENT: boolean;
  104586. AMBIENTDIRECTUV: number;
  104587. OPACITY: boolean;
  104588. OPACITYDIRECTUV: number;
  104589. OPACITYRGB: boolean;
  104590. REFLECTION: boolean;
  104591. EMISSIVE: boolean;
  104592. EMISSIVEDIRECTUV: number;
  104593. SPECULAR: boolean;
  104594. SPECULARDIRECTUV: number;
  104595. BUMP: boolean;
  104596. BUMPDIRECTUV: number;
  104597. PARALLAX: boolean;
  104598. PARALLAXOCCLUSION: boolean;
  104599. SPECULAROVERALPHA: boolean;
  104600. CLIPPLANE: boolean;
  104601. CLIPPLANE2: boolean;
  104602. CLIPPLANE3: boolean;
  104603. CLIPPLANE4: boolean;
  104604. CLIPPLANE5: boolean;
  104605. CLIPPLANE6: boolean;
  104606. ALPHATEST: boolean;
  104607. DEPTHPREPASS: boolean;
  104608. ALPHAFROMDIFFUSE: boolean;
  104609. POINTSIZE: boolean;
  104610. FOG: boolean;
  104611. SPECULARTERM: boolean;
  104612. DIFFUSEFRESNEL: boolean;
  104613. OPACITYFRESNEL: boolean;
  104614. REFLECTIONFRESNEL: boolean;
  104615. REFRACTIONFRESNEL: boolean;
  104616. EMISSIVEFRESNEL: boolean;
  104617. FRESNEL: boolean;
  104618. NORMAL: boolean;
  104619. UV1: boolean;
  104620. UV2: boolean;
  104621. VERTEXCOLOR: boolean;
  104622. VERTEXALPHA: boolean;
  104623. NUM_BONE_INFLUENCERS: number;
  104624. BonesPerMesh: number;
  104625. BONETEXTURE: boolean;
  104626. BONES_VELOCITY_ENABLED: boolean;
  104627. INSTANCES: boolean;
  104628. THIN_INSTANCES: boolean;
  104629. GLOSSINESS: boolean;
  104630. ROUGHNESS: boolean;
  104631. EMISSIVEASILLUMINATION: boolean;
  104632. LINKEMISSIVEWITHDIFFUSE: boolean;
  104633. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104634. LIGHTMAP: boolean;
  104635. LIGHTMAPDIRECTUV: number;
  104636. OBJECTSPACE_NORMALMAP: boolean;
  104637. USELIGHTMAPASSHADOWMAP: boolean;
  104638. REFLECTIONMAP_3D: boolean;
  104639. REFLECTIONMAP_SPHERICAL: boolean;
  104640. REFLECTIONMAP_PLANAR: boolean;
  104641. REFLECTIONMAP_CUBIC: boolean;
  104642. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104643. REFLECTIONMAP_PROJECTION: boolean;
  104644. REFLECTIONMAP_SKYBOX: boolean;
  104645. REFLECTIONMAP_EXPLICIT: boolean;
  104646. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104647. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104648. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104649. INVERTCUBICMAP: boolean;
  104650. LOGARITHMICDEPTH: boolean;
  104651. REFRACTION: boolean;
  104652. REFRACTIONMAP_3D: boolean;
  104653. REFLECTIONOVERALPHA: boolean;
  104654. TWOSIDEDLIGHTING: boolean;
  104655. SHADOWFLOAT: boolean;
  104656. MORPHTARGETS: boolean;
  104657. MORPHTARGETS_NORMAL: boolean;
  104658. MORPHTARGETS_TANGENT: boolean;
  104659. MORPHTARGETS_UV: boolean;
  104660. NUM_MORPH_INFLUENCERS: number;
  104661. NONUNIFORMSCALING: boolean;
  104662. PREMULTIPLYALPHA: boolean;
  104663. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104664. ALPHABLEND: boolean;
  104665. PREPASS: boolean;
  104666. PREPASS_IRRADIANCE: boolean;
  104667. PREPASS_IRRADIANCE_INDEX: number;
  104668. PREPASS_ALBEDO: boolean;
  104669. PREPASS_ALBEDO_INDEX: number;
  104670. PREPASS_DEPTHNORMAL: boolean;
  104671. PREPASS_DEPTHNORMAL_INDEX: number;
  104672. PREPASS_POSITION: boolean;
  104673. PREPASS_POSITION_INDEX: number;
  104674. PREPASS_VELOCITY: boolean;
  104675. PREPASS_VELOCITY_INDEX: number;
  104676. PREPASS_REFLECTIVITY: boolean;
  104677. PREPASS_REFLECTIVITY_INDEX: number;
  104678. SCENE_MRT_COUNT: number;
  104679. RGBDLIGHTMAP: boolean;
  104680. RGBDREFLECTION: boolean;
  104681. RGBDREFRACTION: boolean;
  104682. IMAGEPROCESSING: boolean;
  104683. VIGNETTE: boolean;
  104684. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104685. VIGNETTEBLENDMODEOPAQUE: boolean;
  104686. TONEMAPPING: boolean;
  104687. TONEMAPPING_ACES: boolean;
  104688. CONTRAST: boolean;
  104689. COLORCURVES: boolean;
  104690. COLORGRADING: boolean;
  104691. COLORGRADING3D: boolean;
  104692. SAMPLER3DGREENDEPTH: boolean;
  104693. SAMPLER3DBGRMAP: boolean;
  104694. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104695. MULTIVIEW: boolean;
  104696. /**
  104697. * If the reflection texture on this material is in linear color space
  104698. * @hidden
  104699. */
  104700. IS_REFLECTION_LINEAR: boolean;
  104701. /**
  104702. * If the refraction texture on this material is in linear color space
  104703. * @hidden
  104704. */
  104705. IS_REFRACTION_LINEAR: boolean;
  104706. EXPOSURE: boolean;
  104707. constructor();
  104708. setReflectionMode(modeToEnable: string): void;
  104709. }
  104710. /**
  104711. * This is the default material used in Babylon. It is the best trade off between quality
  104712. * and performances.
  104713. * @see https://doc.babylonjs.com/babylon101/materials
  104714. */
  104715. export class StandardMaterial extends PushMaterial {
  104716. private _diffuseTexture;
  104717. /**
  104718. * The basic texture of the material as viewed under a light.
  104719. */
  104720. diffuseTexture: Nullable<BaseTexture>;
  104721. private _ambientTexture;
  104722. /**
  104723. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104724. */
  104725. ambientTexture: Nullable<BaseTexture>;
  104726. private _opacityTexture;
  104727. /**
  104728. * Define the transparency of the material from a texture.
  104729. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104730. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104731. */
  104732. opacityTexture: Nullable<BaseTexture>;
  104733. private _reflectionTexture;
  104734. /**
  104735. * Define the texture used to display the reflection.
  104736. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104737. */
  104738. reflectionTexture: Nullable<BaseTexture>;
  104739. private _emissiveTexture;
  104740. /**
  104741. * Define texture of the material as if self lit.
  104742. * This will be mixed in the final result even in the absence of light.
  104743. */
  104744. emissiveTexture: Nullable<BaseTexture>;
  104745. private _specularTexture;
  104746. /**
  104747. * Define how the color and intensity of the highlight given by the light in the material.
  104748. */
  104749. specularTexture: Nullable<BaseTexture>;
  104750. private _bumpTexture;
  104751. /**
  104752. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104753. * 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.
  104754. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104755. */
  104756. bumpTexture: Nullable<BaseTexture>;
  104757. private _lightmapTexture;
  104758. /**
  104759. * Complex lighting can be computationally expensive to compute at runtime.
  104760. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104761. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104762. */
  104763. lightmapTexture: Nullable<BaseTexture>;
  104764. private _refractionTexture;
  104765. /**
  104766. * Define the texture used to display the refraction.
  104767. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104768. */
  104769. refractionTexture: Nullable<BaseTexture>;
  104770. /**
  104771. * The color of the material lit by the environmental background lighting.
  104772. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104773. */
  104774. ambientColor: Color3;
  104775. /**
  104776. * The basic color of the material as viewed under a light.
  104777. */
  104778. diffuseColor: Color3;
  104779. /**
  104780. * Define how the color and intensity of the highlight given by the light in the material.
  104781. */
  104782. specularColor: Color3;
  104783. /**
  104784. * Define the color of the material as if self lit.
  104785. * This will be mixed in the final result even in the absence of light.
  104786. */
  104787. emissiveColor: Color3;
  104788. /**
  104789. * Defines how sharp are the highlights in the material.
  104790. * The bigger the value the sharper giving a more glossy feeling to the result.
  104791. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104792. */
  104793. specularPower: number;
  104794. private _useAlphaFromDiffuseTexture;
  104795. /**
  104796. * Does the transparency come from the diffuse texture alpha channel.
  104797. */
  104798. useAlphaFromDiffuseTexture: boolean;
  104799. private _useEmissiveAsIllumination;
  104800. /**
  104801. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104802. */
  104803. useEmissiveAsIllumination: boolean;
  104804. private _linkEmissiveWithDiffuse;
  104805. /**
  104806. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104807. * the emissive level when the final color is close to one.
  104808. */
  104809. linkEmissiveWithDiffuse: boolean;
  104810. private _useSpecularOverAlpha;
  104811. /**
  104812. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104813. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104814. */
  104815. useSpecularOverAlpha: boolean;
  104816. private _useReflectionOverAlpha;
  104817. /**
  104818. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104819. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104820. */
  104821. useReflectionOverAlpha: boolean;
  104822. private _disableLighting;
  104823. /**
  104824. * Does lights from the scene impacts this material.
  104825. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104826. */
  104827. disableLighting: boolean;
  104828. private _useObjectSpaceNormalMap;
  104829. /**
  104830. * Allows using an object space normal map (instead of tangent space).
  104831. */
  104832. useObjectSpaceNormalMap: boolean;
  104833. private _useParallax;
  104834. /**
  104835. * Is parallax enabled or not.
  104836. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104837. */
  104838. useParallax: boolean;
  104839. private _useParallaxOcclusion;
  104840. /**
  104841. * Is parallax occlusion enabled or not.
  104842. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104843. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104844. */
  104845. useParallaxOcclusion: boolean;
  104846. /**
  104847. * 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.
  104848. */
  104849. parallaxScaleBias: number;
  104850. private _roughness;
  104851. /**
  104852. * Helps to define how blurry the reflections should appears in the material.
  104853. */
  104854. roughness: number;
  104855. /**
  104856. * In case of refraction, define the value of the index of refraction.
  104857. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104858. */
  104859. indexOfRefraction: number;
  104860. /**
  104861. * Invert the refraction texture alongside the y axis.
  104862. * It can be useful with procedural textures or probe for instance.
  104863. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104864. */
  104865. invertRefractionY: boolean;
  104866. /**
  104867. * Defines the alpha limits in alpha test mode.
  104868. */
  104869. alphaCutOff: number;
  104870. private _useLightmapAsShadowmap;
  104871. /**
  104872. * In case of light mapping, define whether the map contains light or shadow informations.
  104873. */
  104874. useLightmapAsShadowmap: boolean;
  104875. private _diffuseFresnelParameters;
  104876. /**
  104877. * Define the diffuse fresnel parameters of the material.
  104878. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104879. */
  104880. diffuseFresnelParameters: FresnelParameters;
  104881. private _opacityFresnelParameters;
  104882. /**
  104883. * Define the opacity fresnel parameters of the material.
  104884. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104885. */
  104886. opacityFresnelParameters: FresnelParameters;
  104887. private _reflectionFresnelParameters;
  104888. /**
  104889. * Define the reflection fresnel parameters of the material.
  104890. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104891. */
  104892. reflectionFresnelParameters: FresnelParameters;
  104893. private _refractionFresnelParameters;
  104894. /**
  104895. * Define the refraction fresnel parameters of the material.
  104896. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104897. */
  104898. refractionFresnelParameters: FresnelParameters;
  104899. private _emissiveFresnelParameters;
  104900. /**
  104901. * Define the emissive fresnel parameters of the material.
  104902. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104903. */
  104904. emissiveFresnelParameters: FresnelParameters;
  104905. private _useReflectionFresnelFromSpecular;
  104906. /**
  104907. * If true automatically deducts the fresnels values from the material specularity.
  104908. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104909. */
  104910. useReflectionFresnelFromSpecular: boolean;
  104911. private _useGlossinessFromSpecularMapAlpha;
  104912. /**
  104913. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104914. */
  104915. useGlossinessFromSpecularMapAlpha: boolean;
  104916. private _maxSimultaneousLights;
  104917. /**
  104918. * Defines the maximum number of lights that can be used in the material
  104919. */
  104920. maxSimultaneousLights: number;
  104921. private _invertNormalMapX;
  104922. /**
  104923. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104924. */
  104925. invertNormalMapX: boolean;
  104926. private _invertNormalMapY;
  104927. /**
  104928. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104929. */
  104930. invertNormalMapY: boolean;
  104931. private _twoSidedLighting;
  104932. /**
  104933. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104934. */
  104935. twoSidedLighting: boolean;
  104936. /**
  104937. * Default configuration related to image processing available in the standard Material.
  104938. */
  104939. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104940. /**
  104941. * Gets the image processing configuration used either in this material.
  104942. */
  104943. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104944. /**
  104945. * Sets the Default image processing configuration used either in the this material.
  104946. *
  104947. * If sets to null, the scene one is in use.
  104948. */
  104949. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104950. /**
  104951. * Keep track of the image processing observer to allow dispose and replace.
  104952. */
  104953. private _imageProcessingObserver;
  104954. /**
  104955. * Attaches a new image processing configuration to the Standard Material.
  104956. * @param configuration
  104957. */
  104958. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104959. /**
  104960. * Defines additionnal PrePass parameters for the material.
  104961. */
  104962. readonly prePassConfiguration: PrePassConfiguration;
  104963. /**
  104964. * Gets wether the color curves effect is enabled.
  104965. */
  104966. get cameraColorCurvesEnabled(): boolean;
  104967. /**
  104968. * Sets wether the color curves effect is enabled.
  104969. */
  104970. set cameraColorCurvesEnabled(value: boolean);
  104971. /**
  104972. * Gets wether the color grading effect is enabled.
  104973. */
  104974. get cameraColorGradingEnabled(): boolean;
  104975. /**
  104976. * Gets wether the color grading effect is enabled.
  104977. */
  104978. set cameraColorGradingEnabled(value: boolean);
  104979. /**
  104980. * Gets wether tonemapping is enabled or not.
  104981. */
  104982. get cameraToneMappingEnabled(): boolean;
  104983. /**
  104984. * Sets wether tonemapping is enabled or not
  104985. */
  104986. set cameraToneMappingEnabled(value: boolean);
  104987. /**
  104988. * The camera exposure used on this material.
  104989. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104990. * This corresponds to a photographic exposure.
  104991. */
  104992. get cameraExposure(): number;
  104993. /**
  104994. * The camera exposure used on this material.
  104995. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104996. * This corresponds to a photographic exposure.
  104997. */
  104998. set cameraExposure(value: number);
  104999. /**
  105000. * Gets The camera contrast used on this material.
  105001. */
  105002. get cameraContrast(): number;
  105003. /**
  105004. * Sets The camera contrast used on this material.
  105005. */
  105006. set cameraContrast(value: number);
  105007. /**
  105008. * Gets the Color Grading 2D Lookup Texture.
  105009. */
  105010. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105011. /**
  105012. * Sets the Color Grading 2D Lookup Texture.
  105013. */
  105014. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105015. /**
  105016. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105017. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105018. * 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;
  105019. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105020. */
  105021. get cameraColorCurves(): Nullable<ColorCurves>;
  105022. /**
  105023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105025. * 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;
  105026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105027. */
  105028. set cameraColorCurves(value: Nullable<ColorCurves>);
  105029. /**
  105030. * Can this material render to several textures at once
  105031. */
  105032. get canRenderToMRT(): boolean;
  105033. /**
  105034. * Defines the detail map parameters for the material.
  105035. */
  105036. readonly detailMap: DetailMapConfiguration;
  105037. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105038. protected _worldViewProjectionMatrix: Matrix;
  105039. protected _globalAmbientColor: Color3;
  105040. protected _useLogarithmicDepth: boolean;
  105041. protected _rebuildInParallel: boolean;
  105042. /**
  105043. * Instantiates a new standard material.
  105044. * This is the default material used in Babylon. It is the best trade off between quality
  105045. * and performances.
  105046. * @see https://doc.babylonjs.com/babylon101/materials
  105047. * @param name Define the name of the material in the scene
  105048. * @param scene Define the scene the material belong to
  105049. */
  105050. constructor(name: string, scene: Scene);
  105051. /**
  105052. * Gets a boolean indicating that current material needs to register RTT
  105053. */
  105054. get hasRenderTargetTextures(): boolean;
  105055. /**
  105056. * Gets the current class name of the material e.g. "StandardMaterial"
  105057. * Mainly use in serialization.
  105058. * @returns the class name
  105059. */
  105060. getClassName(): string;
  105061. /**
  105062. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105063. * You can try switching to logarithmic depth.
  105064. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105065. */
  105066. get useLogarithmicDepth(): boolean;
  105067. set useLogarithmicDepth(value: boolean);
  105068. /**
  105069. * Specifies if the material will require alpha blending
  105070. * @returns a boolean specifying if alpha blending is needed
  105071. */
  105072. needAlphaBlending(): boolean;
  105073. /**
  105074. * Specifies if this material should be rendered in alpha test mode
  105075. * @returns a boolean specifying if an alpha test is needed.
  105076. */
  105077. needAlphaTesting(): boolean;
  105078. /**
  105079. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105080. */
  105081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105082. /**
  105083. * Specifies whether or not there is a usable alpha channel for transparency.
  105084. */
  105085. protected _hasAlphaChannel(): boolean;
  105086. /**
  105087. * Get the texture used for alpha test purpose.
  105088. * @returns the diffuse texture in case of the standard material.
  105089. */
  105090. getAlphaTestTexture(): Nullable<BaseTexture>;
  105091. /**
  105092. * Get if the submesh is ready to be used and all its information available.
  105093. * Child classes can use it to update shaders
  105094. * @param mesh defines the mesh to check
  105095. * @param subMesh defines which submesh to check
  105096. * @param useInstances specifies that instances should be used
  105097. * @returns a boolean indicating that the submesh is ready or not
  105098. */
  105099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105100. /**
  105101. * Builds the material UBO layouts.
  105102. * Used internally during the effect preparation.
  105103. */
  105104. buildUniformLayout(): void;
  105105. /**
  105106. * Unbinds the material from the mesh
  105107. */
  105108. unbind(): void;
  105109. /**
  105110. * Binds the submesh to this material by preparing the effect and shader to draw
  105111. * @param world defines the world transformation matrix
  105112. * @param mesh defines the mesh containing the submesh
  105113. * @param subMesh defines the submesh to bind the material to
  105114. */
  105115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105116. /**
  105117. * Get the list of animatables in the material.
  105118. * @returns the list of animatables object used in the material
  105119. */
  105120. getAnimatables(): IAnimatable[];
  105121. /**
  105122. * Gets the active textures from the material
  105123. * @returns an array of textures
  105124. */
  105125. getActiveTextures(): BaseTexture[];
  105126. /**
  105127. * Specifies if the material uses a texture
  105128. * @param texture defines the texture to check against the material
  105129. * @returns a boolean specifying if the material uses the texture
  105130. */
  105131. hasTexture(texture: BaseTexture): boolean;
  105132. /**
  105133. * Disposes the material
  105134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105136. */
  105137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105138. /**
  105139. * Makes a duplicate of the material, and gives it a new name
  105140. * @param name defines the new name for the duplicated material
  105141. * @returns the cloned material
  105142. */
  105143. clone(name: string): StandardMaterial;
  105144. /**
  105145. * Serializes this material in a JSON representation
  105146. * @returns the serialized material object
  105147. */
  105148. serialize(): any;
  105149. /**
  105150. * Creates a standard material from parsed material data
  105151. * @param source defines the JSON representation of the material
  105152. * @param scene defines the hosting scene
  105153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105154. * @returns a new standard material
  105155. */
  105156. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105157. /**
  105158. * Are diffuse textures enabled in the application.
  105159. */
  105160. static get DiffuseTextureEnabled(): boolean;
  105161. static set DiffuseTextureEnabled(value: boolean);
  105162. /**
  105163. * Are detail textures enabled in the application.
  105164. */
  105165. static get DetailTextureEnabled(): boolean;
  105166. static set DetailTextureEnabled(value: boolean);
  105167. /**
  105168. * Are ambient textures enabled in the application.
  105169. */
  105170. static get AmbientTextureEnabled(): boolean;
  105171. static set AmbientTextureEnabled(value: boolean);
  105172. /**
  105173. * Are opacity textures enabled in the application.
  105174. */
  105175. static get OpacityTextureEnabled(): boolean;
  105176. static set OpacityTextureEnabled(value: boolean);
  105177. /**
  105178. * Are reflection textures enabled in the application.
  105179. */
  105180. static get ReflectionTextureEnabled(): boolean;
  105181. static set ReflectionTextureEnabled(value: boolean);
  105182. /**
  105183. * Are emissive textures enabled in the application.
  105184. */
  105185. static get EmissiveTextureEnabled(): boolean;
  105186. static set EmissiveTextureEnabled(value: boolean);
  105187. /**
  105188. * Are specular textures enabled in the application.
  105189. */
  105190. static get SpecularTextureEnabled(): boolean;
  105191. static set SpecularTextureEnabled(value: boolean);
  105192. /**
  105193. * Are bump textures enabled in the application.
  105194. */
  105195. static get BumpTextureEnabled(): boolean;
  105196. static set BumpTextureEnabled(value: boolean);
  105197. /**
  105198. * Are lightmap textures enabled in the application.
  105199. */
  105200. static get LightmapTextureEnabled(): boolean;
  105201. static set LightmapTextureEnabled(value: boolean);
  105202. /**
  105203. * Are refraction textures enabled in the application.
  105204. */
  105205. static get RefractionTextureEnabled(): boolean;
  105206. static set RefractionTextureEnabled(value: boolean);
  105207. /**
  105208. * Are color grading textures enabled in the application.
  105209. */
  105210. static get ColorGradingTextureEnabled(): boolean;
  105211. static set ColorGradingTextureEnabled(value: boolean);
  105212. /**
  105213. * Are fresnels enabled in the application.
  105214. */
  105215. static get FresnelEnabled(): boolean;
  105216. static set FresnelEnabled(value: boolean);
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /** @hidden */
  105221. export var rgbdDecodePixelShader: {
  105222. name: string;
  105223. shader: string;
  105224. };
  105225. }
  105226. declare module BABYLON {
  105227. /**
  105228. * Class used to host RGBD texture specific utilities
  105229. */
  105230. export class RGBDTextureTools {
  105231. /**
  105232. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105233. * @param texture the texture to expand.
  105234. */
  105235. static ExpandRGBDTexture(texture: Texture): void;
  105236. }
  105237. }
  105238. declare module BABYLON {
  105239. /**
  105240. * Class used to host texture specific utilities
  105241. */
  105242. export class BRDFTextureTools {
  105243. /**
  105244. * Prevents texture cache collision
  105245. */
  105246. private static _instanceNumber;
  105247. /**
  105248. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105249. * @param scene defines the hosting scene
  105250. * @returns the environment BRDF texture
  105251. */
  105252. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105253. private static _environmentBRDFBase64Texture;
  105254. }
  105255. }
  105256. declare module BABYLON {
  105257. /**
  105258. * @hidden
  105259. */
  105260. export interface IMaterialClearCoatDefines {
  105261. CLEARCOAT: boolean;
  105262. CLEARCOAT_DEFAULTIOR: boolean;
  105263. CLEARCOAT_TEXTURE: boolean;
  105264. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105265. CLEARCOAT_TEXTUREDIRECTUV: number;
  105266. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105267. CLEARCOAT_BUMP: boolean;
  105268. CLEARCOAT_BUMPDIRECTUV: number;
  105269. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105270. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105271. CLEARCOAT_REMAP_F0: boolean;
  105272. CLEARCOAT_TINT: boolean;
  105273. CLEARCOAT_TINT_TEXTURE: boolean;
  105274. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105275. /** @hidden */
  105276. _areTexturesDirty: boolean;
  105277. }
  105278. /**
  105279. * Define the code related to the clear coat parameters of the pbr material.
  105280. */
  105281. export class PBRClearCoatConfiguration {
  105282. /**
  105283. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105284. * The default fits with a polyurethane material.
  105285. */
  105286. private static readonly _DefaultIndexOfRefraction;
  105287. private _isEnabled;
  105288. /**
  105289. * Defines if the clear coat is enabled in the material.
  105290. */
  105291. isEnabled: boolean;
  105292. /**
  105293. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105294. */
  105295. intensity: number;
  105296. /**
  105297. * Defines the clear coat layer roughness.
  105298. */
  105299. roughness: number;
  105300. private _indexOfRefraction;
  105301. /**
  105302. * Defines the index of refraction of the clear coat.
  105303. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105304. * The default fits with a polyurethane material.
  105305. * Changing the default value is more performance intensive.
  105306. */
  105307. indexOfRefraction: number;
  105308. private _texture;
  105309. /**
  105310. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105311. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105312. * if textureRoughness is not empty, else no texture roughness is used
  105313. */
  105314. texture: Nullable<BaseTexture>;
  105315. private _useRoughnessFromMainTexture;
  105316. /**
  105317. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105318. * If false, the green channel from textureRoughness is used for roughness
  105319. */
  105320. useRoughnessFromMainTexture: boolean;
  105321. private _textureRoughness;
  105322. /**
  105323. * Stores the clear coat roughness in a texture (green channel)
  105324. * Not used if useRoughnessFromMainTexture is true
  105325. */
  105326. textureRoughness: Nullable<BaseTexture>;
  105327. private _remapF0OnInterfaceChange;
  105328. /**
  105329. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105330. */
  105331. remapF0OnInterfaceChange: boolean;
  105332. private _bumpTexture;
  105333. /**
  105334. * Define the clear coat specific bump texture.
  105335. */
  105336. bumpTexture: Nullable<BaseTexture>;
  105337. private _isTintEnabled;
  105338. /**
  105339. * Defines if the clear coat tint is enabled in the material.
  105340. */
  105341. isTintEnabled: boolean;
  105342. /**
  105343. * Defines the clear coat tint of the material.
  105344. * This is only use if tint is enabled
  105345. */
  105346. tintColor: Color3;
  105347. /**
  105348. * Defines the distance at which the tint color should be found in the
  105349. * clear coat media.
  105350. * This is only use if tint is enabled
  105351. */
  105352. tintColorAtDistance: number;
  105353. /**
  105354. * Defines the clear coat layer thickness.
  105355. * This is only use if tint is enabled
  105356. */
  105357. tintThickness: number;
  105358. private _tintTexture;
  105359. /**
  105360. * Stores the clear tint values in a texture.
  105361. * rgb is tint
  105362. * a is a thickness factor
  105363. */
  105364. tintTexture: Nullable<BaseTexture>;
  105365. /** @hidden */
  105366. private _internalMarkAllSubMeshesAsTexturesDirty;
  105367. /** @hidden */
  105368. _markAllSubMeshesAsTexturesDirty(): void;
  105369. /**
  105370. * Instantiate a new istance of clear coat configuration.
  105371. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105372. */
  105373. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105374. /**
  105375. * Gets wehter the submesh is ready to be used or not.
  105376. * @param defines the list of "defines" to update.
  105377. * @param scene defines the scene the material belongs to.
  105378. * @param engine defines the engine the material belongs to.
  105379. * @param disableBumpMap defines wether the material disables bump or not.
  105380. * @returns - boolean indicating that the submesh is ready or not.
  105381. */
  105382. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105383. /**
  105384. * Checks to see if a texture is used in the material.
  105385. * @param defines the list of "defines" to update.
  105386. * @param scene defines the scene to the material belongs to.
  105387. */
  105388. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105389. /**
  105390. * Binds the material data.
  105391. * @param uniformBuffer defines the Uniform buffer to fill in.
  105392. * @param scene defines the scene the material belongs to.
  105393. * @param engine defines the engine the material belongs to.
  105394. * @param disableBumpMap defines wether the material disables bump or not.
  105395. * @param isFrozen defines wether the material is frozen or not.
  105396. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105397. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105398. * @param subMesh the submesh to bind data for
  105399. */
  105400. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105401. /**
  105402. * Checks to see if a texture is used in the material.
  105403. * @param texture - Base texture to use.
  105404. * @returns - Boolean specifying if a texture is used in the material.
  105405. */
  105406. hasTexture(texture: BaseTexture): boolean;
  105407. /**
  105408. * Returns an array of the actively used textures.
  105409. * @param activeTextures Array of BaseTextures
  105410. */
  105411. getActiveTextures(activeTextures: BaseTexture[]): void;
  105412. /**
  105413. * Returns the animatable textures.
  105414. * @param animatables Array of animatable textures.
  105415. */
  105416. getAnimatables(animatables: IAnimatable[]): void;
  105417. /**
  105418. * Disposes the resources of the material.
  105419. * @param forceDisposeTextures - Forces the disposal of all textures.
  105420. */
  105421. dispose(forceDisposeTextures?: boolean): void;
  105422. /**
  105423. * Get the current class name of the texture useful for serialization or dynamic coding.
  105424. * @returns "PBRClearCoatConfiguration"
  105425. */
  105426. getClassName(): string;
  105427. /**
  105428. * Add fallbacks to the effect fallbacks list.
  105429. * @param defines defines the Base texture to use.
  105430. * @param fallbacks defines the current fallback list.
  105431. * @param currentRank defines the current fallback rank.
  105432. * @returns the new fallback rank.
  105433. */
  105434. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105435. /**
  105436. * Add the required uniforms to the current list.
  105437. * @param uniforms defines the current uniform list.
  105438. */
  105439. static AddUniforms(uniforms: string[]): void;
  105440. /**
  105441. * Add the required samplers to the current list.
  105442. * @param samplers defines the current sampler list.
  105443. */
  105444. static AddSamplers(samplers: string[]): void;
  105445. /**
  105446. * Add the required uniforms to the current buffer.
  105447. * @param uniformBuffer defines the current uniform buffer.
  105448. */
  105449. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105450. /**
  105451. * Makes a duplicate of the current configuration into another one.
  105452. * @param clearCoatConfiguration define the config where to copy the info
  105453. */
  105454. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105455. /**
  105456. * Serializes this clear coat configuration.
  105457. * @returns - An object with the serialized config.
  105458. */
  105459. serialize(): any;
  105460. /**
  105461. * Parses a anisotropy Configuration from a serialized object.
  105462. * @param source - Serialized object.
  105463. * @param scene Defines the scene we are parsing for
  105464. * @param rootUrl Defines the rootUrl to load from
  105465. */
  105466. parse(source: any, scene: Scene, rootUrl: string): void;
  105467. }
  105468. }
  105469. declare module BABYLON {
  105470. /**
  105471. * @hidden
  105472. */
  105473. export interface IMaterialAnisotropicDefines {
  105474. ANISOTROPIC: boolean;
  105475. ANISOTROPIC_TEXTURE: boolean;
  105476. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105477. MAINUV1: boolean;
  105478. _areTexturesDirty: boolean;
  105479. _needUVs: boolean;
  105480. }
  105481. /**
  105482. * Define the code related to the anisotropic parameters of the pbr material.
  105483. */
  105484. export class PBRAnisotropicConfiguration {
  105485. private _isEnabled;
  105486. /**
  105487. * Defines if the anisotropy is enabled in the material.
  105488. */
  105489. isEnabled: boolean;
  105490. /**
  105491. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105492. */
  105493. intensity: number;
  105494. /**
  105495. * Defines if the effect is along the tangents, bitangents or in between.
  105496. * By default, the effect is "strectching" the highlights along the tangents.
  105497. */
  105498. direction: Vector2;
  105499. private _texture;
  105500. /**
  105501. * Stores the anisotropy values in a texture.
  105502. * rg is direction (like normal from -1 to 1)
  105503. * b is a intensity
  105504. */
  105505. texture: Nullable<BaseTexture>;
  105506. /** @hidden */
  105507. private _internalMarkAllSubMeshesAsTexturesDirty;
  105508. /** @hidden */
  105509. _markAllSubMeshesAsTexturesDirty(): void;
  105510. /**
  105511. * Instantiate a new istance of anisotropy configuration.
  105512. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105513. */
  105514. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105515. /**
  105516. * Specifies that the submesh is ready to be used.
  105517. * @param defines the list of "defines" to update.
  105518. * @param scene defines the scene the material belongs to.
  105519. * @returns - boolean indicating that the submesh is ready or not.
  105520. */
  105521. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105522. /**
  105523. * Checks to see if a texture is used in the material.
  105524. * @param defines the list of "defines" to update.
  105525. * @param mesh the mesh we are preparing the defines for.
  105526. * @param scene defines the scene the material belongs to.
  105527. */
  105528. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105529. /**
  105530. * Binds the material data.
  105531. * @param uniformBuffer defines the Uniform buffer to fill in.
  105532. * @param scene defines the scene the material belongs to.
  105533. * @param isFrozen defines wether the material is frozen or not.
  105534. */
  105535. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105536. /**
  105537. * Checks to see if a texture is used in the material.
  105538. * @param texture - Base texture to use.
  105539. * @returns - Boolean specifying if a texture is used in the material.
  105540. */
  105541. hasTexture(texture: BaseTexture): boolean;
  105542. /**
  105543. * Returns an array of the actively used textures.
  105544. * @param activeTextures Array of BaseTextures
  105545. */
  105546. getActiveTextures(activeTextures: BaseTexture[]): void;
  105547. /**
  105548. * Returns the animatable textures.
  105549. * @param animatables Array of animatable textures.
  105550. */
  105551. getAnimatables(animatables: IAnimatable[]): void;
  105552. /**
  105553. * Disposes the resources of the material.
  105554. * @param forceDisposeTextures - Forces the disposal of all textures.
  105555. */
  105556. dispose(forceDisposeTextures?: boolean): void;
  105557. /**
  105558. * Get the current class name of the texture useful for serialization or dynamic coding.
  105559. * @returns "PBRAnisotropicConfiguration"
  105560. */
  105561. getClassName(): string;
  105562. /**
  105563. * Add fallbacks to the effect fallbacks list.
  105564. * @param defines defines the Base texture to use.
  105565. * @param fallbacks defines the current fallback list.
  105566. * @param currentRank defines the current fallback rank.
  105567. * @returns the new fallback rank.
  105568. */
  105569. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105570. /**
  105571. * Add the required uniforms to the current list.
  105572. * @param uniforms defines the current uniform list.
  105573. */
  105574. static AddUniforms(uniforms: string[]): void;
  105575. /**
  105576. * Add the required uniforms to the current buffer.
  105577. * @param uniformBuffer defines the current uniform buffer.
  105578. */
  105579. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105580. /**
  105581. * Add the required samplers to the current list.
  105582. * @param samplers defines the current sampler list.
  105583. */
  105584. static AddSamplers(samplers: string[]): void;
  105585. /**
  105586. * Makes a duplicate of the current configuration into another one.
  105587. * @param anisotropicConfiguration define the config where to copy the info
  105588. */
  105589. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105590. /**
  105591. * Serializes this anisotropy configuration.
  105592. * @returns - An object with the serialized config.
  105593. */
  105594. serialize(): any;
  105595. /**
  105596. * Parses a anisotropy Configuration from a serialized object.
  105597. * @param source - Serialized object.
  105598. * @param scene Defines the scene we are parsing for
  105599. * @param rootUrl Defines the rootUrl to load from
  105600. */
  105601. parse(source: any, scene: Scene, rootUrl: string): void;
  105602. }
  105603. }
  105604. declare module BABYLON {
  105605. /**
  105606. * @hidden
  105607. */
  105608. export interface IMaterialBRDFDefines {
  105609. BRDF_V_HEIGHT_CORRELATED: boolean;
  105610. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105611. SPHERICAL_HARMONICS: boolean;
  105612. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105613. /** @hidden */
  105614. _areMiscDirty: boolean;
  105615. }
  105616. /**
  105617. * Define the code related to the BRDF parameters of the pbr material.
  105618. */
  105619. export class PBRBRDFConfiguration {
  105620. /**
  105621. * Default value used for the energy conservation.
  105622. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105623. */
  105624. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105625. /**
  105626. * Default value used for the Smith Visibility Height Correlated mode.
  105627. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105628. */
  105629. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105630. /**
  105631. * Default value used for the IBL diffuse part.
  105632. * This can help switching back to the polynomials mode globally which is a tiny bit
  105633. * less GPU intensive at the drawback of a lower quality.
  105634. */
  105635. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105636. /**
  105637. * Default value used for activating energy conservation for the specular workflow.
  105638. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105639. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105640. */
  105641. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105642. private _useEnergyConservation;
  105643. /**
  105644. * Defines if the material uses energy conservation.
  105645. */
  105646. useEnergyConservation: boolean;
  105647. private _useSmithVisibilityHeightCorrelated;
  105648. /**
  105649. * LEGACY Mode set to false
  105650. * Defines if the material uses height smith correlated visibility term.
  105651. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105652. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105653. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105654. * Not relying on height correlated will also disable energy conservation.
  105655. */
  105656. useSmithVisibilityHeightCorrelated: boolean;
  105657. private _useSphericalHarmonics;
  105658. /**
  105659. * LEGACY Mode set to false
  105660. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105661. * diffuse part of the IBL.
  105662. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105663. * to the ground truth.
  105664. */
  105665. useSphericalHarmonics: boolean;
  105666. private _useSpecularGlossinessInputEnergyConservation;
  105667. /**
  105668. * Defines if the material uses energy conservation, when the specular workflow is active.
  105669. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105670. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105671. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105672. */
  105673. useSpecularGlossinessInputEnergyConservation: boolean;
  105674. /** @hidden */
  105675. private _internalMarkAllSubMeshesAsMiscDirty;
  105676. /** @hidden */
  105677. _markAllSubMeshesAsMiscDirty(): void;
  105678. /**
  105679. * Instantiate a new istance of clear coat configuration.
  105680. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105681. */
  105682. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105683. /**
  105684. * Checks to see if a texture is used in the material.
  105685. * @param defines the list of "defines" to update.
  105686. */
  105687. prepareDefines(defines: IMaterialBRDFDefines): void;
  105688. /**
  105689. * Get the current class name of the texture useful for serialization or dynamic coding.
  105690. * @returns "PBRClearCoatConfiguration"
  105691. */
  105692. getClassName(): string;
  105693. /**
  105694. * Makes a duplicate of the current configuration into another one.
  105695. * @param brdfConfiguration define the config where to copy the info
  105696. */
  105697. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105698. /**
  105699. * Serializes this BRDF configuration.
  105700. * @returns - An object with the serialized config.
  105701. */
  105702. serialize(): any;
  105703. /**
  105704. * Parses a anisotropy Configuration from a serialized object.
  105705. * @param source - Serialized object.
  105706. * @param scene Defines the scene we are parsing for
  105707. * @param rootUrl Defines the rootUrl to load from
  105708. */
  105709. parse(source: any, scene: Scene, rootUrl: string): void;
  105710. }
  105711. }
  105712. declare module BABYLON {
  105713. /**
  105714. * @hidden
  105715. */
  105716. export interface IMaterialSheenDefines {
  105717. SHEEN: boolean;
  105718. SHEEN_TEXTURE: boolean;
  105719. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105720. SHEEN_TEXTUREDIRECTUV: number;
  105721. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105722. SHEEN_LINKWITHALBEDO: boolean;
  105723. SHEEN_ROUGHNESS: boolean;
  105724. SHEEN_ALBEDOSCALING: boolean;
  105725. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105726. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105727. /** @hidden */
  105728. _areTexturesDirty: boolean;
  105729. }
  105730. /**
  105731. * Define the code related to the Sheen parameters of the pbr material.
  105732. */
  105733. export class PBRSheenConfiguration {
  105734. private _isEnabled;
  105735. /**
  105736. * Defines if the material uses sheen.
  105737. */
  105738. isEnabled: boolean;
  105739. private _linkSheenWithAlbedo;
  105740. /**
  105741. * Defines if the sheen is linked to the sheen color.
  105742. */
  105743. linkSheenWithAlbedo: boolean;
  105744. /**
  105745. * Defines the sheen intensity.
  105746. */
  105747. intensity: number;
  105748. /**
  105749. * Defines the sheen color.
  105750. */
  105751. color: Color3;
  105752. private _texture;
  105753. /**
  105754. * Stores the sheen tint values in a texture.
  105755. * rgb is tint
  105756. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  105757. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105758. */
  105759. texture: Nullable<BaseTexture>;
  105760. private _useRoughnessFromMainTexture;
  105761. /**
  105762. * Indicates that the alpha channel of the texture property will be used for roughness.
  105763. * Has no effect if the roughness (and texture!) property is not defined
  105764. */
  105765. useRoughnessFromMainTexture: boolean;
  105766. private _roughness;
  105767. /**
  105768. * Defines the sheen roughness.
  105769. * It is not taken into account if linkSheenWithAlbedo is true.
  105770. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105771. */
  105772. roughness: Nullable<number>;
  105773. private _textureRoughness;
  105774. /**
  105775. * Stores the sheen roughness in a texture.
  105776. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105777. */
  105778. textureRoughness: Nullable<BaseTexture>;
  105779. private _albedoScaling;
  105780. /**
  105781. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105782. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105783. * making it easier to setup and tweak the effect
  105784. */
  105785. albedoScaling: boolean;
  105786. /** @hidden */
  105787. private _internalMarkAllSubMeshesAsTexturesDirty;
  105788. /** @hidden */
  105789. _markAllSubMeshesAsTexturesDirty(): void;
  105790. /**
  105791. * Instantiate a new istance of clear coat configuration.
  105792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105793. */
  105794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105795. /**
  105796. * Specifies that the submesh is ready to be used.
  105797. * @param defines the list of "defines" to update.
  105798. * @param scene defines the scene the material belongs to.
  105799. * @returns - boolean indicating that the submesh is ready or not.
  105800. */
  105801. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105802. /**
  105803. * Checks to see if a texture is used in the material.
  105804. * @param defines the list of "defines" to update.
  105805. * @param scene defines the scene the material belongs to.
  105806. */
  105807. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105808. /**
  105809. * Binds the material data.
  105810. * @param uniformBuffer defines the Uniform buffer to fill in.
  105811. * @param scene defines the scene the material belongs to.
  105812. * @param isFrozen defines wether the material is frozen or not.
  105813. * @param subMesh the submesh to bind data for
  105814. */
  105815. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105816. /**
  105817. * Checks to see if a texture is used in the material.
  105818. * @param texture - Base texture to use.
  105819. * @returns - Boolean specifying if a texture is used in the material.
  105820. */
  105821. hasTexture(texture: BaseTexture): boolean;
  105822. /**
  105823. * Returns an array of the actively used textures.
  105824. * @param activeTextures Array of BaseTextures
  105825. */
  105826. getActiveTextures(activeTextures: BaseTexture[]): void;
  105827. /**
  105828. * Returns the animatable textures.
  105829. * @param animatables Array of animatable textures.
  105830. */
  105831. getAnimatables(animatables: IAnimatable[]): void;
  105832. /**
  105833. * Disposes the resources of the material.
  105834. * @param forceDisposeTextures - Forces the disposal of all textures.
  105835. */
  105836. dispose(forceDisposeTextures?: boolean): void;
  105837. /**
  105838. * Get the current class name of the texture useful for serialization or dynamic coding.
  105839. * @returns "PBRSheenConfiguration"
  105840. */
  105841. getClassName(): string;
  105842. /**
  105843. * Add fallbacks to the effect fallbacks list.
  105844. * @param defines defines the Base texture to use.
  105845. * @param fallbacks defines the current fallback list.
  105846. * @param currentRank defines the current fallback rank.
  105847. * @returns the new fallback rank.
  105848. */
  105849. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105850. /**
  105851. * Add the required uniforms to the current list.
  105852. * @param uniforms defines the current uniform list.
  105853. */
  105854. static AddUniforms(uniforms: string[]): void;
  105855. /**
  105856. * Add the required uniforms to the current buffer.
  105857. * @param uniformBuffer defines the current uniform buffer.
  105858. */
  105859. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105860. /**
  105861. * Add the required samplers to the current list.
  105862. * @param samplers defines the current sampler list.
  105863. */
  105864. static AddSamplers(samplers: string[]): void;
  105865. /**
  105866. * Makes a duplicate of the current configuration into another one.
  105867. * @param sheenConfiguration define the config where to copy the info
  105868. */
  105869. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105870. /**
  105871. * Serializes this BRDF configuration.
  105872. * @returns - An object with the serialized config.
  105873. */
  105874. serialize(): any;
  105875. /**
  105876. * Parses a anisotropy Configuration from a serialized object.
  105877. * @param source - Serialized object.
  105878. * @param scene Defines the scene we are parsing for
  105879. * @param rootUrl Defines the rootUrl to load from
  105880. */
  105881. parse(source: any, scene: Scene, rootUrl: string): void;
  105882. }
  105883. }
  105884. declare module BABYLON {
  105885. /**
  105886. * @hidden
  105887. */
  105888. export interface IMaterialSubSurfaceDefines {
  105889. SUBSURFACE: boolean;
  105890. SS_REFRACTION: boolean;
  105891. SS_TRANSLUCENCY: boolean;
  105892. SS_SCATTERING: boolean;
  105893. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105894. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105895. SS_REFRACTIONMAP_3D: boolean;
  105896. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105897. SS_LODINREFRACTIONALPHA: boolean;
  105898. SS_GAMMAREFRACTION: boolean;
  105899. SS_RGBDREFRACTION: boolean;
  105900. SS_LINEARSPECULARREFRACTION: boolean;
  105901. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105902. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105903. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105904. /** @hidden */
  105905. _areTexturesDirty: boolean;
  105906. }
  105907. /**
  105908. * Define the code related to the sub surface parameters of the pbr material.
  105909. */
  105910. export class PBRSubSurfaceConfiguration {
  105911. private _isRefractionEnabled;
  105912. /**
  105913. * Defines if the refraction is enabled in the material.
  105914. */
  105915. isRefractionEnabled: boolean;
  105916. private _isTranslucencyEnabled;
  105917. /**
  105918. * Defines if the translucency is enabled in the material.
  105919. */
  105920. isTranslucencyEnabled: boolean;
  105921. private _isScatteringEnabled;
  105922. /**
  105923. * Defines if the sub surface scattering is enabled in the material.
  105924. */
  105925. isScatteringEnabled: boolean;
  105926. private _scatteringDiffusionProfileIndex;
  105927. /**
  105928. * Diffusion profile for subsurface scattering.
  105929. * Useful for better scattering in the skins or foliages.
  105930. */
  105931. get scatteringDiffusionProfile(): Nullable<Color3>;
  105932. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105933. /**
  105934. * Defines the refraction intensity of the material.
  105935. * The refraction when enabled replaces the Diffuse part of the material.
  105936. * The intensity helps transitionning between diffuse and refraction.
  105937. */
  105938. refractionIntensity: number;
  105939. /**
  105940. * Defines the translucency intensity of the material.
  105941. * When translucency has been enabled, this defines how much of the "translucency"
  105942. * is addded to the diffuse part of the material.
  105943. */
  105944. translucencyIntensity: number;
  105945. /**
  105946. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105947. */
  105948. useAlbedoToTintRefraction: boolean;
  105949. private _thicknessTexture;
  105950. /**
  105951. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105952. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105953. * 0 would mean minimumThickness
  105954. * 1 would mean maximumThickness
  105955. * The other channels might be use as a mask to vary the different effects intensity.
  105956. */
  105957. thicknessTexture: Nullable<BaseTexture>;
  105958. private _refractionTexture;
  105959. /**
  105960. * Defines the texture to use for refraction.
  105961. */
  105962. refractionTexture: Nullable<BaseTexture>;
  105963. private _indexOfRefraction;
  105964. /**
  105965. * Index of refraction of the material base layer.
  105966. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105967. *
  105968. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105969. *
  105970. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105971. */
  105972. indexOfRefraction: number;
  105973. private _volumeIndexOfRefraction;
  105974. /**
  105975. * Index of refraction of the material's volume.
  105976. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105977. *
  105978. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105979. * the volume will use the same IOR as the surface.
  105980. */
  105981. get volumeIndexOfRefraction(): number;
  105982. set volumeIndexOfRefraction(value: number);
  105983. private _invertRefractionY;
  105984. /**
  105985. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105986. */
  105987. invertRefractionY: boolean;
  105988. private _linkRefractionWithTransparency;
  105989. /**
  105990. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105991. * Materials half opaque for instance using refraction could benefit from this control.
  105992. */
  105993. linkRefractionWithTransparency: boolean;
  105994. /**
  105995. * Defines the minimum thickness stored in the thickness map.
  105996. * If no thickness map is defined, this value will be used to simulate thickness.
  105997. */
  105998. minimumThickness: number;
  105999. /**
  106000. * Defines the maximum thickness stored in the thickness map.
  106001. */
  106002. maximumThickness: number;
  106003. /**
  106004. * Defines the volume tint of the material.
  106005. * This is used for both translucency and scattering.
  106006. */
  106007. tintColor: Color3;
  106008. /**
  106009. * Defines the distance at which the tint color should be found in the media.
  106010. * This is used for refraction only.
  106011. */
  106012. tintColorAtDistance: number;
  106013. /**
  106014. * Defines how far each channel transmit through the media.
  106015. * It is defined as a color to simplify it selection.
  106016. */
  106017. diffusionDistance: Color3;
  106018. private _useMaskFromThicknessTexture;
  106019. /**
  106020. * Stores the intensity of the different subsurface effects in the thickness texture.
  106021. * * the green channel is the translucency intensity.
  106022. * * the blue channel is the scattering intensity.
  106023. * * the alpha channel is the refraction intensity.
  106024. */
  106025. useMaskFromThicknessTexture: boolean;
  106026. private _scene;
  106027. /** @hidden */
  106028. private _internalMarkAllSubMeshesAsTexturesDirty;
  106029. private _internalMarkScenePrePassDirty;
  106030. /** @hidden */
  106031. _markAllSubMeshesAsTexturesDirty(): void;
  106032. /** @hidden */
  106033. _markScenePrePassDirty(): void;
  106034. /**
  106035. * Instantiate a new istance of sub surface configuration.
  106036. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106037. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106038. * @param scene The scene
  106039. */
  106040. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106041. /**
  106042. * Gets wehter the submesh is ready to be used or not.
  106043. * @param defines the list of "defines" to update.
  106044. * @param scene defines the scene the material belongs to.
  106045. * @returns - boolean indicating that the submesh is ready or not.
  106046. */
  106047. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106048. /**
  106049. * Checks to see if a texture is used in the material.
  106050. * @param defines the list of "defines" to update.
  106051. * @param scene defines the scene to the material belongs to.
  106052. */
  106053. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106054. /**
  106055. * Binds the material data.
  106056. * @param uniformBuffer defines the Uniform buffer to fill in.
  106057. * @param scene defines the scene the material belongs to.
  106058. * @param engine defines the engine the material belongs to.
  106059. * @param isFrozen defines whether the material is frozen or not.
  106060. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106061. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106062. */
  106063. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106064. /**
  106065. * Unbinds the material from the mesh.
  106066. * @param activeEffect defines the effect that should be unbound from.
  106067. * @returns true if unbound, otherwise false
  106068. */
  106069. unbind(activeEffect: Effect): boolean;
  106070. /**
  106071. * Returns the texture used for refraction or null if none is used.
  106072. * @param scene defines the scene the material belongs to.
  106073. * @returns - Refraction texture if present. If no refraction texture and refraction
  106074. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106075. */
  106076. private _getRefractionTexture;
  106077. /**
  106078. * Returns true if alpha blending should be disabled.
  106079. */
  106080. get disableAlphaBlending(): boolean;
  106081. /**
  106082. * Fills the list of render target textures.
  106083. * @param renderTargets the list of render targets to update
  106084. */
  106085. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106086. /**
  106087. * Checks to see if a texture is used in the material.
  106088. * @param texture - Base texture to use.
  106089. * @returns - Boolean specifying if a texture is used in the material.
  106090. */
  106091. hasTexture(texture: BaseTexture): boolean;
  106092. /**
  106093. * Gets a boolean indicating that current material needs to register RTT
  106094. * @returns true if this uses a render target otherwise false.
  106095. */
  106096. hasRenderTargetTextures(): boolean;
  106097. /**
  106098. * Returns an array of the actively used textures.
  106099. * @param activeTextures Array of BaseTextures
  106100. */
  106101. getActiveTextures(activeTextures: BaseTexture[]): void;
  106102. /**
  106103. * Returns the animatable textures.
  106104. * @param animatables Array of animatable textures.
  106105. */
  106106. getAnimatables(animatables: IAnimatable[]): void;
  106107. /**
  106108. * Disposes the resources of the material.
  106109. * @param forceDisposeTextures - Forces the disposal of all textures.
  106110. */
  106111. dispose(forceDisposeTextures?: boolean): void;
  106112. /**
  106113. * Get the current class name of the texture useful for serialization or dynamic coding.
  106114. * @returns "PBRSubSurfaceConfiguration"
  106115. */
  106116. getClassName(): string;
  106117. /**
  106118. * Add fallbacks to the effect fallbacks list.
  106119. * @param defines defines the Base texture to use.
  106120. * @param fallbacks defines the current fallback list.
  106121. * @param currentRank defines the current fallback rank.
  106122. * @returns the new fallback rank.
  106123. */
  106124. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106125. /**
  106126. * Add the required uniforms to the current list.
  106127. * @param uniforms defines the current uniform list.
  106128. */
  106129. static AddUniforms(uniforms: string[]): void;
  106130. /**
  106131. * Add the required samplers to the current list.
  106132. * @param samplers defines the current sampler list.
  106133. */
  106134. static AddSamplers(samplers: string[]): void;
  106135. /**
  106136. * Add the required uniforms to the current buffer.
  106137. * @param uniformBuffer defines the current uniform buffer.
  106138. */
  106139. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106140. /**
  106141. * Makes a duplicate of the current configuration into another one.
  106142. * @param configuration define the config where to copy the info
  106143. */
  106144. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106145. /**
  106146. * Serializes this Sub Surface configuration.
  106147. * @returns - An object with the serialized config.
  106148. */
  106149. serialize(): any;
  106150. /**
  106151. * Parses a anisotropy Configuration from a serialized object.
  106152. * @param source - Serialized object.
  106153. * @param scene Defines the scene we are parsing for
  106154. * @param rootUrl Defines the rootUrl to load from
  106155. */
  106156. parse(source: any, scene: Scene, rootUrl: string): void;
  106157. }
  106158. }
  106159. declare module BABYLON {
  106160. /**
  106161. * Class representing spherical harmonics coefficients to the 3rd degree
  106162. */
  106163. export class SphericalHarmonics {
  106164. /**
  106165. * Defines whether or not the harmonics have been prescaled for rendering.
  106166. */
  106167. preScaled: boolean;
  106168. /**
  106169. * The l0,0 coefficients of the spherical harmonics
  106170. */
  106171. l00: Vector3;
  106172. /**
  106173. * The l1,-1 coefficients of the spherical harmonics
  106174. */
  106175. l1_1: Vector3;
  106176. /**
  106177. * The l1,0 coefficients of the spherical harmonics
  106178. */
  106179. l10: Vector3;
  106180. /**
  106181. * The l1,1 coefficients of the spherical harmonics
  106182. */
  106183. l11: Vector3;
  106184. /**
  106185. * The l2,-2 coefficients of the spherical harmonics
  106186. */
  106187. l2_2: Vector3;
  106188. /**
  106189. * The l2,-1 coefficients of the spherical harmonics
  106190. */
  106191. l2_1: Vector3;
  106192. /**
  106193. * The l2,0 coefficients of the spherical harmonics
  106194. */
  106195. l20: Vector3;
  106196. /**
  106197. * The l2,1 coefficients of the spherical harmonics
  106198. */
  106199. l21: Vector3;
  106200. /**
  106201. * The l2,2 coefficients of the spherical harmonics
  106202. */
  106203. l22: Vector3;
  106204. /**
  106205. * Adds a light to the spherical harmonics
  106206. * @param direction the direction of the light
  106207. * @param color the color of the light
  106208. * @param deltaSolidAngle the delta solid angle of the light
  106209. */
  106210. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106211. /**
  106212. * Scales the spherical harmonics by the given amount
  106213. * @param scale the amount to scale
  106214. */
  106215. scaleInPlace(scale: number): void;
  106216. /**
  106217. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106218. *
  106219. * ```
  106220. * E_lm = A_l * L_lm
  106221. * ```
  106222. *
  106223. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106224. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106225. * the scaling factors are given in equation 9.
  106226. */
  106227. convertIncidentRadianceToIrradiance(): void;
  106228. /**
  106229. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106230. *
  106231. * ```
  106232. * L = (1/pi) * E * rho
  106233. * ```
  106234. *
  106235. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106236. */
  106237. convertIrradianceToLambertianRadiance(): void;
  106238. /**
  106239. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106240. * required operations at run time.
  106241. *
  106242. * This is simply done by scaling back the SH with Ylm constants parameter.
  106243. * The trigonometric part being applied by the shader at run time.
  106244. */
  106245. preScaleForRendering(): void;
  106246. /**
  106247. * Constructs a spherical harmonics from an array.
  106248. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106249. * @returns the spherical harmonics
  106250. */
  106251. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106252. /**
  106253. * Gets the spherical harmonics from polynomial
  106254. * @param polynomial the spherical polynomial
  106255. * @returns the spherical harmonics
  106256. */
  106257. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106258. }
  106259. /**
  106260. * Class representing spherical polynomial coefficients to the 3rd degree
  106261. */
  106262. export class SphericalPolynomial {
  106263. private _harmonics;
  106264. /**
  106265. * The spherical harmonics used to create the polynomials.
  106266. */
  106267. get preScaledHarmonics(): SphericalHarmonics;
  106268. /**
  106269. * The x coefficients of the spherical polynomial
  106270. */
  106271. x: Vector3;
  106272. /**
  106273. * The y coefficients of the spherical polynomial
  106274. */
  106275. y: Vector3;
  106276. /**
  106277. * The z coefficients of the spherical polynomial
  106278. */
  106279. z: Vector3;
  106280. /**
  106281. * The xx coefficients of the spherical polynomial
  106282. */
  106283. xx: Vector3;
  106284. /**
  106285. * The yy coefficients of the spherical polynomial
  106286. */
  106287. yy: Vector3;
  106288. /**
  106289. * The zz coefficients of the spherical polynomial
  106290. */
  106291. zz: Vector3;
  106292. /**
  106293. * The xy coefficients of the spherical polynomial
  106294. */
  106295. xy: Vector3;
  106296. /**
  106297. * The yz coefficients of the spherical polynomial
  106298. */
  106299. yz: Vector3;
  106300. /**
  106301. * The zx coefficients of the spherical polynomial
  106302. */
  106303. zx: Vector3;
  106304. /**
  106305. * Adds an ambient color to the spherical polynomial
  106306. * @param color the color to add
  106307. */
  106308. addAmbient(color: Color3): void;
  106309. /**
  106310. * Scales the spherical polynomial by the given amount
  106311. * @param scale the amount to scale
  106312. */
  106313. scaleInPlace(scale: number): void;
  106314. /**
  106315. * Gets the spherical polynomial from harmonics
  106316. * @param harmonics the spherical harmonics
  106317. * @returns the spherical polynomial
  106318. */
  106319. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106320. /**
  106321. * Constructs a spherical polynomial from an array.
  106322. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106323. * @returns the spherical polynomial
  106324. */
  106325. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106326. }
  106327. }
  106328. declare module BABYLON {
  106329. /**
  106330. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106331. */
  106332. export interface CubeMapInfo {
  106333. /**
  106334. * The pixel array for the front face.
  106335. * This is stored in format, left to right, up to down format.
  106336. */
  106337. front: Nullable<ArrayBufferView>;
  106338. /**
  106339. * The pixel array for the back face.
  106340. * This is stored in format, left to right, up to down format.
  106341. */
  106342. back: Nullable<ArrayBufferView>;
  106343. /**
  106344. * The pixel array for the left face.
  106345. * This is stored in format, left to right, up to down format.
  106346. */
  106347. left: Nullable<ArrayBufferView>;
  106348. /**
  106349. * The pixel array for the right face.
  106350. * This is stored in format, left to right, up to down format.
  106351. */
  106352. right: Nullable<ArrayBufferView>;
  106353. /**
  106354. * The pixel array for the up face.
  106355. * This is stored in format, left to right, up to down format.
  106356. */
  106357. up: Nullable<ArrayBufferView>;
  106358. /**
  106359. * The pixel array for the down face.
  106360. * This is stored in format, left to right, up to down format.
  106361. */
  106362. down: Nullable<ArrayBufferView>;
  106363. /**
  106364. * The size of the cubemap stored.
  106365. *
  106366. * Each faces will be size * size pixels.
  106367. */
  106368. size: number;
  106369. /**
  106370. * The format of the texture.
  106371. *
  106372. * RGBA, RGB.
  106373. */
  106374. format: number;
  106375. /**
  106376. * The type of the texture data.
  106377. *
  106378. * UNSIGNED_INT, FLOAT.
  106379. */
  106380. type: number;
  106381. /**
  106382. * Specifies whether the texture is in gamma space.
  106383. */
  106384. gammaSpace: boolean;
  106385. }
  106386. /**
  106387. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106388. */
  106389. export class PanoramaToCubeMapTools {
  106390. private static FACE_LEFT;
  106391. private static FACE_RIGHT;
  106392. private static FACE_FRONT;
  106393. private static FACE_BACK;
  106394. private static FACE_DOWN;
  106395. private static FACE_UP;
  106396. /**
  106397. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106398. *
  106399. * @param float32Array The source data.
  106400. * @param inputWidth The width of the input panorama.
  106401. * @param inputHeight The height of the input panorama.
  106402. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106403. * @return The cubemap data
  106404. */
  106405. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106406. private static CreateCubemapTexture;
  106407. private static CalcProjectionSpherical;
  106408. }
  106409. }
  106410. declare module BABYLON {
  106411. /**
  106412. * Helper class dealing with the extraction of spherical polynomial dataArray
  106413. * from a cube map.
  106414. */
  106415. export class CubeMapToSphericalPolynomialTools {
  106416. private static FileFaces;
  106417. /**
  106418. * Converts a texture to the according Spherical Polynomial data.
  106419. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106420. *
  106421. * @param texture The texture to extract the information from.
  106422. * @return The Spherical Polynomial data.
  106423. */
  106424. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106425. /**
  106426. * Converts a cubemap to the according Spherical Polynomial data.
  106427. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106428. *
  106429. * @param cubeInfo The Cube map to extract the information from.
  106430. * @return The Spherical Polynomial data.
  106431. */
  106432. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106433. }
  106434. }
  106435. declare module BABYLON {
  106436. interface BaseTexture {
  106437. /**
  106438. * Get the polynomial representation of the texture data.
  106439. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106440. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106441. */
  106442. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106443. }
  106444. }
  106445. declare module BABYLON {
  106446. /** @hidden */
  106447. export var pbrFragmentDeclaration: {
  106448. name: string;
  106449. shader: string;
  106450. };
  106451. }
  106452. declare module BABYLON {
  106453. /** @hidden */
  106454. export var pbrUboDeclaration: {
  106455. name: string;
  106456. shader: string;
  106457. };
  106458. }
  106459. declare module BABYLON {
  106460. /** @hidden */
  106461. export var pbrFragmentExtraDeclaration: {
  106462. name: string;
  106463. shader: string;
  106464. };
  106465. }
  106466. declare module BABYLON {
  106467. /** @hidden */
  106468. export var pbrFragmentSamplersDeclaration: {
  106469. name: string;
  106470. shader: string;
  106471. };
  106472. }
  106473. declare module BABYLON {
  106474. /** @hidden */
  106475. export var subSurfaceScatteringFunctions: {
  106476. name: string;
  106477. shader: string;
  106478. };
  106479. }
  106480. declare module BABYLON {
  106481. /** @hidden */
  106482. export var importanceSampling: {
  106483. name: string;
  106484. shader: string;
  106485. };
  106486. }
  106487. declare module BABYLON {
  106488. /** @hidden */
  106489. export var pbrHelperFunctions: {
  106490. name: string;
  106491. shader: string;
  106492. };
  106493. }
  106494. declare module BABYLON {
  106495. /** @hidden */
  106496. export var harmonicsFunctions: {
  106497. name: string;
  106498. shader: string;
  106499. };
  106500. }
  106501. declare module BABYLON {
  106502. /** @hidden */
  106503. export var pbrDirectLightingSetupFunctions: {
  106504. name: string;
  106505. shader: string;
  106506. };
  106507. }
  106508. declare module BABYLON {
  106509. /** @hidden */
  106510. export var pbrDirectLightingFalloffFunctions: {
  106511. name: string;
  106512. shader: string;
  106513. };
  106514. }
  106515. declare module BABYLON {
  106516. /** @hidden */
  106517. export var pbrBRDFFunctions: {
  106518. name: string;
  106519. shader: string;
  106520. };
  106521. }
  106522. declare module BABYLON {
  106523. /** @hidden */
  106524. export var hdrFilteringFunctions: {
  106525. name: string;
  106526. shader: string;
  106527. };
  106528. }
  106529. declare module BABYLON {
  106530. /** @hidden */
  106531. export var pbrDirectLightingFunctions: {
  106532. name: string;
  106533. shader: string;
  106534. };
  106535. }
  106536. declare module BABYLON {
  106537. /** @hidden */
  106538. export var pbrIBLFunctions: {
  106539. name: string;
  106540. shader: string;
  106541. };
  106542. }
  106543. declare module BABYLON {
  106544. /** @hidden */
  106545. export var pbrBlockAlbedoOpacity: {
  106546. name: string;
  106547. shader: string;
  106548. };
  106549. }
  106550. declare module BABYLON {
  106551. /** @hidden */
  106552. export var pbrBlockReflectivity: {
  106553. name: string;
  106554. shader: string;
  106555. };
  106556. }
  106557. declare module BABYLON {
  106558. /** @hidden */
  106559. export var pbrBlockAmbientOcclusion: {
  106560. name: string;
  106561. shader: string;
  106562. };
  106563. }
  106564. declare module BABYLON {
  106565. /** @hidden */
  106566. export var pbrBlockAlphaFresnel: {
  106567. name: string;
  106568. shader: string;
  106569. };
  106570. }
  106571. declare module BABYLON {
  106572. /** @hidden */
  106573. export var pbrBlockAnisotropic: {
  106574. name: string;
  106575. shader: string;
  106576. };
  106577. }
  106578. declare module BABYLON {
  106579. /** @hidden */
  106580. export var pbrBlockReflection: {
  106581. name: string;
  106582. shader: string;
  106583. };
  106584. }
  106585. declare module BABYLON {
  106586. /** @hidden */
  106587. export var pbrBlockSheen: {
  106588. name: string;
  106589. shader: string;
  106590. };
  106591. }
  106592. declare module BABYLON {
  106593. /** @hidden */
  106594. export var pbrBlockClearcoat: {
  106595. name: string;
  106596. shader: string;
  106597. };
  106598. }
  106599. declare module BABYLON {
  106600. /** @hidden */
  106601. export var pbrBlockSubSurface: {
  106602. name: string;
  106603. shader: string;
  106604. };
  106605. }
  106606. declare module BABYLON {
  106607. /** @hidden */
  106608. export var pbrBlockNormalGeometric: {
  106609. name: string;
  106610. shader: string;
  106611. };
  106612. }
  106613. declare module BABYLON {
  106614. /** @hidden */
  106615. export var pbrBlockNormalFinal: {
  106616. name: string;
  106617. shader: string;
  106618. };
  106619. }
  106620. declare module BABYLON {
  106621. /** @hidden */
  106622. export var pbrBlockLightmapInit: {
  106623. name: string;
  106624. shader: string;
  106625. };
  106626. }
  106627. declare module BABYLON {
  106628. /** @hidden */
  106629. export var pbrBlockGeometryInfo: {
  106630. name: string;
  106631. shader: string;
  106632. };
  106633. }
  106634. declare module BABYLON {
  106635. /** @hidden */
  106636. export var pbrBlockReflectance0: {
  106637. name: string;
  106638. shader: string;
  106639. };
  106640. }
  106641. declare module BABYLON {
  106642. /** @hidden */
  106643. export var pbrBlockReflectance: {
  106644. name: string;
  106645. shader: string;
  106646. };
  106647. }
  106648. declare module BABYLON {
  106649. /** @hidden */
  106650. export var pbrBlockDirectLighting: {
  106651. name: string;
  106652. shader: string;
  106653. };
  106654. }
  106655. declare module BABYLON {
  106656. /** @hidden */
  106657. export var pbrBlockFinalLitComponents: {
  106658. name: string;
  106659. shader: string;
  106660. };
  106661. }
  106662. declare module BABYLON {
  106663. /** @hidden */
  106664. export var pbrBlockFinalUnlitComponents: {
  106665. name: string;
  106666. shader: string;
  106667. };
  106668. }
  106669. declare module BABYLON {
  106670. /** @hidden */
  106671. export var pbrBlockFinalColorComposition: {
  106672. name: string;
  106673. shader: string;
  106674. };
  106675. }
  106676. declare module BABYLON {
  106677. /** @hidden */
  106678. export var pbrBlockImageProcessing: {
  106679. name: string;
  106680. shader: string;
  106681. };
  106682. }
  106683. declare module BABYLON {
  106684. /** @hidden */
  106685. export var pbrDebug: {
  106686. name: string;
  106687. shader: string;
  106688. };
  106689. }
  106690. declare module BABYLON {
  106691. /** @hidden */
  106692. export var pbrPixelShader: {
  106693. name: string;
  106694. shader: string;
  106695. };
  106696. }
  106697. declare module BABYLON {
  106698. /** @hidden */
  106699. export var pbrVertexDeclaration: {
  106700. name: string;
  106701. shader: string;
  106702. };
  106703. }
  106704. declare module BABYLON {
  106705. /** @hidden */
  106706. export var pbrVertexShader: {
  106707. name: string;
  106708. shader: string;
  106709. };
  106710. }
  106711. declare module BABYLON {
  106712. /**
  106713. * Manages the defines for the PBR Material.
  106714. * @hidden
  106715. */
  106716. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106717. PBR: boolean;
  106718. NUM_SAMPLES: string;
  106719. REALTIME_FILTERING: boolean;
  106720. MAINUV1: boolean;
  106721. MAINUV2: boolean;
  106722. UV1: boolean;
  106723. UV2: boolean;
  106724. ALBEDO: boolean;
  106725. GAMMAALBEDO: boolean;
  106726. ALBEDODIRECTUV: number;
  106727. VERTEXCOLOR: boolean;
  106728. DETAIL: boolean;
  106729. DETAILDIRECTUV: number;
  106730. DETAIL_NORMALBLENDMETHOD: number;
  106731. AMBIENT: boolean;
  106732. AMBIENTDIRECTUV: number;
  106733. AMBIENTINGRAYSCALE: boolean;
  106734. OPACITY: boolean;
  106735. VERTEXALPHA: boolean;
  106736. OPACITYDIRECTUV: number;
  106737. OPACITYRGB: boolean;
  106738. ALPHATEST: boolean;
  106739. DEPTHPREPASS: boolean;
  106740. ALPHABLEND: boolean;
  106741. ALPHAFROMALBEDO: boolean;
  106742. ALPHATESTVALUE: string;
  106743. SPECULAROVERALPHA: boolean;
  106744. RADIANCEOVERALPHA: boolean;
  106745. ALPHAFRESNEL: boolean;
  106746. LINEARALPHAFRESNEL: boolean;
  106747. PREMULTIPLYALPHA: boolean;
  106748. EMISSIVE: boolean;
  106749. EMISSIVEDIRECTUV: number;
  106750. REFLECTIVITY: boolean;
  106751. REFLECTIVITYDIRECTUV: number;
  106752. SPECULARTERM: boolean;
  106753. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106754. MICROSURFACEAUTOMATIC: boolean;
  106755. LODBASEDMICROSFURACE: boolean;
  106756. MICROSURFACEMAP: boolean;
  106757. MICROSURFACEMAPDIRECTUV: number;
  106758. METALLICWORKFLOW: boolean;
  106759. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106760. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106761. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106762. AOSTOREINMETALMAPRED: boolean;
  106763. METALLIC_REFLECTANCE: boolean;
  106764. METALLIC_REFLECTANCEDIRECTUV: number;
  106765. ENVIRONMENTBRDF: boolean;
  106766. ENVIRONMENTBRDF_RGBD: boolean;
  106767. NORMAL: boolean;
  106768. TANGENT: boolean;
  106769. BUMP: boolean;
  106770. BUMPDIRECTUV: number;
  106771. OBJECTSPACE_NORMALMAP: boolean;
  106772. PARALLAX: boolean;
  106773. PARALLAXOCCLUSION: boolean;
  106774. NORMALXYSCALE: boolean;
  106775. LIGHTMAP: boolean;
  106776. LIGHTMAPDIRECTUV: number;
  106777. USELIGHTMAPASSHADOWMAP: boolean;
  106778. GAMMALIGHTMAP: boolean;
  106779. RGBDLIGHTMAP: boolean;
  106780. REFLECTION: boolean;
  106781. REFLECTIONMAP_3D: boolean;
  106782. REFLECTIONMAP_SPHERICAL: boolean;
  106783. REFLECTIONMAP_PLANAR: boolean;
  106784. REFLECTIONMAP_CUBIC: boolean;
  106785. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106786. REFLECTIONMAP_PROJECTION: boolean;
  106787. REFLECTIONMAP_SKYBOX: boolean;
  106788. REFLECTIONMAP_EXPLICIT: boolean;
  106789. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106790. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106791. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106792. INVERTCUBICMAP: boolean;
  106793. USESPHERICALFROMREFLECTIONMAP: boolean;
  106794. USEIRRADIANCEMAP: boolean;
  106795. SPHERICAL_HARMONICS: boolean;
  106796. USESPHERICALINVERTEX: boolean;
  106797. REFLECTIONMAP_OPPOSITEZ: boolean;
  106798. LODINREFLECTIONALPHA: boolean;
  106799. GAMMAREFLECTION: boolean;
  106800. RGBDREFLECTION: boolean;
  106801. LINEARSPECULARREFLECTION: boolean;
  106802. RADIANCEOCCLUSION: boolean;
  106803. HORIZONOCCLUSION: boolean;
  106804. INSTANCES: boolean;
  106805. THIN_INSTANCES: boolean;
  106806. PREPASS: boolean;
  106807. PREPASS_IRRADIANCE: boolean;
  106808. PREPASS_IRRADIANCE_INDEX: number;
  106809. PREPASS_ALBEDO: boolean;
  106810. PREPASS_ALBEDO_INDEX: number;
  106811. PREPASS_DEPTHNORMAL: boolean;
  106812. PREPASS_DEPTHNORMAL_INDEX: number;
  106813. PREPASS_POSITION: boolean;
  106814. PREPASS_POSITION_INDEX: number;
  106815. PREPASS_VELOCITY: boolean;
  106816. PREPASS_VELOCITY_INDEX: number;
  106817. PREPASS_REFLECTIVITY: boolean;
  106818. PREPASS_REFLECTIVITY_INDEX: number;
  106819. SCENE_MRT_COUNT: number;
  106820. NUM_BONE_INFLUENCERS: number;
  106821. BonesPerMesh: number;
  106822. BONETEXTURE: boolean;
  106823. BONES_VELOCITY_ENABLED: boolean;
  106824. NONUNIFORMSCALING: boolean;
  106825. MORPHTARGETS: boolean;
  106826. MORPHTARGETS_NORMAL: boolean;
  106827. MORPHTARGETS_TANGENT: boolean;
  106828. MORPHTARGETS_UV: boolean;
  106829. NUM_MORPH_INFLUENCERS: number;
  106830. IMAGEPROCESSING: boolean;
  106831. VIGNETTE: boolean;
  106832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106833. VIGNETTEBLENDMODEOPAQUE: boolean;
  106834. TONEMAPPING: boolean;
  106835. TONEMAPPING_ACES: boolean;
  106836. CONTRAST: boolean;
  106837. COLORCURVES: boolean;
  106838. COLORGRADING: boolean;
  106839. COLORGRADING3D: boolean;
  106840. SAMPLER3DGREENDEPTH: boolean;
  106841. SAMPLER3DBGRMAP: boolean;
  106842. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106843. EXPOSURE: boolean;
  106844. MULTIVIEW: boolean;
  106845. USEPHYSICALLIGHTFALLOFF: boolean;
  106846. USEGLTFLIGHTFALLOFF: boolean;
  106847. TWOSIDEDLIGHTING: boolean;
  106848. SHADOWFLOAT: boolean;
  106849. CLIPPLANE: boolean;
  106850. CLIPPLANE2: boolean;
  106851. CLIPPLANE3: boolean;
  106852. CLIPPLANE4: boolean;
  106853. CLIPPLANE5: boolean;
  106854. CLIPPLANE6: boolean;
  106855. POINTSIZE: boolean;
  106856. FOG: boolean;
  106857. LOGARITHMICDEPTH: boolean;
  106858. FORCENORMALFORWARD: boolean;
  106859. SPECULARAA: boolean;
  106860. CLEARCOAT: boolean;
  106861. CLEARCOAT_DEFAULTIOR: boolean;
  106862. CLEARCOAT_TEXTURE: boolean;
  106863. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106864. CLEARCOAT_TEXTUREDIRECTUV: number;
  106865. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106866. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106867. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106868. CLEARCOAT_BUMP: boolean;
  106869. CLEARCOAT_BUMPDIRECTUV: number;
  106870. CLEARCOAT_REMAP_F0: boolean;
  106871. CLEARCOAT_TINT: boolean;
  106872. CLEARCOAT_TINT_TEXTURE: boolean;
  106873. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106874. ANISOTROPIC: boolean;
  106875. ANISOTROPIC_TEXTURE: boolean;
  106876. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106877. BRDF_V_HEIGHT_CORRELATED: boolean;
  106878. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106879. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106880. SHEEN: boolean;
  106881. SHEEN_TEXTURE: boolean;
  106882. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106883. SHEEN_TEXTUREDIRECTUV: number;
  106884. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106885. SHEEN_LINKWITHALBEDO: boolean;
  106886. SHEEN_ROUGHNESS: boolean;
  106887. SHEEN_ALBEDOSCALING: boolean;
  106888. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106889. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106890. SUBSURFACE: boolean;
  106891. SS_REFRACTION: boolean;
  106892. SS_TRANSLUCENCY: boolean;
  106893. SS_SCATTERING: boolean;
  106894. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106895. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106896. SS_REFRACTIONMAP_3D: boolean;
  106897. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106898. SS_LODINREFRACTIONALPHA: boolean;
  106899. SS_GAMMAREFRACTION: boolean;
  106900. SS_RGBDREFRACTION: boolean;
  106901. SS_LINEARSPECULARREFRACTION: boolean;
  106902. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106903. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106904. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106905. UNLIT: boolean;
  106906. DEBUGMODE: number;
  106907. /**
  106908. * Initializes the PBR Material defines.
  106909. */
  106910. constructor();
  106911. /**
  106912. * Resets the PBR Material defines.
  106913. */
  106914. reset(): void;
  106915. }
  106916. /**
  106917. * The Physically based material base class of BJS.
  106918. *
  106919. * This offers the main features of a standard PBR material.
  106920. * For more information, please refer to the documentation :
  106921. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106922. */
  106923. export abstract class PBRBaseMaterial extends PushMaterial {
  106924. /**
  106925. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106926. */
  106927. static readonly PBRMATERIAL_OPAQUE: number;
  106928. /**
  106929. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106930. */
  106931. static readonly PBRMATERIAL_ALPHATEST: number;
  106932. /**
  106933. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106934. */
  106935. static readonly PBRMATERIAL_ALPHABLEND: number;
  106936. /**
  106937. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106938. * They are also discarded below the alpha cutoff threshold to improve performances.
  106939. */
  106940. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106941. /**
  106942. * Defines the default value of how much AO map is occluding the analytical lights
  106943. * (point spot...).
  106944. */
  106945. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106946. /**
  106947. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106948. */
  106949. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106950. /**
  106951. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106952. * to enhance interoperability with other engines.
  106953. */
  106954. static readonly LIGHTFALLOFF_GLTF: number;
  106955. /**
  106956. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106957. * to enhance interoperability with other materials.
  106958. */
  106959. static readonly LIGHTFALLOFF_STANDARD: number;
  106960. /**
  106961. * Intensity of the direct lights e.g. the four lights available in your scene.
  106962. * This impacts both the direct diffuse and specular highlights.
  106963. */
  106964. protected _directIntensity: number;
  106965. /**
  106966. * Intensity of the emissive part of the material.
  106967. * This helps controlling the emissive effect without modifying the emissive color.
  106968. */
  106969. protected _emissiveIntensity: number;
  106970. /**
  106971. * Intensity of the environment e.g. how much the environment will light the object
  106972. * either through harmonics for rough material or through the refelction for shiny ones.
  106973. */
  106974. protected _environmentIntensity: number;
  106975. /**
  106976. * This is a special control allowing the reduction of the specular highlights coming from the
  106977. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106978. */
  106979. protected _specularIntensity: number;
  106980. /**
  106981. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106982. */
  106983. private _lightingInfos;
  106984. /**
  106985. * Debug Control allowing disabling the bump map on this material.
  106986. */
  106987. protected _disableBumpMap: boolean;
  106988. /**
  106989. * AKA Diffuse Texture in standard nomenclature.
  106990. */
  106991. protected _albedoTexture: Nullable<BaseTexture>;
  106992. /**
  106993. * AKA Occlusion Texture in other nomenclature.
  106994. */
  106995. protected _ambientTexture: Nullable<BaseTexture>;
  106996. /**
  106997. * AKA Occlusion Texture Intensity in other nomenclature.
  106998. */
  106999. protected _ambientTextureStrength: number;
  107000. /**
  107001. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107002. * 1 means it completely occludes it
  107003. * 0 mean it has no impact
  107004. */
  107005. protected _ambientTextureImpactOnAnalyticalLights: number;
  107006. /**
  107007. * Stores the alpha values in a texture.
  107008. */
  107009. protected _opacityTexture: Nullable<BaseTexture>;
  107010. /**
  107011. * Stores the reflection values in a texture.
  107012. */
  107013. protected _reflectionTexture: Nullable<BaseTexture>;
  107014. /**
  107015. * Stores the emissive values in a texture.
  107016. */
  107017. protected _emissiveTexture: Nullable<BaseTexture>;
  107018. /**
  107019. * AKA Specular texture in other nomenclature.
  107020. */
  107021. protected _reflectivityTexture: Nullable<BaseTexture>;
  107022. /**
  107023. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107024. */
  107025. protected _metallicTexture: Nullable<BaseTexture>;
  107026. /**
  107027. * Specifies the metallic scalar of the metallic/roughness workflow.
  107028. * Can also be used to scale the metalness values of the metallic texture.
  107029. */
  107030. protected _metallic: Nullable<number>;
  107031. /**
  107032. * Specifies the roughness scalar of the metallic/roughness workflow.
  107033. * Can also be used to scale the roughness values of the metallic texture.
  107034. */
  107035. protected _roughness: Nullable<number>;
  107036. /**
  107037. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107038. * By default the indexOfrefraction is used to compute F0;
  107039. *
  107040. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107041. *
  107042. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107043. * F90 = metallicReflectanceColor;
  107044. */
  107045. protected _metallicF0Factor: number;
  107046. /**
  107047. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107048. * By default the F90 is always 1;
  107049. *
  107050. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107051. *
  107052. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107053. * F90 = metallicReflectanceColor;
  107054. */
  107055. protected _metallicReflectanceColor: Color3;
  107056. /**
  107057. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107058. * This is multiply against the scalar values defined in the material.
  107059. */
  107060. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107061. /**
  107062. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107063. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107064. */
  107065. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107066. /**
  107067. * Stores surface normal data used to displace a mesh in a texture.
  107068. */
  107069. protected _bumpTexture: Nullable<BaseTexture>;
  107070. /**
  107071. * Stores the pre-calculated light information of a mesh in a texture.
  107072. */
  107073. protected _lightmapTexture: Nullable<BaseTexture>;
  107074. /**
  107075. * The color of a material in ambient lighting.
  107076. */
  107077. protected _ambientColor: Color3;
  107078. /**
  107079. * AKA Diffuse Color in other nomenclature.
  107080. */
  107081. protected _albedoColor: Color3;
  107082. /**
  107083. * AKA Specular Color in other nomenclature.
  107084. */
  107085. protected _reflectivityColor: Color3;
  107086. /**
  107087. * The color applied when light is reflected from a material.
  107088. */
  107089. protected _reflectionColor: Color3;
  107090. /**
  107091. * The color applied when light is emitted from a material.
  107092. */
  107093. protected _emissiveColor: Color3;
  107094. /**
  107095. * AKA Glossiness in other nomenclature.
  107096. */
  107097. protected _microSurface: number;
  107098. /**
  107099. * Specifies that the material will use the light map as a show map.
  107100. */
  107101. protected _useLightmapAsShadowmap: boolean;
  107102. /**
  107103. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107104. * makes the reflect vector face the model (under horizon).
  107105. */
  107106. protected _useHorizonOcclusion: boolean;
  107107. /**
  107108. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107109. * too much the area relying on ambient texture to define their ambient occlusion.
  107110. */
  107111. protected _useRadianceOcclusion: boolean;
  107112. /**
  107113. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107114. */
  107115. protected _useAlphaFromAlbedoTexture: boolean;
  107116. /**
  107117. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107118. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107119. */
  107120. protected _useSpecularOverAlpha: boolean;
  107121. /**
  107122. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107123. */
  107124. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107125. /**
  107126. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107127. */
  107128. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107129. /**
  107130. * Specifies if the metallic texture contains the roughness information in its green channel.
  107131. */
  107132. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107133. /**
  107134. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107135. */
  107136. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107137. /**
  107138. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107139. */
  107140. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107141. /**
  107142. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107143. */
  107144. protected _useAmbientInGrayScale: boolean;
  107145. /**
  107146. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107147. * The material will try to infer what glossiness each pixel should be.
  107148. */
  107149. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107150. /**
  107151. * Defines the falloff type used in this material.
  107152. * It by default is Physical.
  107153. */
  107154. protected _lightFalloff: number;
  107155. /**
  107156. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107157. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107158. */
  107159. protected _useRadianceOverAlpha: boolean;
  107160. /**
  107161. * Allows using an object space normal map (instead of tangent space).
  107162. */
  107163. protected _useObjectSpaceNormalMap: boolean;
  107164. /**
  107165. * Allows using the bump map in parallax mode.
  107166. */
  107167. protected _useParallax: boolean;
  107168. /**
  107169. * Allows using the bump map in parallax occlusion mode.
  107170. */
  107171. protected _useParallaxOcclusion: boolean;
  107172. /**
  107173. * Controls the scale bias of the parallax mode.
  107174. */
  107175. protected _parallaxScaleBias: number;
  107176. /**
  107177. * If sets to true, disables all the lights affecting the material.
  107178. */
  107179. protected _disableLighting: boolean;
  107180. /**
  107181. * Number of Simultaneous lights allowed on the material.
  107182. */
  107183. protected _maxSimultaneousLights: number;
  107184. /**
  107185. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107186. */
  107187. protected _invertNormalMapX: boolean;
  107188. /**
  107189. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107190. */
  107191. protected _invertNormalMapY: boolean;
  107192. /**
  107193. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107194. */
  107195. protected _twoSidedLighting: boolean;
  107196. /**
  107197. * Defines the alpha limits in alpha test mode.
  107198. */
  107199. protected _alphaCutOff: number;
  107200. /**
  107201. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107202. */
  107203. protected _forceAlphaTest: boolean;
  107204. /**
  107205. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107206. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107207. */
  107208. protected _useAlphaFresnel: boolean;
  107209. /**
  107210. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107211. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107212. */
  107213. protected _useLinearAlphaFresnel: boolean;
  107214. /**
  107215. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107216. * from cos thetav and roughness:
  107217. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107218. */
  107219. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107220. /**
  107221. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107222. */
  107223. protected _forceIrradianceInFragment: boolean;
  107224. private _realTimeFiltering;
  107225. /**
  107226. * Enables realtime filtering on the texture.
  107227. */
  107228. get realTimeFiltering(): boolean;
  107229. set realTimeFiltering(b: boolean);
  107230. private _realTimeFilteringQuality;
  107231. /**
  107232. * Quality switch for realtime filtering
  107233. */
  107234. get realTimeFilteringQuality(): number;
  107235. set realTimeFilteringQuality(n: number);
  107236. /**
  107237. * Can this material render to several textures at once
  107238. */
  107239. get canRenderToMRT(): boolean;
  107240. /**
  107241. * Force normal to face away from face.
  107242. */
  107243. protected _forceNormalForward: boolean;
  107244. /**
  107245. * Enables specular anti aliasing in the PBR shader.
  107246. * It will both interacts on the Geometry for analytical and IBL lighting.
  107247. * It also prefilter the roughness map based on the bump values.
  107248. */
  107249. protected _enableSpecularAntiAliasing: boolean;
  107250. /**
  107251. * Default configuration related to image processing available in the PBR Material.
  107252. */
  107253. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107254. /**
  107255. * Keep track of the image processing observer to allow dispose and replace.
  107256. */
  107257. private _imageProcessingObserver;
  107258. /**
  107259. * Attaches a new image processing configuration to the PBR Material.
  107260. * @param configuration
  107261. */
  107262. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107263. /**
  107264. * Stores the available render targets.
  107265. */
  107266. private _renderTargets;
  107267. /**
  107268. * Sets the global ambient color for the material used in lighting calculations.
  107269. */
  107270. private _globalAmbientColor;
  107271. /**
  107272. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107273. */
  107274. private _useLogarithmicDepth;
  107275. /**
  107276. * If set to true, no lighting calculations will be applied.
  107277. */
  107278. private _unlit;
  107279. private _debugMode;
  107280. /**
  107281. * @hidden
  107282. * This is reserved for the inspector.
  107283. * Defines the material debug mode.
  107284. * It helps seeing only some components of the material while troubleshooting.
  107285. */
  107286. debugMode: number;
  107287. /**
  107288. * @hidden
  107289. * This is reserved for the inspector.
  107290. * Specify from where on screen the debug mode should start.
  107291. * The value goes from -1 (full screen) to 1 (not visible)
  107292. * It helps with side by side comparison against the final render
  107293. * This defaults to -1
  107294. */
  107295. private debugLimit;
  107296. /**
  107297. * @hidden
  107298. * This is reserved for the inspector.
  107299. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107300. * You can use the factor to better multiply the final value.
  107301. */
  107302. private debugFactor;
  107303. /**
  107304. * Defines the clear coat layer parameters for the material.
  107305. */
  107306. readonly clearCoat: PBRClearCoatConfiguration;
  107307. /**
  107308. * Defines the anisotropic parameters for the material.
  107309. */
  107310. readonly anisotropy: PBRAnisotropicConfiguration;
  107311. /**
  107312. * Defines the BRDF parameters for the material.
  107313. */
  107314. readonly brdf: PBRBRDFConfiguration;
  107315. /**
  107316. * Defines the Sheen parameters for the material.
  107317. */
  107318. readonly sheen: PBRSheenConfiguration;
  107319. /**
  107320. * Defines the SubSurface parameters for the material.
  107321. */
  107322. readonly subSurface: PBRSubSurfaceConfiguration;
  107323. /**
  107324. * Defines additionnal PrePass parameters for the material.
  107325. */
  107326. readonly prePassConfiguration: PrePassConfiguration;
  107327. /**
  107328. * Defines the detail map parameters for the material.
  107329. */
  107330. readonly detailMap: DetailMapConfiguration;
  107331. protected _rebuildInParallel: boolean;
  107332. /**
  107333. * Instantiates a new PBRMaterial instance.
  107334. *
  107335. * @param name The material name
  107336. * @param scene The scene the material will be use in.
  107337. */
  107338. constructor(name: string, scene: Scene);
  107339. /**
  107340. * Gets a boolean indicating that current material needs to register RTT
  107341. */
  107342. get hasRenderTargetTextures(): boolean;
  107343. /**
  107344. * Gets the name of the material class.
  107345. */
  107346. getClassName(): string;
  107347. /**
  107348. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107349. */
  107350. get useLogarithmicDepth(): boolean;
  107351. /**
  107352. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107353. */
  107354. set useLogarithmicDepth(value: boolean);
  107355. /**
  107356. * Returns true if alpha blending should be disabled.
  107357. */
  107358. protected get _disableAlphaBlending(): boolean;
  107359. /**
  107360. * Specifies whether or not this material should be rendered in alpha blend mode.
  107361. */
  107362. needAlphaBlending(): boolean;
  107363. /**
  107364. * Specifies whether or not this material should be rendered in alpha test mode.
  107365. */
  107366. needAlphaTesting(): boolean;
  107367. /**
  107368. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107369. */
  107370. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107371. /**
  107372. * Specifies whether or not there is a usable alpha channel for transparency.
  107373. */
  107374. protected _hasAlphaChannel(): boolean;
  107375. /**
  107376. * Gets the texture used for the alpha test.
  107377. */
  107378. getAlphaTestTexture(): Nullable<BaseTexture>;
  107379. /**
  107380. * Specifies that the submesh is ready to be used.
  107381. * @param mesh - BJS mesh.
  107382. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107383. * @param useInstances - Specifies that instances should be used.
  107384. * @returns - boolean indicating that the submesh is ready or not.
  107385. */
  107386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107387. /**
  107388. * Specifies if the material uses metallic roughness workflow.
  107389. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107390. */
  107391. isMetallicWorkflow(): boolean;
  107392. private _prepareEffect;
  107393. private _prepareDefines;
  107394. /**
  107395. * Force shader compilation
  107396. */
  107397. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107398. /**
  107399. * Initializes the uniform buffer layout for the shader.
  107400. */
  107401. buildUniformLayout(): void;
  107402. /**
  107403. * Unbinds the material from the mesh
  107404. */
  107405. unbind(): void;
  107406. /**
  107407. * Binds the submesh data.
  107408. * @param world - The world matrix.
  107409. * @param mesh - The BJS mesh.
  107410. * @param subMesh - A submesh of the BJS mesh.
  107411. */
  107412. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107413. /**
  107414. * Returns the animatable textures.
  107415. * @returns - Array of animatable textures.
  107416. */
  107417. getAnimatables(): IAnimatable[];
  107418. /**
  107419. * Returns the texture used for reflections.
  107420. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107421. */
  107422. private _getReflectionTexture;
  107423. /**
  107424. * Returns an array of the actively used textures.
  107425. * @returns - Array of BaseTextures
  107426. */
  107427. getActiveTextures(): BaseTexture[];
  107428. /**
  107429. * Checks to see if a texture is used in the material.
  107430. * @param texture - Base texture to use.
  107431. * @returns - Boolean specifying if a texture is used in the material.
  107432. */
  107433. hasTexture(texture: BaseTexture): boolean;
  107434. /**
  107435. * Sets the required values to the prepass renderer.
  107436. * @param prePassRenderer defines the prepass renderer to setup
  107437. */
  107438. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107439. /**
  107440. * Disposes the resources of the material.
  107441. * @param forceDisposeEffect - Forces the disposal of effects.
  107442. * @param forceDisposeTextures - Forces the disposal of all textures.
  107443. */
  107444. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107445. }
  107446. }
  107447. declare module BABYLON {
  107448. /**
  107449. * The Physically based material of BJS.
  107450. *
  107451. * This offers the main features of a standard PBR material.
  107452. * For more information, please refer to the documentation :
  107453. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107454. */
  107455. export class PBRMaterial extends PBRBaseMaterial {
  107456. /**
  107457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107458. */
  107459. static readonly PBRMATERIAL_OPAQUE: number;
  107460. /**
  107461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107462. */
  107463. static readonly PBRMATERIAL_ALPHATEST: number;
  107464. /**
  107465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107466. */
  107467. static readonly PBRMATERIAL_ALPHABLEND: number;
  107468. /**
  107469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107470. * They are also discarded below the alpha cutoff threshold to improve performances.
  107471. */
  107472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107473. /**
  107474. * Defines the default value of how much AO map is occluding the analytical lights
  107475. * (point spot...).
  107476. */
  107477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107478. /**
  107479. * Intensity of the direct lights e.g. the four lights available in your scene.
  107480. * This impacts both the direct diffuse and specular highlights.
  107481. */
  107482. directIntensity: number;
  107483. /**
  107484. * Intensity of the emissive part of the material.
  107485. * This helps controlling the emissive effect without modifying the emissive color.
  107486. */
  107487. emissiveIntensity: number;
  107488. /**
  107489. * Intensity of the environment e.g. how much the environment will light the object
  107490. * either through harmonics for rough material or through the refelction for shiny ones.
  107491. */
  107492. environmentIntensity: number;
  107493. /**
  107494. * This is a special control allowing the reduction of the specular highlights coming from the
  107495. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107496. */
  107497. specularIntensity: number;
  107498. /**
  107499. * Debug Control allowing disabling the bump map on this material.
  107500. */
  107501. disableBumpMap: boolean;
  107502. /**
  107503. * AKA Diffuse Texture in standard nomenclature.
  107504. */
  107505. albedoTexture: BaseTexture;
  107506. /**
  107507. * AKA Occlusion Texture in other nomenclature.
  107508. */
  107509. ambientTexture: BaseTexture;
  107510. /**
  107511. * AKA Occlusion Texture Intensity in other nomenclature.
  107512. */
  107513. ambientTextureStrength: number;
  107514. /**
  107515. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107516. * 1 means it completely occludes it
  107517. * 0 mean it has no impact
  107518. */
  107519. ambientTextureImpactOnAnalyticalLights: number;
  107520. /**
  107521. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107522. */
  107523. opacityTexture: BaseTexture;
  107524. /**
  107525. * Stores the reflection values in a texture.
  107526. */
  107527. reflectionTexture: Nullable<BaseTexture>;
  107528. /**
  107529. * Stores the emissive values in a texture.
  107530. */
  107531. emissiveTexture: BaseTexture;
  107532. /**
  107533. * AKA Specular texture in other nomenclature.
  107534. */
  107535. reflectivityTexture: BaseTexture;
  107536. /**
  107537. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107538. */
  107539. metallicTexture: BaseTexture;
  107540. /**
  107541. * Specifies the metallic scalar of the metallic/roughness workflow.
  107542. * Can also be used to scale the metalness values of the metallic texture.
  107543. */
  107544. metallic: Nullable<number>;
  107545. /**
  107546. * Specifies the roughness scalar of the metallic/roughness workflow.
  107547. * Can also be used to scale the roughness values of the metallic texture.
  107548. */
  107549. roughness: Nullable<number>;
  107550. /**
  107551. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107552. * By default the indexOfrefraction is used to compute F0;
  107553. *
  107554. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107555. *
  107556. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107557. * F90 = metallicReflectanceColor;
  107558. */
  107559. metallicF0Factor: number;
  107560. /**
  107561. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107562. * By default the F90 is always 1;
  107563. *
  107564. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107565. *
  107566. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107567. * F90 = metallicReflectanceColor;
  107568. */
  107569. metallicReflectanceColor: Color3;
  107570. /**
  107571. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107572. * This is multiply against the scalar values defined in the material.
  107573. */
  107574. metallicReflectanceTexture: Nullable<BaseTexture>;
  107575. /**
  107576. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107577. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107578. */
  107579. microSurfaceTexture: BaseTexture;
  107580. /**
  107581. * Stores surface normal data used to displace a mesh in a texture.
  107582. */
  107583. bumpTexture: BaseTexture;
  107584. /**
  107585. * Stores the pre-calculated light information of a mesh in a texture.
  107586. */
  107587. lightmapTexture: BaseTexture;
  107588. /**
  107589. * Stores the refracted light information in a texture.
  107590. */
  107591. get refractionTexture(): Nullable<BaseTexture>;
  107592. set refractionTexture(value: Nullable<BaseTexture>);
  107593. /**
  107594. * The color of a material in ambient lighting.
  107595. */
  107596. ambientColor: Color3;
  107597. /**
  107598. * AKA Diffuse Color in other nomenclature.
  107599. */
  107600. albedoColor: Color3;
  107601. /**
  107602. * AKA Specular Color in other nomenclature.
  107603. */
  107604. reflectivityColor: Color3;
  107605. /**
  107606. * The color reflected from the material.
  107607. */
  107608. reflectionColor: Color3;
  107609. /**
  107610. * The color emitted from the material.
  107611. */
  107612. emissiveColor: Color3;
  107613. /**
  107614. * AKA Glossiness in other nomenclature.
  107615. */
  107616. microSurface: number;
  107617. /**
  107618. * Index of refraction of the material base layer.
  107619. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107620. *
  107621. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107622. *
  107623. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107624. */
  107625. get indexOfRefraction(): number;
  107626. set indexOfRefraction(value: number);
  107627. /**
  107628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107629. */
  107630. get invertRefractionY(): boolean;
  107631. set invertRefractionY(value: boolean);
  107632. /**
  107633. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107634. * Materials half opaque for instance using refraction could benefit from this control.
  107635. */
  107636. get linkRefractionWithTransparency(): boolean;
  107637. set linkRefractionWithTransparency(value: boolean);
  107638. /**
  107639. * If true, the light map contains occlusion information instead of lighting info.
  107640. */
  107641. useLightmapAsShadowmap: boolean;
  107642. /**
  107643. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107644. */
  107645. useAlphaFromAlbedoTexture: boolean;
  107646. /**
  107647. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107648. */
  107649. forceAlphaTest: boolean;
  107650. /**
  107651. * Defines the alpha limits in alpha test mode.
  107652. */
  107653. alphaCutOff: number;
  107654. /**
  107655. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107656. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107657. */
  107658. useSpecularOverAlpha: boolean;
  107659. /**
  107660. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107661. */
  107662. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107663. /**
  107664. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107665. */
  107666. useRoughnessFromMetallicTextureAlpha: boolean;
  107667. /**
  107668. * Specifies if the metallic texture contains the roughness information in its green channel.
  107669. */
  107670. useRoughnessFromMetallicTextureGreen: boolean;
  107671. /**
  107672. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107673. */
  107674. useMetallnessFromMetallicTextureBlue: boolean;
  107675. /**
  107676. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107677. */
  107678. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107679. /**
  107680. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107681. */
  107682. useAmbientInGrayScale: boolean;
  107683. /**
  107684. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107685. * The material will try to infer what glossiness each pixel should be.
  107686. */
  107687. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107688. /**
  107689. * BJS is using an harcoded light falloff based on a manually sets up range.
  107690. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107691. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107692. */
  107693. get usePhysicalLightFalloff(): boolean;
  107694. /**
  107695. * BJS is using an harcoded light falloff based on a manually sets up range.
  107696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107698. */
  107699. set usePhysicalLightFalloff(value: boolean);
  107700. /**
  107701. * In order to support the falloff compatibility with gltf, a special mode has been added
  107702. * to reproduce the gltf light falloff.
  107703. */
  107704. get useGLTFLightFalloff(): boolean;
  107705. /**
  107706. * In order to support the falloff compatibility with gltf, a special mode has been added
  107707. * to reproduce the gltf light falloff.
  107708. */
  107709. set useGLTFLightFalloff(value: boolean);
  107710. /**
  107711. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107712. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107713. */
  107714. useRadianceOverAlpha: boolean;
  107715. /**
  107716. * Allows using an object space normal map (instead of tangent space).
  107717. */
  107718. useObjectSpaceNormalMap: boolean;
  107719. /**
  107720. * Allows using the bump map in parallax mode.
  107721. */
  107722. useParallax: boolean;
  107723. /**
  107724. * Allows using the bump map in parallax occlusion mode.
  107725. */
  107726. useParallaxOcclusion: boolean;
  107727. /**
  107728. * Controls the scale bias of the parallax mode.
  107729. */
  107730. parallaxScaleBias: number;
  107731. /**
  107732. * If sets to true, disables all the lights affecting the material.
  107733. */
  107734. disableLighting: boolean;
  107735. /**
  107736. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107737. */
  107738. forceIrradianceInFragment: boolean;
  107739. /**
  107740. * Number of Simultaneous lights allowed on the material.
  107741. */
  107742. maxSimultaneousLights: number;
  107743. /**
  107744. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107745. */
  107746. invertNormalMapX: boolean;
  107747. /**
  107748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107749. */
  107750. invertNormalMapY: boolean;
  107751. /**
  107752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107753. */
  107754. twoSidedLighting: boolean;
  107755. /**
  107756. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107757. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107758. */
  107759. useAlphaFresnel: boolean;
  107760. /**
  107761. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107762. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107763. */
  107764. useLinearAlphaFresnel: boolean;
  107765. /**
  107766. * Let user defines the brdf lookup texture used for IBL.
  107767. * A default 8bit version is embedded but you could point at :
  107768. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107769. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107770. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107771. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107772. */
  107773. environmentBRDFTexture: Nullable<BaseTexture>;
  107774. /**
  107775. * Force normal to face away from face.
  107776. */
  107777. forceNormalForward: boolean;
  107778. /**
  107779. * Enables specular anti aliasing in the PBR shader.
  107780. * It will both interacts on the Geometry for analytical and IBL lighting.
  107781. * It also prefilter the roughness map based on the bump values.
  107782. */
  107783. enableSpecularAntiAliasing: boolean;
  107784. /**
  107785. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107786. * makes the reflect vector face the model (under horizon).
  107787. */
  107788. useHorizonOcclusion: boolean;
  107789. /**
  107790. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107791. * too much the area relying on ambient texture to define their ambient occlusion.
  107792. */
  107793. useRadianceOcclusion: boolean;
  107794. /**
  107795. * If set to true, no lighting calculations will be applied.
  107796. */
  107797. unlit: boolean;
  107798. /**
  107799. * Gets the image processing configuration used either in this material.
  107800. */
  107801. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107802. /**
  107803. * Sets the Default image processing configuration used either in the this material.
  107804. *
  107805. * If sets to null, the scene one is in use.
  107806. */
  107807. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107808. /**
  107809. * Gets wether the color curves effect is enabled.
  107810. */
  107811. get cameraColorCurvesEnabled(): boolean;
  107812. /**
  107813. * Sets wether the color curves effect is enabled.
  107814. */
  107815. set cameraColorCurvesEnabled(value: boolean);
  107816. /**
  107817. * Gets wether the color grading effect is enabled.
  107818. */
  107819. get cameraColorGradingEnabled(): boolean;
  107820. /**
  107821. * Gets wether the color grading effect is enabled.
  107822. */
  107823. set cameraColorGradingEnabled(value: boolean);
  107824. /**
  107825. * Gets wether tonemapping is enabled or not.
  107826. */
  107827. get cameraToneMappingEnabled(): boolean;
  107828. /**
  107829. * Sets wether tonemapping is enabled or not
  107830. */
  107831. set cameraToneMappingEnabled(value: boolean);
  107832. /**
  107833. * The camera exposure used on this material.
  107834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107835. * This corresponds to a photographic exposure.
  107836. */
  107837. get cameraExposure(): number;
  107838. /**
  107839. * The camera exposure used on this material.
  107840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107841. * This corresponds to a photographic exposure.
  107842. */
  107843. set cameraExposure(value: number);
  107844. /**
  107845. * Gets The camera contrast used on this material.
  107846. */
  107847. get cameraContrast(): number;
  107848. /**
  107849. * Sets The camera contrast used on this material.
  107850. */
  107851. set cameraContrast(value: number);
  107852. /**
  107853. * Gets the Color Grading 2D Lookup Texture.
  107854. */
  107855. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107856. /**
  107857. * Sets the Color Grading 2D Lookup Texture.
  107858. */
  107859. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107860. /**
  107861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107863. * 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;
  107864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107865. */
  107866. get cameraColorCurves(): Nullable<ColorCurves>;
  107867. /**
  107868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107870. * 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;
  107871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107872. */
  107873. set cameraColorCurves(value: Nullable<ColorCurves>);
  107874. /**
  107875. * Instantiates a new PBRMaterial instance.
  107876. *
  107877. * @param name The material name
  107878. * @param scene The scene the material will be use in.
  107879. */
  107880. constructor(name: string, scene: Scene);
  107881. /**
  107882. * Returns the name of this material class.
  107883. */
  107884. getClassName(): string;
  107885. /**
  107886. * Makes a duplicate of the current material.
  107887. * @param name - name to use for the new material.
  107888. */
  107889. clone(name: string): PBRMaterial;
  107890. /**
  107891. * Serializes this PBR Material.
  107892. * @returns - An object with the serialized material.
  107893. */
  107894. serialize(): any;
  107895. /**
  107896. * Parses a PBR Material from a serialized object.
  107897. * @param source - Serialized object.
  107898. * @param scene - BJS scene instance.
  107899. * @param rootUrl - url for the scene object
  107900. * @returns - PBRMaterial
  107901. */
  107902. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107903. }
  107904. }
  107905. declare module BABYLON {
  107906. /** @hidden */
  107907. export var mrtFragmentDeclaration: {
  107908. name: string;
  107909. shader: string;
  107910. };
  107911. }
  107912. declare module BABYLON {
  107913. /** @hidden */
  107914. export var geometryPixelShader: {
  107915. name: string;
  107916. shader: string;
  107917. };
  107918. }
  107919. declare module BABYLON {
  107920. /** @hidden */
  107921. export var geometryVertexShader: {
  107922. name: string;
  107923. shader: string;
  107924. };
  107925. }
  107926. declare module BABYLON {
  107927. /** @hidden */
  107928. interface ISavedTransformationMatrix {
  107929. world: Matrix;
  107930. viewProjection: Matrix;
  107931. }
  107932. /**
  107933. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107934. */
  107935. export class GeometryBufferRenderer {
  107936. /**
  107937. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107938. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107939. */
  107940. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107941. /**
  107942. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107943. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107944. */
  107945. static readonly POSITION_TEXTURE_TYPE: number;
  107946. /**
  107947. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107948. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107949. */
  107950. static readonly VELOCITY_TEXTURE_TYPE: number;
  107951. /**
  107952. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107953. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107954. */
  107955. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107956. /**
  107957. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107958. * in order to compute objects velocities when enableVelocity is set to "true"
  107959. * @hidden
  107960. */
  107961. _previousTransformationMatrices: {
  107962. [index: number]: ISavedTransformationMatrix;
  107963. };
  107964. /**
  107965. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107966. * in order to compute objects velocities when enableVelocity is set to "true"
  107967. * @hidden
  107968. */
  107969. _previousBonesTransformationMatrices: {
  107970. [index: number]: Float32Array;
  107971. };
  107972. /**
  107973. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107974. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107975. */
  107976. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107977. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107978. renderTransparentMeshes: boolean;
  107979. private _scene;
  107980. private _resizeObserver;
  107981. private _multiRenderTarget;
  107982. private _ratio;
  107983. private _enablePosition;
  107984. private _enableVelocity;
  107985. private _enableReflectivity;
  107986. private _positionIndex;
  107987. private _velocityIndex;
  107988. private _reflectivityIndex;
  107989. private _depthNormalIndex;
  107990. private _linkedWithPrePass;
  107991. private _prePassRenderer;
  107992. private _attachments;
  107993. protected _effect: Effect;
  107994. protected _cachedDefines: string;
  107995. /**
  107996. * @hidden
  107997. * Sets up internal structures to share outputs with PrePassRenderer
  107998. * This method should only be called by the PrePassRenderer itself
  107999. */
  108000. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108001. /**
  108002. * @hidden
  108003. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108004. * This method should only be called by the PrePassRenderer itself
  108005. */
  108006. _unlinkPrePassRenderer(): void;
  108007. /**
  108008. * @hidden
  108009. * Resets the geometry buffer layout
  108010. */
  108011. _resetLayout(): void;
  108012. /**
  108013. * @hidden
  108014. * Replaces a texture in the geometry buffer renderer
  108015. * Useful when linking textures of the prepass renderer
  108016. */
  108017. _forceTextureType(geometryBufferType: number, index: number): void;
  108018. /**
  108019. * @hidden
  108020. * Sets texture attachments
  108021. * Useful when linking textures of the prepass renderer
  108022. */
  108023. _setAttachments(attachments: number[]): void;
  108024. /**
  108025. * @hidden
  108026. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108027. * Useful when linking textures of the prepass renderer
  108028. */
  108029. _linkInternalTexture(internalTexture: InternalTexture): void;
  108030. /**
  108031. * Gets the render list (meshes to be rendered) used in the G buffer.
  108032. */
  108033. get renderList(): Nullable<AbstractMesh[]>;
  108034. /**
  108035. * Set the render list (meshes to be rendered) used in the G buffer.
  108036. */
  108037. set renderList(meshes: Nullable<AbstractMesh[]>);
  108038. /**
  108039. * Gets wether or not G buffer are supported by the running hardware.
  108040. * This requires draw buffer supports
  108041. */
  108042. get isSupported(): boolean;
  108043. /**
  108044. * Returns the index of the given texture type in the G-Buffer textures array
  108045. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108046. * @returns the index of the given texture type in the G-Buffer textures array
  108047. */
  108048. getTextureIndex(textureType: number): number;
  108049. /**
  108050. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108051. */
  108052. get enablePosition(): boolean;
  108053. /**
  108054. * Sets whether or not objects positions are enabled for the G buffer.
  108055. */
  108056. set enablePosition(enable: boolean);
  108057. /**
  108058. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108059. */
  108060. get enableVelocity(): boolean;
  108061. /**
  108062. * Sets wether or not objects velocities are enabled for the G buffer.
  108063. */
  108064. set enableVelocity(enable: boolean);
  108065. /**
  108066. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108067. */
  108068. get enableReflectivity(): boolean;
  108069. /**
  108070. * Sets wether or not objects roughness are enabled for the G buffer.
  108071. */
  108072. set enableReflectivity(enable: boolean);
  108073. /**
  108074. * Gets the scene associated with the buffer.
  108075. */
  108076. get scene(): Scene;
  108077. /**
  108078. * Gets the ratio used by the buffer during its creation.
  108079. * How big is the buffer related to the main canvas.
  108080. */
  108081. get ratio(): number;
  108082. /** @hidden */
  108083. static _SceneComponentInitialization: (scene: Scene) => void;
  108084. /**
  108085. * Creates a new G Buffer for the scene
  108086. * @param scene The scene the buffer belongs to
  108087. * @param ratio How big is the buffer related to the main canvas.
  108088. */
  108089. constructor(scene: Scene, ratio?: number);
  108090. /**
  108091. * Checks wether everything is ready to render a submesh to the G buffer.
  108092. * @param subMesh the submesh to check readiness for
  108093. * @param useInstances is the mesh drawn using instance or not
  108094. * @returns true if ready otherwise false
  108095. */
  108096. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108097. /**
  108098. * Gets the current underlying G Buffer.
  108099. * @returns the buffer
  108100. */
  108101. getGBuffer(): MultiRenderTarget;
  108102. /**
  108103. * Gets the number of samples used to render the buffer (anti aliasing).
  108104. */
  108105. get samples(): number;
  108106. /**
  108107. * Sets the number of samples used to render the buffer (anti aliasing).
  108108. */
  108109. set samples(value: number);
  108110. /**
  108111. * Disposes the renderer and frees up associated resources.
  108112. */
  108113. dispose(): void;
  108114. private _assignRenderTargetIndices;
  108115. protected _createRenderTargets(): void;
  108116. private _copyBonesTransformationMatrices;
  108117. }
  108118. }
  108119. declare module BABYLON {
  108120. /**
  108121. * Renders a pre pass of the scene
  108122. * This means every mesh in the scene will be rendered to a render target texture
  108123. * And then this texture will be composited to the rendering canvas with post processes
  108124. * It is necessary for effects like subsurface scattering or deferred shading
  108125. */
  108126. export class PrePassRenderer {
  108127. /** @hidden */
  108128. static _SceneComponentInitialization: (scene: Scene) => void;
  108129. private _textureFormats;
  108130. /**
  108131. * To save performance, we can excluded skinned meshes from the prepass
  108132. */
  108133. excludedSkinnedMesh: AbstractMesh[];
  108134. /**
  108135. * Force material to be excluded from the prepass
  108136. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108137. * and you don't want a material to show in the effect.
  108138. */
  108139. excludedMaterials: Material[];
  108140. private _textureIndices;
  108141. private _scene;
  108142. private _engine;
  108143. private _isDirty;
  108144. /**
  108145. * Number of textures in the multi render target texture where the scene is directly rendered
  108146. */
  108147. mrtCount: number;
  108148. /**
  108149. * The render target where the scene is directly rendered
  108150. */
  108151. prePassRT: MultiRenderTarget;
  108152. private _multiRenderAttachments;
  108153. private _defaultAttachments;
  108154. private _clearAttachments;
  108155. private _postProcesses;
  108156. private readonly _clearColor;
  108157. /**
  108158. * Image processing post process for composition
  108159. */
  108160. imageProcessingPostProcess: ImageProcessingPostProcess;
  108161. /**
  108162. * Configuration for prepass effects
  108163. */
  108164. private _effectConfigurations;
  108165. private _mrtFormats;
  108166. private _mrtLayout;
  108167. private _enabled;
  108168. /**
  108169. * Indicates if the prepass is enabled
  108170. */
  108171. get enabled(): boolean;
  108172. /**
  108173. * How many samples are used for MSAA of the scene render target
  108174. */
  108175. get samples(): number;
  108176. set samples(n: number);
  108177. private _geometryBuffer;
  108178. private _useGeometryBufferFallback;
  108179. /**
  108180. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108181. */
  108182. get useGeometryBufferFallback(): boolean;
  108183. set useGeometryBufferFallback(value: boolean);
  108184. /**
  108185. * Instanciates a prepass renderer
  108186. * @param scene The scene
  108187. */
  108188. constructor(scene: Scene);
  108189. private _initializeAttachments;
  108190. private _createCompositionEffect;
  108191. /**
  108192. * Indicates if rendering a prepass is supported
  108193. */
  108194. get isSupported(): boolean;
  108195. /**
  108196. * Sets the proper output textures to draw in the engine.
  108197. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108198. * @param subMesh Submesh on which the effect is applied
  108199. */
  108200. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108201. /**
  108202. * @hidden
  108203. */
  108204. _beforeCameraDraw(): void;
  108205. /**
  108206. * @hidden
  108207. */
  108208. _afterCameraDraw(): void;
  108209. private _checkRTSize;
  108210. private _bindFrameBuffer;
  108211. /**
  108212. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108213. */
  108214. clear(): void;
  108215. private _setState;
  108216. private _updateGeometryBufferLayout;
  108217. /**
  108218. * Adds an effect configuration to the prepass.
  108219. * If an effect has already been added, it won't add it twice and will return the configuration
  108220. * already present.
  108221. * @param cfg the effect configuration
  108222. * @return the effect configuration now used by the prepass
  108223. */
  108224. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108225. /**
  108226. * Returns the index of a texture in the multi render target texture array.
  108227. * @param type Texture type
  108228. * @return The index
  108229. */
  108230. getIndex(type: number): number;
  108231. private _enable;
  108232. private _disable;
  108233. private _resetLayout;
  108234. private _resetPostProcessChain;
  108235. private _bindPostProcessChain;
  108236. /**
  108237. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108238. */
  108239. markAsDirty(): void;
  108240. /**
  108241. * Enables a texture on the MultiRenderTarget for prepass
  108242. */
  108243. private _enableTextures;
  108244. private _update;
  108245. private _markAllMaterialsAsPrePassDirty;
  108246. /**
  108247. * Disposes the prepass renderer.
  108248. */
  108249. dispose(): void;
  108250. }
  108251. }
  108252. declare module BABYLON {
  108253. /**
  108254. * Size options for a post process
  108255. */
  108256. export type PostProcessOptions = {
  108257. width: number;
  108258. height: number;
  108259. };
  108260. /**
  108261. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108262. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108263. */
  108264. export class PostProcess {
  108265. /**
  108266. * Gets or sets the unique id of the post process
  108267. */
  108268. uniqueId: number;
  108269. /** Name of the PostProcess. */
  108270. name: string;
  108271. /**
  108272. * Width of the texture to apply the post process on
  108273. */
  108274. width: number;
  108275. /**
  108276. * Height of the texture to apply the post process on
  108277. */
  108278. height: number;
  108279. /**
  108280. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108281. */
  108282. nodeMaterialSource: Nullable<NodeMaterial>;
  108283. /**
  108284. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108285. * @hidden
  108286. */
  108287. _outputTexture: Nullable<InternalTexture>;
  108288. /**
  108289. * Sampling mode used by the shader
  108290. * See https://doc.babylonjs.com/classes/3.1/texture
  108291. */
  108292. renderTargetSamplingMode: number;
  108293. /**
  108294. * Clear color to use when screen clearing
  108295. */
  108296. clearColor: Color4;
  108297. /**
  108298. * If the buffer needs to be cleared before applying the post process. (default: true)
  108299. * Should be set to false if shader will overwrite all previous pixels.
  108300. */
  108301. autoClear: boolean;
  108302. /**
  108303. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108304. */
  108305. alphaMode: number;
  108306. /**
  108307. * Sets the setAlphaBlendConstants of the babylon engine
  108308. */
  108309. alphaConstants: Color4;
  108310. /**
  108311. * Animations to be used for the post processing
  108312. */
  108313. animations: Animation[];
  108314. /**
  108315. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108316. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108317. */
  108318. enablePixelPerfectMode: boolean;
  108319. /**
  108320. * Force the postprocess to be applied without taking in account viewport
  108321. */
  108322. forceFullscreenViewport: boolean;
  108323. /**
  108324. * List of inspectable custom properties (used by the Inspector)
  108325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108326. */
  108327. inspectableCustomProperties: IInspectable[];
  108328. /**
  108329. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108330. *
  108331. * | Value | Type | Description |
  108332. * | ----- | ----------------------------------- | ----------- |
  108333. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108334. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108335. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108336. *
  108337. */
  108338. scaleMode: number;
  108339. /**
  108340. * Force textures to be a power of two (default: false)
  108341. */
  108342. alwaysForcePOT: boolean;
  108343. private _samples;
  108344. /**
  108345. * Number of sample textures (default: 1)
  108346. */
  108347. get samples(): number;
  108348. set samples(n: number);
  108349. /**
  108350. * Modify the scale of the post process to be the same as the viewport (default: false)
  108351. */
  108352. adaptScaleToCurrentViewport: boolean;
  108353. private _camera;
  108354. protected _scene: Scene;
  108355. private _engine;
  108356. private _options;
  108357. private _reusable;
  108358. private _textureType;
  108359. private _textureFormat;
  108360. /**
  108361. * Smart array of input and output textures for the post process.
  108362. * @hidden
  108363. */
  108364. _textures: SmartArray<InternalTexture>;
  108365. /**
  108366. * The index in _textures that corresponds to the output texture.
  108367. * @hidden
  108368. */
  108369. _currentRenderTextureInd: number;
  108370. private _effect;
  108371. private _samplers;
  108372. private _fragmentUrl;
  108373. private _vertexUrl;
  108374. private _parameters;
  108375. private _scaleRatio;
  108376. protected _indexParameters: any;
  108377. private _shareOutputWithPostProcess;
  108378. private _texelSize;
  108379. private _forcedOutputTexture;
  108380. /**
  108381. * Prepass configuration in case this post process needs a texture from prepass
  108382. * @hidden
  108383. */
  108384. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108385. /**
  108386. * Returns the fragment url or shader name used in the post process.
  108387. * @returns the fragment url or name in the shader store.
  108388. */
  108389. getEffectName(): string;
  108390. /**
  108391. * An event triggered when the postprocess is activated.
  108392. */
  108393. onActivateObservable: Observable<Camera>;
  108394. private _onActivateObserver;
  108395. /**
  108396. * A function that is added to the onActivateObservable
  108397. */
  108398. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108399. /**
  108400. * An event triggered when the postprocess changes its size.
  108401. */
  108402. onSizeChangedObservable: Observable<PostProcess>;
  108403. private _onSizeChangedObserver;
  108404. /**
  108405. * A function that is added to the onSizeChangedObservable
  108406. */
  108407. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108408. /**
  108409. * An event triggered when the postprocess applies its effect.
  108410. */
  108411. onApplyObservable: Observable<Effect>;
  108412. private _onApplyObserver;
  108413. /**
  108414. * A function that is added to the onApplyObservable
  108415. */
  108416. set onApply(callback: (effect: Effect) => void);
  108417. /**
  108418. * An event triggered before rendering the postprocess
  108419. */
  108420. onBeforeRenderObservable: Observable<Effect>;
  108421. private _onBeforeRenderObserver;
  108422. /**
  108423. * A function that is added to the onBeforeRenderObservable
  108424. */
  108425. set onBeforeRender(callback: (effect: Effect) => void);
  108426. /**
  108427. * An event triggered after rendering the postprocess
  108428. */
  108429. onAfterRenderObservable: Observable<Effect>;
  108430. private _onAfterRenderObserver;
  108431. /**
  108432. * A function that is added to the onAfterRenderObservable
  108433. */
  108434. set onAfterRender(callback: (efect: Effect) => void);
  108435. /**
  108436. * 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
  108437. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108438. */
  108439. get inputTexture(): InternalTexture;
  108440. set inputTexture(value: InternalTexture);
  108441. /**
  108442. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108443. * the only way to unset it is to use this function to restore its internal state
  108444. */
  108445. restoreDefaultInputTexture(): void;
  108446. /**
  108447. * Gets the camera which post process is applied to.
  108448. * @returns The camera the post process is applied to.
  108449. */
  108450. getCamera(): Camera;
  108451. /**
  108452. * Gets the texel size of the postprocess.
  108453. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108454. */
  108455. get texelSize(): Vector2;
  108456. /**
  108457. * Creates a new instance PostProcess
  108458. * @param name The name of the PostProcess.
  108459. * @param fragmentUrl The url of the fragment shader to be used.
  108460. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108461. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108462. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108463. * @param camera The camera to apply the render pass to.
  108464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108465. * @param engine The engine which the post process will be applied. (default: current engine)
  108466. * @param reusable If the post process can be reused on the same frame. (default: false)
  108467. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108468. * @param textureType Type of textures used when performing the post process. (default: 0)
  108469. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108470. * @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
  108471. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108472. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108473. */
  108474. 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);
  108475. /**
  108476. * Gets a string identifying the name of the class
  108477. * @returns "PostProcess" string
  108478. */
  108479. getClassName(): string;
  108480. /**
  108481. * Gets the engine which this post process belongs to.
  108482. * @returns The engine the post process was enabled with.
  108483. */
  108484. getEngine(): Engine;
  108485. /**
  108486. * The effect that is created when initializing the post process.
  108487. * @returns The created effect corresponding the the postprocess.
  108488. */
  108489. getEffect(): Effect;
  108490. /**
  108491. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108492. * @param postProcess The post process to share the output with.
  108493. * @returns This post process.
  108494. */
  108495. shareOutputWith(postProcess: PostProcess): PostProcess;
  108496. /**
  108497. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108498. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108499. */
  108500. useOwnOutput(): void;
  108501. /**
  108502. * Updates the effect with the current post process compile time values and recompiles the shader.
  108503. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108504. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108505. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108506. * @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
  108507. * @param onCompiled Called when the shader has been compiled.
  108508. * @param onError Called if there is an error when compiling a shader.
  108509. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108510. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108511. */
  108512. 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;
  108513. /**
  108514. * The post process is reusable if it can be used multiple times within one frame.
  108515. * @returns If the post process is reusable
  108516. */
  108517. isReusable(): boolean;
  108518. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108519. markTextureDirty(): void;
  108520. /**
  108521. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108522. * 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.
  108523. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108524. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108525. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108526. * @returns The target texture that was bound to be written to.
  108527. */
  108528. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108529. /**
  108530. * If the post process is supported.
  108531. */
  108532. get isSupported(): boolean;
  108533. /**
  108534. * The aspect ratio of the output texture.
  108535. */
  108536. get aspectRatio(): number;
  108537. /**
  108538. * Get a value indicating if the post-process is ready to be used
  108539. * @returns true if the post-process is ready (shader is compiled)
  108540. */
  108541. isReady(): boolean;
  108542. /**
  108543. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108544. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108545. */
  108546. apply(): Nullable<Effect>;
  108547. private _disposeTextures;
  108548. /**
  108549. * Sets the required values to the prepass renderer.
  108550. * @param prePassRenderer defines the prepass renderer to setup.
  108551. * @returns true if the pre pass is needed.
  108552. */
  108553. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108554. /**
  108555. * Disposes the post process.
  108556. * @param camera The camera to dispose the post process on.
  108557. */
  108558. dispose(camera?: Camera): void;
  108559. /**
  108560. * Serializes the particle system to a JSON object
  108561. * @returns the JSON object
  108562. */
  108563. serialize(): any;
  108564. /**
  108565. * Creates a material from parsed material data
  108566. * @param parsedPostProcess defines parsed post process data
  108567. * @param scene defines the hosting scene
  108568. * @param rootUrl defines the root URL to use to load textures
  108569. * @returns a new post process
  108570. */
  108571. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108572. }
  108573. }
  108574. declare module BABYLON {
  108575. /** @hidden */
  108576. export var kernelBlurVaryingDeclaration: {
  108577. name: string;
  108578. shader: string;
  108579. };
  108580. }
  108581. declare module BABYLON {
  108582. /** @hidden */
  108583. export var kernelBlurFragment: {
  108584. name: string;
  108585. shader: string;
  108586. };
  108587. }
  108588. declare module BABYLON {
  108589. /** @hidden */
  108590. export var kernelBlurFragment2: {
  108591. name: string;
  108592. shader: string;
  108593. };
  108594. }
  108595. declare module BABYLON {
  108596. /** @hidden */
  108597. export var kernelBlurPixelShader: {
  108598. name: string;
  108599. shader: string;
  108600. };
  108601. }
  108602. declare module BABYLON {
  108603. /** @hidden */
  108604. export var kernelBlurVertex: {
  108605. name: string;
  108606. shader: string;
  108607. };
  108608. }
  108609. declare module BABYLON {
  108610. /** @hidden */
  108611. export var kernelBlurVertexShader: {
  108612. name: string;
  108613. shader: string;
  108614. };
  108615. }
  108616. declare module BABYLON {
  108617. /**
  108618. * The Blur Post Process which blurs an image based on a kernel and direction.
  108619. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108620. */
  108621. export class BlurPostProcess extends PostProcess {
  108622. private blockCompilation;
  108623. protected _kernel: number;
  108624. protected _idealKernel: number;
  108625. protected _packedFloat: boolean;
  108626. private _staticDefines;
  108627. /** The direction in which to blur the image. */
  108628. direction: Vector2;
  108629. /**
  108630. * Sets the length in pixels of the blur sample region
  108631. */
  108632. set kernel(v: number);
  108633. /**
  108634. * Gets the length in pixels of the blur sample region
  108635. */
  108636. get kernel(): number;
  108637. /**
  108638. * Sets wether or not the blur needs to unpack/repack floats
  108639. */
  108640. set packedFloat(v: boolean);
  108641. /**
  108642. * Gets wether or not the blur is unpacking/repacking floats
  108643. */
  108644. get packedFloat(): boolean;
  108645. /**
  108646. * Gets a string identifying the name of the class
  108647. * @returns "BlurPostProcess" string
  108648. */
  108649. getClassName(): string;
  108650. /**
  108651. * Creates a new instance BlurPostProcess
  108652. * @param name The name of the effect.
  108653. * @param direction The direction in which to blur the image.
  108654. * @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.
  108655. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108656. * @param camera The camera to apply the render pass to.
  108657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108658. * @param engine The engine which the post process will be applied. (default: current engine)
  108659. * @param reusable If the post process can be reused on the same frame. (default: false)
  108660. * @param textureType Type of textures used when performing the post process. (default: 0)
  108661. * @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)
  108662. */
  108663. 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);
  108664. /**
  108665. * Updates the effect with the current post process compile time values and recompiles the shader.
  108666. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108667. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108668. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108669. * @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
  108670. * @param onCompiled Called when the shader has been compiled.
  108671. * @param onError Called if there is an error when compiling a shader.
  108672. */
  108673. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108674. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108675. /**
  108676. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108677. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108678. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108679. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108680. * The gaps between physical kernels are compensated for in the weighting of the samples
  108681. * @param idealKernel Ideal blur kernel.
  108682. * @return Nearest best kernel.
  108683. */
  108684. protected _nearestBestKernel(idealKernel: number): number;
  108685. /**
  108686. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108687. * @param x The point on the Gaussian distribution to sample.
  108688. * @return the value of the Gaussian function at x.
  108689. */
  108690. protected _gaussianWeight(x: number): number;
  108691. /**
  108692. * Generates a string that can be used as a floating point number in GLSL.
  108693. * @param x Value to print.
  108694. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108695. * @return GLSL float string.
  108696. */
  108697. protected _glslFloat(x: number, decimalFigures?: number): string;
  108698. /** @hidden */
  108699. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108700. }
  108701. }
  108702. declare module BABYLON {
  108703. /**
  108704. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108705. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108706. * You can then easily use it as a reflectionTexture on a flat surface.
  108707. * In case the surface is not a plane, please consider relying on reflection probes.
  108708. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108709. */
  108710. export class MirrorTexture extends RenderTargetTexture {
  108711. private scene;
  108712. /**
  108713. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108714. * 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.
  108715. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108716. */
  108717. mirrorPlane: Plane;
  108718. /**
  108719. * Define the blur ratio used to blur the reflection if needed.
  108720. */
  108721. set blurRatio(value: number);
  108722. get blurRatio(): number;
  108723. /**
  108724. * Define the adaptive blur kernel used to blur the reflection if needed.
  108725. * This will autocompute the closest best match for the `blurKernel`
  108726. */
  108727. set adaptiveBlurKernel(value: number);
  108728. /**
  108729. * Define the blur kernel used to blur the reflection if needed.
  108730. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108731. */
  108732. set blurKernel(value: number);
  108733. /**
  108734. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108735. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108736. */
  108737. set blurKernelX(value: number);
  108738. get blurKernelX(): number;
  108739. /**
  108740. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108741. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108742. */
  108743. set blurKernelY(value: number);
  108744. get blurKernelY(): number;
  108745. private _autoComputeBlurKernel;
  108746. protected _onRatioRescale(): void;
  108747. private _updateGammaSpace;
  108748. private _imageProcessingConfigChangeObserver;
  108749. private _transformMatrix;
  108750. private _mirrorMatrix;
  108751. private _savedViewMatrix;
  108752. private _blurX;
  108753. private _blurY;
  108754. private _adaptiveBlurKernel;
  108755. private _blurKernelX;
  108756. private _blurKernelY;
  108757. private _blurRatio;
  108758. /**
  108759. * Instantiates a Mirror Texture.
  108760. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108761. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108762. * You can then easily use it as a reflectionTexture on a flat surface.
  108763. * In case the surface is not a plane, please consider relying on reflection probes.
  108764. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108765. * @param name
  108766. * @param size
  108767. * @param scene
  108768. * @param generateMipMaps
  108769. * @param type
  108770. * @param samplingMode
  108771. * @param generateDepthBuffer
  108772. */
  108773. constructor(name: string, size: number | {
  108774. width: number;
  108775. height: number;
  108776. } | {
  108777. ratio: number;
  108778. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108779. private _preparePostProcesses;
  108780. /**
  108781. * Clone the mirror texture.
  108782. * @returns the cloned texture
  108783. */
  108784. clone(): MirrorTexture;
  108785. /**
  108786. * Serialize the texture to a JSON representation you could use in Parse later on
  108787. * @returns the serialized JSON representation
  108788. */
  108789. serialize(): any;
  108790. /**
  108791. * Dispose the texture and release its associated resources.
  108792. */
  108793. dispose(): void;
  108794. }
  108795. }
  108796. declare module BABYLON {
  108797. /**
  108798. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108799. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108800. */
  108801. export class Texture extends BaseTexture {
  108802. /**
  108803. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108804. */
  108805. static SerializeBuffers: boolean;
  108806. /** @hidden */
  108807. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108808. /** @hidden */
  108809. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108810. /** @hidden */
  108811. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108812. /** nearest is mag = nearest and min = nearest and mip = linear */
  108813. static readonly NEAREST_SAMPLINGMODE: number;
  108814. /** nearest is mag = nearest and min = nearest and mip = linear */
  108815. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108816. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108817. static readonly BILINEAR_SAMPLINGMODE: number;
  108818. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108819. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108820. /** Trilinear is mag = linear and min = linear and mip = linear */
  108821. static readonly TRILINEAR_SAMPLINGMODE: number;
  108822. /** Trilinear is mag = linear and min = linear and mip = linear */
  108823. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108824. /** mag = nearest and min = nearest and mip = nearest */
  108825. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108826. /** mag = nearest and min = linear and mip = nearest */
  108827. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108828. /** mag = nearest and min = linear and mip = linear */
  108829. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108830. /** mag = nearest and min = linear and mip = none */
  108831. static readonly NEAREST_LINEAR: number;
  108832. /** mag = nearest and min = nearest and mip = none */
  108833. static readonly NEAREST_NEAREST: number;
  108834. /** mag = linear and min = nearest and mip = nearest */
  108835. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108836. /** mag = linear and min = nearest and mip = linear */
  108837. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108838. /** mag = linear and min = linear and mip = none */
  108839. static readonly LINEAR_LINEAR: number;
  108840. /** mag = linear and min = nearest and mip = none */
  108841. static readonly LINEAR_NEAREST: number;
  108842. /** Explicit coordinates mode */
  108843. static readonly EXPLICIT_MODE: number;
  108844. /** Spherical coordinates mode */
  108845. static readonly SPHERICAL_MODE: number;
  108846. /** Planar coordinates mode */
  108847. static readonly PLANAR_MODE: number;
  108848. /** Cubic coordinates mode */
  108849. static readonly CUBIC_MODE: number;
  108850. /** Projection coordinates mode */
  108851. static readonly PROJECTION_MODE: number;
  108852. /** Inverse Cubic coordinates mode */
  108853. static readonly SKYBOX_MODE: number;
  108854. /** Inverse Cubic coordinates mode */
  108855. static readonly INVCUBIC_MODE: number;
  108856. /** Equirectangular coordinates mode */
  108857. static readonly EQUIRECTANGULAR_MODE: number;
  108858. /** Equirectangular Fixed coordinates mode */
  108859. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108860. /** Equirectangular Fixed Mirrored coordinates mode */
  108861. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108862. /** Texture is not repeating outside of 0..1 UVs */
  108863. static readonly CLAMP_ADDRESSMODE: number;
  108864. /** Texture is repeating outside of 0..1 UVs */
  108865. static readonly WRAP_ADDRESSMODE: number;
  108866. /** Texture is repeating and mirrored */
  108867. static readonly MIRROR_ADDRESSMODE: number;
  108868. /**
  108869. * 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
  108870. */
  108871. static UseSerializedUrlIfAny: boolean;
  108872. /**
  108873. * Define the url of the texture.
  108874. */
  108875. url: Nullable<string>;
  108876. /**
  108877. * Define an offset on the texture to offset the u coordinates of the UVs
  108878. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108879. */
  108880. uOffset: number;
  108881. /**
  108882. * Define an offset on the texture to offset the v coordinates of the UVs
  108883. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108884. */
  108885. vOffset: number;
  108886. /**
  108887. * Define an offset on the texture to scale the u coordinates of the UVs
  108888. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108889. */
  108890. uScale: number;
  108891. /**
  108892. * Define an offset on the texture to scale the v coordinates of the UVs
  108893. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108894. */
  108895. vScale: number;
  108896. /**
  108897. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108898. * @see https://doc.babylonjs.com/how_to/more_materials
  108899. */
  108900. uAng: number;
  108901. /**
  108902. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108903. * @see https://doc.babylonjs.com/how_to/more_materials
  108904. */
  108905. vAng: number;
  108906. /**
  108907. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108908. * @see https://doc.babylonjs.com/how_to/more_materials
  108909. */
  108910. wAng: number;
  108911. /**
  108912. * Defines the center of rotation (U)
  108913. */
  108914. uRotationCenter: number;
  108915. /**
  108916. * Defines the center of rotation (V)
  108917. */
  108918. vRotationCenter: number;
  108919. /**
  108920. * Defines the center of rotation (W)
  108921. */
  108922. wRotationCenter: number;
  108923. /**
  108924. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108925. */
  108926. homogeneousRotationInUVTransform: boolean;
  108927. /**
  108928. * Are mip maps generated for this texture or not.
  108929. */
  108930. get noMipmap(): boolean;
  108931. /**
  108932. * List of inspectable custom properties (used by the Inspector)
  108933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108934. */
  108935. inspectableCustomProperties: Nullable<IInspectable[]>;
  108936. private _noMipmap;
  108937. /** @hidden */
  108938. _invertY: boolean;
  108939. private _rowGenerationMatrix;
  108940. private _cachedTextureMatrix;
  108941. private _projectionModeMatrix;
  108942. private _t0;
  108943. private _t1;
  108944. private _t2;
  108945. private _cachedUOffset;
  108946. private _cachedVOffset;
  108947. private _cachedUScale;
  108948. private _cachedVScale;
  108949. private _cachedUAng;
  108950. private _cachedVAng;
  108951. private _cachedWAng;
  108952. private _cachedProjectionMatrixId;
  108953. private _cachedURotationCenter;
  108954. private _cachedVRotationCenter;
  108955. private _cachedWRotationCenter;
  108956. private _cachedHomogeneousRotationInUVTransform;
  108957. private _cachedCoordinatesMode;
  108958. /** @hidden */
  108959. protected _initialSamplingMode: number;
  108960. /** @hidden */
  108961. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108962. private _deleteBuffer;
  108963. protected _format: Nullable<number>;
  108964. private _delayedOnLoad;
  108965. private _delayedOnError;
  108966. private _mimeType?;
  108967. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108968. get mimeType(): string | undefined;
  108969. /**
  108970. * Observable triggered once the texture has been loaded.
  108971. */
  108972. onLoadObservable: Observable<Texture>;
  108973. protected _isBlocking: boolean;
  108974. /**
  108975. * Is the texture preventing material to render while loading.
  108976. * If false, a default texture will be used instead of the loading one during the preparation step.
  108977. */
  108978. set isBlocking(value: boolean);
  108979. get isBlocking(): boolean;
  108980. /**
  108981. * Get the current sampling mode associated with the texture.
  108982. */
  108983. get samplingMode(): number;
  108984. /**
  108985. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108986. */
  108987. get invertY(): boolean;
  108988. /**
  108989. * Instantiates a new texture.
  108990. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108991. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108992. * @param url defines the url of the picture to load as a texture
  108993. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108994. * @param noMipmap defines if the texture will require mip maps or not
  108995. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108996. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108997. * @param onLoad defines a callback triggered when the texture has been loaded
  108998. * @param onError defines a callback triggered when an error occurred during the loading session
  108999. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109000. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109001. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109002. * @param mimeType defines an optional mime type information
  109003. */
  109004. 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);
  109005. /**
  109006. * Update the url (and optional buffer) of this texture if url was null during construction.
  109007. * @param url the url of the texture
  109008. * @param buffer the buffer of the texture (defaults to null)
  109009. * @param onLoad callback called when the texture is loaded (defaults to null)
  109010. */
  109011. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109012. /**
  109013. * Finish the loading sequence of a texture flagged as delayed load.
  109014. * @hidden
  109015. */
  109016. delayLoad(): void;
  109017. private _prepareRowForTextureGeneration;
  109018. /**
  109019. * Checks if the texture has the same transform matrix than another texture
  109020. * @param texture texture to check against
  109021. * @returns true if the transforms are the same, else false
  109022. */
  109023. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109024. /**
  109025. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109026. * @returns the transform matrix of the texture.
  109027. */
  109028. getTextureMatrix(uBase?: number): Matrix;
  109029. /**
  109030. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109031. * @returns The reflection texture transform
  109032. */
  109033. getReflectionTextureMatrix(): Matrix;
  109034. /**
  109035. * Clones the texture.
  109036. * @returns the cloned texture
  109037. */
  109038. clone(): Texture;
  109039. /**
  109040. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109041. * @returns The JSON representation of the texture
  109042. */
  109043. serialize(): any;
  109044. /**
  109045. * Get the current class name of the texture useful for serialization or dynamic coding.
  109046. * @returns "Texture"
  109047. */
  109048. getClassName(): string;
  109049. /**
  109050. * Dispose the texture and release its associated resources.
  109051. */
  109052. dispose(): void;
  109053. /**
  109054. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109055. * @param parsedTexture Define the JSON representation of the texture
  109056. * @param scene Define the scene the parsed texture should be instantiated in
  109057. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109058. * @returns The parsed texture if successful
  109059. */
  109060. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109061. /**
  109062. * Creates a texture from its base 64 representation.
  109063. * @param data Define the base64 payload without the data: prefix
  109064. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109065. * @param scene Define the scene the texture should belong to
  109066. * @param noMipmap Forces the texture to not create mip map information if true
  109067. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109068. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109069. * @param onLoad define a callback triggered when the texture has been loaded
  109070. * @param onError define a callback triggered when an error occurred during the loading session
  109071. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109072. * @returns the created texture
  109073. */
  109074. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109075. /**
  109076. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109077. * @param data Define the base64 payload without the data: prefix
  109078. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109079. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109080. * @param scene Define the scene the texture should belong to
  109081. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109082. * @param noMipmap Forces the texture to not create mip map information if true
  109083. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109084. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109085. * @param onLoad define a callback triggered when the texture has been loaded
  109086. * @param onError define a callback triggered when an error occurred during the loading session
  109087. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109088. * @returns the created texture
  109089. */
  109090. 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;
  109091. }
  109092. }
  109093. declare module BABYLON {
  109094. /**
  109095. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109096. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109097. */
  109098. export class PostProcessManager {
  109099. private _scene;
  109100. private _indexBuffer;
  109101. private _vertexBuffers;
  109102. /**
  109103. * Creates a new instance PostProcess
  109104. * @param scene The scene that the post process is associated with.
  109105. */
  109106. constructor(scene: Scene);
  109107. private _prepareBuffers;
  109108. private _buildIndexBuffer;
  109109. /**
  109110. * Rebuilds the vertex buffers of the manager.
  109111. * @hidden
  109112. */
  109113. _rebuild(): void;
  109114. /**
  109115. * Prepares a frame to be run through a post process.
  109116. * @param sourceTexture The input texture to the post procesess. (default: null)
  109117. * @param postProcesses An array of post processes to be run. (default: null)
  109118. * @returns True if the post processes were able to be run.
  109119. * @hidden
  109120. */
  109121. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109122. /**
  109123. * Manually render a set of post processes to a texture.
  109124. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109125. * @param postProcesses An array of post processes to be run.
  109126. * @param targetTexture The target texture to render to.
  109127. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109128. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109129. * @param lodLevel defines which lod of the texture to render to
  109130. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109131. */
  109132. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109133. /**
  109134. * Finalize the result of the output of the postprocesses.
  109135. * @param doNotPresent If true the result will not be displayed to the screen.
  109136. * @param targetTexture The target texture to render to.
  109137. * @param faceIndex The index of the face to bind the target texture to.
  109138. * @param postProcesses The array of post processes to render.
  109139. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109140. * @hidden
  109141. */
  109142. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109143. /**
  109144. * Disposes of the post process manager.
  109145. */
  109146. dispose(): void;
  109147. }
  109148. }
  109149. declare module BABYLON {
  109150. /**
  109151. * This Helps creating a texture that will be created from a camera in your scene.
  109152. * It is basically a dynamic texture that could be used to create special effects for instance.
  109153. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109154. */
  109155. export class RenderTargetTexture extends Texture {
  109156. /**
  109157. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109158. */
  109159. static readonly REFRESHRATE_RENDER_ONCE: number;
  109160. /**
  109161. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109162. */
  109163. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109164. /**
  109165. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109166. * the central point of your effect and can save a lot of performances.
  109167. */
  109168. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109169. /**
  109170. * Use this predicate to dynamically define the list of mesh you want to render.
  109171. * If set, the renderList property will be overwritten.
  109172. */
  109173. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109174. private _renderList;
  109175. /**
  109176. * Use this list to define the list of mesh you want to render.
  109177. */
  109178. get renderList(): Nullable<Array<AbstractMesh>>;
  109179. set renderList(value: Nullable<Array<AbstractMesh>>);
  109180. /**
  109181. * Use this function to overload the renderList array at rendering time.
  109182. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109183. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109184. * the cube (if the RTT is a cube, else layerOrFace=0).
  109185. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109186. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109187. * hold dummy elements!
  109188. */
  109189. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109190. private _hookArray;
  109191. /**
  109192. * Define if particles should be rendered in your texture.
  109193. */
  109194. renderParticles: boolean;
  109195. /**
  109196. * Define if sprites should be rendered in your texture.
  109197. */
  109198. renderSprites: boolean;
  109199. /**
  109200. * Define the camera used to render the texture.
  109201. */
  109202. activeCamera: Nullable<Camera>;
  109203. /**
  109204. * Override the mesh isReady function with your own one.
  109205. */
  109206. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109207. /**
  109208. * Override the render function of the texture with your own one.
  109209. */
  109210. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109211. /**
  109212. * Define if camera post processes should be use while rendering the texture.
  109213. */
  109214. useCameraPostProcesses: boolean;
  109215. /**
  109216. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109217. */
  109218. ignoreCameraViewport: boolean;
  109219. private _postProcessManager;
  109220. private _postProcesses;
  109221. private _resizeObserver;
  109222. /**
  109223. * An event triggered when the texture is unbind.
  109224. */
  109225. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109226. /**
  109227. * An event triggered when the texture is unbind.
  109228. */
  109229. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109230. private _onAfterUnbindObserver;
  109231. /**
  109232. * Set a after unbind callback in the texture.
  109233. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109234. */
  109235. set onAfterUnbind(callback: () => void);
  109236. /**
  109237. * An event triggered before rendering the texture
  109238. */
  109239. onBeforeRenderObservable: Observable<number>;
  109240. private _onBeforeRenderObserver;
  109241. /**
  109242. * Set a before render callback in the texture.
  109243. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109244. */
  109245. set onBeforeRender(callback: (faceIndex: number) => void);
  109246. /**
  109247. * An event triggered after rendering the texture
  109248. */
  109249. onAfterRenderObservable: Observable<number>;
  109250. private _onAfterRenderObserver;
  109251. /**
  109252. * Set a after render callback in the texture.
  109253. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109254. */
  109255. set onAfterRender(callback: (faceIndex: number) => void);
  109256. /**
  109257. * An event triggered after the texture clear
  109258. */
  109259. onClearObservable: Observable<Engine>;
  109260. private _onClearObserver;
  109261. /**
  109262. * Set a clear callback in the texture.
  109263. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109264. */
  109265. set onClear(callback: (Engine: Engine) => void);
  109266. /**
  109267. * An event triggered when the texture is resized.
  109268. */
  109269. onResizeObservable: Observable<RenderTargetTexture>;
  109270. /**
  109271. * Define the clear color of the Render Target if it should be different from the scene.
  109272. */
  109273. clearColor: Color4;
  109274. protected _size: number | {
  109275. width: number;
  109276. height: number;
  109277. layers?: number;
  109278. };
  109279. protected _initialSizeParameter: number | {
  109280. width: number;
  109281. height: number;
  109282. } | {
  109283. ratio: number;
  109284. };
  109285. protected _sizeRatio: Nullable<number>;
  109286. /** @hidden */
  109287. _generateMipMaps: boolean;
  109288. protected _renderingManager: RenderingManager;
  109289. /** @hidden */
  109290. _waitingRenderList?: string[];
  109291. protected _doNotChangeAspectRatio: boolean;
  109292. protected _currentRefreshId: number;
  109293. protected _refreshRate: number;
  109294. protected _textureMatrix: Matrix;
  109295. protected _samples: number;
  109296. protected _renderTargetOptions: RenderTargetCreationOptions;
  109297. /**
  109298. * Gets render target creation options that were used.
  109299. */
  109300. get renderTargetOptions(): RenderTargetCreationOptions;
  109301. protected _onRatioRescale(): void;
  109302. /**
  109303. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109304. * It must define where the camera used to render the texture is set
  109305. */
  109306. boundingBoxPosition: Vector3;
  109307. private _boundingBoxSize;
  109308. /**
  109309. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109310. * When defined, the cubemap will switch to local mode
  109311. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109312. * @example https://www.babylonjs-playground.com/#RNASML
  109313. */
  109314. set boundingBoxSize(value: Vector3);
  109315. get boundingBoxSize(): Vector3;
  109316. /**
  109317. * In case the RTT has been created with a depth texture, get the associated
  109318. * depth texture.
  109319. * Otherwise, return null.
  109320. */
  109321. get depthStencilTexture(): Nullable<InternalTexture>;
  109322. /**
  109323. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109324. * or used a shadow, depth texture...
  109325. * @param name The friendly name of the texture
  109326. * @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)
  109327. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109328. * @param generateMipMaps True if mip maps need to be generated after render.
  109329. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109330. * @param type The type of the buffer in the RTT (int, half float, float...)
  109331. * @param isCube True if a cube texture needs to be created
  109332. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109333. * @param generateDepthBuffer True to generate a depth buffer
  109334. * @param generateStencilBuffer True to generate a stencil buffer
  109335. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109336. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109337. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109338. */
  109339. constructor(name: string, size: number | {
  109340. width: number;
  109341. height: number;
  109342. layers?: number;
  109343. } | {
  109344. ratio: number;
  109345. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109346. /**
  109347. * Creates a depth stencil texture.
  109348. * This is only available in WebGL 2 or with the depth texture extension available.
  109349. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109350. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109351. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109352. */
  109353. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109354. private _processSizeParameter;
  109355. /**
  109356. * Define the number of samples to use in case of MSAA.
  109357. * It defaults to one meaning no MSAA has been enabled.
  109358. */
  109359. get samples(): number;
  109360. set samples(value: number);
  109361. /**
  109362. * Resets the refresh counter of the texture and start bak from scratch.
  109363. * Could be useful to regenerate the texture if it is setup to render only once.
  109364. */
  109365. resetRefreshCounter(): void;
  109366. /**
  109367. * Define the refresh rate of the texture or the rendering frequency.
  109368. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109369. */
  109370. get refreshRate(): number;
  109371. set refreshRate(value: number);
  109372. /**
  109373. * Adds a post process to the render target rendering passes.
  109374. * @param postProcess define the post process to add
  109375. */
  109376. addPostProcess(postProcess: PostProcess): void;
  109377. /**
  109378. * Clear all the post processes attached to the render target
  109379. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109380. */
  109381. clearPostProcesses(dispose?: boolean): void;
  109382. /**
  109383. * Remove one of the post process from the list of attached post processes to the texture
  109384. * @param postProcess define the post process to remove from the list
  109385. */
  109386. removePostProcess(postProcess: PostProcess): void;
  109387. /** @hidden */
  109388. _shouldRender(): boolean;
  109389. /**
  109390. * Gets the actual render size of the texture.
  109391. * @returns the width of the render size
  109392. */
  109393. getRenderSize(): number;
  109394. /**
  109395. * Gets the actual render width of the texture.
  109396. * @returns the width of the render size
  109397. */
  109398. getRenderWidth(): number;
  109399. /**
  109400. * Gets the actual render height of the texture.
  109401. * @returns the height of the render size
  109402. */
  109403. getRenderHeight(): number;
  109404. /**
  109405. * Gets the actual number of layers of the texture.
  109406. * @returns the number of layers
  109407. */
  109408. getRenderLayers(): number;
  109409. /**
  109410. * Get if the texture can be rescaled or not.
  109411. */
  109412. get canRescale(): boolean;
  109413. /**
  109414. * Resize the texture using a ratio.
  109415. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109416. */
  109417. scale(ratio: number): void;
  109418. /**
  109419. * Get the texture reflection matrix used to rotate/transform the reflection.
  109420. * @returns the reflection matrix
  109421. */
  109422. getReflectionTextureMatrix(): Matrix;
  109423. /**
  109424. * Resize the texture to a new desired size.
  109425. * Be carrefull as it will recreate all the data in the new texture.
  109426. * @param size Define the new size. It can be:
  109427. * - a number for squared texture,
  109428. * - an object containing { width: number, height: number }
  109429. * - or an object containing a ratio { ratio: number }
  109430. */
  109431. resize(size: number | {
  109432. width: number;
  109433. height: number;
  109434. } | {
  109435. ratio: number;
  109436. }): void;
  109437. private _defaultRenderListPrepared;
  109438. /**
  109439. * Renders all the objects from the render list into the texture.
  109440. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109441. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109442. */
  109443. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109444. private _bestReflectionRenderTargetDimension;
  109445. private _prepareRenderingManager;
  109446. /**
  109447. * @hidden
  109448. * @param faceIndex face index to bind to if this is a cubetexture
  109449. * @param layer defines the index of the texture to bind in the array
  109450. */
  109451. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109452. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109453. private renderToTarget;
  109454. /**
  109455. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109456. * This allowed control for front to back rendering or reversly depending of the special needs.
  109457. *
  109458. * @param renderingGroupId The rendering group id corresponding to its index
  109459. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109460. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109461. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109462. */
  109463. 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;
  109464. /**
  109465. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109466. *
  109467. * @param renderingGroupId The rendering group id corresponding to its index
  109468. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109469. */
  109470. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109471. /**
  109472. * Clones the texture.
  109473. * @returns the cloned texture
  109474. */
  109475. clone(): RenderTargetTexture;
  109476. /**
  109477. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109478. * @returns The JSON representation of the texture
  109479. */
  109480. serialize(): any;
  109481. /**
  109482. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109483. */
  109484. disposeFramebufferObjects(): void;
  109485. /**
  109486. * Dispose the texture and release its associated resources.
  109487. */
  109488. dispose(): void;
  109489. /** @hidden */
  109490. _rebuild(): void;
  109491. /**
  109492. * Clear the info related to rendering groups preventing retention point in material dispose.
  109493. */
  109494. freeRenderingGroups(): void;
  109495. /**
  109496. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109497. * @returns the view count
  109498. */
  109499. getViewCount(): number;
  109500. }
  109501. }
  109502. declare module BABYLON {
  109503. /**
  109504. * Class used to manipulate GUIDs
  109505. */
  109506. export class GUID {
  109507. /**
  109508. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109509. * Be aware Math.random() could cause collisions, but:
  109510. * "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"
  109511. * @returns a pseudo random id
  109512. */
  109513. static RandomId(): string;
  109514. }
  109515. }
  109516. declare module BABYLON {
  109517. /**
  109518. * Options to be used when creating a shadow depth material
  109519. */
  109520. export interface IIOptionShadowDepthMaterial {
  109521. /** Variables in the vertex shader code that need to have their names remapped.
  109522. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109523. * "var_name" should be either: worldPos or vNormalW
  109524. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109525. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109526. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109527. */
  109528. remappedVariables?: string[];
  109529. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109530. standalone?: boolean;
  109531. }
  109532. /**
  109533. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109534. */
  109535. export class ShadowDepthWrapper {
  109536. private _scene;
  109537. private _options?;
  109538. private _baseMaterial;
  109539. private _onEffectCreatedObserver;
  109540. private _subMeshToEffect;
  109541. private _subMeshToDepthEffect;
  109542. private _meshes;
  109543. /** @hidden */
  109544. _matriceNames: any;
  109545. /** Gets the standalone status of the wrapper */
  109546. get standalone(): boolean;
  109547. /** Gets the base material the wrapper is built upon */
  109548. get baseMaterial(): Material;
  109549. /**
  109550. * Instantiate a new shadow depth wrapper.
  109551. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109552. * generate the shadow depth map. For more information, please refer to the documentation:
  109553. * https://doc.babylonjs.com/babylon101/shadows
  109554. * @param baseMaterial Material to wrap
  109555. * @param scene Define the scene the material belongs to
  109556. * @param options Options used to create the wrapper
  109557. */
  109558. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109559. /**
  109560. * Gets the effect to use to generate the depth map
  109561. * @param subMesh subMesh to get the effect for
  109562. * @param shadowGenerator shadow generator to get the effect for
  109563. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109564. */
  109565. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109566. /**
  109567. * Specifies that the submesh is ready to be used for depth rendering
  109568. * @param subMesh submesh to check
  109569. * @param defines the list of defines to take into account when checking the effect
  109570. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109571. * @param useInstances specifies that instances should be used
  109572. * @returns a boolean indicating that the submesh is ready or not
  109573. */
  109574. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109575. /**
  109576. * Disposes the resources
  109577. */
  109578. dispose(): void;
  109579. private _makeEffect;
  109580. }
  109581. }
  109582. declare module BABYLON {
  109583. /**
  109584. * Options for compiling materials.
  109585. */
  109586. export interface IMaterialCompilationOptions {
  109587. /**
  109588. * Defines whether clip planes are enabled.
  109589. */
  109590. clipPlane: boolean;
  109591. /**
  109592. * Defines whether instances are enabled.
  109593. */
  109594. useInstances: boolean;
  109595. }
  109596. /**
  109597. * Options passed when calling customShaderNameResolve
  109598. */
  109599. export interface ICustomShaderNameResolveOptions {
  109600. /**
  109601. * 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
  109602. */
  109603. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109604. }
  109605. /**
  109606. * Base class for the main features of a material in Babylon.js
  109607. */
  109608. export class Material implements IAnimatable {
  109609. /**
  109610. * Returns the triangle fill mode
  109611. */
  109612. static readonly TriangleFillMode: number;
  109613. /**
  109614. * Returns the wireframe mode
  109615. */
  109616. static readonly WireFrameFillMode: number;
  109617. /**
  109618. * Returns the point fill mode
  109619. */
  109620. static readonly PointFillMode: number;
  109621. /**
  109622. * Returns the point list draw mode
  109623. */
  109624. static readonly PointListDrawMode: number;
  109625. /**
  109626. * Returns the line list draw mode
  109627. */
  109628. static readonly LineListDrawMode: number;
  109629. /**
  109630. * Returns the line loop draw mode
  109631. */
  109632. static readonly LineLoopDrawMode: number;
  109633. /**
  109634. * Returns the line strip draw mode
  109635. */
  109636. static readonly LineStripDrawMode: number;
  109637. /**
  109638. * Returns the triangle strip draw mode
  109639. */
  109640. static readonly TriangleStripDrawMode: number;
  109641. /**
  109642. * Returns the triangle fan draw mode
  109643. */
  109644. static readonly TriangleFanDrawMode: number;
  109645. /**
  109646. * Stores the clock-wise side orientation
  109647. */
  109648. static readonly ClockWiseSideOrientation: number;
  109649. /**
  109650. * Stores the counter clock-wise side orientation
  109651. */
  109652. static readonly CounterClockWiseSideOrientation: number;
  109653. /**
  109654. * The dirty texture flag value
  109655. */
  109656. static readonly TextureDirtyFlag: number;
  109657. /**
  109658. * The dirty light flag value
  109659. */
  109660. static readonly LightDirtyFlag: number;
  109661. /**
  109662. * The dirty fresnel flag value
  109663. */
  109664. static readonly FresnelDirtyFlag: number;
  109665. /**
  109666. * The dirty attribute flag value
  109667. */
  109668. static readonly AttributesDirtyFlag: number;
  109669. /**
  109670. * The dirty misc flag value
  109671. */
  109672. static readonly MiscDirtyFlag: number;
  109673. /**
  109674. * The dirty prepass flag value
  109675. */
  109676. static readonly PrePassDirtyFlag: number;
  109677. /**
  109678. * The all dirty flag value
  109679. */
  109680. static readonly AllDirtyFlag: number;
  109681. /**
  109682. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109683. */
  109684. static readonly MATERIAL_OPAQUE: number;
  109685. /**
  109686. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109687. */
  109688. static readonly MATERIAL_ALPHATEST: number;
  109689. /**
  109690. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109691. */
  109692. static readonly MATERIAL_ALPHABLEND: number;
  109693. /**
  109694. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109695. * They are also discarded below the alpha cutoff threshold to improve performances.
  109696. */
  109697. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109698. /**
  109699. * The Whiteout method is used to blend normals.
  109700. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109701. */
  109702. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109703. /**
  109704. * The Reoriented Normal Mapping method is used to blend normals.
  109705. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109706. */
  109707. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109708. /**
  109709. * Custom callback helping to override the default shader used in the material.
  109710. */
  109711. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109712. /**
  109713. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109714. */
  109715. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109716. /**
  109717. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109718. * This means that the material can keep using a previous shader while a new one is being compiled.
  109719. * This is mostly used when shader parallel compilation is supported (true by default)
  109720. */
  109721. allowShaderHotSwapping: boolean;
  109722. /**
  109723. * The ID of the material
  109724. */
  109725. id: string;
  109726. /**
  109727. * Gets or sets the unique id of the material
  109728. */
  109729. uniqueId: number;
  109730. /**
  109731. * The name of the material
  109732. */
  109733. name: string;
  109734. /**
  109735. * Gets or sets user defined metadata
  109736. */
  109737. metadata: any;
  109738. /**
  109739. * For internal use only. Please do not use.
  109740. */
  109741. reservedDataStore: any;
  109742. /**
  109743. * Specifies if the ready state should be checked on each call
  109744. */
  109745. checkReadyOnEveryCall: boolean;
  109746. /**
  109747. * Specifies if the ready state should be checked once
  109748. */
  109749. checkReadyOnlyOnce: boolean;
  109750. /**
  109751. * The state of the material
  109752. */
  109753. state: string;
  109754. /**
  109755. * If the material can be rendered to several textures with MRT extension
  109756. */
  109757. get canRenderToMRT(): boolean;
  109758. /**
  109759. * The alpha value of the material
  109760. */
  109761. protected _alpha: number;
  109762. /**
  109763. * List of inspectable custom properties (used by the Inspector)
  109764. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109765. */
  109766. inspectableCustomProperties: IInspectable[];
  109767. /**
  109768. * Sets the alpha value of the material
  109769. */
  109770. set alpha(value: number);
  109771. /**
  109772. * Gets the alpha value of the material
  109773. */
  109774. get alpha(): number;
  109775. /**
  109776. * Specifies if back face culling is enabled
  109777. */
  109778. protected _backFaceCulling: boolean;
  109779. /**
  109780. * Sets the back-face culling state
  109781. */
  109782. set backFaceCulling(value: boolean);
  109783. /**
  109784. * Gets the back-face culling state
  109785. */
  109786. get backFaceCulling(): boolean;
  109787. /**
  109788. * Stores the value for side orientation
  109789. */
  109790. sideOrientation: number;
  109791. /**
  109792. * Callback triggered when the material is compiled
  109793. */
  109794. onCompiled: Nullable<(effect: Effect) => void>;
  109795. /**
  109796. * Callback triggered when an error occurs
  109797. */
  109798. onError: Nullable<(effect: Effect, errors: string) => void>;
  109799. /**
  109800. * Callback triggered to get the render target textures
  109801. */
  109802. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109803. /**
  109804. * Gets a boolean indicating that current material needs to register RTT
  109805. */
  109806. get hasRenderTargetTextures(): boolean;
  109807. /**
  109808. * Specifies if the material should be serialized
  109809. */
  109810. doNotSerialize: boolean;
  109811. /**
  109812. * @hidden
  109813. */
  109814. _storeEffectOnSubMeshes: boolean;
  109815. /**
  109816. * Stores the animations for the material
  109817. */
  109818. animations: Nullable<Array<Animation>>;
  109819. /**
  109820. * An event triggered when the material is disposed
  109821. */
  109822. onDisposeObservable: Observable<Material>;
  109823. /**
  109824. * An observer which watches for dispose events
  109825. */
  109826. private _onDisposeObserver;
  109827. private _onUnBindObservable;
  109828. /**
  109829. * Called during a dispose event
  109830. */
  109831. set onDispose(callback: () => void);
  109832. private _onBindObservable;
  109833. /**
  109834. * An event triggered when the material is bound
  109835. */
  109836. get onBindObservable(): Observable<AbstractMesh>;
  109837. /**
  109838. * An observer which watches for bind events
  109839. */
  109840. private _onBindObserver;
  109841. /**
  109842. * Called during a bind event
  109843. */
  109844. set onBind(callback: (Mesh: AbstractMesh) => void);
  109845. /**
  109846. * An event triggered when the material is unbound
  109847. */
  109848. get onUnBindObservable(): Observable<Material>;
  109849. protected _onEffectCreatedObservable: Nullable<Observable<{
  109850. effect: Effect;
  109851. subMesh: Nullable<SubMesh>;
  109852. }>>;
  109853. /**
  109854. * An event triggered when the effect is (re)created
  109855. */
  109856. get onEffectCreatedObservable(): Observable<{
  109857. effect: Effect;
  109858. subMesh: Nullable<SubMesh>;
  109859. }>;
  109860. /**
  109861. * Stores the value of the alpha mode
  109862. */
  109863. private _alphaMode;
  109864. /**
  109865. * Sets the value of the alpha mode.
  109866. *
  109867. * | Value | Type | Description |
  109868. * | --- | --- | --- |
  109869. * | 0 | ALPHA_DISABLE | |
  109870. * | 1 | ALPHA_ADD | |
  109871. * | 2 | ALPHA_COMBINE | |
  109872. * | 3 | ALPHA_SUBTRACT | |
  109873. * | 4 | ALPHA_MULTIPLY | |
  109874. * | 5 | ALPHA_MAXIMIZED | |
  109875. * | 6 | ALPHA_ONEONE | |
  109876. * | 7 | ALPHA_PREMULTIPLIED | |
  109877. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109878. * | 9 | ALPHA_INTERPOLATE | |
  109879. * | 10 | ALPHA_SCREENMODE | |
  109880. *
  109881. */
  109882. set alphaMode(value: number);
  109883. /**
  109884. * Gets the value of the alpha mode
  109885. */
  109886. get alphaMode(): number;
  109887. /**
  109888. * Stores the state of the need depth pre-pass value
  109889. */
  109890. private _needDepthPrePass;
  109891. /**
  109892. * Sets the need depth pre-pass value
  109893. */
  109894. set needDepthPrePass(value: boolean);
  109895. /**
  109896. * Gets the depth pre-pass value
  109897. */
  109898. get needDepthPrePass(): boolean;
  109899. /**
  109900. * Specifies if depth writing should be disabled
  109901. */
  109902. disableDepthWrite: boolean;
  109903. /**
  109904. * Specifies if color writing should be disabled
  109905. */
  109906. disableColorWrite: boolean;
  109907. /**
  109908. * Specifies if depth writing should be forced
  109909. */
  109910. forceDepthWrite: boolean;
  109911. /**
  109912. * Specifies the depth function that should be used. 0 means the default engine function
  109913. */
  109914. depthFunction: number;
  109915. /**
  109916. * Specifies if there should be a separate pass for culling
  109917. */
  109918. separateCullingPass: boolean;
  109919. /**
  109920. * Stores the state specifing if fog should be enabled
  109921. */
  109922. private _fogEnabled;
  109923. /**
  109924. * Sets the state for enabling fog
  109925. */
  109926. set fogEnabled(value: boolean);
  109927. /**
  109928. * Gets the value of the fog enabled state
  109929. */
  109930. get fogEnabled(): boolean;
  109931. /**
  109932. * Stores the size of points
  109933. */
  109934. pointSize: number;
  109935. /**
  109936. * Stores the z offset value
  109937. */
  109938. zOffset: number;
  109939. get wireframe(): boolean;
  109940. /**
  109941. * Sets the state of wireframe mode
  109942. */
  109943. set wireframe(value: boolean);
  109944. /**
  109945. * Gets the value specifying if point clouds are enabled
  109946. */
  109947. get pointsCloud(): boolean;
  109948. /**
  109949. * Sets the state of point cloud mode
  109950. */
  109951. set pointsCloud(value: boolean);
  109952. /**
  109953. * Gets the material fill mode
  109954. */
  109955. get fillMode(): number;
  109956. /**
  109957. * Sets the material fill mode
  109958. */
  109959. set fillMode(value: number);
  109960. /**
  109961. * @hidden
  109962. * Stores the effects for the material
  109963. */
  109964. _effect: Nullable<Effect>;
  109965. /**
  109966. * Specifies if uniform buffers should be used
  109967. */
  109968. private _useUBO;
  109969. /**
  109970. * Stores a reference to the scene
  109971. */
  109972. private _scene;
  109973. /**
  109974. * Stores the fill mode state
  109975. */
  109976. private _fillMode;
  109977. /**
  109978. * Specifies if the depth write state should be cached
  109979. */
  109980. private _cachedDepthWriteState;
  109981. /**
  109982. * Specifies if the color write state should be cached
  109983. */
  109984. private _cachedColorWriteState;
  109985. /**
  109986. * Specifies if the depth function state should be cached
  109987. */
  109988. private _cachedDepthFunctionState;
  109989. /**
  109990. * Stores the uniform buffer
  109991. */
  109992. protected _uniformBuffer: UniformBuffer;
  109993. /** @hidden */
  109994. _indexInSceneMaterialArray: number;
  109995. /** @hidden */
  109996. meshMap: Nullable<{
  109997. [id: string]: AbstractMesh | undefined;
  109998. }>;
  109999. /**
  110000. * Creates a material instance
  110001. * @param name defines the name of the material
  110002. * @param scene defines the scene to reference
  110003. * @param doNotAdd specifies if the material should be added to the scene
  110004. */
  110005. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110006. /**
  110007. * Returns a string representation of the current material
  110008. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110009. * @returns a string with material information
  110010. */
  110011. toString(fullDetails?: boolean): string;
  110012. /**
  110013. * Gets the class name of the material
  110014. * @returns a string with the class name of the material
  110015. */
  110016. getClassName(): string;
  110017. /**
  110018. * Specifies if updates for the material been locked
  110019. */
  110020. get isFrozen(): boolean;
  110021. /**
  110022. * Locks updates for the material
  110023. */
  110024. freeze(): void;
  110025. /**
  110026. * Unlocks updates for the material
  110027. */
  110028. unfreeze(): void;
  110029. /**
  110030. * Specifies if the material is ready to be used
  110031. * @param mesh defines the mesh to check
  110032. * @param useInstances specifies if instances should be used
  110033. * @returns a boolean indicating if the material is ready to be used
  110034. */
  110035. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110036. /**
  110037. * Specifies that the submesh is ready to be used
  110038. * @param mesh defines the mesh to check
  110039. * @param subMesh defines which submesh to check
  110040. * @param useInstances specifies that instances should be used
  110041. * @returns a boolean indicating that the submesh is ready or not
  110042. */
  110043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110044. /**
  110045. * Returns the material effect
  110046. * @returns the effect associated with the material
  110047. */
  110048. getEffect(): Nullable<Effect>;
  110049. /**
  110050. * Returns the current scene
  110051. * @returns a Scene
  110052. */
  110053. getScene(): Scene;
  110054. /**
  110055. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110056. */
  110057. protected _forceAlphaTest: boolean;
  110058. /**
  110059. * The transparency mode of the material.
  110060. */
  110061. protected _transparencyMode: Nullable<number>;
  110062. /**
  110063. * Gets the current transparency mode.
  110064. */
  110065. get transparencyMode(): Nullable<number>;
  110066. /**
  110067. * Sets the transparency mode of the material.
  110068. *
  110069. * | Value | Type | Description |
  110070. * | ----- | ----------------------------------- | ----------- |
  110071. * | 0 | OPAQUE | |
  110072. * | 1 | ALPHATEST | |
  110073. * | 2 | ALPHABLEND | |
  110074. * | 3 | ALPHATESTANDBLEND | |
  110075. *
  110076. */
  110077. set transparencyMode(value: Nullable<number>);
  110078. /**
  110079. * Returns true if alpha blending should be disabled.
  110080. */
  110081. protected get _disableAlphaBlending(): boolean;
  110082. /**
  110083. * Specifies whether or not this material should be rendered in alpha blend mode.
  110084. * @returns a boolean specifying if alpha blending is needed
  110085. */
  110086. needAlphaBlending(): boolean;
  110087. /**
  110088. * Specifies if the mesh will require alpha blending
  110089. * @param mesh defines the mesh to check
  110090. * @returns a boolean specifying if alpha blending is needed for the mesh
  110091. */
  110092. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110093. /**
  110094. * Specifies whether or not this material should be rendered in alpha test mode.
  110095. * @returns a boolean specifying if an alpha test is needed.
  110096. */
  110097. needAlphaTesting(): boolean;
  110098. /**
  110099. * Specifies if material alpha testing should be turned on for the mesh
  110100. * @param mesh defines the mesh to check
  110101. */
  110102. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110103. /**
  110104. * Gets the texture used for the alpha test
  110105. * @returns the texture to use for alpha testing
  110106. */
  110107. getAlphaTestTexture(): Nullable<BaseTexture>;
  110108. /**
  110109. * Marks the material to indicate that it needs to be re-calculated
  110110. */
  110111. markDirty(): void;
  110112. /** @hidden */
  110113. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110114. /**
  110115. * Binds the material to the mesh
  110116. * @param world defines the world transformation matrix
  110117. * @param mesh defines the mesh to bind the material to
  110118. */
  110119. bind(world: Matrix, mesh?: Mesh): void;
  110120. /**
  110121. * Binds the submesh to the material
  110122. * @param world defines the world transformation matrix
  110123. * @param mesh defines the mesh containing the submesh
  110124. * @param subMesh defines the submesh to bind the material to
  110125. */
  110126. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110127. /**
  110128. * Binds the world matrix to the material
  110129. * @param world defines the world transformation matrix
  110130. */
  110131. bindOnlyWorldMatrix(world: Matrix): void;
  110132. /**
  110133. * Binds the scene's uniform buffer to the effect.
  110134. * @param effect defines the effect to bind to the scene uniform buffer
  110135. * @param sceneUbo defines the uniform buffer storing scene data
  110136. */
  110137. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110138. /**
  110139. * Binds the view matrix to the effect
  110140. * @param effect defines the effect to bind the view matrix to
  110141. */
  110142. bindView(effect: Effect): void;
  110143. /**
  110144. * Binds the view projection matrix to the effect
  110145. * @param effect defines the effect to bind the view projection matrix to
  110146. */
  110147. bindViewProjection(effect: Effect): void;
  110148. /**
  110149. * Processes to execute after binding the material to a mesh
  110150. * @param mesh defines the rendered mesh
  110151. */
  110152. protected _afterBind(mesh?: Mesh): void;
  110153. /**
  110154. * Unbinds the material from the mesh
  110155. */
  110156. unbind(): void;
  110157. /**
  110158. * Gets the active textures from the material
  110159. * @returns an array of textures
  110160. */
  110161. getActiveTextures(): BaseTexture[];
  110162. /**
  110163. * Specifies if the material uses a texture
  110164. * @param texture defines the texture to check against the material
  110165. * @returns a boolean specifying if the material uses the texture
  110166. */
  110167. hasTexture(texture: BaseTexture): boolean;
  110168. /**
  110169. * Makes a duplicate of the material, and gives it a new name
  110170. * @param name defines the new name for the duplicated material
  110171. * @returns the cloned material
  110172. */
  110173. clone(name: string): Nullable<Material>;
  110174. /**
  110175. * Gets the meshes bound to the material
  110176. * @returns an array of meshes bound to the material
  110177. */
  110178. getBindedMeshes(): AbstractMesh[];
  110179. /**
  110180. * Force shader compilation
  110181. * @param mesh defines the mesh associated with this material
  110182. * @param onCompiled defines a function to execute once the material is compiled
  110183. * @param options defines the options to configure the compilation
  110184. * @param onError defines a function to execute if the material fails compiling
  110185. */
  110186. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110187. /**
  110188. * Force shader compilation
  110189. * @param mesh defines the mesh that will use this material
  110190. * @param options defines additional options for compiling the shaders
  110191. * @returns a promise that resolves when the compilation completes
  110192. */
  110193. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110194. private static readonly _AllDirtyCallBack;
  110195. private static readonly _ImageProcessingDirtyCallBack;
  110196. private static readonly _TextureDirtyCallBack;
  110197. private static readonly _FresnelDirtyCallBack;
  110198. private static readonly _MiscDirtyCallBack;
  110199. private static readonly _PrePassDirtyCallBack;
  110200. private static readonly _LightsDirtyCallBack;
  110201. private static readonly _AttributeDirtyCallBack;
  110202. private static _FresnelAndMiscDirtyCallBack;
  110203. private static _TextureAndMiscDirtyCallBack;
  110204. private static readonly _DirtyCallbackArray;
  110205. private static readonly _RunDirtyCallBacks;
  110206. /**
  110207. * Marks a define in the material to indicate that it needs to be re-computed
  110208. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110209. */
  110210. markAsDirty(flag: number): void;
  110211. /**
  110212. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110213. * @param func defines a function which checks material defines against the submeshes
  110214. */
  110215. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110216. /**
  110217. * Indicates that the scene should check if the rendering now needs a prepass
  110218. */
  110219. protected _markScenePrePassDirty(): void;
  110220. /**
  110221. * Indicates that we need to re-calculated for all submeshes
  110222. */
  110223. protected _markAllSubMeshesAsAllDirty(): void;
  110224. /**
  110225. * Indicates that image processing needs to be re-calculated for all submeshes
  110226. */
  110227. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110228. /**
  110229. * Indicates that textures need to be re-calculated for all submeshes
  110230. */
  110231. protected _markAllSubMeshesAsTexturesDirty(): void;
  110232. /**
  110233. * Indicates that fresnel needs to be re-calculated for all submeshes
  110234. */
  110235. protected _markAllSubMeshesAsFresnelDirty(): void;
  110236. /**
  110237. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110238. */
  110239. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110240. /**
  110241. * Indicates that lights need to be re-calculated for all submeshes
  110242. */
  110243. protected _markAllSubMeshesAsLightsDirty(): void;
  110244. /**
  110245. * Indicates that attributes need to be re-calculated for all submeshes
  110246. */
  110247. protected _markAllSubMeshesAsAttributesDirty(): void;
  110248. /**
  110249. * Indicates that misc needs to be re-calculated for all submeshes
  110250. */
  110251. protected _markAllSubMeshesAsMiscDirty(): void;
  110252. /**
  110253. * Indicates that prepass needs to be re-calculated for all submeshes
  110254. */
  110255. protected _markAllSubMeshesAsPrePassDirty(): void;
  110256. /**
  110257. * Indicates that textures and misc need to be re-calculated for all submeshes
  110258. */
  110259. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110260. /**
  110261. * Sets the required values to the prepass renderer.
  110262. * @param prePassRenderer defines the prepass renderer to setup.
  110263. * @returns true if the pre pass is needed.
  110264. */
  110265. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110266. /**
  110267. * Disposes the material
  110268. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110269. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110270. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110271. */
  110272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110273. /** @hidden */
  110274. private releaseVertexArrayObject;
  110275. /**
  110276. * Serializes this material
  110277. * @returns the serialized material object
  110278. */
  110279. serialize(): any;
  110280. /**
  110281. * Creates a material from parsed material data
  110282. * @param parsedMaterial defines parsed material data
  110283. * @param scene defines the hosting scene
  110284. * @param rootUrl defines the root URL to use to load textures
  110285. * @returns a new material
  110286. */
  110287. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110288. }
  110289. }
  110290. declare module BABYLON {
  110291. /**
  110292. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110293. * separate meshes. This can be use to improve performances.
  110294. * @see https://doc.babylonjs.com/how_to/multi_materials
  110295. */
  110296. export class MultiMaterial extends Material {
  110297. private _subMaterials;
  110298. /**
  110299. * Gets or Sets the list of Materials used within the multi material.
  110300. * They need to be ordered according to the submeshes order in the associated mesh
  110301. */
  110302. get subMaterials(): Nullable<Material>[];
  110303. set subMaterials(value: Nullable<Material>[]);
  110304. /**
  110305. * Function used to align with Node.getChildren()
  110306. * @returns the list of Materials used within the multi material
  110307. */
  110308. getChildren(): Nullable<Material>[];
  110309. /**
  110310. * Instantiates a new Multi Material
  110311. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110312. * separate meshes. This can be use to improve performances.
  110313. * @see https://doc.babylonjs.com/how_to/multi_materials
  110314. * @param name Define the name in the scene
  110315. * @param scene Define the scene the material belongs to
  110316. */
  110317. constructor(name: string, scene: Scene);
  110318. private _hookArray;
  110319. /**
  110320. * Get one of the submaterial by its index in the submaterials array
  110321. * @param index The index to look the sub material at
  110322. * @returns The Material if the index has been defined
  110323. */
  110324. getSubMaterial(index: number): Nullable<Material>;
  110325. /**
  110326. * Get the list of active textures for the whole sub materials list.
  110327. * @returns All the textures that will be used during the rendering
  110328. */
  110329. getActiveTextures(): BaseTexture[];
  110330. /**
  110331. * Gets the current class name of the material e.g. "MultiMaterial"
  110332. * Mainly use in serialization.
  110333. * @returns the class name
  110334. */
  110335. getClassName(): string;
  110336. /**
  110337. * Checks if the material is ready to render the requested sub mesh
  110338. * @param mesh Define the mesh the submesh belongs to
  110339. * @param subMesh Define the sub mesh to look readyness for
  110340. * @param useInstances Define whether or not the material is used with instances
  110341. * @returns true if ready, otherwise false
  110342. */
  110343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110344. /**
  110345. * Clones the current material and its related sub materials
  110346. * @param name Define the name of the newly cloned material
  110347. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110348. * @returns the cloned material
  110349. */
  110350. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110351. /**
  110352. * Serializes the materials into a JSON representation.
  110353. * @returns the JSON representation
  110354. */
  110355. serialize(): any;
  110356. /**
  110357. * Dispose the material and release its associated resources
  110358. * @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)
  110359. * @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)
  110360. * @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)
  110361. */
  110362. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110363. /**
  110364. * Creates a MultiMaterial from parsed MultiMaterial data.
  110365. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110366. * @param scene defines the hosting scene
  110367. * @returns a new MultiMaterial
  110368. */
  110369. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110370. }
  110371. }
  110372. declare module BABYLON {
  110373. /**
  110374. * Defines a subdivision inside a mesh
  110375. */
  110376. export class SubMesh implements ICullable {
  110377. /** the material index to use */
  110378. materialIndex: number;
  110379. /** vertex index start */
  110380. verticesStart: number;
  110381. /** vertices count */
  110382. verticesCount: number;
  110383. /** index start */
  110384. indexStart: number;
  110385. /** indices count */
  110386. indexCount: number;
  110387. /** @hidden */
  110388. _materialDefines: Nullable<MaterialDefines>;
  110389. /** @hidden */
  110390. _materialEffect: Nullable<Effect>;
  110391. /** @hidden */
  110392. _effectOverride: Nullable<Effect>;
  110393. /**
  110394. * Gets material defines used by the effect associated to the sub mesh
  110395. */
  110396. get materialDefines(): Nullable<MaterialDefines>;
  110397. /**
  110398. * Sets material defines used by the effect associated to the sub mesh
  110399. */
  110400. set materialDefines(defines: Nullable<MaterialDefines>);
  110401. /**
  110402. * Gets associated effect
  110403. */
  110404. get effect(): Nullable<Effect>;
  110405. /**
  110406. * Sets associated effect (effect used to render this submesh)
  110407. * @param effect defines the effect to associate with
  110408. * @param defines defines the set of defines used to compile this effect
  110409. */
  110410. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110411. /** @hidden */
  110412. _linesIndexCount: number;
  110413. private _mesh;
  110414. private _renderingMesh;
  110415. private _boundingInfo;
  110416. private _linesIndexBuffer;
  110417. /** @hidden */
  110418. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110419. /** @hidden */
  110420. _trianglePlanes: Plane[];
  110421. /** @hidden */
  110422. _lastColliderTransformMatrix: Nullable<Matrix>;
  110423. /** @hidden */
  110424. _renderId: number;
  110425. /** @hidden */
  110426. _alphaIndex: number;
  110427. /** @hidden */
  110428. _distanceToCamera: number;
  110429. /** @hidden */
  110430. _id: number;
  110431. private _currentMaterial;
  110432. /**
  110433. * Add a new submesh to a mesh
  110434. * @param materialIndex defines the material index to use
  110435. * @param verticesStart defines vertex index start
  110436. * @param verticesCount defines vertices count
  110437. * @param indexStart defines index start
  110438. * @param indexCount defines indices count
  110439. * @param mesh defines the parent mesh
  110440. * @param renderingMesh defines an optional rendering mesh
  110441. * @param createBoundingBox defines if bounding box should be created for this submesh
  110442. * @returns the new submesh
  110443. */
  110444. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110445. /**
  110446. * Creates a new submesh
  110447. * @param materialIndex defines the material index to use
  110448. * @param verticesStart defines vertex index start
  110449. * @param verticesCount defines vertices count
  110450. * @param indexStart defines index start
  110451. * @param indexCount defines indices count
  110452. * @param mesh defines the parent mesh
  110453. * @param renderingMesh defines an optional rendering mesh
  110454. * @param createBoundingBox defines if bounding box should be created for this submesh
  110455. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110456. */
  110457. constructor(
  110458. /** the material index to use */
  110459. materialIndex: number,
  110460. /** vertex index start */
  110461. verticesStart: number,
  110462. /** vertices count */
  110463. verticesCount: number,
  110464. /** index start */
  110465. indexStart: number,
  110466. /** indices count */
  110467. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110468. /**
  110469. * Returns true if this submesh covers the entire parent mesh
  110470. * @ignorenaming
  110471. */
  110472. get IsGlobal(): boolean;
  110473. /**
  110474. * Returns the submesh BoudingInfo object
  110475. * @returns current bounding info (or mesh's one if the submesh is global)
  110476. */
  110477. getBoundingInfo(): BoundingInfo;
  110478. /**
  110479. * Sets the submesh BoundingInfo
  110480. * @param boundingInfo defines the new bounding info to use
  110481. * @returns the SubMesh
  110482. */
  110483. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110484. /**
  110485. * Returns the mesh of the current submesh
  110486. * @return the parent mesh
  110487. */
  110488. getMesh(): AbstractMesh;
  110489. /**
  110490. * Returns the rendering mesh of the submesh
  110491. * @returns the rendering mesh (could be different from parent mesh)
  110492. */
  110493. getRenderingMesh(): Mesh;
  110494. /**
  110495. * Returns the replacement mesh of the submesh
  110496. * @returns the replacement mesh (could be different from parent mesh)
  110497. */
  110498. getReplacementMesh(): Nullable<AbstractMesh>;
  110499. /**
  110500. * Returns the effective mesh of the submesh
  110501. * @returns the effective mesh (could be different from parent mesh)
  110502. */
  110503. getEffectiveMesh(): AbstractMesh;
  110504. /**
  110505. * Returns the submesh material
  110506. * @returns null or the current material
  110507. */
  110508. getMaterial(): Nullable<Material>;
  110509. private _IsMultiMaterial;
  110510. /**
  110511. * Sets a new updated BoundingInfo object to the submesh
  110512. * @param data defines an optional position array to use to determine the bounding info
  110513. * @returns the SubMesh
  110514. */
  110515. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110516. /** @hidden */
  110517. _checkCollision(collider: Collider): boolean;
  110518. /**
  110519. * Updates the submesh BoundingInfo
  110520. * @param world defines the world matrix to use to update the bounding info
  110521. * @returns the submesh
  110522. */
  110523. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110524. /**
  110525. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110526. * @param frustumPlanes defines the frustum planes
  110527. * @returns true if the submesh is intersecting with the frustum
  110528. */
  110529. isInFrustum(frustumPlanes: Plane[]): boolean;
  110530. /**
  110531. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110532. * @param frustumPlanes defines the frustum planes
  110533. * @returns true if the submesh is inside the frustum
  110534. */
  110535. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110536. /**
  110537. * Renders the submesh
  110538. * @param enableAlphaMode defines if alpha needs to be used
  110539. * @returns the submesh
  110540. */
  110541. render(enableAlphaMode: boolean): SubMesh;
  110542. /**
  110543. * @hidden
  110544. */
  110545. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110546. /**
  110547. * Checks if the submesh intersects with a ray
  110548. * @param ray defines the ray to test
  110549. * @returns true is the passed ray intersects the submesh bounding box
  110550. */
  110551. canIntersects(ray: Ray): boolean;
  110552. /**
  110553. * Intersects current submesh with a ray
  110554. * @param ray defines the ray to test
  110555. * @param positions defines mesh's positions array
  110556. * @param indices defines mesh's indices array
  110557. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110558. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110559. * @returns intersection info or null if no intersection
  110560. */
  110561. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110562. /** @hidden */
  110563. private _intersectLines;
  110564. /** @hidden */
  110565. private _intersectUnIndexedLines;
  110566. /** @hidden */
  110567. private _intersectTriangles;
  110568. /** @hidden */
  110569. private _intersectUnIndexedTriangles;
  110570. /** @hidden */
  110571. _rebuild(): void;
  110572. /**
  110573. * Creates a new submesh from the passed mesh
  110574. * @param newMesh defines the new hosting mesh
  110575. * @param newRenderingMesh defines an optional rendering mesh
  110576. * @returns the new submesh
  110577. */
  110578. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110579. /**
  110580. * Release associated resources
  110581. */
  110582. dispose(): void;
  110583. /**
  110584. * Gets the class name
  110585. * @returns the string "SubMesh".
  110586. */
  110587. getClassName(): string;
  110588. /**
  110589. * Creates a new submesh from indices data
  110590. * @param materialIndex the index of the main mesh material
  110591. * @param startIndex the index where to start the copy in the mesh indices array
  110592. * @param indexCount the number of indices to copy then from the startIndex
  110593. * @param mesh the main mesh to create the submesh from
  110594. * @param renderingMesh the optional rendering mesh
  110595. * @returns a new submesh
  110596. */
  110597. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110598. }
  110599. }
  110600. declare module BABYLON {
  110601. /**
  110602. * Class used to represent data loading progression
  110603. */
  110604. export class SceneLoaderFlags {
  110605. private static _ForceFullSceneLoadingForIncremental;
  110606. private static _ShowLoadingScreen;
  110607. private static _CleanBoneMatrixWeights;
  110608. private static _loggingLevel;
  110609. /**
  110610. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110611. */
  110612. static get ForceFullSceneLoadingForIncremental(): boolean;
  110613. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110614. /**
  110615. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110616. */
  110617. static get ShowLoadingScreen(): boolean;
  110618. static set ShowLoadingScreen(value: boolean);
  110619. /**
  110620. * Defines the current logging level (while loading the scene)
  110621. * @ignorenaming
  110622. */
  110623. static get loggingLevel(): number;
  110624. static set loggingLevel(value: number);
  110625. /**
  110626. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110627. */
  110628. static get CleanBoneMatrixWeights(): boolean;
  110629. static set CleanBoneMatrixWeights(value: boolean);
  110630. }
  110631. }
  110632. declare module BABYLON {
  110633. /**
  110634. * Class used to store geometry data (vertex buffers + index buffer)
  110635. */
  110636. export class Geometry implements IGetSetVerticesData {
  110637. /**
  110638. * Gets or sets the ID of the geometry
  110639. */
  110640. id: string;
  110641. /**
  110642. * Gets or sets the unique ID of the geometry
  110643. */
  110644. uniqueId: number;
  110645. /**
  110646. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110647. */
  110648. delayLoadState: number;
  110649. /**
  110650. * Gets the file containing the data to load when running in delay load state
  110651. */
  110652. delayLoadingFile: Nullable<string>;
  110653. /**
  110654. * Callback called when the geometry is updated
  110655. */
  110656. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110657. private _scene;
  110658. private _engine;
  110659. private _meshes;
  110660. private _totalVertices;
  110661. /** @hidden */
  110662. _indices: IndicesArray;
  110663. /** @hidden */
  110664. _vertexBuffers: {
  110665. [key: string]: VertexBuffer;
  110666. };
  110667. private _isDisposed;
  110668. private _extend;
  110669. private _boundingBias;
  110670. /** @hidden */
  110671. _delayInfo: Array<string>;
  110672. private _indexBuffer;
  110673. private _indexBufferIsUpdatable;
  110674. /** @hidden */
  110675. _boundingInfo: Nullable<BoundingInfo>;
  110676. /** @hidden */
  110677. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110678. /** @hidden */
  110679. _softwareSkinningFrameId: number;
  110680. private _vertexArrayObjects;
  110681. private _updatable;
  110682. /** @hidden */
  110683. _positions: Nullable<Vector3[]>;
  110684. /**
  110685. * 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
  110686. */
  110687. get boundingBias(): Vector2;
  110688. /**
  110689. * 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
  110690. */
  110691. set boundingBias(value: Vector2);
  110692. /**
  110693. * Static function used to attach a new empty geometry to a mesh
  110694. * @param mesh defines the mesh to attach the geometry to
  110695. * @returns the new Geometry
  110696. */
  110697. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110698. /** Get the list of meshes using this geometry */
  110699. get meshes(): Mesh[];
  110700. /**
  110701. * 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
  110702. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110703. */
  110704. useBoundingInfoFromGeometry: boolean;
  110705. /**
  110706. * Creates a new geometry
  110707. * @param id defines the unique ID
  110708. * @param scene defines the hosting scene
  110709. * @param vertexData defines the VertexData used to get geometry data
  110710. * @param updatable defines if geometry must be updatable (false by default)
  110711. * @param mesh defines the mesh that will be associated with the geometry
  110712. */
  110713. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110714. /**
  110715. * Gets the current extend of the geometry
  110716. */
  110717. get extend(): {
  110718. minimum: Vector3;
  110719. maximum: Vector3;
  110720. };
  110721. /**
  110722. * Gets the hosting scene
  110723. * @returns the hosting Scene
  110724. */
  110725. getScene(): Scene;
  110726. /**
  110727. * Gets the hosting engine
  110728. * @returns the hosting Engine
  110729. */
  110730. getEngine(): Engine;
  110731. /**
  110732. * Defines if the geometry is ready to use
  110733. * @returns true if the geometry is ready to be used
  110734. */
  110735. isReady(): boolean;
  110736. /**
  110737. * Gets a value indicating that the geometry should not be serialized
  110738. */
  110739. get doNotSerialize(): boolean;
  110740. /** @hidden */
  110741. _rebuild(): void;
  110742. /**
  110743. * Affects all geometry data in one call
  110744. * @param vertexData defines the geometry data
  110745. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110746. */
  110747. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110748. /**
  110749. * Set specific vertex data
  110750. * @param kind defines the data kind (Position, normal, etc...)
  110751. * @param data defines the vertex data to use
  110752. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110753. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110754. */
  110755. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110756. /**
  110757. * Removes a specific vertex data
  110758. * @param kind defines the data kind (Position, normal, etc...)
  110759. */
  110760. removeVerticesData(kind: string): void;
  110761. /**
  110762. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110763. * @param buffer defines the vertex buffer to use
  110764. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110765. */
  110766. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110767. /**
  110768. * Update a specific vertex buffer
  110769. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110770. * It will do nothing if the buffer is not updatable
  110771. * @param kind defines the data kind (Position, normal, etc...)
  110772. * @param data defines the data to use
  110773. * @param offset defines the offset in the target buffer where to store the data
  110774. * @param useBytes set to true if the offset is in bytes
  110775. */
  110776. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110777. /**
  110778. * Update a specific vertex buffer
  110779. * This function will create a new buffer if the current one is not updatable
  110780. * @param kind defines the data kind (Position, normal, etc...)
  110781. * @param data defines the data to use
  110782. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110783. */
  110784. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110785. private _updateBoundingInfo;
  110786. /** @hidden */
  110787. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110788. /**
  110789. * Gets total number of vertices
  110790. * @returns the total number of vertices
  110791. */
  110792. getTotalVertices(): number;
  110793. /**
  110794. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110795. * @param kind defines the data kind (Position, normal, etc...)
  110796. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110797. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110798. * @returns a float array containing vertex data
  110799. */
  110800. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110801. /**
  110802. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110803. * @param kind defines the data kind (Position, normal, etc...)
  110804. * @returns true if the vertex buffer with the specified kind is updatable
  110805. */
  110806. isVertexBufferUpdatable(kind: string): boolean;
  110807. /**
  110808. * Gets a specific vertex buffer
  110809. * @param kind defines the data kind (Position, normal, etc...)
  110810. * @returns a VertexBuffer
  110811. */
  110812. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110813. /**
  110814. * Returns all vertex buffers
  110815. * @return an object holding all vertex buffers indexed by kind
  110816. */
  110817. getVertexBuffers(): Nullable<{
  110818. [key: string]: VertexBuffer;
  110819. }>;
  110820. /**
  110821. * Gets a boolean indicating if specific vertex buffer is present
  110822. * @param kind defines the data kind (Position, normal, etc...)
  110823. * @returns true if data is present
  110824. */
  110825. isVerticesDataPresent(kind: string): boolean;
  110826. /**
  110827. * Gets a list of all attached data kinds (Position, normal, etc...)
  110828. * @returns a list of string containing all kinds
  110829. */
  110830. getVerticesDataKinds(): string[];
  110831. /**
  110832. * Update index buffer
  110833. * @param indices defines the indices to store in the index buffer
  110834. * @param offset defines the offset in the target buffer where to store the data
  110835. * @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)
  110836. */
  110837. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110838. /**
  110839. * Creates a new index buffer
  110840. * @param indices defines the indices to store in the index buffer
  110841. * @param totalVertices defines the total number of vertices (could be null)
  110842. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110843. */
  110844. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110845. /**
  110846. * Return the total number of indices
  110847. * @returns the total number of indices
  110848. */
  110849. getTotalIndices(): number;
  110850. /**
  110851. * Gets the index buffer array
  110852. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110854. * @returns the index buffer array
  110855. */
  110856. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110857. /**
  110858. * Gets the index buffer
  110859. * @return the index buffer
  110860. */
  110861. getIndexBuffer(): Nullable<DataBuffer>;
  110862. /** @hidden */
  110863. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110864. /**
  110865. * Release the associated resources for a specific mesh
  110866. * @param mesh defines the source mesh
  110867. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110868. */
  110869. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110870. /**
  110871. * Apply current geometry to a given mesh
  110872. * @param mesh defines the mesh to apply geometry to
  110873. */
  110874. applyToMesh(mesh: Mesh): void;
  110875. private _updateExtend;
  110876. private _applyToMesh;
  110877. private notifyUpdate;
  110878. /**
  110879. * Load the geometry if it was flagged as delay loaded
  110880. * @param scene defines the hosting scene
  110881. * @param onLoaded defines a callback called when the geometry is loaded
  110882. */
  110883. load(scene: Scene, onLoaded?: () => void): void;
  110884. private _queueLoad;
  110885. /**
  110886. * Invert the geometry to move from a right handed system to a left handed one.
  110887. */
  110888. toLeftHanded(): void;
  110889. /** @hidden */
  110890. _resetPointsArrayCache(): void;
  110891. /** @hidden */
  110892. _generatePointsArray(): boolean;
  110893. /**
  110894. * Gets a value indicating if the geometry is disposed
  110895. * @returns true if the geometry was disposed
  110896. */
  110897. isDisposed(): boolean;
  110898. private _disposeVertexArrayObjects;
  110899. /**
  110900. * Free all associated resources
  110901. */
  110902. dispose(): void;
  110903. /**
  110904. * Clone the current geometry into a new geometry
  110905. * @param id defines the unique ID of the new geometry
  110906. * @returns a new geometry object
  110907. */
  110908. copy(id: string): Geometry;
  110909. /**
  110910. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110911. * @return a JSON representation of the current geometry data (without the vertices data)
  110912. */
  110913. serialize(): any;
  110914. private toNumberArray;
  110915. /**
  110916. * Serialize all vertices data into a JSON oject
  110917. * @returns a JSON representation of the current geometry data
  110918. */
  110919. serializeVerticeData(): any;
  110920. /**
  110921. * Extracts a clone of a mesh geometry
  110922. * @param mesh defines the source mesh
  110923. * @param id defines the unique ID of the new geometry object
  110924. * @returns the new geometry object
  110925. */
  110926. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110927. /**
  110928. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110929. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110930. * Be aware Math.random() could cause collisions, but:
  110931. * "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"
  110932. * @returns a string containing a new GUID
  110933. */
  110934. static RandomId(): string;
  110935. /** @hidden */
  110936. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110937. private static _CleanMatricesWeights;
  110938. /**
  110939. * Create a new geometry from persisted data (Using .babylon file format)
  110940. * @param parsedVertexData defines the persisted data
  110941. * @param scene defines the hosting scene
  110942. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110943. * @returns the new geometry object
  110944. */
  110945. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110946. }
  110947. }
  110948. declare module BABYLON {
  110949. /**
  110950. * Define an interface for all classes that will get and set the data on vertices
  110951. */
  110952. export interface IGetSetVerticesData {
  110953. /**
  110954. * Gets a boolean indicating if specific vertex data is present
  110955. * @param kind defines the vertex data kind to use
  110956. * @returns true is data kind is present
  110957. */
  110958. isVerticesDataPresent(kind: string): boolean;
  110959. /**
  110960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110961. * @param kind defines the data kind (Position, normal, etc...)
  110962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110964. * @returns a float array containing vertex data
  110965. */
  110966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110967. /**
  110968. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110969. * @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.
  110970. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110971. * @returns the indices array or an empty array if the mesh has no geometry
  110972. */
  110973. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110974. /**
  110975. * Set specific vertex data
  110976. * @param kind defines the data kind (Position, normal, etc...)
  110977. * @param data defines the vertex data to use
  110978. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110979. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110980. */
  110981. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  110982. /**
  110983. * Update a specific associated vertex buffer
  110984. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  110985. * - VertexBuffer.PositionKind
  110986. * - VertexBuffer.UVKind
  110987. * - VertexBuffer.UV2Kind
  110988. * - VertexBuffer.UV3Kind
  110989. * - VertexBuffer.UV4Kind
  110990. * - VertexBuffer.UV5Kind
  110991. * - VertexBuffer.UV6Kind
  110992. * - VertexBuffer.ColorKind
  110993. * - VertexBuffer.MatricesIndicesKind
  110994. * - VertexBuffer.MatricesIndicesExtraKind
  110995. * - VertexBuffer.MatricesWeightsKind
  110996. * - VertexBuffer.MatricesWeightsExtraKind
  110997. * @param data defines the data source
  110998. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  110999. * @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)
  111000. */
  111001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111002. /**
  111003. * Creates a new index buffer
  111004. * @param indices defines the indices to store in the index buffer
  111005. * @param totalVertices defines the total number of vertices (could be null)
  111006. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111007. */
  111008. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111009. }
  111010. /**
  111011. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111012. */
  111013. export class VertexData {
  111014. /**
  111015. * Mesh side orientation : usually the external or front surface
  111016. */
  111017. static readonly FRONTSIDE: number;
  111018. /**
  111019. * Mesh side orientation : usually the internal or back surface
  111020. */
  111021. static readonly BACKSIDE: number;
  111022. /**
  111023. * Mesh side orientation : both internal and external or front and back surfaces
  111024. */
  111025. static readonly DOUBLESIDE: number;
  111026. /**
  111027. * Mesh side orientation : by default, `FRONTSIDE`
  111028. */
  111029. static readonly DEFAULTSIDE: number;
  111030. /**
  111031. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111032. */
  111033. positions: Nullable<FloatArray>;
  111034. /**
  111035. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111036. */
  111037. normals: Nullable<FloatArray>;
  111038. /**
  111039. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111040. */
  111041. tangents: Nullable<FloatArray>;
  111042. /**
  111043. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111044. */
  111045. uvs: Nullable<FloatArray>;
  111046. /**
  111047. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111048. */
  111049. uvs2: Nullable<FloatArray>;
  111050. /**
  111051. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111052. */
  111053. uvs3: Nullable<FloatArray>;
  111054. /**
  111055. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111056. */
  111057. uvs4: Nullable<FloatArray>;
  111058. /**
  111059. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111060. */
  111061. uvs5: Nullable<FloatArray>;
  111062. /**
  111063. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111064. */
  111065. uvs6: Nullable<FloatArray>;
  111066. /**
  111067. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111068. */
  111069. colors: Nullable<FloatArray>;
  111070. /**
  111071. * 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).
  111072. */
  111073. matricesIndices: Nullable<FloatArray>;
  111074. /**
  111075. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111076. */
  111077. matricesWeights: Nullable<FloatArray>;
  111078. /**
  111079. * An array extending the number of possible indices
  111080. */
  111081. matricesIndicesExtra: Nullable<FloatArray>;
  111082. /**
  111083. * An array extending the number of possible weights when the number of indices is extended
  111084. */
  111085. matricesWeightsExtra: Nullable<FloatArray>;
  111086. /**
  111087. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111088. */
  111089. indices: Nullable<IndicesArray>;
  111090. /**
  111091. * Uses the passed data array to set the set the values for the specified kind of data
  111092. * @param data a linear array of floating numbers
  111093. * @param kind the type of data that is being set, eg positions, colors etc
  111094. */
  111095. set(data: FloatArray, kind: string): void;
  111096. /**
  111097. * Associates the vertexData to the passed Mesh.
  111098. * Sets it as updatable or not (default `false`)
  111099. * @param mesh the mesh the vertexData is applied to
  111100. * @param updatable when used and having the value true allows new data to update the vertexData
  111101. * @returns the VertexData
  111102. */
  111103. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111104. /**
  111105. * Associates the vertexData to the passed Geometry.
  111106. * Sets it as updatable or not (default `false`)
  111107. * @param geometry the geometry the vertexData is applied to
  111108. * @param updatable when used and having the value true allows new data to update the vertexData
  111109. * @returns VertexData
  111110. */
  111111. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111112. /**
  111113. * Updates the associated mesh
  111114. * @param mesh the mesh to be updated
  111115. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111116. * @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
  111117. * @returns VertexData
  111118. */
  111119. updateMesh(mesh: Mesh): VertexData;
  111120. /**
  111121. * Updates the associated geometry
  111122. * @param geometry the geometry to be updated
  111123. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111124. * @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
  111125. * @returns VertexData.
  111126. */
  111127. updateGeometry(geometry: Geometry): VertexData;
  111128. private _applyTo;
  111129. private _update;
  111130. /**
  111131. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111132. * @param matrix the transforming matrix
  111133. * @returns the VertexData
  111134. */
  111135. transform(matrix: Matrix): VertexData;
  111136. /**
  111137. * Merges the passed VertexData into the current one
  111138. * @param other the VertexData to be merged into the current one
  111139. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111140. * @returns the modified VertexData
  111141. */
  111142. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111143. private _mergeElement;
  111144. private _validate;
  111145. /**
  111146. * Serializes the VertexData
  111147. * @returns a serialized object
  111148. */
  111149. serialize(): any;
  111150. /**
  111151. * Extracts the vertexData from a mesh
  111152. * @param mesh the mesh from which to extract the VertexData
  111153. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111154. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111155. * @returns the object VertexData associated to the passed mesh
  111156. */
  111157. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111158. /**
  111159. * Extracts the vertexData from the geometry
  111160. * @param geometry the geometry from which to extract the VertexData
  111161. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111162. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111163. * @returns the object VertexData associated to the passed mesh
  111164. */
  111165. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111166. private static _ExtractFrom;
  111167. /**
  111168. * Creates the VertexData for a Ribbon
  111169. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111170. * * pathArray array of paths, each of which an array of successive Vector3
  111171. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111172. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111173. * * 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
  111174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111175. * * 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)
  111176. * * 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)
  111177. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111178. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111179. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111180. * @returns the VertexData of the ribbon
  111181. */
  111182. static CreateRibbon(options: {
  111183. pathArray: Vector3[][];
  111184. closeArray?: boolean;
  111185. closePath?: boolean;
  111186. offset?: number;
  111187. sideOrientation?: number;
  111188. frontUVs?: Vector4;
  111189. backUVs?: Vector4;
  111190. invertUV?: boolean;
  111191. uvs?: Vector2[];
  111192. colors?: Color4[];
  111193. }): VertexData;
  111194. /**
  111195. * Creates the VertexData for a box
  111196. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111197. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111198. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111199. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111200. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111201. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111202. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111204. * * 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)
  111205. * * 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)
  111206. * @returns the VertexData of the box
  111207. */
  111208. static CreateBox(options: {
  111209. size?: number;
  111210. width?: number;
  111211. height?: number;
  111212. depth?: number;
  111213. faceUV?: Vector4[];
  111214. faceColors?: Color4[];
  111215. sideOrientation?: number;
  111216. frontUVs?: Vector4;
  111217. backUVs?: Vector4;
  111218. }): VertexData;
  111219. /**
  111220. * Creates the VertexData for a tiled box
  111221. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111222. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111223. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111224. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111226. * @returns the VertexData of the box
  111227. */
  111228. static CreateTiledBox(options: {
  111229. pattern?: number;
  111230. width?: number;
  111231. height?: number;
  111232. depth?: number;
  111233. tileSize?: number;
  111234. tileWidth?: number;
  111235. tileHeight?: number;
  111236. alignHorizontal?: number;
  111237. alignVertical?: number;
  111238. faceUV?: Vector4[];
  111239. faceColors?: Color4[];
  111240. sideOrientation?: number;
  111241. }): VertexData;
  111242. /**
  111243. * Creates the VertexData for a tiled plane
  111244. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111245. * * pattern a limited pattern arrangement depending on the number
  111246. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111247. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111248. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111250. * * 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)
  111251. * * 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)
  111252. * @returns the VertexData of the tiled plane
  111253. */
  111254. static CreateTiledPlane(options: {
  111255. pattern?: number;
  111256. tileSize?: number;
  111257. tileWidth?: number;
  111258. tileHeight?: number;
  111259. size?: number;
  111260. width?: number;
  111261. height?: number;
  111262. alignHorizontal?: number;
  111263. alignVertical?: number;
  111264. sideOrientation?: number;
  111265. frontUVs?: Vector4;
  111266. backUVs?: Vector4;
  111267. }): VertexData;
  111268. /**
  111269. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111270. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111271. * * segments sets the number of horizontal strips optional, default 32
  111272. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111273. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111274. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111275. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111276. * * 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
  111277. * * 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
  111278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111279. * * 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)
  111280. * * 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)
  111281. * @returns the VertexData of the ellipsoid
  111282. */
  111283. static CreateSphere(options: {
  111284. segments?: number;
  111285. diameter?: number;
  111286. diameterX?: number;
  111287. diameterY?: number;
  111288. diameterZ?: number;
  111289. arc?: number;
  111290. slice?: number;
  111291. sideOrientation?: number;
  111292. frontUVs?: Vector4;
  111293. backUVs?: Vector4;
  111294. }): VertexData;
  111295. /**
  111296. * Creates the VertexData for a cylinder, cone or prism
  111297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111298. * * height sets the height (y direction) of the cylinder, optional, default 2
  111299. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111300. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111301. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111302. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111303. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111304. * * 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
  111305. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111306. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111307. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111308. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111310. * * 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)
  111311. * * 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)
  111312. * @returns the VertexData of the cylinder, cone or prism
  111313. */
  111314. static CreateCylinder(options: {
  111315. height?: number;
  111316. diameterTop?: number;
  111317. diameterBottom?: number;
  111318. diameter?: number;
  111319. tessellation?: number;
  111320. subdivisions?: number;
  111321. arc?: number;
  111322. faceColors?: Color4[];
  111323. faceUV?: Vector4[];
  111324. hasRings?: boolean;
  111325. enclose?: boolean;
  111326. sideOrientation?: number;
  111327. frontUVs?: Vector4;
  111328. backUVs?: Vector4;
  111329. }): VertexData;
  111330. /**
  111331. * Creates the VertexData for a torus
  111332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111333. * * diameter the diameter of the torus, optional default 1
  111334. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111335. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111337. * * 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)
  111338. * * 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)
  111339. * @returns the VertexData of the torus
  111340. */
  111341. static CreateTorus(options: {
  111342. diameter?: number;
  111343. thickness?: number;
  111344. tessellation?: number;
  111345. sideOrientation?: number;
  111346. frontUVs?: Vector4;
  111347. backUVs?: Vector4;
  111348. }): VertexData;
  111349. /**
  111350. * Creates the VertexData of the LineSystem
  111351. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111352. * - lines an array of lines, each line being an array of successive Vector3
  111353. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111354. * @returns the VertexData of the LineSystem
  111355. */
  111356. static CreateLineSystem(options: {
  111357. lines: Vector3[][];
  111358. colors?: Nullable<Color4[][]>;
  111359. }): VertexData;
  111360. /**
  111361. * Create the VertexData for a DashedLines
  111362. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111363. * - points an array successive Vector3
  111364. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111365. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111366. * - dashNb the intended total number of dashes, optional, default 200
  111367. * @returns the VertexData for the DashedLines
  111368. */
  111369. static CreateDashedLines(options: {
  111370. points: Vector3[];
  111371. dashSize?: number;
  111372. gapSize?: number;
  111373. dashNb?: number;
  111374. }): VertexData;
  111375. /**
  111376. * Creates the VertexData for a Ground
  111377. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111378. * - width the width (x direction) of the ground, optional, default 1
  111379. * - height the height (z direction) of the ground, optional, default 1
  111380. * - subdivisions the number of subdivisions per side, optional, default 1
  111381. * @returns the VertexData of the Ground
  111382. */
  111383. static CreateGround(options: {
  111384. width?: number;
  111385. height?: number;
  111386. subdivisions?: number;
  111387. subdivisionsX?: number;
  111388. subdivisionsY?: number;
  111389. }): VertexData;
  111390. /**
  111391. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111393. * * xmin the ground minimum X coordinate, optional, default -1
  111394. * * zmin the ground minimum Z coordinate, optional, default -1
  111395. * * xmax the ground maximum X coordinate, optional, default 1
  111396. * * zmax the ground maximum Z coordinate, optional, default 1
  111397. * * 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}
  111398. * * 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}
  111399. * @returns the VertexData of the TiledGround
  111400. */
  111401. static CreateTiledGround(options: {
  111402. xmin: number;
  111403. zmin: number;
  111404. xmax: number;
  111405. zmax: number;
  111406. subdivisions?: {
  111407. w: number;
  111408. h: number;
  111409. };
  111410. precision?: {
  111411. w: number;
  111412. h: number;
  111413. };
  111414. }): VertexData;
  111415. /**
  111416. * Creates the VertexData of the Ground designed from a heightmap
  111417. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111418. * * width the width (x direction) of the ground
  111419. * * height the height (z direction) of the ground
  111420. * * subdivisions the number of subdivisions per side
  111421. * * minHeight the minimum altitude on the ground, optional, default 0
  111422. * * maxHeight the maximum altitude on the ground, optional default 1
  111423. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111424. * * buffer the array holding the image color data
  111425. * * bufferWidth the width of image
  111426. * * bufferHeight the height of image
  111427. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111428. * @returns the VertexData of the Ground designed from a heightmap
  111429. */
  111430. static CreateGroundFromHeightMap(options: {
  111431. width: number;
  111432. height: number;
  111433. subdivisions: number;
  111434. minHeight: number;
  111435. maxHeight: number;
  111436. colorFilter: Color3;
  111437. buffer: Uint8Array;
  111438. bufferWidth: number;
  111439. bufferHeight: number;
  111440. alphaFilter: number;
  111441. }): VertexData;
  111442. /**
  111443. * Creates the VertexData for a Plane
  111444. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111445. * * size sets the width and height of the plane to the value of size, optional default 1
  111446. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111447. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111449. * * 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)
  111450. * * 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)
  111451. * @returns the VertexData of the box
  111452. */
  111453. static CreatePlane(options: {
  111454. size?: number;
  111455. width?: number;
  111456. height?: number;
  111457. sideOrientation?: number;
  111458. frontUVs?: Vector4;
  111459. backUVs?: Vector4;
  111460. }): VertexData;
  111461. /**
  111462. * Creates the VertexData of the Disc or regular Polygon
  111463. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111464. * * radius the radius of the disc, optional default 0.5
  111465. * * tessellation the number of polygon sides, optional, default 64
  111466. * * 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
  111467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111468. * * 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)
  111469. * * 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)
  111470. * @returns the VertexData of the box
  111471. */
  111472. static CreateDisc(options: {
  111473. radius?: number;
  111474. tessellation?: number;
  111475. arc?: number;
  111476. sideOrientation?: number;
  111477. frontUVs?: Vector4;
  111478. backUVs?: Vector4;
  111479. }): VertexData;
  111480. /**
  111481. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111482. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111483. * @param polygon a mesh built from polygonTriangulation.build()
  111484. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111485. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111486. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111487. * @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)
  111488. * @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)
  111489. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111490. * @returns the VertexData of the Polygon
  111491. */
  111492. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111493. /**
  111494. * Creates the VertexData of the IcoSphere
  111495. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111496. * * radius the radius of the IcoSphere, optional default 1
  111497. * * radiusX allows stretching in the x direction, optional, default radius
  111498. * * radiusY allows stretching in the y direction, optional, default radius
  111499. * * radiusZ allows stretching in the z direction, optional, default radius
  111500. * * flat when true creates a flat shaded mesh, optional, default true
  111501. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111503. * * 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)
  111504. * * 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)
  111505. * @returns the VertexData of the IcoSphere
  111506. */
  111507. static CreateIcoSphere(options: {
  111508. radius?: number;
  111509. radiusX?: number;
  111510. radiusY?: number;
  111511. radiusZ?: number;
  111512. flat?: boolean;
  111513. subdivisions?: number;
  111514. sideOrientation?: number;
  111515. frontUVs?: Vector4;
  111516. backUVs?: Vector4;
  111517. }): VertexData;
  111518. /**
  111519. * Creates the VertexData for a Polyhedron
  111520. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111521. * * type provided types are:
  111522. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111523. * * 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)
  111524. * * size the size of the IcoSphere, optional default 1
  111525. * * sizeX allows stretching in the x direction, optional, default size
  111526. * * sizeY allows stretching in the y direction, optional, default size
  111527. * * sizeZ allows stretching in the z direction, optional, default size
  111528. * * 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
  111529. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111530. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111531. * * flat when true creates a flat shaded mesh, optional, default true
  111532. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111534. * * 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)
  111535. * * 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)
  111536. * @returns the VertexData of the Polyhedron
  111537. */
  111538. static CreatePolyhedron(options: {
  111539. type?: number;
  111540. size?: number;
  111541. sizeX?: number;
  111542. sizeY?: number;
  111543. sizeZ?: number;
  111544. custom?: any;
  111545. faceUV?: Vector4[];
  111546. faceColors?: Color4[];
  111547. flat?: boolean;
  111548. sideOrientation?: number;
  111549. frontUVs?: Vector4;
  111550. backUVs?: Vector4;
  111551. }): VertexData;
  111552. /**
  111553. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111554. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111555. * @returns the VertexData of the Capsule
  111556. */
  111557. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111558. /**
  111559. * Creates the VertexData for a TorusKnot
  111560. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111561. * * radius the radius of the torus knot, optional, default 2
  111562. * * tube the thickness of the tube, optional, default 0.5
  111563. * * radialSegments the number of sides on each tube segments, optional, default 32
  111564. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111565. * * p the number of windings around the z axis, optional, default 2
  111566. * * q the number of windings around the x axis, optional, default 3
  111567. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111568. * * 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)
  111569. * * 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)
  111570. * @returns the VertexData of the Torus Knot
  111571. */
  111572. static CreateTorusKnot(options: {
  111573. radius?: number;
  111574. tube?: number;
  111575. radialSegments?: number;
  111576. tubularSegments?: number;
  111577. p?: number;
  111578. q?: number;
  111579. sideOrientation?: number;
  111580. frontUVs?: Vector4;
  111581. backUVs?: Vector4;
  111582. }): VertexData;
  111583. /**
  111584. * Compute normals for given positions and indices
  111585. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111586. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111587. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111588. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111589. * * facetNormals : optional array of facet normals (vector3)
  111590. * * facetPositions : optional array of facet positions (vector3)
  111591. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111592. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111593. * * bInfo : optional bounding info, required for facetPartitioning computation
  111594. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111595. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111596. * * useRightHandedSystem: optional boolean to for right handed system computation
  111597. * * depthSort : optional boolean to enable the facet depth sort computation
  111598. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111599. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111600. */
  111601. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111602. facetNormals?: any;
  111603. facetPositions?: any;
  111604. facetPartitioning?: any;
  111605. ratio?: number;
  111606. bInfo?: any;
  111607. bbSize?: Vector3;
  111608. subDiv?: any;
  111609. useRightHandedSystem?: boolean;
  111610. depthSort?: boolean;
  111611. distanceTo?: Vector3;
  111612. depthSortedFacets?: any;
  111613. }): void;
  111614. /** @hidden */
  111615. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111616. /**
  111617. * Applies VertexData created from the imported parameters to the geometry
  111618. * @param parsedVertexData the parsed data from an imported file
  111619. * @param geometry the geometry to apply the VertexData to
  111620. */
  111621. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111622. }
  111623. }
  111624. declare module BABYLON {
  111625. /**
  111626. * Defines a target to use with MorphTargetManager
  111627. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111628. */
  111629. export class MorphTarget implements IAnimatable {
  111630. /** defines the name of the target */
  111631. name: string;
  111632. /**
  111633. * Gets or sets the list of animations
  111634. */
  111635. animations: Animation[];
  111636. private _scene;
  111637. private _positions;
  111638. private _normals;
  111639. private _tangents;
  111640. private _uvs;
  111641. private _influence;
  111642. private _uniqueId;
  111643. /**
  111644. * Observable raised when the influence changes
  111645. */
  111646. onInfluenceChanged: Observable<boolean>;
  111647. /** @hidden */
  111648. _onDataLayoutChanged: Observable<void>;
  111649. /**
  111650. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111651. */
  111652. get influence(): number;
  111653. set influence(influence: number);
  111654. /**
  111655. * Gets or sets the id of the morph Target
  111656. */
  111657. id: string;
  111658. private _animationPropertiesOverride;
  111659. /**
  111660. * Gets or sets the animation properties override
  111661. */
  111662. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111663. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111664. /**
  111665. * Creates a new MorphTarget
  111666. * @param name defines the name of the target
  111667. * @param influence defines the influence to use
  111668. * @param scene defines the scene the morphtarget belongs to
  111669. */
  111670. constructor(
  111671. /** defines the name of the target */
  111672. name: string, influence?: number, scene?: Nullable<Scene>);
  111673. /**
  111674. * Gets the unique ID of this manager
  111675. */
  111676. get uniqueId(): number;
  111677. /**
  111678. * Gets a boolean defining if the target contains position data
  111679. */
  111680. get hasPositions(): boolean;
  111681. /**
  111682. * Gets a boolean defining if the target contains normal data
  111683. */
  111684. get hasNormals(): boolean;
  111685. /**
  111686. * Gets a boolean defining if the target contains tangent data
  111687. */
  111688. get hasTangents(): boolean;
  111689. /**
  111690. * Gets a boolean defining if the target contains texture coordinates data
  111691. */
  111692. get hasUVs(): boolean;
  111693. /**
  111694. * Affects position data to this target
  111695. * @param data defines the position data to use
  111696. */
  111697. setPositions(data: Nullable<FloatArray>): void;
  111698. /**
  111699. * Gets the position data stored in this target
  111700. * @returns a FloatArray containing the position data (or null if not present)
  111701. */
  111702. getPositions(): Nullable<FloatArray>;
  111703. /**
  111704. * Affects normal data to this target
  111705. * @param data defines the normal data to use
  111706. */
  111707. setNormals(data: Nullable<FloatArray>): void;
  111708. /**
  111709. * Gets the normal data stored in this target
  111710. * @returns a FloatArray containing the normal data (or null if not present)
  111711. */
  111712. getNormals(): Nullable<FloatArray>;
  111713. /**
  111714. * Affects tangent data to this target
  111715. * @param data defines the tangent data to use
  111716. */
  111717. setTangents(data: Nullable<FloatArray>): void;
  111718. /**
  111719. * Gets the tangent data stored in this target
  111720. * @returns a FloatArray containing the tangent data (or null if not present)
  111721. */
  111722. getTangents(): Nullable<FloatArray>;
  111723. /**
  111724. * Affects texture coordinates data to this target
  111725. * @param data defines the texture coordinates data to use
  111726. */
  111727. setUVs(data: Nullable<FloatArray>): void;
  111728. /**
  111729. * Gets the texture coordinates data stored in this target
  111730. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111731. */
  111732. getUVs(): Nullable<FloatArray>;
  111733. /**
  111734. * Clone the current target
  111735. * @returns a new MorphTarget
  111736. */
  111737. clone(): MorphTarget;
  111738. /**
  111739. * Serializes the current target into a Serialization object
  111740. * @returns the serialized object
  111741. */
  111742. serialize(): any;
  111743. /**
  111744. * Returns the string "MorphTarget"
  111745. * @returns "MorphTarget"
  111746. */
  111747. getClassName(): string;
  111748. /**
  111749. * Creates a new target from serialized data
  111750. * @param serializationObject defines the serialized data to use
  111751. * @returns a new MorphTarget
  111752. */
  111753. static Parse(serializationObject: any): MorphTarget;
  111754. /**
  111755. * Creates a MorphTarget from mesh data
  111756. * @param mesh defines the source mesh
  111757. * @param name defines the name to use for the new target
  111758. * @param influence defines the influence to attach to the target
  111759. * @returns a new MorphTarget
  111760. */
  111761. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111762. }
  111763. }
  111764. declare module BABYLON {
  111765. /**
  111766. * This class is used to deform meshes using morphing between different targets
  111767. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111768. */
  111769. export class MorphTargetManager {
  111770. private _targets;
  111771. private _targetInfluenceChangedObservers;
  111772. private _targetDataLayoutChangedObservers;
  111773. private _activeTargets;
  111774. private _scene;
  111775. private _influences;
  111776. private _supportsNormals;
  111777. private _supportsTangents;
  111778. private _supportsUVs;
  111779. private _vertexCount;
  111780. private _uniqueId;
  111781. private _tempInfluences;
  111782. /**
  111783. * Gets or sets a boolean indicating if normals must be morphed
  111784. */
  111785. enableNormalMorphing: boolean;
  111786. /**
  111787. * Gets or sets a boolean indicating if tangents must be morphed
  111788. */
  111789. enableTangentMorphing: boolean;
  111790. /**
  111791. * Gets or sets a boolean indicating if UV must be morphed
  111792. */
  111793. enableUVMorphing: boolean;
  111794. /**
  111795. * Creates a new MorphTargetManager
  111796. * @param scene defines the current scene
  111797. */
  111798. constructor(scene?: Nullable<Scene>);
  111799. /**
  111800. * Gets the unique ID of this manager
  111801. */
  111802. get uniqueId(): number;
  111803. /**
  111804. * Gets the number of vertices handled by this manager
  111805. */
  111806. get vertexCount(): number;
  111807. /**
  111808. * Gets a boolean indicating if this manager supports morphing of normals
  111809. */
  111810. get supportsNormals(): boolean;
  111811. /**
  111812. * Gets a boolean indicating if this manager supports morphing of tangents
  111813. */
  111814. get supportsTangents(): boolean;
  111815. /**
  111816. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111817. */
  111818. get supportsUVs(): boolean;
  111819. /**
  111820. * Gets the number of targets stored in this manager
  111821. */
  111822. get numTargets(): number;
  111823. /**
  111824. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111825. */
  111826. get numInfluencers(): number;
  111827. /**
  111828. * Gets the list of influences (one per target)
  111829. */
  111830. get influences(): Float32Array;
  111831. /**
  111832. * Gets the active target at specified index. An active target is a target with an influence > 0
  111833. * @param index defines the index to check
  111834. * @returns the requested target
  111835. */
  111836. getActiveTarget(index: number): MorphTarget;
  111837. /**
  111838. * Gets the target at specified index
  111839. * @param index defines the index to check
  111840. * @returns the requested target
  111841. */
  111842. getTarget(index: number): MorphTarget;
  111843. /**
  111844. * Add a new target to this manager
  111845. * @param target defines the target to add
  111846. */
  111847. addTarget(target: MorphTarget): void;
  111848. /**
  111849. * Removes a target from the manager
  111850. * @param target defines the target to remove
  111851. */
  111852. removeTarget(target: MorphTarget): void;
  111853. /**
  111854. * Clone the current manager
  111855. * @returns a new MorphTargetManager
  111856. */
  111857. clone(): MorphTargetManager;
  111858. /**
  111859. * Serializes the current manager into a Serialization object
  111860. * @returns the serialized object
  111861. */
  111862. serialize(): any;
  111863. private _syncActiveTargets;
  111864. /**
  111865. * Syncrhonize the targets with all the meshes using this morph target manager
  111866. */
  111867. synchronize(): void;
  111868. /**
  111869. * Creates a new MorphTargetManager from serialized data
  111870. * @param serializationObject defines the serialized data
  111871. * @param scene defines the hosting scene
  111872. * @returns the new MorphTargetManager
  111873. */
  111874. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111875. }
  111876. }
  111877. declare module BABYLON {
  111878. /**
  111879. * Class used to represent a specific level of detail of a mesh
  111880. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111881. */
  111882. export class MeshLODLevel {
  111883. /** Defines the distance where this level should start being displayed */
  111884. distance: number;
  111885. /** Defines the mesh to use to render this level */
  111886. mesh: Nullable<Mesh>;
  111887. /**
  111888. * Creates a new LOD level
  111889. * @param distance defines the distance where this level should star being displayed
  111890. * @param mesh defines the mesh to use to render this level
  111891. */
  111892. constructor(
  111893. /** Defines the distance where this level should start being displayed */
  111894. distance: number,
  111895. /** Defines the mesh to use to render this level */
  111896. mesh: Nullable<Mesh>);
  111897. }
  111898. }
  111899. declare module BABYLON {
  111900. /**
  111901. * Helper class used to generate a canvas to manipulate images
  111902. */
  111903. export class CanvasGenerator {
  111904. /**
  111905. * Create a new canvas (or offscreen canvas depending on the context)
  111906. * @param width defines the expected width
  111907. * @param height defines the expected height
  111908. * @return a new canvas or offscreen canvas
  111909. */
  111910. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111911. }
  111912. }
  111913. declare module BABYLON {
  111914. /**
  111915. * Mesh representing the gorund
  111916. */
  111917. export class GroundMesh extends Mesh {
  111918. /** If octree should be generated */
  111919. generateOctree: boolean;
  111920. private _heightQuads;
  111921. /** @hidden */
  111922. _subdivisionsX: number;
  111923. /** @hidden */
  111924. _subdivisionsY: number;
  111925. /** @hidden */
  111926. _width: number;
  111927. /** @hidden */
  111928. _height: number;
  111929. /** @hidden */
  111930. _minX: number;
  111931. /** @hidden */
  111932. _maxX: number;
  111933. /** @hidden */
  111934. _minZ: number;
  111935. /** @hidden */
  111936. _maxZ: number;
  111937. constructor(name: string, scene: Scene);
  111938. /**
  111939. * "GroundMesh"
  111940. * @returns "GroundMesh"
  111941. */
  111942. getClassName(): string;
  111943. /**
  111944. * The minimum of x and y subdivisions
  111945. */
  111946. get subdivisions(): number;
  111947. /**
  111948. * X subdivisions
  111949. */
  111950. get subdivisionsX(): number;
  111951. /**
  111952. * Y subdivisions
  111953. */
  111954. get subdivisionsY(): number;
  111955. /**
  111956. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111957. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111958. * @param chunksCount the number of subdivisions for x and y
  111959. * @param octreeBlocksSize (Default: 32)
  111960. */
  111961. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111962. /**
  111963. * Returns a height (y) value in the Worl system :
  111964. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111965. * @param x x coordinate
  111966. * @param z z coordinate
  111967. * @returns the ground y position if (x, z) are outside the ground surface.
  111968. */
  111969. getHeightAtCoordinates(x: number, z: number): number;
  111970. /**
  111971. * Returns a normalized vector (Vector3) orthogonal to the ground
  111972. * at the ground coordinates (x, z) expressed in the World system.
  111973. * @param x x coordinate
  111974. * @param z z coordinate
  111975. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111976. */
  111977. getNormalAtCoordinates(x: number, z: number): Vector3;
  111978. /**
  111979. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111980. * at the ground coordinates (x, z) expressed in the World system.
  111981. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  111982. * @param x x coordinate
  111983. * @param z z coordinate
  111984. * @param ref vector to store the result
  111985. * @returns the GroundMesh.
  111986. */
  111987. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  111988. /**
  111989. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  111990. * if the ground has been updated.
  111991. * This can be used in the render loop.
  111992. * @returns the GroundMesh.
  111993. */
  111994. updateCoordinateHeights(): GroundMesh;
  111995. private _getFacetAt;
  111996. private _initHeightQuads;
  111997. private _computeHeightQuads;
  111998. /**
  111999. * Serializes this ground mesh
  112000. * @param serializationObject object to write serialization to
  112001. */
  112002. serialize(serializationObject: any): void;
  112003. /**
  112004. * Parses a serialized ground mesh
  112005. * @param parsedMesh the serialized mesh
  112006. * @param scene the scene to create the ground mesh in
  112007. * @returns the created ground mesh
  112008. */
  112009. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112010. }
  112011. }
  112012. declare module BABYLON {
  112013. /**
  112014. * Interface for Physics-Joint data
  112015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112016. */
  112017. export interface PhysicsJointData {
  112018. /**
  112019. * The main pivot of the joint
  112020. */
  112021. mainPivot?: Vector3;
  112022. /**
  112023. * The connected pivot of the joint
  112024. */
  112025. connectedPivot?: Vector3;
  112026. /**
  112027. * The main axis of the joint
  112028. */
  112029. mainAxis?: Vector3;
  112030. /**
  112031. * The connected axis of the joint
  112032. */
  112033. connectedAxis?: Vector3;
  112034. /**
  112035. * The collision of the joint
  112036. */
  112037. collision?: boolean;
  112038. /**
  112039. * Native Oimo/Cannon/Energy data
  112040. */
  112041. nativeParams?: any;
  112042. }
  112043. /**
  112044. * This is a holder class for the physics joint created by the physics plugin
  112045. * It holds a set of functions to control the underlying joint
  112046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112047. */
  112048. export class PhysicsJoint {
  112049. /**
  112050. * The type of the physics joint
  112051. */
  112052. type: number;
  112053. /**
  112054. * The data for the physics joint
  112055. */
  112056. jointData: PhysicsJointData;
  112057. private _physicsJoint;
  112058. protected _physicsPlugin: IPhysicsEnginePlugin;
  112059. /**
  112060. * Initializes the physics joint
  112061. * @param type The type of the physics joint
  112062. * @param jointData The data for the physics joint
  112063. */
  112064. constructor(
  112065. /**
  112066. * The type of the physics joint
  112067. */
  112068. type: number,
  112069. /**
  112070. * The data for the physics joint
  112071. */
  112072. jointData: PhysicsJointData);
  112073. /**
  112074. * Gets the physics joint
  112075. */
  112076. get physicsJoint(): any;
  112077. /**
  112078. * Sets the physics joint
  112079. */
  112080. set physicsJoint(newJoint: any);
  112081. /**
  112082. * Sets the physics plugin
  112083. */
  112084. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112085. /**
  112086. * Execute a function that is physics-plugin specific.
  112087. * @param {Function} func the function that will be executed.
  112088. * It accepts two parameters: the physics world and the physics joint
  112089. */
  112090. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112091. /**
  112092. * Distance-Joint type
  112093. */
  112094. static DistanceJoint: number;
  112095. /**
  112096. * Hinge-Joint type
  112097. */
  112098. static HingeJoint: number;
  112099. /**
  112100. * Ball-and-Socket joint type
  112101. */
  112102. static BallAndSocketJoint: number;
  112103. /**
  112104. * Wheel-Joint type
  112105. */
  112106. static WheelJoint: number;
  112107. /**
  112108. * Slider-Joint type
  112109. */
  112110. static SliderJoint: number;
  112111. /**
  112112. * Prismatic-Joint type
  112113. */
  112114. static PrismaticJoint: number;
  112115. /**
  112116. * Universal-Joint type
  112117. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112118. */
  112119. static UniversalJoint: number;
  112120. /**
  112121. * Hinge-Joint 2 type
  112122. */
  112123. static Hinge2Joint: number;
  112124. /**
  112125. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112126. */
  112127. static PointToPointJoint: number;
  112128. /**
  112129. * Spring-Joint type
  112130. */
  112131. static SpringJoint: number;
  112132. /**
  112133. * Lock-Joint type
  112134. */
  112135. static LockJoint: number;
  112136. }
  112137. /**
  112138. * A class representing a physics distance joint
  112139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112140. */
  112141. export class DistanceJoint extends PhysicsJoint {
  112142. /**
  112143. *
  112144. * @param jointData The data for the Distance-Joint
  112145. */
  112146. constructor(jointData: DistanceJointData);
  112147. /**
  112148. * Update the predefined distance.
  112149. * @param maxDistance The maximum preferred distance
  112150. * @param minDistance The minimum preferred distance
  112151. */
  112152. updateDistance(maxDistance: number, minDistance?: number): void;
  112153. }
  112154. /**
  112155. * Represents a Motor-Enabled Joint
  112156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112157. */
  112158. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112159. /**
  112160. * Initializes the Motor-Enabled Joint
  112161. * @param type The type of the joint
  112162. * @param jointData The physica joint data for the joint
  112163. */
  112164. constructor(type: number, jointData: PhysicsJointData);
  112165. /**
  112166. * Set the motor values.
  112167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112168. * @param force the force to apply
  112169. * @param maxForce max force for this motor.
  112170. */
  112171. setMotor(force?: number, maxForce?: number): void;
  112172. /**
  112173. * Set the motor's limits.
  112174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112175. * @param upperLimit The upper limit of the motor
  112176. * @param lowerLimit The lower limit of the motor
  112177. */
  112178. setLimit(upperLimit: number, lowerLimit?: number): void;
  112179. }
  112180. /**
  112181. * This class represents a single physics Hinge-Joint
  112182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112183. */
  112184. export class HingeJoint extends MotorEnabledJoint {
  112185. /**
  112186. * Initializes the Hinge-Joint
  112187. * @param jointData The joint data for the Hinge-Joint
  112188. */
  112189. constructor(jointData: PhysicsJointData);
  112190. /**
  112191. * Set the motor values.
  112192. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112193. * @param {number} force the force to apply
  112194. * @param {number} maxForce max force for this motor.
  112195. */
  112196. setMotor(force?: number, maxForce?: number): void;
  112197. /**
  112198. * Set the motor's limits.
  112199. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112200. * @param upperLimit The upper limit of the motor
  112201. * @param lowerLimit The lower limit of the motor
  112202. */
  112203. setLimit(upperLimit: number, lowerLimit?: number): void;
  112204. }
  112205. /**
  112206. * This class represents a dual hinge physics joint (same as wheel joint)
  112207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112208. */
  112209. export class Hinge2Joint extends MotorEnabledJoint {
  112210. /**
  112211. * Initializes the Hinge2-Joint
  112212. * @param jointData The joint data for the Hinge2-Joint
  112213. */
  112214. constructor(jointData: PhysicsJointData);
  112215. /**
  112216. * Set the motor values.
  112217. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112218. * @param {number} targetSpeed the speed the motor is to reach
  112219. * @param {number} maxForce max force for this motor.
  112220. * @param {motorIndex} the motor's index, 0 or 1.
  112221. */
  112222. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112223. /**
  112224. * Set the motor limits.
  112225. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112226. * @param {number} upperLimit the upper limit
  112227. * @param {number} lowerLimit lower limit
  112228. * @param {motorIndex} the motor's index, 0 or 1.
  112229. */
  112230. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112231. }
  112232. /**
  112233. * Interface for a motor enabled joint
  112234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112235. */
  112236. export interface IMotorEnabledJoint {
  112237. /**
  112238. * Physics joint
  112239. */
  112240. physicsJoint: any;
  112241. /**
  112242. * Sets the motor of the motor-enabled joint
  112243. * @param force The force of the motor
  112244. * @param maxForce The maximum force of the motor
  112245. * @param motorIndex The index of the motor
  112246. */
  112247. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112248. /**
  112249. * Sets the limit of the motor
  112250. * @param upperLimit The upper limit of the motor
  112251. * @param lowerLimit The lower limit of the motor
  112252. * @param motorIndex The index of the motor
  112253. */
  112254. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112255. }
  112256. /**
  112257. * Joint data for a Distance-Joint
  112258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112259. */
  112260. export interface DistanceJointData extends PhysicsJointData {
  112261. /**
  112262. * Max distance the 2 joint objects can be apart
  112263. */
  112264. maxDistance: number;
  112265. }
  112266. /**
  112267. * Joint data from a spring joint
  112268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112269. */
  112270. export interface SpringJointData extends PhysicsJointData {
  112271. /**
  112272. * Length of the spring
  112273. */
  112274. length: number;
  112275. /**
  112276. * Stiffness of the spring
  112277. */
  112278. stiffness: number;
  112279. /**
  112280. * Damping of the spring
  112281. */
  112282. damping: number;
  112283. /** this callback will be called when applying the force to the impostors. */
  112284. forceApplicationCallback: () => void;
  112285. }
  112286. }
  112287. declare module BABYLON {
  112288. /**
  112289. * Holds the data for the raycast result
  112290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112291. */
  112292. export class PhysicsRaycastResult {
  112293. private _hasHit;
  112294. private _hitDistance;
  112295. private _hitNormalWorld;
  112296. private _hitPointWorld;
  112297. private _rayFromWorld;
  112298. private _rayToWorld;
  112299. /**
  112300. * Gets if there was a hit
  112301. */
  112302. get hasHit(): boolean;
  112303. /**
  112304. * Gets the distance from the hit
  112305. */
  112306. get hitDistance(): number;
  112307. /**
  112308. * Gets the hit normal/direction in the world
  112309. */
  112310. get hitNormalWorld(): Vector3;
  112311. /**
  112312. * Gets the hit point in the world
  112313. */
  112314. get hitPointWorld(): Vector3;
  112315. /**
  112316. * Gets the ray "start point" of the ray in the world
  112317. */
  112318. get rayFromWorld(): Vector3;
  112319. /**
  112320. * Gets the ray "end point" of the ray in the world
  112321. */
  112322. get rayToWorld(): Vector3;
  112323. /**
  112324. * Sets the hit data (normal & point in world space)
  112325. * @param hitNormalWorld defines the normal in world space
  112326. * @param hitPointWorld defines the point in world space
  112327. */
  112328. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112329. /**
  112330. * Sets the distance from the start point to the hit point
  112331. * @param distance
  112332. */
  112333. setHitDistance(distance: number): void;
  112334. /**
  112335. * Calculates the distance manually
  112336. */
  112337. calculateHitDistance(): void;
  112338. /**
  112339. * Resets all the values to default
  112340. * @param from The from point on world space
  112341. * @param to The to point on world space
  112342. */
  112343. reset(from?: Vector3, to?: Vector3): void;
  112344. }
  112345. /**
  112346. * Interface for the size containing width and height
  112347. */
  112348. interface IXYZ {
  112349. /**
  112350. * X
  112351. */
  112352. x: number;
  112353. /**
  112354. * Y
  112355. */
  112356. y: number;
  112357. /**
  112358. * Z
  112359. */
  112360. z: number;
  112361. }
  112362. }
  112363. declare module BABYLON {
  112364. /**
  112365. * Interface used to describe a physics joint
  112366. */
  112367. export interface PhysicsImpostorJoint {
  112368. /** Defines the main impostor to which the joint is linked */
  112369. mainImpostor: PhysicsImpostor;
  112370. /** Defines the impostor that is connected to the main impostor using this joint */
  112371. connectedImpostor: PhysicsImpostor;
  112372. /** Defines the joint itself */
  112373. joint: PhysicsJoint;
  112374. }
  112375. /** @hidden */
  112376. export interface IPhysicsEnginePlugin {
  112377. world: any;
  112378. name: string;
  112379. setGravity(gravity: Vector3): void;
  112380. setTimeStep(timeStep: number): void;
  112381. getTimeStep(): number;
  112382. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112386. removePhysicsBody(impostor: PhysicsImpostor): void;
  112387. generateJoint(joint: PhysicsImpostorJoint): void;
  112388. removeJoint(joint: PhysicsImpostorJoint): void;
  112389. isSupported(): boolean;
  112390. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112391. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112392. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112393. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112394. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112395. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112396. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112397. getBodyMass(impostor: PhysicsImpostor): number;
  112398. getBodyFriction(impostor: PhysicsImpostor): number;
  112399. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112400. getBodyRestitution(impostor: PhysicsImpostor): number;
  112401. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112402. getBodyPressure?(impostor: PhysicsImpostor): number;
  112403. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112404. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112405. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112406. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112407. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112408. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112409. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112410. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112411. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112412. sleepBody(impostor: PhysicsImpostor): void;
  112413. wakeUpBody(impostor: PhysicsImpostor): void;
  112414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112416. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112418. getRadius(impostor: PhysicsImpostor): number;
  112419. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112420. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112421. dispose(): void;
  112422. }
  112423. /**
  112424. * Interface used to define a physics engine
  112425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112426. */
  112427. export interface IPhysicsEngine {
  112428. /**
  112429. * Gets the gravity vector used by the simulation
  112430. */
  112431. gravity: Vector3;
  112432. /**
  112433. * Sets the gravity vector used by the simulation
  112434. * @param gravity defines the gravity vector to use
  112435. */
  112436. setGravity(gravity: Vector3): void;
  112437. /**
  112438. * Set the time step of the physics engine.
  112439. * Default is 1/60.
  112440. * To slow it down, enter 1/600 for example.
  112441. * To speed it up, 1/30
  112442. * @param newTimeStep the new timestep to apply to this world.
  112443. */
  112444. setTimeStep(newTimeStep: number): void;
  112445. /**
  112446. * Get the time step of the physics engine.
  112447. * @returns the current time step
  112448. */
  112449. getTimeStep(): number;
  112450. /**
  112451. * Set the sub time step of the physics engine.
  112452. * Default is 0 meaning there is no sub steps
  112453. * To increase physics resolution precision, set a small value (like 1 ms)
  112454. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112455. */
  112456. setSubTimeStep(subTimeStep: number): void;
  112457. /**
  112458. * Get the sub time step of the physics engine.
  112459. * @returns the current sub time step
  112460. */
  112461. getSubTimeStep(): number;
  112462. /**
  112463. * Release all resources
  112464. */
  112465. dispose(): void;
  112466. /**
  112467. * Gets the name of the current physics plugin
  112468. * @returns the name of the plugin
  112469. */
  112470. getPhysicsPluginName(): string;
  112471. /**
  112472. * Adding a new impostor for the impostor tracking.
  112473. * This will be done by the impostor itself.
  112474. * @param impostor the impostor to add
  112475. */
  112476. addImpostor(impostor: PhysicsImpostor): void;
  112477. /**
  112478. * Remove an impostor from the engine.
  112479. * This impostor and its mesh will not longer be updated by the physics engine.
  112480. * @param impostor the impostor to remove
  112481. */
  112482. removeImpostor(impostor: PhysicsImpostor): void;
  112483. /**
  112484. * Add a joint to the physics engine
  112485. * @param mainImpostor defines the main impostor to which the joint is added.
  112486. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112487. * @param joint defines the joint that will connect both impostors.
  112488. */
  112489. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112490. /**
  112491. * Removes a joint from the simulation
  112492. * @param mainImpostor defines the impostor used with the joint
  112493. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112494. * @param joint defines the joint to remove
  112495. */
  112496. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112497. /**
  112498. * Gets the current plugin used to run the simulation
  112499. * @returns current plugin
  112500. */
  112501. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112502. /**
  112503. * Gets the list of physic impostors
  112504. * @returns an array of PhysicsImpostor
  112505. */
  112506. getImpostors(): Array<PhysicsImpostor>;
  112507. /**
  112508. * Gets the impostor for a physics enabled object
  112509. * @param object defines the object impersonated by the impostor
  112510. * @returns the PhysicsImpostor or null if not found
  112511. */
  112512. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112513. /**
  112514. * Gets the impostor for a physics body object
  112515. * @param body defines physics body used by the impostor
  112516. * @returns the PhysicsImpostor or null if not found
  112517. */
  112518. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112519. /**
  112520. * Does a raycast in the physics world
  112521. * @param from when should the ray start?
  112522. * @param to when should the ray end?
  112523. * @returns PhysicsRaycastResult
  112524. */
  112525. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112526. /**
  112527. * Called by the scene. No need to call it.
  112528. * @param delta defines the timespam between frames
  112529. */
  112530. _step(delta: number): void;
  112531. }
  112532. }
  112533. declare module BABYLON {
  112534. /**
  112535. * The interface for the physics imposter parameters
  112536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112537. */
  112538. export interface PhysicsImpostorParameters {
  112539. /**
  112540. * The mass of the physics imposter
  112541. */
  112542. mass: number;
  112543. /**
  112544. * The friction of the physics imposter
  112545. */
  112546. friction?: number;
  112547. /**
  112548. * The coefficient of restitution of the physics imposter
  112549. */
  112550. restitution?: number;
  112551. /**
  112552. * The native options of the physics imposter
  112553. */
  112554. nativeOptions?: any;
  112555. /**
  112556. * Specifies if the parent should be ignored
  112557. */
  112558. ignoreParent?: boolean;
  112559. /**
  112560. * Specifies if bi-directional transformations should be disabled
  112561. */
  112562. disableBidirectionalTransformation?: boolean;
  112563. /**
  112564. * The pressure inside the physics imposter, soft object only
  112565. */
  112566. pressure?: number;
  112567. /**
  112568. * The stiffness the physics imposter, soft object only
  112569. */
  112570. stiffness?: number;
  112571. /**
  112572. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112573. */
  112574. velocityIterations?: number;
  112575. /**
  112576. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112577. */
  112578. positionIterations?: number;
  112579. /**
  112580. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112581. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112582. * Add to fix multiple points
  112583. */
  112584. fixedPoints?: number;
  112585. /**
  112586. * The collision margin around a soft object
  112587. */
  112588. margin?: number;
  112589. /**
  112590. * The collision margin around a soft object
  112591. */
  112592. damping?: number;
  112593. /**
  112594. * The path for a rope based on an extrusion
  112595. */
  112596. path?: any;
  112597. /**
  112598. * The shape of an extrusion used for a rope based on an extrusion
  112599. */
  112600. shape?: any;
  112601. }
  112602. /**
  112603. * Interface for a physics-enabled object
  112604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112605. */
  112606. export interface IPhysicsEnabledObject {
  112607. /**
  112608. * The position of the physics-enabled object
  112609. */
  112610. position: Vector3;
  112611. /**
  112612. * The rotation of the physics-enabled object
  112613. */
  112614. rotationQuaternion: Nullable<Quaternion>;
  112615. /**
  112616. * The scale of the physics-enabled object
  112617. */
  112618. scaling: Vector3;
  112619. /**
  112620. * The rotation of the physics-enabled object
  112621. */
  112622. rotation?: Vector3;
  112623. /**
  112624. * The parent of the physics-enabled object
  112625. */
  112626. parent?: any;
  112627. /**
  112628. * The bounding info of the physics-enabled object
  112629. * @returns The bounding info of the physics-enabled object
  112630. */
  112631. getBoundingInfo(): BoundingInfo;
  112632. /**
  112633. * Computes the world matrix
  112634. * @param force Specifies if the world matrix should be computed by force
  112635. * @returns A world matrix
  112636. */
  112637. computeWorldMatrix(force: boolean): Matrix;
  112638. /**
  112639. * Gets the world matrix
  112640. * @returns A world matrix
  112641. */
  112642. getWorldMatrix?(): Matrix;
  112643. /**
  112644. * Gets the child meshes
  112645. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112646. * @returns An array of abstract meshes
  112647. */
  112648. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112649. /**
  112650. * Gets the vertex data
  112651. * @param kind The type of vertex data
  112652. * @returns A nullable array of numbers, or a float32 array
  112653. */
  112654. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112655. /**
  112656. * Gets the indices from the mesh
  112657. * @returns A nullable array of index arrays
  112658. */
  112659. getIndices?(): Nullable<IndicesArray>;
  112660. /**
  112661. * Gets the scene from the mesh
  112662. * @returns the indices array or null
  112663. */
  112664. getScene?(): Scene;
  112665. /**
  112666. * Gets the absolute position from the mesh
  112667. * @returns the absolute position
  112668. */
  112669. getAbsolutePosition(): Vector3;
  112670. /**
  112671. * Gets the absolute pivot point from the mesh
  112672. * @returns the absolute pivot point
  112673. */
  112674. getAbsolutePivotPoint(): Vector3;
  112675. /**
  112676. * Rotates the mesh
  112677. * @param axis The axis of rotation
  112678. * @param amount The amount of rotation
  112679. * @param space The space of the rotation
  112680. * @returns The rotation transform node
  112681. */
  112682. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112683. /**
  112684. * Translates the mesh
  112685. * @param axis The axis of translation
  112686. * @param distance The distance of translation
  112687. * @param space The space of the translation
  112688. * @returns The transform node
  112689. */
  112690. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112691. /**
  112692. * Sets the absolute position of the mesh
  112693. * @param absolutePosition The absolute position of the mesh
  112694. * @returns The transform node
  112695. */
  112696. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112697. /**
  112698. * Gets the class name of the mesh
  112699. * @returns The class name
  112700. */
  112701. getClassName(): string;
  112702. }
  112703. /**
  112704. * Represents a physics imposter
  112705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112706. */
  112707. export class PhysicsImpostor {
  112708. /**
  112709. * The physics-enabled object used as the physics imposter
  112710. */
  112711. object: IPhysicsEnabledObject;
  112712. /**
  112713. * The type of the physics imposter
  112714. */
  112715. type: number;
  112716. private _options;
  112717. private _scene?;
  112718. /**
  112719. * The default object size of the imposter
  112720. */
  112721. static DEFAULT_OBJECT_SIZE: Vector3;
  112722. /**
  112723. * The identity quaternion of the imposter
  112724. */
  112725. static IDENTITY_QUATERNION: Quaternion;
  112726. /** @hidden */
  112727. _pluginData: any;
  112728. private _physicsEngine;
  112729. private _physicsBody;
  112730. private _bodyUpdateRequired;
  112731. private _onBeforePhysicsStepCallbacks;
  112732. private _onAfterPhysicsStepCallbacks;
  112733. /** @hidden */
  112734. _onPhysicsCollideCallbacks: Array<{
  112735. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  112736. otherImpostors: Array<PhysicsImpostor>;
  112737. }>;
  112738. private _deltaPosition;
  112739. private _deltaRotation;
  112740. private _deltaRotationConjugated;
  112741. /** @hidden */
  112742. _isFromLine: boolean;
  112743. private _parent;
  112744. private _isDisposed;
  112745. private static _tmpVecs;
  112746. private static _tmpQuat;
  112747. /**
  112748. * Specifies if the physics imposter is disposed
  112749. */
  112750. get isDisposed(): boolean;
  112751. /**
  112752. * Gets the mass of the physics imposter
  112753. */
  112754. get mass(): number;
  112755. set mass(value: number);
  112756. /**
  112757. * Gets the coefficient of friction
  112758. */
  112759. get friction(): number;
  112760. /**
  112761. * Sets the coefficient of friction
  112762. */
  112763. set friction(value: number);
  112764. /**
  112765. * Gets the coefficient of restitution
  112766. */
  112767. get restitution(): number;
  112768. /**
  112769. * Sets the coefficient of restitution
  112770. */
  112771. set restitution(value: number);
  112772. /**
  112773. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112774. */
  112775. get pressure(): number;
  112776. /**
  112777. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112778. */
  112779. set pressure(value: number);
  112780. /**
  112781. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112782. */
  112783. get stiffness(): number;
  112784. /**
  112785. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112786. */
  112787. set stiffness(value: number);
  112788. /**
  112789. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112790. */
  112791. get velocityIterations(): number;
  112792. /**
  112793. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112794. */
  112795. set velocityIterations(value: number);
  112796. /**
  112797. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112798. */
  112799. get positionIterations(): number;
  112800. /**
  112801. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112802. */
  112803. set positionIterations(value: number);
  112804. /**
  112805. * The unique id of the physics imposter
  112806. * set by the physics engine when adding this impostor to the array
  112807. */
  112808. uniqueId: number;
  112809. /**
  112810. * @hidden
  112811. */
  112812. soft: boolean;
  112813. /**
  112814. * @hidden
  112815. */
  112816. segments: number;
  112817. private _joints;
  112818. /**
  112819. * Initializes the physics imposter
  112820. * @param object The physics-enabled object used as the physics imposter
  112821. * @param type The type of the physics imposter
  112822. * @param _options The options for the physics imposter
  112823. * @param _scene The Babylon scene
  112824. */
  112825. constructor(
  112826. /**
  112827. * The physics-enabled object used as the physics imposter
  112828. */
  112829. object: IPhysicsEnabledObject,
  112830. /**
  112831. * The type of the physics imposter
  112832. */
  112833. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112834. /**
  112835. * This function will completly initialize this impostor.
  112836. * It will create a new body - but only if this mesh has no parent.
  112837. * If it has, this impostor will not be used other than to define the impostor
  112838. * of the child mesh.
  112839. * @hidden
  112840. */
  112841. _init(): void;
  112842. private _getPhysicsParent;
  112843. /**
  112844. * Should a new body be generated.
  112845. * @returns boolean specifying if body initialization is required
  112846. */
  112847. isBodyInitRequired(): boolean;
  112848. /**
  112849. * Sets the updated scaling
  112850. * @param updated Specifies if the scaling is updated
  112851. */
  112852. setScalingUpdated(): void;
  112853. /**
  112854. * Force a regeneration of this or the parent's impostor's body.
  112855. * Use under cautious - This will remove all joints already implemented.
  112856. */
  112857. forceUpdate(): void;
  112858. /**
  112859. * Gets the body that holds this impostor. Either its own, or its parent.
  112860. */
  112861. get physicsBody(): any;
  112862. /**
  112863. * Get the parent of the physics imposter
  112864. * @returns Physics imposter or null
  112865. */
  112866. get parent(): Nullable<PhysicsImpostor>;
  112867. /**
  112868. * Sets the parent of the physics imposter
  112869. */
  112870. set parent(value: Nullable<PhysicsImpostor>);
  112871. /**
  112872. * Set the physics body. Used mainly by the physics engine/plugin
  112873. */
  112874. set physicsBody(physicsBody: any);
  112875. /**
  112876. * Resets the update flags
  112877. */
  112878. resetUpdateFlags(): void;
  112879. /**
  112880. * Gets the object extend size
  112881. * @returns the object extend size
  112882. */
  112883. getObjectExtendSize(): Vector3;
  112884. /**
  112885. * Gets the object center
  112886. * @returns The object center
  112887. */
  112888. getObjectCenter(): Vector3;
  112889. /**
  112890. * Get a specific parameter from the options parameters
  112891. * @param paramName The object parameter name
  112892. * @returns The object parameter
  112893. */
  112894. getParam(paramName: string): any;
  112895. /**
  112896. * Sets a specific parameter in the options given to the physics plugin
  112897. * @param paramName The parameter name
  112898. * @param value The value of the parameter
  112899. */
  112900. setParam(paramName: string, value: number): void;
  112901. /**
  112902. * Specifically change the body's mass option. Won't recreate the physics body object
  112903. * @param mass The mass of the physics imposter
  112904. */
  112905. setMass(mass: number): void;
  112906. /**
  112907. * Gets the linear velocity
  112908. * @returns linear velocity or null
  112909. */
  112910. getLinearVelocity(): Nullable<Vector3>;
  112911. /**
  112912. * Sets the linear velocity
  112913. * @param velocity linear velocity or null
  112914. */
  112915. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112916. /**
  112917. * Gets the angular velocity
  112918. * @returns angular velocity or null
  112919. */
  112920. getAngularVelocity(): Nullable<Vector3>;
  112921. /**
  112922. * Sets the angular velocity
  112923. * @param velocity The velocity or null
  112924. */
  112925. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112926. /**
  112927. * Execute a function with the physics plugin native code
  112928. * Provide a function the will have two variables - the world object and the physics body object
  112929. * @param func The function to execute with the physics plugin native code
  112930. */
  112931. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112932. /**
  112933. * Register a function that will be executed before the physics world is stepping forward
  112934. * @param func The function to execute before the physics world is stepped forward
  112935. */
  112936. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112937. /**
  112938. * Unregister a function that will be executed before the physics world is stepping forward
  112939. * @param func The function to execute before the physics world is stepped forward
  112940. */
  112941. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112942. /**
  112943. * Register a function that will be executed after the physics step
  112944. * @param func The function to execute after physics step
  112945. */
  112946. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112947. /**
  112948. * Unregisters a function that will be executed after the physics step
  112949. * @param func The function to execute after physics step
  112950. */
  112951. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112952. /**
  112953. * register a function that will be executed when this impostor collides against a different body
  112954. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112955. * @param func Callback that is executed on collision
  112956. */
  112957. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112958. /**
  112959. * Unregisters the physics imposter on contact
  112960. * @param collideAgainst The physics object to collide against
  112961. * @param func Callback to execute on collision
  112962. */
  112963. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112964. private _tmpQuat;
  112965. private _tmpQuat2;
  112966. /**
  112967. * Get the parent rotation
  112968. * @returns The parent rotation
  112969. */
  112970. getParentsRotation(): Quaternion;
  112971. /**
  112972. * this function is executed by the physics engine.
  112973. */
  112974. beforeStep: () => void;
  112975. /**
  112976. * this function is executed by the physics engine
  112977. */
  112978. afterStep: () => void;
  112979. /**
  112980. * Legacy collision detection event support
  112981. */
  112982. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  112983. /**
  112984. * event and body object due to cannon's event-based architecture.
  112985. */
  112986. onCollide: (e: {
  112987. body: any;
  112988. point: Nullable<Vector3>;
  112989. }) => void;
  112990. /**
  112991. * Apply a force
  112992. * @param force The force to apply
  112993. * @param contactPoint The contact point for the force
  112994. * @returns The physics imposter
  112995. */
  112996. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112997. /**
  112998. * Apply an impulse
  112999. * @param force The impulse force
  113000. * @param contactPoint The contact point for the impulse force
  113001. * @returns The physics imposter
  113002. */
  113003. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113004. /**
  113005. * A help function to create a joint
  113006. * @param otherImpostor A physics imposter used to create a joint
  113007. * @param jointType The type of joint
  113008. * @param jointData The data for the joint
  113009. * @returns The physics imposter
  113010. */
  113011. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113012. /**
  113013. * Add a joint to this impostor with a different impostor
  113014. * @param otherImpostor A physics imposter used to add a joint
  113015. * @param joint The joint to add
  113016. * @returns The physics imposter
  113017. */
  113018. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113019. /**
  113020. * Add an anchor to a cloth impostor
  113021. * @param otherImpostor rigid impostor to anchor to
  113022. * @param width ratio across width from 0 to 1
  113023. * @param height ratio up height from 0 to 1
  113024. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113025. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113026. * @returns impostor the soft imposter
  113027. */
  113028. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113029. /**
  113030. * Add a hook to a rope impostor
  113031. * @param otherImpostor rigid impostor to anchor to
  113032. * @param length ratio across rope from 0 to 1
  113033. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113034. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113035. * @returns impostor the rope imposter
  113036. */
  113037. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113038. /**
  113039. * Will keep this body still, in a sleep mode.
  113040. * @returns the physics imposter
  113041. */
  113042. sleep(): PhysicsImpostor;
  113043. /**
  113044. * Wake the body up.
  113045. * @returns The physics imposter
  113046. */
  113047. wakeUp(): PhysicsImpostor;
  113048. /**
  113049. * Clones the physics imposter
  113050. * @param newObject The physics imposter clones to this physics-enabled object
  113051. * @returns A nullable physics imposter
  113052. */
  113053. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113054. /**
  113055. * Disposes the physics imposter
  113056. */
  113057. dispose(): void;
  113058. /**
  113059. * Sets the delta position
  113060. * @param position The delta position amount
  113061. */
  113062. setDeltaPosition(position: Vector3): void;
  113063. /**
  113064. * Sets the delta rotation
  113065. * @param rotation The delta rotation amount
  113066. */
  113067. setDeltaRotation(rotation: Quaternion): void;
  113068. /**
  113069. * Gets the box size of the physics imposter and stores the result in the input parameter
  113070. * @param result Stores the box size
  113071. * @returns The physics imposter
  113072. */
  113073. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113074. /**
  113075. * Gets the radius of the physics imposter
  113076. * @returns Radius of the physics imposter
  113077. */
  113078. getRadius(): number;
  113079. /**
  113080. * Sync a bone with this impostor
  113081. * @param bone The bone to sync to the impostor.
  113082. * @param boneMesh The mesh that the bone is influencing.
  113083. * @param jointPivot The pivot of the joint / bone in local space.
  113084. * @param distToJoint Optional distance from the impostor to the joint.
  113085. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113086. */
  113087. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113088. /**
  113089. * Sync impostor to a bone
  113090. * @param bone The bone that the impostor will be synced to.
  113091. * @param boneMesh The mesh that the bone is influencing.
  113092. * @param jointPivot The pivot of the joint / bone in local space.
  113093. * @param distToJoint Optional distance from the impostor to the joint.
  113094. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113095. * @param boneAxis Optional vector3 axis the bone is aligned with
  113096. */
  113097. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113098. /**
  113099. * No-Imposter type
  113100. */
  113101. static NoImpostor: number;
  113102. /**
  113103. * Sphere-Imposter type
  113104. */
  113105. static SphereImpostor: number;
  113106. /**
  113107. * Box-Imposter type
  113108. */
  113109. static BoxImpostor: number;
  113110. /**
  113111. * Plane-Imposter type
  113112. */
  113113. static PlaneImpostor: number;
  113114. /**
  113115. * Mesh-imposter type
  113116. */
  113117. static MeshImpostor: number;
  113118. /**
  113119. * Capsule-Impostor type (Ammo.js plugin only)
  113120. */
  113121. static CapsuleImpostor: number;
  113122. /**
  113123. * Cylinder-Imposter type
  113124. */
  113125. static CylinderImpostor: number;
  113126. /**
  113127. * Particle-Imposter type
  113128. */
  113129. static ParticleImpostor: number;
  113130. /**
  113131. * Heightmap-Imposter type
  113132. */
  113133. static HeightmapImpostor: number;
  113134. /**
  113135. * ConvexHull-Impostor type (Ammo.js plugin only)
  113136. */
  113137. static ConvexHullImpostor: number;
  113138. /**
  113139. * Custom-Imposter type (Ammo.js plugin only)
  113140. */
  113141. static CustomImpostor: number;
  113142. /**
  113143. * Rope-Imposter type
  113144. */
  113145. static RopeImpostor: number;
  113146. /**
  113147. * Cloth-Imposter type
  113148. */
  113149. static ClothImpostor: number;
  113150. /**
  113151. * Softbody-Imposter type
  113152. */
  113153. static SoftbodyImpostor: number;
  113154. }
  113155. }
  113156. declare module BABYLON {
  113157. /**
  113158. * @hidden
  113159. **/
  113160. export class _CreationDataStorage {
  113161. closePath?: boolean;
  113162. closeArray?: boolean;
  113163. idx: number[];
  113164. dashSize: number;
  113165. gapSize: number;
  113166. path3D: Path3D;
  113167. pathArray: Vector3[][];
  113168. arc: number;
  113169. radius: number;
  113170. cap: number;
  113171. tessellation: number;
  113172. }
  113173. /**
  113174. * @hidden
  113175. **/
  113176. class _InstanceDataStorage {
  113177. visibleInstances: any;
  113178. batchCache: _InstancesBatch;
  113179. instancesBufferSize: number;
  113180. instancesBuffer: Nullable<Buffer>;
  113181. instancesData: Float32Array;
  113182. overridenInstanceCount: number;
  113183. isFrozen: boolean;
  113184. previousBatch: Nullable<_InstancesBatch>;
  113185. hardwareInstancedRendering: boolean;
  113186. sideOrientation: number;
  113187. manualUpdate: boolean;
  113188. previousRenderId: number;
  113189. }
  113190. /**
  113191. * @hidden
  113192. **/
  113193. export class _InstancesBatch {
  113194. mustReturn: boolean;
  113195. visibleInstances: Nullable<InstancedMesh[]>[];
  113196. renderSelf: boolean[];
  113197. hardwareInstancedRendering: boolean[];
  113198. }
  113199. /**
  113200. * @hidden
  113201. **/
  113202. class _ThinInstanceDataStorage {
  113203. instancesCount: number;
  113204. matrixBuffer: Nullable<Buffer>;
  113205. matrixBufferSize: number;
  113206. matrixData: Nullable<Float32Array>;
  113207. boundingVectors: Array<Vector3>;
  113208. worldMatrices: Nullable<Matrix[]>;
  113209. }
  113210. /**
  113211. * Class used to represent renderable models
  113212. */
  113213. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113214. /**
  113215. * Mesh side orientation : usually the external or front surface
  113216. */
  113217. static readonly FRONTSIDE: number;
  113218. /**
  113219. * Mesh side orientation : usually the internal or back surface
  113220. */
  113221. static readonly BACKSIDE: number;
  113222. /**
  113223. * Mesh side orientation : both internal and external or front and back surfaces
  113224. */
  113225. static readonly DOUBLESIDE: number;
  113226. /**
  113227. * Mesh side orientation : by default, `FRONTSIDE`
  113228. */
  113229. static readonly DEFAULTSIDE: number;
  113230. /**
  113231. * Mesh cap setting : no cap
  113232. */
  113233. static readonly NO_CAP: number;
  113234. /**
  113235. * Mesh cap setting : one cap at the beginning of the mesh
  113236. */
  113237. static readonly CAP_START: number;
  113238. /**
  113239. * Mesh cap setting : one cap at the end of the mesh
  113240. */
  113241. static readonly CAP_END: number;
  113242. /**
  113243. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113244. */
  113245. static readonly CAP_ALL: number;
  113246. /**
  113247. * Mesh pattern setting : no flip or rotate
  113248. */
  113249. static readonly NO_FLIP: number;
  113250. /**
  113251. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113252. */
  113253. static readonly FLIP_TILE: number;
  113254. /**
  113255. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113256. */
  113257. static readonly ROTATE_TILE: number;
  113258. /**
  113259. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113260. */
  113261. static readonly FLIP_ROW: number;
  113262. /**
  113263. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113264. */
  113265. static readonly ROTATE_ROW: number;
  113266. /**
  113267. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113268. */
  113269. static readonly FLIP_N_ROTATE_TILE: number;
  113270. /**
  113271. * Mesh pattern setting : rotate pattern and rotate
  113272. */
  113273. static readonly FLIP_N_ROTATE_ROW: number;
  113274. /**
  113275. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113276. */
  113277. static readonly CENTER: number;
  113278. /**
  113279. * Mesh tile positioning : part tiles on left
  113280. */
  113281. static readonly LEFT: number;
  113282. /**
  113283. * Mesh tile positioning : part tiles on right
  113284. */
  113285. static readonly RIGHT: number;
  113286. /**
  113287. * Mesh tile positioning : part tiles on top
  113288. */
  113289. static readonly TOP: number;
  113290. /**
  113291. * Mesh tile positioning : part tiles on bottom
  113292. */
  113293. static readonly BOTTOM: number;
  113294. /**
  113295. * Gets the default side orientation.
  113296. * @param orientation the orientation to value to attempt to get
  113297. * @returns the default orientation
  113298. * @hidden
  113299. */
  113300. static _GetDefaultSideOrientation(orientation?: number): number;
  113301. private _internalMeshDataInfo;
  113302. get computeBonesUsingShaders(): boolean;
  113303. set computeBonesUsingShaders(value: boolean);
  113304. /**
  113305. * An event triggered before rendering the mesh
  113306. */
  113307. get onBeforeRenderObservable(): Observable<Mesh>;
  113308. /**
  113309. * An event triggered before binding the mesh
  113310. */
  113311. get onBeforeBindObservable(): Observable<Mesh>;
  113312. /**
  113313. * An event triggered after rendering the mesh
  113314. */
  113315. get onAfterRenderObservable(): Observable<Mesh>;
  113316. /**
  113317. * An event triggered before drawing the mesh
  113318. */
  113319. get onBeforeDrawObservable(): Observable<Mesh>;
  113320. private _onBeforeDrawObserver;
  113321. /**
  113322. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113323. */
  113324. set onBeforeDraw(callback: () => void);
  113325. get hasInstances(): boolean;
  113326. get hasThinInstances(): boolean;
  113327. /**
  113328. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113329. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113330. */
  113331. delayLoadState: number;
  113332. /**
  113333. * Gets the list of instances created from this mesh
  113334. * it is not supposed to be modified manually.
  113335. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113336. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113337. */
  113338. instances: InstancedMesh[];
  113339. /**
  113340. * Gets the file containing delay loading data for this mesh
  113341. */
  113342. delayLoadingFile: string;
  113343. /** @hidden */
  113344. _binaryInfo: any;
  113345. /**
  113346. * User defined function used to change how LOD level selection is done
  113347. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113348. */
  113349. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113350. /**
  113351. * Gets or sets the morph target manager
  113352. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113353. */
  113354. get morphTargetManager(): Nullable<MorphTargetManager>;
  113355. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113356. /** @hidden */
  113357. _creationDataStorage: Nullable<_CreationDataStorage>;
  113358. /** @hidden */
  113359. _geometry: Nullable<Geometry>;
  113360. /** @hidden */
  113361. _delayInfo: Array<string>;
  113362. /** @hidden */
  113363. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113364. /** @hidden */
  113365. _instanceDataStorage: _InstanceDataStorage;
  113366. /** @hidden */
  113367. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113368. private _effectiveMaterial;
  113369. /** @hidden */
  113370. _shouldGenerateFlatShading: boolean;
  113371. /** @hidden */
  113372. _originalBuilderSideOrientation: number;
  113373. /**
  113374. * Use this property to change the original side orientation defined at construction time
  113375. */
  113376. overrideMaterialSideOrientation: Nullable<number>;
  113377. /**
  113378. * Gets the source mesh (the one used to clone this one from)
  113379. */
  113380. get source(): Nullable<Mesh>;
  113381. /**
  113382. * Gets the list of clones of this mesh
  113383. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113384. * Note that useClonedMeshMap=true is the default setting
  113385. */
  113386. get cloneMeshMap(): Nullable<{
  113387. [id: string]: Mesh | undefined;
  113388. }>;
  113389. /**
  113390. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113391. */
  113392. get isUnIndexed(): boolean;
  113393. set isUnIndexed(value: boolean);
  113394. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113395. get worldMatrixInstancedBuffer(): Float32Array;
  113396. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113397. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113398. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113399. /**
  113400. * @constructor
  113401. * @param name The value used by scene.getMeshByName() to do a lookup.
  113402. * @param scene The scene to add this mesh to.
  113403. * @param parent The parent of this mesh, if it has one
  113404. * @param source An optional Mesh from which geometry is shared, cloned.
  113405. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113406. * When false, achieved by calling a clone(), also passing False.
  113407. * This will make creation of children, recursive.
  113408. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113409. */
  113410. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113411. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113412. doNotInstantiate: boolean;
  113413. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113414. /**
  113415. * Gets the class name
  113416. * @returns the string "Mesh".
  113417. */
  113418. getClassName(): string;
  113419. /** @hidden */
  113420. get _isMesh(): boolean;
  113421. /**
  113422. * Returns a description of this mesh
  113423. * @param fullDetails define if full details about this mesh must be used
  113424. * @returns a descriptive string representing this mesh
  113425. */
  113426. toString(fullDetails?: boolean): string;
  113427. /** @hidden */
  113428. _unBindEffect(): void;
  113429. /**
  113430. * Gets a boolean indicating if this mesh has LOD
  113431. */
  113432. get hasLODLevels(): boolean;
  113433. /**
  113434. * Gets the list of MeshLODLevel associated with the current mesh
  113435. * @returns an array of MeshLODLevel
  113436. */
  113437. getLODLevels(): MeshLODLevel[];
  113438. private _sortLODLevels;
  113439. /**
  113440. * Add a mesh as LOD level triggered at the given distance.
  113441. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113442. * @param distance The distance from the center of the object to show this level
  113443. * @param mesh The mesh to be added as LOD level (can be null)
  113444. * @return This mesh (for chaining)
  113445. */
  113446. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113447. /**
  113448. * Returns the LOD level mesh at the passed distance or null if not found.
  113449. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113450. * @param distance The distance from the center of the object to show this level
  113451. * @returns a Mesh or `null`
  113452. */
  113453. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113454. /**
  113455. * Remove a mesh from the LOD array
  113456. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113457. * @param mesh defines the mesh to be removed
  113458. * @return This mesh (for chaining)
  113459. */
  113460. removeLODLevel(mesh: Mesh): Mesh;
  113461. /**
  113462. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113463. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113464. * @param camera defines the camera to use to compute distance
  113465. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113466. * @return This mesh (for chaining)
  113467. */
  113468. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113469. /**
  113470. * Gets the mesh internal Geometry object
  113471. */
  113472. get geometry(): Nullable<Geometry>;
  113473. /**
  113474. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113475. * @returns the total number of vertices
  113476. */
  113477. getTotalVertices(): number;
  113478. /**
  113479. * Returns the content of an associated vertex buffer
  113480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113481. * - VertexBuffer.PositionKind
  113482. * - VertexBuffer.UVKind
  113483. * - VertexBuffer.UV2Kind
  113484. * - VertexBuffer.UV3Kind
  113485. * - VertexBuffer.UV4Kind
  113486. * - VertexBuffer.UV5Kind
  113487. * - VertexBuffer.UV6Kind
  113488. * - VertexBuffer.ColorKind
  113489. * - VertexBuffer.MatricesIndicesKind
  113490. * - VertexBuffer.MatricesIndicesExtraKind
  113491. * - VertexBuffer.MatricesWeightsKind
  113492. * - VertexBuffer.MatricesWeightsExtraKind
  113493. * @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
  113494. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113495. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113496. */
  113497. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113498. /**
  113499. * Returns the mesh VertexBuffer object from the requested `kind`
  113500. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113501. * - VertexBuffer.PositionKind
  113502. * - VertexBuffer.NormalKind
  113503. * - VertexBuffer.UVKind
  113504. * - VertexBuffer.UV2Kind
  113505. * - VertexBuffer.UV3Kind
  113506. * - VertexBuffer.UV4Kind
  113507. * - VertexBuffer.UV5Kind
  113508. * - VertexBuffer.UV6Kind
  113509. * - VertexBuffer.ColorKind
  113510. * - VertexBuffer.MatricesIndicesKind
  113511. * - VertexBuffer.MatricesIndicesExtraKind
  113512. * - VertexBuffer.MatricesWeightsKind
  113513. * - VertexBuffer.MatricesWeightsExtraKind
  113514. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113515. */
  113516. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113517. /**
  113518. * Tests if a specific vertex buffer is associated with this mesh
  113519. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113520. * - VertexBuffer.PositionKind
  113521. * - VertexBuffer.NormalKind
  113522. * - VertexBuffer.UVKind
  113523. * - VertexBuffer.UV2Kind
  113524. * - VertexBuffer.UV3Kind
  113525. * - VertexBuffer.UV4Kind
  113526. * - VertexBuffer.UV5Kind
  113527. * - VertexBuffer.UV6Kind
  113528. * - VertexBuffer.ColorKind
  113529. * - VertexBuffer.MatricesIndicesKind
  113530. * - VertexBuffer.MatricesIndicesExtraKind
  113531. * - VertexBuffer.MatricesWeightsKind
  113532. * - VertexBuffer.MatricesWeightsExtraKind
  113533. * @returns a boolean
  113534. */
  113535. isVerticesDataPresent(kind: string): boolean;
  113536. /**
  113537. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113538. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113539. * - VertexBuffer.PositionKind
  113540. * - VertexBuffer.UVKind
  113541. * - VertexBuffer.UV2Kind
  113542. * - VertexBuffer.UV3Kind
  113543. * - VertexBuffer.UV4Kind
  113544. * - VertexBuffer.UV5Kind
  113545. * - VertexBuffer.UV6Kind
  113546. * - VertexBuffer.ColorKind
  113547. * - VertexBuffer.MatricesIndicesKind
  113548. * - VertexBuffer.MatricesIndicesExtraKind
  113549. * - VertexBuffer.MatricesWeightsKind
  113550. * - VertexBuffer.MatricesWeightsExtraKind
  113551. * @returns a boolean
  113552. */
  113553. isVertexBufferUpdatable(kind: string): boolean;
  113554. /**
  113555. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113556. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113557. * - VertexBuffer.PositionKind
  113558. * - VertexBuffer.NormalKind
  113559. * - VertexBuffer.UVKind
  113560. * - VertexBuffer.UV2Kind
  113561. * - VertexBuffer.UV3Kind
  113562. * - VertexBuffer.UV4Kind
  113563. * - VertexBuffer.UV5Kind
  113564. * - VertexBuffer.UV6Kind
  113565. * - VertexBuffer.ColorKind
  113566. * - VertexBuffer.MatricesIndicesKind
  113567. * - VertexBuffer.MatricesIndicesExtraKind
  113568. * - VertexBuffer.MatricesWeightsKind
  113569. * - VertexBuffer.MatricesWeightsExtraKind
  113570. * @returns an array of strings
  113571. */
  113572. getVerticesDataKinds(): string[];
  113573. /**
  113574. * Returns a positive integer : the total number of indices in this mesh geometry.
  113575. * @returns the numner of indices or zero if the mesh has no geometry.
  113576. */
  113577. getTotalIndices(): number;
  113578. /**
  113579. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113580. * @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.
  113581. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113582. * @returns the indices array or an empty array if the mesh has no geometry
  113583. */
  113584. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113585. get isBlocked(): boolean;
  113586. /**
  113587. * Determine if the current mesh is ready to be rendered
  113588. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113589. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113590. * @returns true if all associated assets are ready (material, textures, shaders)
  113591. */
  113592. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113593. /**
  113594. * 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.
  113595. */
  113596. get areNormalsFrozen(): boolean;
  113597. /**
  113598. * 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.
  113599. * @returns the current mesh
  113600. */
  113601. freezeNormals(): Mesh;
  113602. /**
  113603. * 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
  113604. * @returns the current mesh
  113605. */
  113606. unfreezeNormals(): Mesh;
  113607. /**
  113608. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113609. */
  113610. set overridenInstanceCount(count: number);
  113611. /** @hidden */
  113612. _preActivate(): Mesh;
  113613. /** @hidden */
  113614. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113615. /** @hidden */
  113616. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113617. protected _afterComputeWorldMatrix(): void;
  113618. /** @hidden */
  113619. _postActivate(): void;
  113620. /**
  113621. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113622. * This means the mesh underlying bounding box and sphere are recomputed.
  113623. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113624. * @returns the current mesh
  113625. */
  113626. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113627. /** @hidden */
  113628. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113629. /**
  113630. * This function will subdivide the mesh into multiple submeshes
  113631. * @param count defines the expected number of submeshes
  113632. */
  113633. subdivide(count: number): void;
  113634. /**
  113635. * Copy a FloatArray into a specific associated vertex buffer
  113636. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113637. * - VertexBuffer.PositionKind
  113638. * - VertexBuffer.UVKind
  113639. * - VertexBuffer.UV2Kind
  113640. * - VertexBuffer.UV3Kind
  113641. * - VertexBuffer.UV4Kind
  113642. * - VertexBuffer.UV5Kind
  113643. * - VertexBuffer.UV6Kind
  113644. * - VertexBuffer.ColorKind
  113645. * - VertexBuffer.MatricesIndicesKind
  113646. * - VertexBuffer.MatricesIndicesExtraKind
  113647. * - VertexBuffer.MatricesWeightsKind
  113648. * - VertexBuffer.MatricesWeightsExtraKind
  113649. * @param data defines the data source
  113650. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113651. * @param stride defines the data stride size (can be null)
  113652. * @returns the current mesh
  113653. */
  113654. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113655. /**
  113656. * Delete a vertex buffer associated with this mesh
  113657. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113658. * - VertexBuffer.PositionKind
  113659. * - VertexBuffer.UVKind
  113660. * - VertexBuffer.UV2Kind
  113661. * - VertexBuffer.UV3Kind
  113662. * - VertexBuffer.UV4Kind
  113663. * - VertexBuffer.UV5Kind
  113664. * - VertexBuffer.UV6Kind
  113665. * - VertexBuffer.ColorKind
  113666. * - VertexBuffer.MatricesIndicesKind
  113667. * - VertexBuffer.MatricesIndicesExtraKind
  113668. * - VertexBuffer.MatricesWeightsKind
  113669. * - VertexBuffer.MatricesWeightsExtraKind
  113670. */
  113671. removeVerticesData(kind: string): void;
  113672. /**
  113673. * Flags an associated vertex buffer as updatable
  113674. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113675. * - VertexBuffer.PositionKind
  113676. * - VertexBuffer.UVKind
  113677. * - VertexBuffer.UV2Kind
  113678. * - VertexBuffer.UV3Kind
  113679. * - VertexBuffer.UV4Kind
  113680. * - VertexBuffer.UV5Kind
  113681. * - VertexBuffer.UV6Kind
  113682. * - VertexBuffer.ColorKind
  113683. * - VertexBuffer.MatricesIndicesKind
  113684. * - VertexBuffer.MatricesIndicesExtraKind
  113685. * - VertexBuffer.MatricesWeightsKind
  113686. * - VertexBuffer.MatricesWeightsExtraKind
  113687. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113688. */
  113689. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113690. /**
  113691. * Sets the mesh global Vertex Buffer
  113692. * @param buffer defines the buffer to use
  113693. * @returns the current mesh
  113694. */
  113695. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113696. /**
  113697. * Update a specific associated vertex buffer
  113698. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113699. * - VertexBuffer.PositionKind
  113700. * - VertexBuffer.UVKind
  113701. * - VertexBuffer.UV2Kind
  113702. * - VertexBuffer.UV3Kind
  113703. * - VertexBuffer.UV4Kind
  113704. * - VertexBuffer.UV5Kind
  113705. * - VertexBuffer.UV6Kind
  113706. * - VertexBuffer.ColorKind
  113707. * - VertexBuffer.MatricesIndicesKind
  113708. * - VertexBuffer.MatricesIndicesExtraKind
  113709. * - VertexBuffer.MatricesWeightsKind
  113710. * - VertexBuffer.MatricesWeightsExtraKind
  113711. * @param data defines the data source
  113712. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113713. * @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)
  113714. * @returns the current mesh
  113715. */
  113716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113717. /**
  113718. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113719. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113720. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113721. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113722. * @returns the current mesh
  113723. */
  113724. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113725. /**
  113726. * Creates a un-shared specific occurence of the geometry for the mesh.
  113727. * @returns the current mesh
  113728. */
  113729. makeGeometryUnique(): Mesh;
  113730. /**
  113731. * Set the index buffer of this mesh
  113732. * @param indices defines the source data
  113733. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113734. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113735. * @returns the current mesh
  113736. */
  113737. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113738. /**
  113739. * Update the current index buffer
  113740. * @param indices defines the source data
  113741. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113742. * @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)
  113743. * @returns the current mesh
  113744. */
  113745. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113746. /**
  113747. * Invert the geometry to move from a right handed system to a left handed one.
  113748. * @returns the current mesh
  113749. */
  113750. toLeftHanded(): Mesh;
  113751. /** @hidden */
  113752. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113753. /** @hidden */
  113754. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113755. /**
  113756. * Registers for this mesh a javascript function called just before the rendering process
  113757. * @param func defines the function to call before rendering this mesh
  113758. * @returns the current mesh
  113759. */
  113760. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113761. /**
  113762. * Disposes a previously registered javascript function called before the rendering
  113763. * @param func defines the function to remove
  113764. * @returns the current mesh
  113765. */
  113766. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113767. /**
  113768. * Registers for this mesh a javascript function called just after the rendering is complete
  113769. * @param func defines the function to call after rendering this mesh
  113770. * @returns the current mesh
  113771. */
  113772. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113773. /**
  113774. * Disposes a previously registered javascript function called after the rendering.
  113775. * @param func defines the function to remove
  113776. * @returns the current mesh
  113777. */
  113778. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113779. /** @hidden */
  113780. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113781. /** @hidden */
  113782. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113783. /** @hidden */
  113784. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113785. /** @hidden */
  113786. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113787. /** @hidden */
  113788. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113789. /** @hidden */
  113790. _rebuild(): void;
  113791. /** @hidden */
  113792. _freeze(): void;
  113793. /** @hidden */
  113794. _unFreeze(): void;
  113795. /**
  113796. * 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
  113797. * @param subMesh defines the subMesh to render
  113798. * @param enableAlphaMode defines if alpha mode can be changed
  113799. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113800. * @returns the current mesh
  113801. */
  113802. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113803. private _onBeforeDraw;
  113804. /**
  113805. * Renormalize the mesh and patch it up if there are no weights
  113806. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113807. * However in the case of zero weights then we set just a single influence to 1.
  113808. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113809. */
  113810. cleanMatrixWeights(): void;
  113811. private normalizeSkinFourWeights;
  113812. private normalizeSkinWeightsAndExtra;
  113813. /**
  113814. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113815. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113816. * the user know there was an issue with importing the mesh
  113817. * @returns a validation object with skinned, valid and report string
  113818. */
  113819. validateSkinning(): {
  113820. skinned: boolean;
  113821. valid: boolean;
  113822. report: string;
  113823. };
  113824. /** @hidden */
  113825. _checkDelayState(): Mesh;
  113826. private _queueLoad;
  113827. /**
  113828. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113829. * A mesh is in the frustum if its bounding box intersects the frustum
  113830. * @param frustumPlanes defines the frustum to test
  113831. * @returns true if the mesh is in the frustum planes
  113832. */
  113833. isInFrustum(frustumPlanes: Plane[]): boolean;
  113834. /**
  113835. * Sets the mesh material by the material or multiMaterial `id` property
  113836. * @param id is a string identifying the material or the multiMaterial
  113837. * @returns the current mesh
  113838. */
  113839. setMaterialByID(id: string): Mesh;
  113840. /**
  113841. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113842. * @returns an array of IAnimatable
  113843. */
  113844. getAnimatables(): IAnimatable[];
  113845. /**
  113846. * Modifies the mesh geometry according to the passed transformation matrix.
  113847. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113848. * The mesh normals are modified using the same transformation.
  113849. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113850. * @param transform defines the transform matrix to use
  113851. * @see https://doc.babylonjs.com/resources/baking_transformations
  113852. * @returns the current mesh
  113853. */
  113854. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113855. /**
  113856. * Modifies the mesh geometry according to its own current World Matrix.
  113857. * The mesh World Matrix is then reset.
  113858. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113859. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113860. * @see https://doc.babylonjs.com/resources/baking_transformations
  113861. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113862. * @returns the current mesh
  113863. */
  113864. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113865. /** @hidden */
  113866. get _positions(): Nullable<Vector3[]>;
  113867. /** @hidden */
  113868. _resetPointsArrayCache(): Mesh;
  113869. /** @hidden */
  113870. _generatePointsArray(): boolean;
  113871. /**
  113872. * Returns a new Mesh object generated from the current mesh properties.
  113873. * This method must not get confused with createInstance()
  113874. * @param name is a string, the name given to the new mesh
  113875. * @param newParent can be any Node object (default `null`)
  113876. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113877. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113878. * @returns a new mesh
  113879. */
  113880. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113881. /**
  113882. * Releases resources associated with this mesh.
  113883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113885. */
  113886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113887. /** @hidden */
  113888. _disposeInstanceSpecificData(): void;
  113889. /** @hidden */
  113890. _disposeThinInstanceSpecificData(): void;
  113891. /**
  113892. * Modifies the mesh geometry according to a displacement map.
  113893. * 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.
  113894. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113895. * @param url is a string, the URL from the image file is to be downloaded.
  113896. * @param minHeight is the lower limit of the displacement.
  113897. * @param maxHeight is the upper limit of the displacement.
  113898. * @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.
  113899. * @param uvOffset is an optional vector2 used to offset UV.
  113900. * @param uvScale is an optional vector2 used to scale UV.
  113901. * @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.
  113902. * @returns the Mesh.
  113903. */
  113904. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113905. /**
  113906. * Modifies the mesh geometry according to a displacementMap buffer.
  113907. * 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.
  113908. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113909. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113910. * @param heightMapWidth is the width of the buffer image.
  113911. * @param heightMapHeight is the height of the buffer image.
  113912. * @param minHeight is the lower limit of the displacement.
  113913. * @param maxHeight is the upper limit of the displacement.
  113914. * @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.
  113915. * @param uvOffset is an optional vector2 used to offset UV.
  113916. * @param uvScale is an optional vector2 used to scale UV.
  113917. * @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.
  113918. * @returns the Mesh.
  113919. */
  113920. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113921. /**
  113922. * Modify the mesh to get a flat shading rendering.
  113923. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113924. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113925. * @returns current mesh
  113926. */
  113927. convertToFlatShadedMesh(): Mesh;
  113928. /**
  113929. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113930. * In other words, more vertices, no more indices and a single bigger VBO.
  113931. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113932. * @returns current mesh
  113933. */
  113934. convertToUnIndexedMesh(): Mesh;
  113935. /**
  113936. * Inverses facet orientations.
  113937. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113938. * @param flipNormals will also inverts the normals
  113939. * @returns current mesh
  113940. */
  113941. flipFaces(flipNormals?: boolean): Mesh;
  113942. /**
  113943. * Increase the number of facets and hence vertices in a mesh
  113944. * Vertex normals are interpolated from existing vertex normals
  113945. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113946. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113947. */
  113948. increaseVertices(numberPerEdge: number): void;
  113949. /**
  113950. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113951. * This will undo any application of covertToFlatShadedMesh
  113952. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113953. */
  113954. forceSharedVertices(): void;
  113955. /** @hidden */
  113956. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113957. /** @hidden */
  113958. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113959. /**
  113960. * Creates a new InstancedMesh object from the mesh model.
  113961. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113962. * @param name defines the name of the new instance
  113963. * @returns a new InstancedMesh
  113964. */
  113965. createInstance(name: string): InstancedMesh;
  113966. /**
  113967. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113968. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113969. * @returns the current mesh
  113970. */
  113971. synchronizeInstances(): Mesh;
  113972. /**
  113973. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113974. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113975. * This should be used together with the simplification to avoid disappearing triangles.
  113976. * @param successCallback an optional success callback to be called after the optimization finished.
  113977. * @returns the current mesh
  113978. */
  113979. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113980. /**
  113981. * Serialize current mesh
  113982. * @param serializationObject defines the object which will receive the serialization data
  113983. */
  113984. serialize(serializationObject: any): void;
  113985. /** @hidden */
  113986. _syncGeometryWithMorphTargetManager(): void;
  113987. /** @hidden */
  113988. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  113989. /**
  113990. * Returns a new Mesh object parsed from the source provided.
  113991. * @param parsedMesh is the source
  113992. * @param scene defines the hosting scene
  113993. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  113994. * @returns a new Mesh
  113995. */
  113996. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  113997. /**
  113998. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  113999. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114000. * @param name defines the name of the mesh to create
  114001. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114002. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114003. * @param closePath creates a seam between the first and the last points of each path of the path array
  114004. * @param offset is taken in account only if the `pathArray` is containing a single path
  114005. * @param scene defines the hosting scene
  114006. * @param updatable defines if the mesh must be flagged as updatable
  114007. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114008. * @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)
  114009. * @returns a new Mesh
  114010. */
  114011. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114012. /**
  114013. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114014. * @param name defines the name of the mesh to create
  114015. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114016. * @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
  114017. * @param scene defines the hosting scene
  114018. * @param updatable defines if the mesh must be flagged as updatable
  114019. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114020. * @returns a new Mesh
  114021. */
  114022. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114023. /**
  114024. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114025. * @param name defines the name of the mesh to create
  114026. * @param size sets the size (float) of each box side (default 1)
  114027. * @param scene defines the hosting scene
  114028. * @param updatable defines if the mesh must be flagged as updatable
  114029. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114030. * @returns a new Mesh
  114031. */
  114032. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114033. /**
  114034. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114035. * @param name defines the name of the mesh to create
  114036. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114037. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114038. * @param scene defines the hosting scene
  114039. * @param updatable defines if the mesh must be flagged as updatable
  114040. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114041. * @returns a new Mesh
  114042. */
  114043. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114044. /**
  114045. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114046. * @param name defines the name of the mesh to create
  114047. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114048. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114049. * @param scene defines the hosting scene
  114050. * @returns a new Mesh
  114051. */
  114052. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114053. /**
  114054. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114055. * @param name defines the name of the mesh to create
  114056. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114057. * @param diameterTop set the top cap diameter (floats, default 1)
  114058. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114059. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114060. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114061. * @param scene defines the hosting scene
  114062. * @param updatable defines if the mesh must be flagged as updatable
  114063. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114064. * @returns a new Mesh
  114065. */
  114066. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114067. /**
  114068. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114069. * @param name defines the name of the mesh to create
  114070. * @param diameter sets the diameter size (float) of the torus (default 1)
  114071. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114072. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114073. * @param scene defines the hosting scene
  114074. * @param updatable defines if the mesh must be flagged as updatable
  114075. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114076. * @returns a new Mesh
  114077. */
  114078. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114079. /**
  114080. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114081. * @param name defines the name of the mesh to create
  114082. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114083. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114084. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114085. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114086. * @param p the number of windings on X axis (positive integers, default 2)
  114087. * @param q the number of windings on Y axis (positive integers, default 3)
  114088. * @param scene defines the hosting scene
  114089. * @param updatable defines if the mesh must be flagged as updatable
  114090. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114091. * @returns a new Mesh
  114092. */
  114093. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114094. /**
  114095. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114096. * @param name defines the name of the mesh to create
  114097. * @param points is an array successive Vector3
  114098. * @param scene defines the hosting scene
  114099. * @param updatable defines if the mesh must be flagged as updatable
  114100. * @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).
  114101. * @returns a new Mesh
  114102. */
  114103. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114104. /**
  114105. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114106. * @param name defines the name of the mesh to create
  114107. * @param points is an array successive Vector3
  114108. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114109. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114110. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114111. * @param scene defines the hosting scene
  114112. * @param updatable defines if the mesh must be flagged as updatable
  114113. * @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)
  114114. * @returns a new Mesh
  114115. */
  114116. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114117. /**
  114118. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114119. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114120. * 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.
  114121. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114122. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114123. * Remember you can only change the shape positions, not their number when updating a polygon.
  114124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114125. * @param name defines the name of the mesh to create
  114126. * @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
  114127. * @param scene defines the hosting scene
  114128. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114129. * @param updatable defines if the mesh must be flagged as updatable
  114130. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114131. * @param earcutInjection can be used to inject your own earcut reference
  114132. * @returns a new Mesh
  114133. */
  114134. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114135. /**
  114136. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114138. * @param name defines the name of the mesh to create
  114139. * @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
  114140. * @param depth defines the height of extrusion
  114141. * @param scene defines the hosting scene
  114142. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114143. * @param updatable defines if the mesh must be flagged as updatable
  114144. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114145. * @param earcutInjection can be used to inject your own earcut reference
  114146. * @returns a new Mesh
  114147. */
  114148. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114149. /**
  114150. * Creates an extruded shape mesh.
  114151. * 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
  114152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114154. * @param name defines the name of the mesh to create
  114155. * @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
  114156. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114157. * @param scale is the value to scale the shape
  114158. * @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
  114159. * @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
  114160. * @param scene defines the hosting scene
  114161. * @param updatable defines if the mesh must be flagged as updatable
  114162. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114163. * @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)
  114164. * @returns a new Mesh
  114165. */
  114166. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114167. /**
  114168. * Creates an custom extruded shape mesh.
  114169. * The custom extrusion is a parametric shape.
  114170. * It has no predefined shape. Its final shape will depend on the input parameters.
  114171. * Please consider using the same method from the MeshBuilder class instead
  114172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114173. * @param name defines the name of the mesh to create
  114174. * @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
  114175. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114176. * @param scaleFunction is a custom Javascript function called on each path point
  114177. * @param rotationFunction is a custom Javascript function called on each path point
  114178. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114179. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114180. * @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
  114181. * @param scene defines the hosting scene
  114182. * @param updatable defines if the mesh must be flagged as updatable
  114183. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114184. * @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)
  114185. * @returns a new Mesh
  114186. */
  114187. 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;
  114188. /**
  114189. * Creates lathe mesh.
  114190. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114191. * Please consider using the same method from the MeshBuilder class instead
  114192. * @param name defines the name of the mesh to create
  114193. * @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
  114194. * @param radius is the radius value of the lathe
  114195. * @param tessellation is the side number of the lathe.
  114196. * @param scene defines the hosting scene
  114197. * @param updatable defines if the mesh must be flagged as updatable
  114198. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114199. * @returns a new Mesh
  114200. */
  114201. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114202. /**
  114203. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114204. * @param name defines the name of the mesh to create
  114205. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114206. * @param scene defines the hosting scene
  114207. * @param updatable defines if the mesh must be flagged as updatable
  114208. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114209. * @returns a new Mesh
  114210. */
  114211. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114212. /**
  114213. * Creates a ground mesh.
  114214. * Please consider using the same method from the MeshBuilder class instead
  114215. * @param name defines the name of the mesh to create
  114216. * @param width set the width of the ground
  114217. * @param height set the height of the ground
  114218. * @param subdivisions sets the number of subdivisions per side
  114219. * @param scene defines the hosting scene
  114220. * @param updatable defines if the mesh must be flagged as updatable
  114221. * @returns a new Mesh
  114222. */
  114223. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114224. /**
  114225. * Creates a tiled ground mesh.
  114226. * Please consider using the same method from the MeshBuilder class instead
  114227. * @param name defines the name of the mesh to create
  114228. * @param xmin set the ground minimum X coordinate
  114229. * @param zmin set the ground minimum Y coordinate
  114230. * @param xmax set the ground maximum X coordinate
  114231. * @param zmax set the ground maximum Z coordinate
  114232. * @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
  114233. * @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
  114234. * @param scene defines the hosting scene
  114235. * @param updatable defines if the mesh must be flagged as updatable
  114236. * @returns a new Mesh
  114237. */
  114238. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114239. w: number;
  114240. h: number;
  114241. }, precision: {
  114242. w: number;
  114243. h: number;
  114244. }, scene: Scene, updatable?: boolean): Mesh;
  114245. /**
  114246. * Creates a ground mesh from a height map.
  114247. * Please consider using the same method from the MeshBuilder class instead
  114248. * @see https://doc.babylonjs.com/babylon101/height_map
  114249. * @param name defines the name of the mesh to create
  114250. * @param url sets the URL of the height map image resource
  114251. * @param width set the ground width size
  114252. * @param height set the ground height size
  114253. * @param subdivisions sets the number of subdivision per side
  114254. * @param minHeight is the minimum altitude on the ground
  114255. * @param maxHeight is the maximum altitude on the ground
  114256. * @param scene defines the hosting scene
  114257. * @param updatable defines if the mesh must be flagged as updatable
  114258. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114259. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114260. * @returns a new Mesh
  114261. */
  114262. 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;
  114263. /**
  114264. * Creates a tube mesh.
  114265. * The tube is a parametric shape.
  114266. * It has no predefined shape. Its final shape will depend on the input parameters.
  114267. * Please consider using the same method from the MeshBuilder class instead
  114268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114269. * @param name defines the name of the mesh to create
  114270. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114271. * @param radius sets the tube radius size
  114272. * @param tessellation is the number of sides on the tubular surface
  114273. * @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
  114274. * @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
  114275. * @param scene defines the hosting scene
  114276. * @param updatable defines if the mesh must be flagged as updatable
  114277. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114278. * @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)
  114279. * @returns a new Mesh
  114280. */
  114281. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114282. (i: number, distance: number): number;
  114283. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114284. /**
  114285. * Creates a polyhedron mesh.
  114286. * Please consider using the same method from the MeshBuilder class instead.
  114287. * * 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
  114288. * * The parameter `size` (positive float, default 1) sets the polygon size
  114289. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114290. * * 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`
  114291. * * 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
  114292. * * 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)`)
  114293. * * 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
  114294. * * 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
  114295. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114298. * @param name defines the name of the mesh to create
  114299. * @param options defines the options used to create the mesh
  114300. * @param scene defines the hosting scene
  114301. * @returns a new Mesh
  114302. */
  114303. static CreatePolyhedron(name: string, options: {
  114304. type?: number;
  114305. size?: number;
  114306. sizeX?: number;
  114307. sizeY?: number;
  114308. sizeZ?: number;
  114309. custom?: any;
  114310. faceUV?: Vector4[];
  114311. faceColors?: Color4[];
  114312. updatable?: boolean;
  114313. sideOrientation?: number;
  114314. }, scene: Scene): Mesh;
  114315. /**
  114316. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114317. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114318. * * 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`)
  114319. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114320. * * 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
  114321. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114324. * @param name defines the name of the mesh
  114325. * @param options defines the options used to create the mesh
  114326. * @param scene defines the hosting scene
  114327. * @returns a new Mesh
  114328. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114329. */
  114330. static CreateIcoSphere(name: string, options: {
  114331. radius?: number;
  114332. flat?: boolean;
  114333. subdivisions?: number;
  114334. sideOrientation?: number;
  114335. updatable?: boolean;
  114336. }, scene: Scene): Mesh;
  114337. /**
  114338. * Creates a decal mesh.
  114339. * Please consider using the same method from the MeshBuilder class instead.
  114340. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114341. * @param name defines the name of the mesh
  114342. * @param sourceMesh defines the mesh receiving the decal
  114343. * @param position sets the position of the decal in world coordinates
  114344. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114345. * @param size sets the decal scaling
  114346. * @param angle sets the angle to rotate the decal
  114347. * @returns a new Mesh
  114348. */
  114349. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114350. /** Creates a Capsule Mesh
  114351. * @param name defines the name of the mesh.
  114352. * @param options the constructors options used to shape the mesh.
  114353. * @param scene defines the scene the mesh is scoped to.
  114354. * @returns the capsule mesh
  114355. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114356. */
  114357. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114358. /**
  114359. * Prepare internal position array for software CPU skinning
  114360. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114361. */
  114362. setPositionsForCPUSkinning(): Float32Array;
  114363. /**
  114364. * Prepare internal normal array for software CPU skinning
  114365. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114366. */
  114367. setNormalsForCPUSkinning(): Float32Array;
  114368. /**
  114369. * Updates the vertex buffer by applying transformation from the bones
  114370. * @param skeleton defines the skeleton to apply to current mesh
  114371. * @returns the current mesh
  114372. */
  114373. applySkeleton(skeleton: Skeleton): Mesh;
  114374. /**
  114375. * 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
  114376. * @param meshes defines the list of meshes to scan
  114377. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114378. */
  114379. static MinMax(meshes: AbstractMesh[]): {
  114380. min: Vector3;
  114381. max: Vector3;
  114382. };
  114383. /**
  114384. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114385. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114386. * @returns a vector3
  114387. */
  114388. static Center(meshesOrMinMaxVector: {
  114389. min: Vector3;
  114390. max: Vector3;
  114391. } | AbstractMesh[]): Vector3;
  114392. /**
  114393. * Merge the array of meshes into a single mesh for performance reasons.
  114394. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114395. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114396. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114397. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114398. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114399. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114400. * @returns a new mesh
  114401. */
  114402. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114403. /** @hidden */
  114404. addInstance(instance: InstancedMesh): void;
  114405. /** @hidden */
  114406. removeInstance(instance: InstancedMesh): void;
  114407. }
  114408. }
  114409. declare module BABYLON {
  114410. /**
  114411. * This is the base class of all the camera used in the application.
  114412. * @see https://doc.babylonjs.com/features/cameras
  114413. */
  114414. export class Camera extends Node {
  114415. /** @hidden */
  114416. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114417. /**
  114418. * This is the default projection mode used by the cameras.
  114419. * It helps recreating a feeling of perspective and better appreciate depth.
  114420. * This is the best way to simulate real life cameras.
  114421. */
  114422. static readonly PERSPECTIVE_CAMERA: number;
  114423. /**
  114424. * This helps creating camera with an orthographic mode.
  114425. * 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.
  114426. */
  114427. static readonly ORTHOGRAPHIC_CAMERA: number;
  114428. /**
  114429. * This is the default FOV mode for perspective cameras.
  114430. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114431. */
  114432. static readonly FOVMODE_VERTICAL_FIXED: number;
  114433. /**
  114434. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114435. */
  114436. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114437. /**
  114438. * This specifies ther is no need for a camera rig.
  114439. * Basically only one eye is rendered corresponding to the camera.
  114440. */
  114441. static readonly RIG_MODE_NONE: number;
  114442. /**
  114443. * Simulates a camera Rig with one blue eye and one red eye.
  114444. * This can be use with 3d blue and red glasses.
  114445. */
  114446. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114447. /**
  114448. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114449. */
  114450. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114451. /**
  114452. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114453. */
  114454. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114455. /**
  114456. * Defines that both eyes of the camera will be rendered over under each other.
  114457. */
  114458. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114459. /**
  114460. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114461. */
  114462. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114463. /**
  114464. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114465. */
  114466. static readonly RIG_MODE_VR: number;
  114467. /**
  114468. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114469. */
  114470. static readonly RIG_MODE_WEBVR: number;
  114471. /**
  114472. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114473. */
  114474. static readonly RIG_MODE_CUSTOM: number;
  114475. /**
  114476. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114477. */
  114478. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114479. /**
  114480. * Define the input manager associated with the camera.
  114481. */
  114482. inputs: CameraInputsManager<Camera>;
  114483. /** @hidden */
  114484. _position: Vector3;
  114485. /**
  114486. * Define the current local position of the camera in the scene
  114487. */
  114488. get position(): Vector3;
  114489. set position(newPosition: Vector3);
  114490. protected _upVector: Vector3;
  114491. /**
  114492. * The vector the camera should consider as up.
  114493. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114494. */
  114495. set upVector(vec: Vector3);
  114496. get upVector(): Vector3;
  114497. /**
  114498. * Define the current limit on the left side for an orthographic camera
  114499. * In scene unit
  114500. */
  114501. orthoLeft: Nullable<number>;
  114502. /**
  114503. * Define the current limit on the right side for an orthographic camera
  114504. * In scene unit
  114505. */
  114506. orthoRight: Nullable<number>;
  114507. /**
  114508. * Define the current limit on the bottom side for an orthographic camera
  114509. * In scene unit
  114510. */
  114511. orthoBottom: Nullable<number>;
  114512. /**
  114513. * Define the current limit on the top side for an orthographic camera
  114514. * In scene unit
  114515. */
  114516. orthoTop: Nullable<number>;
  114517. /**
  114518. * Field Of View is set in Radians. (default is 0.8)
  114519. */
  114520. fov: number;
  114521. /**
  114522. * Define the minimum distance the camera can see from.
  114523. * This is important to note that the depth buffer are not infinite and the closer it starts
  114524. * the more your scene might encounter depth fighting issue.
  114525. */
  114526. minZ: number;
  114527. /**
  114528. * Define the maximum distance the camera can see to.
  114529. * This is important to note that the depth buffer are not infinite and the further it end
  114530. * the more your scene might encounter depth fighting issue.
  114531. */
  114532. maxZ: number;
  114533. /**
  114534. * Define the default inertia of the camera.
  114535. * This helps giving a smooth feeling to the camera movement.
  114536. */
  114537. inertia: number;
  114538. /**
  114539. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114540. */
  114541. mode: number;
  114542. /**
  114543. * Define whether the camera is intermediate.
  114544. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114545. */
  114546. isIntermediate: boolean;
  114547. /**
  114548. * Define the viewport of the camera.
  114549. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114550. */
  114551. viewport: Viewport;
  114552. /**
  114553. * Restricts the camera to viewing objects with the same layerMask.
  114554. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114555. */
  114556. layerMask: number;
  114557. /**
  114558. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114559. */
  114560. fovMode: number;
  114561. /**
  114562. * Rig mode of the camera.
  114563. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114564. * This is normally controlled byt the camera themselves as internal use.
  114565. */
  114566. cameraRigMode: number;
  114567. /**
  114568. * Defines the distance between both "eyes" in case of a RIG
  114569. */
  114570. interaxialDistance: number;
  114571. /**
  114572. * Defines if stereoscopic rendering is done side by side or over under.
  114573. */
  114574. isStereoscopicSideBySide: boolean;
  114575. /**
  114576. * 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
  114577. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114578. * else in the scene. (Eg. security camera)
  114579. *
  114580. * 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)
  114581. */
  114582. customRenderTargets: RenderTargetTexture[];
  114583. /**
  114584. * When set, the camera will render to this render target instead of the default canvas
  114585. *
  114586. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114587. */
  114588. outputRenderTarget: Nullable<RenderTargetTexture>;
  114589. /**
  114590. * Observable triggered when the camera view matrix has changed.
  114591. */
  114592. onViewMatrixChangedObservable: Observable<Camera>;
  114593. /**
  114594. * Observable triggered when the camera Projection matrix has changed.
  114595. */
  114596. onProjectionMatrixChangedObservable: Observable<Camera>;
  114597. /**
  114598. * Observable triggered when the inputs have been processed.
  114599. */
  114600. onAfterCheckInputsObservable: Observable<Camera>;
  114601. /**
  114602. * Observable triggered when reset has been called and applied to the camera.
  114603. */
  114604. onRestoreStateObservable: Observable<Camera>;
  114605. /**
  114606. * Is this camera a part of a rig system?
  114607. */
  114608. isRigCamera: boolean;
  114609. /**
  114610. * If isRigCamera set to true this will be set with the parent camera.
  114611. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114612. */
  114613. rigParent?: Camera;
  114614. /** @hidden */
  114615. _cameraRigParams: any;
  114616. /** @hidden */
  114617. _rigCameras: Camera[];
  114618. /** @hidden */
  114619. _rigPostProcess: Nullable<PostProcess>;
  114620. protected _webvrViewMatrix: Matrix;
  114621. /** @hidden */
  114622. _skipRendering: boolean;
  114623. /** @hidden */
  114624. _projectionMatrix: Matrix;
  114625. /** @hidden */
  114626. _postProcesses: Nullable<PostProcess>[];
  114627. /** @hidden */
  114628. _activeMeshes: SmartArray<AbstractMesh>;
  114629. protected _globalPosition: Vector3;
  114630. /** @hidden */
  114631. _computedViewMatrix: Matrix;
  114632. private _doNotComputeProjectionMatrix;
  114633. private _transformMatrix;
  114634. private _frustumPlanes;
  114635. private _refreshFrustumPlanes;
  114636. private _storedFov;
  114637. private _stateStored;
  114638. /**
  114639. * Instantiates a new camera object.
  114640. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114641. * @see https://doc.babylonjs.com/features/cameras
  114642. * @param name Defines the name of the camera in the scene
  114643. * @param position Defines the position of the camera
  114644. * @param scene Defines the scene the camera belongs too
  114645. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114646. */
  114647. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114648. /**
  114649. * Store current camera state (fov, position, etc..)
  114650. * @returns the camera
  114651. */
  114652. storeState(): Camera;
  114653. /**
  114654. * Restores the camera state values if it has been stored. You must call storeState() first
  114655. */
  114656. protected _restoreStateValues(): boolean;
  114657. /**
  114658. * Restored camera state. You must call storeState() first.
  114659. * @returns true if restored and false otherwise
  114660. */
  114661. restoreState(): boolean;
  114662. /**
  114663. * Gets the class name of the camera.
  114664. * @returns the class name
  114665. */
  114666. getClassName(): string;
  114667. /** @hidden */
  114668. readonly _isCamera: boolean;
  114669. /**
  114670. * Gets a string representation of the camera useful for debug purpose.
  114671. * @param fullDetails Defines that a more verboe level of logging is required
  114672. * @returns the string representation
  114673. */
  114674. toString(fullDetails?: boolean): string;
  114675. /**
  114676. * Gets the current world space position of the camera.
  114677. */
  114678. get globalPosition(): Vector3;
  114679. /**
  114680. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114681. * @returns the active meshe list
  114682. */
  114683. getActiveMeshes(): SmartArray<AbstractMesh>;
  114684. /**
  114685. * Check whether a mesh is part of the current active mesh list of the camera
  114686. * @param mesh Defines the mesh to check
  114687. * @returns true if active, false otherwise
  114688. */
  114689. isActiveMesh(mesh: Mesh): boolean;
  114690. /**
  114691. * Is this camera ready to be used/rendered
  114692. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114693. * @return true if the camera is ready
  114694. */
  114695. isReady(completeCheck?: boolean): boolean;
  114696. /** @hidden */
  114697. _initCache(): void;
  114698. /** @hidden */
  114699. _updateCache(ignoreParentClass?: boolean): void;
  114700. /** @hidden */
  114701. _isSynchronized(): boolean;
  114702. /** @hidden */
  114703. _isSynchronizedViewMatrix(): boolean;
  114704. /** @hidden */
  114705. _isSynchronizedProjectionMatrix(): boolean;
  114706. /**
  114707. * Attach the input controls to a specific dom element to get the input from.
  114708. * @param element Defines the element the controls should be listened from
  114709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114710. */
  114711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114712. /**
  114713. * Detach the current controls from the specified dom element.
  114714. * @param element Defines the element to stop listening the inputs from
  114715. */
  114716. detachControl(element: HTMLElement): void;
  114717. /**
  114718. * Update the camera state according to the different inputs gathered during the frame.
  114719. */
  114720. update(): void;
  114721. /** @hidden */
  114722. _checkInputs(): void;
  114723. /** @hidden */
  114724. get rigCameras(): Camera[];
  114725. /**
  114726. * Gets the post process used by the rig cameras
  114727. */
  114728. get rigPostProcess(): Nullable<PostProcess>;
  114729. /**
  114730. * Internal, gets the first post proces.
  114731. * @returns the first post process to be run on this camera.
  114732. */
  114733. _getFirstPostProcess(): Nullable<PostProcess>;
  114734. private _cascadePostProcessesToRigCams;
  114735. /**
  114736. * Attach a post process to the camera.
  114737. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114738. * @param postProcess The post process to attach to the camera
  114739. * @param insertAt The position of the post process in case several of them are in use in the scene
  114740. * @returns the position the post process has been inserted at
  114741. */
  114742. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114743. /**
  114744. * Detach a post process to the camera.
  114745. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114746. * @param postProcess The post process to detach from the camera
  114747. */
  114748. detachPostProcess(postProcess: PostProcess): void;
  114749. /**
  114750. * Gets the current world matrix of the camera
  114751. */
  114752. getWorldMatrix(): Matrix;
  114753. /** @hidden */
  114754. _getViewMatrix(): Matrix;
  114755. /**
  114756. * Gets the current view matrix of the camera.
  114757. * @param force forces the camera to recompute the matrix without looking at the cached state
  114758. * @returns the view matrix
  114759. */
  114760. getViewMatrix(force?: boolean): Matrix;
  114761. /**
  114762. * Freeze the projection matrix.
  114763. * It will prevent the cache check of the camera projection compute and can speed up perf
  114764. * if no parameter of the camera are meant to change
  114765. * @param projection Defines manually a projection if necessary
  114766. */
  114767. freezeProjectionMatrix(projection?: Matrix): void;
  114768. /**
  114769. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114770. */
  114771. unfreezeProjectionMatrix(): void;
  114772. /**
  114773. * Gets the current projection matrix of the camera.
  114774. * @param force forces the camera to recompute the matrix without looking at the cached state
  114775. * @returns the projection matrix
  114776. */
  114777. getProjectionMatrix(force?: boolean): Matrix;
  114778. /**
  114779. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114780. * @returns a Matrix
  114781. */
  114782. getTransformationMatrix(): Matrix;
  114783. private _updateFrustumPlanes;
  114784. /**
  114785. * Checks if a cullable object (mesh...) is in the camera frustum
  114786. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114787. * @param target The object to check
  114788. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114789. * @returns true if the object is in frustum otherwise false
  114790. */
  114791. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114792. /**
  114793. * Checks if a cullable object (mesh...) is in the camera frustum
  114794. * Unlike isInFrustum this cheks the full bounding box
  114795. * @param target The object to check
  114796. * @returns true if the object is in frustum otherwise false
  114797. */
  114798. isCompletelyInFrustum(target: ICullable): boolean;
  114799. /**
  114800. * Gets a ray in the forward direction from the camera.
  114801. * @param length Defines the length of the ray to create
  114802. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114803. * @param origin Defines the start point of the ray which defaults to the camera position
  114804. * @returns the forward ray
  114805. */
  114806. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114807. /**
  114808. * Gets a ray in the forward direction from the camera.
  114809. * @param refRay the ray to (re)use when setting the values
  114810. * @param length Defines the length of the ray to create
  114811. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114812. * @param origin Defines the start point of the ray which defaults to the camera position
  114813. * @returns the forward ray
  114814. */
  114815. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114816. /**
  114817. * Releases resources associated with this node.
  114818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114820. */
  114821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114822. /** @hidden */
  114823. _isLeftCamera: boolean;
  114824. /**
  114825. * Gets the left camera of a rig setup in case of Rigged Camera
  114826. */
  114827. get isLeftCamera(): boolean;
  114828. /** @hidden */
  114829. _isRightCamera: boolean;
  114830. /**
  114831. * Gets the right camera of a rig setup in case of Rigged Camera
  114832. */
  114833. get isRightCamera(): boolean;
  114834. /**
  114835. * Gets the left camera of a rig setup in case of Rigged Camera
  114836. */
  114837. get leftCamera(): Nullable<FreeCamera>;
  114838. /**
  114839. * Gets the right camera of a rig setup in case of Rigged Camera
  114840. */
  114841. get rightCamera(): Nullable<FreeCamera>;
  114842. /**
  114843. * Gets the left camera target of a rig setup in case of Rigged Camera
  114844. * @returns the target position
  114845. */
  114846. getLeftTarget(): Nullable<Vector3>;
  114847. /**
  114848. * Gets the right camera target of a rig setup in case of Rigged Camera
  114849. * @returns the target position
  114850. */
  114851. getRightTarget(): Nullable<Vector3>;
  114852. /**
  114853. * @hidden
  114854. */
  114855. setCameraRigMode(mode: number, rigParams: any): void;
  114856. /** @hidden */
  114857. static _setStereoscopicRigMode(camera: Camera): void;
  114858. /** @hidden */
  114859. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114860. /** @hidden */
  114861. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114862. /** @hidden */
  114863. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114864. /** @hidden */
  114865. _getVRProjectionMatrix(): Matrix;
  114866. protected _updateCameraRotationMatrix(): void;
  114867. protected _updateWebVRCameraRotationMatrix(): void;
  114868. /**
  114869. * This function MUST be overwritten by the different WebVR cameras available.
  114870. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114871. * @hidden
  114872. */
  114873. _getWebVRProjectionMatrix(): Matrix;
  114874. /**
  114875. * This function MUST be overwritten by the different WebVR cameras available.
  114876. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114877. * @hidden
  114878. */
  114879. _getWebVRViewMatrix(): Matrix;
  114880. /** @hidden */
  114881. setCameraRigParameter(name: string, value: any): void;
  114882. /**
  114883. * needs to be overridden by children so sub has required properties to be copied
  114884. * @hidden
  114885. */
  114886. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114887. /**
  114888. * May need to be overridden by children
  114889. * @hidden
  114890. */
  114891. _updateRigCameras(): void;
  114892. /** @hidden */
  114893. _setupInputs(): void;
  114894. /**
  114895. * Serialiaze the camera setup to a json represention
  114896. * @returns the JSON representation
  114897. */
  114898. serialize(): any;
  114899. /**
  114900. * Clones the current camera.
  114901. * @param name The cloned camera name
  114902. * @returns the cloned camera
  114903. */
  114904. clone(name: string): Camera;
  114905. /**
  114906. * Gets the direction of the camera relative to a given local axis.
  114907. * @param localAxis Defines the reference axis to provide a relative direction.
  114908. * @return the direction
  114909. */
  114910. getDirection(localAxis: Vector3): Vector3;
  114911. /**
  114912. * Returns the current camera absolute rotation
  114913. */
  114914. get absoluteRotation(): Quaternion;
  114915. /**
  114916. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114917. * @param localAxis Defines the reference axis to provide a relative direction.
  114918. * @param result Defines the vector to store the result in
  114919. */
  114920. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114921. /**
  114922. * Gets a camera constructor for a given camera type
  114923. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114924. * @param name The name of the camera the result will be able to instantiate
  114925. * @param scene The scene the result will construct the camera in
  114926. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114927. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114928. * @returns a factory method to construc the camera
  114929. */
  114930. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114931. /**
  114932. * Compute the world matrix of the camera.
  114933. * @returns the camera world matrix
  114934. */
  114935. computeWorldMatrix(): Matrix;
  114936. /**
  114937. * Parse a JSON and creates the camera from the parsed information
  114938. * @param parsedCamera The JSON to parse
  114939. * @param scene The scene to instantiate the camera in
  114940. * @returns the newly constructed camera
  114941. */
  114942. static Parse(parsedCamera: any, scene: Scene): Camera;
  114943. }
  114944. }
  114945. declare module BABYLON {
  114946. /**
  114947. * Class containing static functions to help procedurally build meshes
  114948. */
  114949. export class DiscBuilder {
  114950. /**
  114951. * Creates a plane polygonal mesh. By default, this is a disc
  114952. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114953. * * 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
  114954. * * 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
  114955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114958. * @param name defines the name of the mesh
  114959. * @param options defines the options used to create the mesh
  114960. * @param scene defines the hosting scene
  114961. * @returns the plane polygonal mesh
  114962. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114963. */
  114964. static CreateDisc(name: string, options: {
  114965. radius?: number;
  114966. tessellation?: number;
  114967. arc?: number;
  114968. updatable?: boolean;
  114969. sideOrientation?: number;
  114970. frontUVs?: Vector4;
  114971. backUVs?: Vector4;
  114972. }, scene?: Nullable<Scene>): Mesh;
  114973. }
  114974. }
  114975. declare module BABYLON {
  114976. /**
  114977. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114978. *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.
  114979. * The SPS is also a particle system. It provides some methods to manage the particles.
  114980. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114981. *
  114982. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  114983. */
  114984. export class SolidParticleSystem implements IDisposable {
  114985. /**
  114986. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114987. * Example : var p = SPS.particles[i];
  114988. */
  114989. particles: SolidParticle[];
  114990. /**
  114991. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114992. */
  114993. nbParticles: number;
  114994. /**
  114995. * If the particles must ever face the camera (default false). Useful for planar particles.
  114996. */
  114997. billboard: boolean;
  114998. /**
  114999. * Recompute normals when adding a shape
  115000. */
  115001. recomputeNormals: boolean;
  115002. /**
  115003. * This a counter ofr your own usage. It's not set by any SPS functions.
  115004. */
  115005. counter: number;
  115006. /**
  115007. * The SPS name. This name is also given to the underlying mesh.
  115008. */
  115009. name: string;
  115010. /**
  115011. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115012. */
  115013. mesh: Mesh;
  115014. /**
  115015. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115016. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115017. */
  115018. vars: any;
  115019. /**
  115020. * This array is populated when the SPS is set as 'pickable'.
  115021. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115022. * Each element of this array is an object `{idx: int, faceId: int}`.
  115023. * `idx` is the picked particle index in the `SPS.particles` array
  115024. * `faceId` is the picked face index counted within this particle.
  115025. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115026. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115027. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115028. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115029. */
  115030. pickedParticles: {
  115031. idx: number;
  115032. faceId: number;
  115033. }[];
  115034. /**
  115035. * This array is populated when the SPS is set as 'pickable'
  115036. * Each key of this array is a submesh index.
  115037. * Each element of this array is a second array defined like this :
  115038. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115039. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115040. * `idx` is the picked particle index in the `SPS.particles` array
  115041. * `faceId` is the picked face index counted within this particle.
  115042. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115043. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115044. */
  115045. pickedBySubMesh: {
  115046. idx: number;
  115047. faceId: number;
  115048. }[][];
  115049. /**
  115050. * This array is populated when `enableDepthSort` is set to true.
  115051. * Each element of this array is an instance of the class DepthSortedParticle.
  115052. */
  115053. depthSortedParticles: DepthSortedParticle[];
  115054. /**
  115055. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115056. * @hidden
  115057. */
  115058. _bSphereOnly: boolean;
  115059. /**
  115060. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115061. * @hidden
  115062. */
  115063. _bSphereRadiusFactor: number;
  115064. private _scene;
  115065. private _positions;
  115066. private _indices;
  115067. private _normals;
  115068. private _colors;
  115069. private _uvs;
  115070. private _indices32;
  115071. private _positions32;
  115072. private _normals32;
  115073. private _fixedNormal32;
  115074. private _colors32;
  115075. private _uvs32;
  115076. private _index;
  115077. private _updatable;
  115078. private _pickable;
  115079. private _isVisibilityBoxLocked;
  115080. private _alwaysVisible;
  115081. private _depthSort;
  115082. private _expandable;
  115083. private _shapeCounter;
  115084. private _copy;
  115085. private _color;
  115086. private _computeParticleColor;
  115087. private _computeParticleTexture;
  115088. private _computeParticleRotation;
  115089. private _computeParticleVertex;
  115090. private _computeBoundingBox;
  115091. private _depthSortParticles;
  115092. private _camera;
  115093. private _mustUnrotateFixedNormals;
  115094. private _particlesIntersect;
  115095. private _needs32Bits;
  115096. private _isNotBuilt;
  115097. private _lastParticleId;
  115098. private _idxOfId;
  115099. private _multimaterialEnabled;
  115100. private _useModelMaterial;
  115101. private _indicesByMaterial;
  115102. private _materialIndexes;
  115103. private _depthSortFunction;
  115104. private _materialSortFunction;
  115105. private _materials;
  115106. private _multimaterial;
  115107. private _materialIndexesById;
  115108. private _defaultMaterial;
  115109. private _autoUpdateSubMeshes;
  115110. private _tmpVertex;
  115111. /**
  115112. * Creates a SPS (Solid Particle System) object.
  115113. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115114. * @param scene (Scene) is the scene in which the SPS is added.
  115115. * @param options defines the options of the sps e.g.
  115116. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115117. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115118. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115119. * * 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.
  115120. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115121. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115122. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115123. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115124. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115125. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115126. */
  115127. constructor(name: string, scene: Scene, options?: {
  115128. updatable?: boolean;
  115129. isPickable?: boolean;
  115130. enableDepthSort?: boolean;
  115131. particleIntersection?: boolean;
  115132. boundingSphereOnly?: boolean;
  115133. bSphereRadiusFactor?: number;
  115134. expandable?: boolean;
  115135. useModelMaterial?: boolean;
  115136. enableMultiMaterial?: boolean;
  115137. });
  115138. /**
  115139. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115140. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115141. * @returns the created mesh
  115142. */
  115143. buildMesh(): Mesh;
  115144. /**
  115145. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115146. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115147. * Thus the particles generated from `digest()` have their property `position` set yet.
  115148. * @param mesh ( Mesh ) is the mesh to be digested
  115149. * @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
  115150. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115151. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115152. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115153. * @returns the current SPS
  115154. */
  115155. digest(mesh: Mesh, options?: {
  115156. facetNb?: number;
  115157. number?: number;
  115158. delta?: number;
  115159. storage?: [];
  115160. }): SolidParticleSystem;
  115161. /**
  115162. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115163. * @hidden
  115164. */
  115165. private _unrotateFixedNormals;
  115166. /**
  115167. * Resets the temporary working copy particle
  115168. * @hidden
  115169. */
  115170. private _resetCopy;
  115171. /**
  115172. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115173. * @param p the current index in the positions array to be updated
  115174. * @param ind the current index in the indices array
  115175. * @param shape a Vector3 array, the shape geometry
  115176. * @param positions the positions array to be updated
  115177. * @param meshInd the shape indices array
  115178. * @param indices the indices array to be updated
  115179. * @param meshUV the shape uv array
  115180. * @param uvs the uv array to be updated
  115181. * @param meshCol the shape color array
  115182. * @param colors the color array to be updated
  115183. * @param meshNor the shape normals array
  115184. * @param normals the normals array to be updated
  115185. * @param idx the particle index
  115186. * @param idxInShape the particle index in its shape
  115187. * @param options the addShape() method passed options
  115188. * @model the particle model
  115189. * @hidden
  115190. */
  115191. private _meshBuilder;
  115192. /**
  115193. * Returns a shape Vector3 array from positions float array
  115194. * @param positions float array
  115195. * @returns a vector3 array
  115196. * @hidden
  115197. */
  115198. private _posToShape;
  115199. /**
  115200. * Returns a shapeUV array from a float uvs (array deep copy)
  115201. * @param uvs as a float array
  115202. * @returns a shapeUV array
  115203. * @hidden
  115204. */
  115205. private _uvsToShapeUV;
  115206. /**
  115207. * Adds a new particle object in the particles array
  115208. * @param idx particle index in particles array
  115209. * @param id particle id
  115210. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115211. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115212. * @param model particle ModelShape object
  115213. * @param shapeId model shape identifier
  115214. * @param idxInShape index of the particle in the current model
  115215. * @param bInfo model bounding info object
  115216. * @param storage target storage array, if any
  115217. * @hidden
  115218. */
  115219. private _addParticle;
  115220. /**
  115221. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115222. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115223. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115224. * @param nb (positive integer) the number of particles to be created from this model
  115225. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115226. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115227. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115228. * @returns the number of shapes in the system
  115229. */
  115230. addShape(mesh: Mesh, nb: number, options?: {
  115231. positionFunction?: any;
  115232. vertexFunction?: any;
  115233. storage?: [];
  115234. }): number;
  115235. /**
  115236. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115237. * @hidden
  115238. */
  115239. private _rebuildParticle;
  115240. /**
  115241. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115242. * @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.
  115243. * @returns the SPS.
  115244. */
  115245. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115246. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115247. * Returns an array with the removed particles.
  115248. * 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.
  115249. * The SPS can't be empty so at least one particle needs to remain in place.
  115250. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115251. * @param start index of the first particle to remove
  115252. * @param end index of the last particle to remove (included)
  115253. * @returns an array populated with the removed particles
  115254. */
  115255. removeParticles(start: number, end: number): SolidParticle[];
  115256. /**
  115257. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115258. * @param solidParticleArray an array populated with Solid Particles objects
  115259. * @returns the SPS
  115260. */
  115261. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115262. /**
  115263. * Creates a new particle and modifies the SPS mesh geometry :
  115264. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115265. * - calls _addParticle() to populate the particle array
  115266. * factorized code from addShape() and insertParticlesFromArray()
  115267. * @param idx particle index in the particles array
  115268. * @param i particle index in its shape
  115269. * @param modelShape particle ModelShape object
  115270. * @param shape shape vertex array
  115271. * @param meshInd shape indices array
  115272. * @param meshUV shape uv array
  115273. * @param meshCol shape color array
  115274. * @param meshNor shape normals array
  115275. * @param bbInfo shape bounding info
  115276. * @param storage target particle storage
  115277. * @options addShape() passed options
  115278. * @hidden
  115279. */
  115280. private _insertNewParticle;
  115281. /**
  115282. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115283. * This method calls `updateParticle()` for each particle of the SPS.
  115284. * For an animated SPS, it is usually called within the render loop.
  115285. * 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.
  115286. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115287. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115288. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115289. * @returns the SPS.
  115290. */
  115291. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115292. /**
  115293. * Disposes the SPS.
  115294. */
  115295. dispose(): void;
  115296. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115297. * idx is the particle index in the SPS
  115298. * faceId is the picked face index counted within this particle.
  115299. * Returns null if the pickInfo can't identify a picked particle.
  115300. * @param pickingInfo (PickingInfo object)
  115301. * @returns {idx: number, faceId: number} or null
  115302. */
  115303. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115304. idx: number;
  115305. faceId: number;
  115306. }>;
  115307. /**
  115308. * Returns a SolidParticle object from its identifier : particle.id
  115309. * @param id (integer) the particle Id
  115310. * @returns the searched particle or null if not found in the SPS.
  115311. */
  115312. getParticleById(id: number): Nullable<SolidParticle>;
  115313. /**
  115314. * Returns a new array populated with the particles having the passed shapeId.
  115315. * @param shapeId (integer) the shape identifier
  115316. * @returns a new solid particle array
  115317. */
  115318. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115319. /**
  115320. * Populates the passed array "ref" with the particles having the passed shapeId.
  115321. * @param shapeId the shape identifier
  115322. * @returns the SPS
  115323. * @param ref
  115324. */
  115325. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115326. /**
  115327. * Computes the required SubMeshes according the materials assigned to the particles.
  115328. * @returns the solid particle system.
  115329. * Does nothing if called before the SPS mesh is built.
  115330. */
  115331. computeSubMeshes(): SolidParticleSystem;
  115332. /**
  115333. * Sorts the solid particles by material when MultiMaterial is enabled.
  115334. * Updates the indices32 array.
  115335. * Updates the indicesByMaterial array.
  115336. * Updates the mesh indices array.
  115337. * @returns the SPS
  115338. * @hidden
  115339. */
  115340. private _sortParticlesByMaterial;
  115341. /**
  115342. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115343. * @hidden
  115344. */
  115345. private _setMaterialIndexesById;
  115346. /**
  115347. * Returns an array with unique values of Materials from the passed array
  115348. * @param array the material array to be checked and filtered
  115349. * @hidden
  115350. */
  115351. private _filterUniqueMaterialId;
  115352. /**
  115353. * Sets a new Standard Material as _defaultMaterial if not already set.
  115354. * @hidden
  115355. */
  115356. private _setDefaultMaterial;
  115357. /**
  115358. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115359. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115360. * @returns the SPS.
  115361. */
  115362. refreshVisibleSize(): SolidParticleSystem;
  115363. /**
  115364. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115365. * @param size the size (float) of the visibility box
  115366. * note : this doesn't lock the SPS mesh bounding box.
  115367. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115368. */
  115369. setVisibilityBox(size: number): void;
  115370. /**
  115371. * Gets whether the SPS as always visible or not
  115372. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115373. */
  115374. get isAlwaysVisible(): boolean;
  115375. /**
  115376. * Sets the SPS as always visible or not
  115377. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115378. */
  115379. set isAlwaysVisible(val: boolean);
  115380. /**
  115381. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115382. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115383. */
  115384. set isVisibilityBoxLocked(val: boolean);
  115385. /**
  115386. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115387. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115388. */
  115389. get isVisibilityBoxLocked(): boolean;
  115390. /**
  115391. * Tells to `setParticles()` to compute the particle rotations or not.
  115392. * Default value : true. The SPS is faster when it's set to false.
  115393. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115394. */
  115395. set computeParticleRotation(val: boolean);
  115396. /**
  115397. * Tells to `setParticles()` to compute the particle colors or not.
  115398. * Default value : true. The SPS is faster when it's set to false.
  115399. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115400. */
  115401. set computeParticleColor(val: boolean);
  115402. set computeParticleTexture(val: boolean);
  115403. /**
  115404. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115405. * Default value : false. The SPS is faster when it's set to false.
  115406. * Note : the particle custom vertex positions aren't stored values.
  115407. */
  115408. set computeParticleVertex(val: boolean);
  115409. /**
  115410. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115411. */
  115412. set computeBoundingBox(val: boolean);
  115413. /**
  115414. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115415. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115416. * Default : `true`
  115417. */
  115418. set depthSortParticles(val: boolean);
  115419. /**
  115420. * Gets if `setParticles()` computes the particle rotations or not.
  115421. * Default value : true. The SPS is faster when it's set to false.
  115422. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115423. */
  115424. get computeParticleRotation(): boolean;
  115425. /**
  115426. * Gets if `setParticles()` computes the particle colors or not.
  115427. * Default value : true. The SPS is faster when it's set to false.
  115428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115429. */
  115430. get computeParticleColor(): boolean;
  115431. /**
  115432. * Gets if `setParticles()` computes the particle textures or not.
  115433. * Default value : true. The SPS is faster when it's set to false.
  115434. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115435. */
  115436. get computeParticleTexture(): boolean;
  115437. /**
  115438. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115439. * Default value : false. The SPS is faster when it's set to false.
  115440. * Note : the particle custom vertex positions aren't stored values.
  115441. */
  115442. get computeParticleVertex(): boolean;
  115443. /**
  115444. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115445. */
  115446. get computeBoundingBox(): boolean;
  115447. /**
  115448. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115449. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115450. * Default : `true`
  115451. */
  115452. get depthSortParticles(): boolean;
  115453. /**
  115454. * Gets if the SPS is created as expandable at construction time.
  115455. * Default : `false`
  115456. */
  115457. get expandable(): boolean;
  115458. /**
  115459. * Gets if the SPS supports the Multi Materials
  115460. */
  115461. get multimaterialEnabled(): boolean;
  115462. /**
  115463. * Gets if the SPS uses the model materials for its own multimaterial.
  115464. */
  115465. get useModelMaterial(): boolean;
  115466. /**
  115467. * The SPS used material array.
  115468. */
  115469. get materials(): Material[];
  115470. /**
  115471. * Sets the SPS MultiMaterial from the passed materials.
  115472. * Note : the passed array is internally copied and not used then by reference.
  115473. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115474. */
  115475. setMultiMaterial(materials: Material[]): void;
  115476. /**
  115477. * The SPS computed multimaterial object
  115478. */
  115479. get multimaterial(): MultiMaterial;
  115480. set multimaterial(mm: MultiMaterial);
  115481. /**
  115482. * If the subMeshes must be updated on the next call to setParticles()
  115483. */
  115484. get autoUpdateSubMeshes(): boolean;
  115485. set autoUpdateSubMeshes(val: boolean);
  115486. /**
  115487. * This function does nothing. It may be overwritten to set all the particle first values.
  115488. * The SPS doesn't call this function, you may have to call it by your own.
  115489. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115490. */
  115491. initParticles(): void;
  115492. /**
  115493. * This function does nothing. It may be overwritten to recycle a particle.
  115494. * The SPS doesn't call this function, you may have to call it by your own.
  115495. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115496. * @param particle The particle to recycle
  115497. * @returns the recycled particle
  115498. */
  115499. recycleParticle(particle: SolidParticle): SolidParticle;
  115500. /**
  115501. * Updates a particle : this function should be overwritten by the user.
  115502. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115504. * @example : just set a particle position or velocity and recycle conditions
  115505. * @param particle The particle to update
  115506. * @returns the updated particle
  115507. */
  115508. updateParticle(particle: SolidParticle): SolidParticle;
  115509. /**
  115510. * Updates a vertex of a particle : it can be overwritten by the user.
  115511. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115512. * @param particle the current particle
  115513. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115514. * @param pt the index of the current vertex in the particle shape
  115515. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115516. * @example : just set a vertex particle position or color
  115517. * @returns the sps
  115518. */
  115519. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115520. /**
  115521. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115522. * This does nothing and may be overwritten by the user.
  115523. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115524. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115525. * @param update the boolean update value actually passed to setParticles()
  115526. */
  115527. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115528. /**
  115529. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115530. * This will be passed three parameters.
  115531. * This does nothing and may be overwritten by the user.
  115532. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115533. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115534. * @param update the boolean update value actually passed to setParticles()
  115535. */
  115536. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115537. }
  115538. }
  115539. declare module BABYLON {
  115540. /**
  115541. * Represents one particle of a solid particle system.
  115542. */
  115543. export class SolidParticle {
  115544. /**
  115545. * particle global index
  115546. */
  115547. idx: number;
  115548. /**
  115549. * particle identifier
  115550. */
  115551. id: number;
  115552. /**
  115553. * The color of the particle
  115554. */
  115555. color: Nullable<Color4>;
  115556. /**
  115557. * The world space position of the particle.
  115558. */
  115559. position: Vector3;
  115560. /**
  115561. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115562. */
  115563. rotation: Vector3;
  115564. /**
  115565. * The world space rotation quaternion of the particle.
  115566. */
  115567. rotationQuaternion: Nullable<Quaternion>;
  115568. /**
  115569. * The scaling of the particle.
  115570. */
  115571. scaling: Vector3;
  115572. /**
  115573. * The uvs of the particle.
  115574. */
  115575. uvs: Vector4;
  115576. /**
  115577. * The current speed of the particle.
  115578. */
  115579. velocity: Vector3;
  115580. /**
  115581. * The pivot point in the particle local space.
  115582. */
  115583. pivot: Vector3;
  115584. /**
  115585. * Must the particle be translated from its pivot point in its local space ?
  115586. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115587. * Default : false
  115588. */
  115589. translateFromPivot: boolean;
  115590. /**
  115591. * Is the particle active or not ?
  115592. */
  115593. alive: boolean;
  115594. /**
  115595. * Is the particle visible or not ?
  115596. */
  115597. isVisible: boolean;
  115598. /**
  115599. * Index of this particle in the global "positions" array (Internal use)
  115600. * @hidden
  115601. */
  115602. _pos: number;
  115603. /**
  115604. * @hidden Index of this particle in the global "indices" array (Internal use)
  115605. */
  115606. _ind: number;
  115607. /**
  115608. * @hidden ModelShape of this particle (Internal use)
  115609. */
  115610. _model: ModelShape;
  115611. /**
  115612. * ModelShape id of this particle
  115613. */
  115614. shapeId: number;
  115615. /**
  115616. * Index of the particle in its shape id
  115617. */
  115618. idxInShape: number;
  115619. /**
  115620. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115621. */
  115622. _modelBoundingInfo: BoundingInfo;
  115623. /**
  115624. * @hidden Particle BoundingInfo object (Internal use)
  115625. */
  115626. _boundingInfo: BoundingInfo;
  115627. /**
  115628. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115629. */
  115630. _sps: SolidParticleSystem;
  115631. /**
  115632. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115633. */
  115634. _stillInvisible: boolean;
  115635. /**
  115636. * @hidden Last computed particle rotation matrix
  115637. */
  115638. _rotationMatrix: number[];
  115639. /**
  115640. * Parent particle Id, if any.
  115641. * Default null.
  115642. */
  115643. parentId: Nullable<number>;
  115644. /**
  115645. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115646. */
  115647. materialIndex: Nullable<number>;
  115648. /**
  115649. * Custom object or properties.
  115650. */
  115651. props: Nullable<any>;
  115652. /**
  115653. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115654. * The possible values are :
  115655. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115656. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115657. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115658. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115659. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115660. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115661. * */
  115662. cullingStrategy: number;
  115663. /**
  115664. * @hidden Internal global position in the SPS.
  115665. */
  115666. _globalPosition: Vector3;
  115667. /**
  115668. * Creates a Solid Particle object.
  115669. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115670. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115671. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115672. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115673. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115674. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115675. * @param shapeId (integer) is the model shape identifier in the SPS.
  115676. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115677. * @param sps defines the sps it is associated to
  115678. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115679. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115680. */
  115681. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115682. /**
  115683. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115684. * @param target the particle target
  115685. * @returns the current particle
  115686. */
  115687. copyToRef(target: SolidParticle): SolidParticle;
  115688. /**
  115689. * Legacy support, changed scale to scaling
  115690. */
  115691. get scale(): Vector3;
  115692. /**
  115693. * Legacy support, changed scale to scaling
  115694. */
  115695. set scale(scale: Vector3);
  115696. /**
  115697. * Legacy support, changed quaternion to rotationQuaternion
  115698. */
  115699. get quaternion(): Nullable<Quaternion>;
  115700. /**
  115701. * Legacy support, changed quaternion to rotationQuaternion
  115702. */
  115703. set quaternion(q: Nullable<Quaternion>);
  115704. /**
  115705. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115706. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115707. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115708. * @returns true if it intersects
  115709. */
  115710. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115711. /**
  115712. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115713. * A particle is in the frustum if its bounding box intersects the frustum
  115714. * @param frustumPlanes defines the frustum to test
  115715. * @returns true if the particle is in the frustum planes
  115716. */
  115717. isInFrustum(frustumPlanes: Plane[]): boolean;
  115718. /**
  115719. * get the rotation matrix of the particle
  115720. * @hidden
  115721. */
  115722. getRotationMatrix(m: Matrix): void;
  115723. }
  115724. /**
  115725. * Represents the shape of the model used by one particle of a solid particle system.
  115726. * SPS internal tool, don't use it manually.
  115727. */
  115728. export class ModelShape {
  115729. /**
  115730. * The shape id
  115731. * @hidden
  115732. */
  115733. shapeID: number;
  115734. /**
  115735. * flat array of model positions (internal use)
  115736. * @hidden
  115737. */
  115738. _shape: Vector3[];
  115739. /**
  115740. * flat array of model UVs (internal use)
  115741. * @hidden
  115742. */
  115743. _shapeUV: number[];
  115744. /**
  115745. * color array of the model
  115746. * @hidden
  115747. */
  115748. _shapeColors: number[];
  115749. /**
  115750. * indices array of the model
  115751. * @hidden
  115752. */
  115753. _indices: number[];
  115754. /**
  115755. * normals array of the model
  115756. * @hidden
  115757. */
  115758. _normals: number[];
  115759. /**
  115760. * length of the shape in the model indices array (internal use)
  115761. * @hidden
  115762. */
  115763. _indicesLength: number;
  115764. /**
  115765. * Custom position function (internal use)
  115766. * @hidden
  115767. */
  115768. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115769. /**
  115770. * Custom vertex function (internal use)
  115771. * @hidden
  115772. */
  115773. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115774. /**
  115775. * Model material (internal use)
  115776. * @hidden
  115777. */
  115778. _material: Nullable<Material>;
  115779. /**
  115780. * 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.
  115781. * SPS internal tool, don't use it manually.
  115782. * @hidden
  115783. */
  115784. 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>);
  115785. }
  115786. /**
  115787. * Represents a Depth Sorted Particle in the solid particle system.
  115788. * @hidden
  115789. */
  115790. export class DepthSortedParticle {
  115791. /**
  115792. * Particle index
  115793. */
  115794. idx: number;
  115795. /**
  115796. * Index of the particle in the "indices" array
  115797. */
  115798. ind: number;
  115799. /**
  115800. * Length of the particle shape in the "indices" array
  115801. */
  115802. indicesLength: number;
  115803. /**
  115804. * Squared distance from the particle to the camera
  115805. */
  115806. sqDistance: number;
  115807. /**
  115808. * Material index when used with MultiMaterials
  115809. */
  115810. materialIndex: number;
  115811. /**
  115812. * Creates a new sorted particle
  115813. * @param materialIndex
  115814. */
  115815. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115816. }
  115817. /**
  115818. * Represents a solid particle vertex
  115819. */
  115820. export class SolidParticleVertex {
  115821. /**
  115822. * Vertex position
  115823. */
  115824. position: Vector3;
  115825. /**
  115826. * Vertex color
  115827. */
  115828. color: Color4;
  115829. /**
  115830. * Vertex UV
  115831. */
  115832. uv: Vector2;
  115833. /**
  115834. * Creates a new solid particle vertex
  115835. */
  115836. constructor();
  115837. /** Vertex x coordinate */
  115838. get x(): number;
  115839. set x(val: number);
  115840. /** Vertex y coordinate */
  115841. get y(): number;
  115842. set y(val: number);
  115843. /** Vertex z coordinate */
  115844. get z(): number;
  115845. set z(val: number);
  115846. }
  115847. }
  115848. declare module BABYLON {
  115849. /**
  115850. * @hidden
  115851. */
  115852. export class _MeshCollisionData {
  115853. _checkCollisions: boolean;
  115854. _collisionMask: number;
  115855. _collisionGroup: number;
  115856. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115857. _collider: Nullable<Collider>;
  115858. _oldPositionForCollisions: Vector3;
  115859. _diffPositionForCollisions: Vector3;
  115860. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115861. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115862. _collisionResponse: boolean;
  115863. }
  115864. }
  115865. declare module BABYLON {
  115866. /** @hidden */
  115867. class _FacetDataStorage {
  115868. facetPositions: Vector3[];
  115869. facetNormals: Vector3[];
  115870. facetPartitioning: number[][];
  115871. facetNb: number;
  115872. partitioningSubdivisions: number;
  115873. partitioningBBoxRatio: number;
  115874. facetDataEnabled: boolean;
  115875. facetParameters: any;
  115876. bbSize: Vector3;
  115877. subDiv: {
  115878. max: number;
  115879. X: number;
  115880. Y: number;
  115881. Z: number;
  115882. };
  115883. facetDepthSort: boolean;
  115884. facetDepthSortEnabled: boolean;
  115885. depthSortedIndices: IndicesArray;
  115886. depthSortedFacets: {
  115887. ind: number;
  115888. sqDistance: number;
  115889. }[];
  115890. facetDepthSortFunction: (f1: {
  115891. ind: number;
  115892. sqDistance: number;
  115893. }, f2: {
  115894. ind: number;
  115895. sqDistance: number;
  115896. }) => number;
  115897. facetDepthSortFrom: Vector3;
  115898. facetDepthSortOrigin: Vector3;
  115899. invertedMatrix: Matrix;
  115900. }
  115901. /**
  115902. * @hidden
  115903. **/
  115904. class _InternalAbstractMeshDataInfo {
  115905. _hasVertexAlpha: boolean;
  115906. _useVertexColors: boolean;
  115907. _numBoneInfluencers: number;
  115908. _applyFog: boolean;
  115909. _receiveShadows: boolean;
  115910. _facetData: _FacetDataStorage;
  115911. _visibility: number;
  115912. _skeleton: Nullable<Skeleton>;
  115913. _layerMask: number;
  115914. _computeBonesUsingShaders: boolean;
  115915. _isActive: boolean;
  115916. _onlyForInstances: boolean;
  115917. _isActiveIntermediate: boolean;
  115918. _onlyForInstancesIntermediate: boolean;
  115919. _actAsRegularMesh: boolean;
  115920. }
  115921. /**
  115922. * Class used to store all common mesh properties
  115923. */
  115924. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115925. /** No occlusion */
  115926. static OCCLUSION_TYPE_NONE: number;
  115927. /** Occlusion set to optimisitic */
  115928. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115929. /** Occlusion set to strict */
  115930. static OCCLUSION_TYPE_STRICT: number;
  115931. /** Use an accurante occlusion algorithm */
  115932. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115933. /** Use a conservative occlusion algorithm */
  115934. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115935. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115936. * Test order :
  115937. * Is the bounding sphere outside the frustum ?
  115938. * If not, are the bounding box vertices outside the frustum ?
  115939. * It not, then the cullable object is in the frustum.
  115940. */
  115941. static readonly CULLINGSTRATEGY_STANDARD: number;
  115942. /** Culling strategy : Bounding Sphere Only.
  115943. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115944. * It's also less accurate than the standard because some not visible objects can still be selected.
  115945. * Test : is the bounding sphere outside the frustum ?
  115946. * If not, then the cullable object is in the frustum.
  115947. */
  115948. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115949. /** Culling strategy : Optimistic Inclusion.
  115950. * This in an inclusion test first, then the standard exclusion test.
  115951. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115952. * 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.
  115953. * Anyway, it's as accurate as the standard strategy.
  115954. * Test :
  115955. * Is the cullable object bounding sphere center in the frustum ?
  115956. * If not, apply the default culling strategy.
  115957. */
  115958. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115959. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115960. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115961. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115962. * 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.
  115963. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115964. * Test :
  115965. * Is the cullable object bounding sphere center in the frustum ?
  115966. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115967. */
  115968. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115969. /**
  115970. * No billboard
  115971. */
  115972. static get BILLBOARDMODE_NONE(): number;
  115973. /** Billboard on X axis */
  115974. static get BILLBOARDMODE_X(): number;
  115975. /** Billboard on Y axis */
  115976. static get BILLBOARDMODE_Y(): number;
  115977. /** Billboard on Z axis */
  115978. static get BILLBOARDMODE_Z(): number;
  115979. /** Billboard on all axes */
  115980. static get BILLBOARDMODE_ALL(): number;
  115981. /** Billboard on using position instead of orientation */
  115982. static get BILLBOARDMODE_USE_POSITION(): number;
  115983. /** @hidden */
  115984. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  115985. /**
  115986. * The culling strategy to use to check whether the mesh must be rendered or not.
  115987. * This value can be changed at any time and will be used on the next render mesh selection.
  115988. * The possible values are :
  115989. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115990. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115992. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115993. * Please read each static variable documentation to get details about the culling process.
  115994. * */
  115995. cullingStrategy: number;
  115996. /**
  115997. * Gets the number of facets in the mesh
  115998. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115999. */
  116000. get facetNb(): number;
  116001. /**
  116002. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116003. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116004. */
  116005. get partitioningSubdivisions(): number;
  116006. set partitioningSubdivisions(nb: number);
  116007. /**
  116008. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116009. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116010. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116011. */
  116012. get partitioningBBoxRatio(): number;
  116013. set partitioningBBoxRatio(ratio: number);
  116014. /**
  116015. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116016. * Works only for updatable meshes.
  116017. * Doesn't work with multi-materials
  116018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116019. */
  116020. get mustDepthSortFacets(): boolean;
  116021. set mustDepthSortFacets(sort: boolean);
  116022. /**
  116023. * The location (Vector3) where the facet depth sort must be computed from.
  116024. * By default, the active camera position.
  116025. * Used only when facet depth sort is enabled
  116026. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116027. */
  116028. get facetDepthSortFrom(): Vector3;
  116029. set facetDepthSortFrom(location: Vector3);
  116030. /**
  116031. * gets a boolean indicating if facetData is enabled
  116032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116033. */
  116034. get isFacetDataEnabled(): boolean;
  116035. /** @hidden */
  116036. _updateNonUniformScalingState(value: boolean): boolean;
  116037. /**
  116038. * An event triggered when this mesh collides with another one
  116039. */
  116040. onCollideObservable: Observable<AbstractMesh>;
  116041. /** Set a function to call when this mesh collides with another one */
  116042. set onCollide(callback: () => void);
  116043. /**
  116044. * An event triggered when the collision's position changes
  116045. */
  116046. onCollisionPositionChangeObservable: Observable<Vector3>;
  116047. /** Set a function to call when the collision's position changes */
  116048. set onCollisionPositionChange(callback: () => void);
  116049. /**
  116050. * An event triggered when material is changed
  116051. */
  116052. onMaterialChangedObservable: Observable<AbstractMesh>;
  116053. /**
  116054. * Gets or sets the orientation for POV movement & rotation
  116055. */
  116056. definedFacingForward: boolean;
  116057. /** @hidden */
  116058. _occlusionQuery: Nullable<WebGLQuery>;
  116059. /** @hidden */
  116060. _renderingGroup: Nullable<RenderingGroup>;
  116061. /**
  116062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116063. */
  116064. get visibility(): number;
  116065. /**
  116066. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116067. */
  116068. set visibility(value: number);
  116069. /** Gets or sets the alpha index used to sort transparent meshes
  116070. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116071. */
  116072. alphaIndex: number;
  116073. /**
  116074. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116075. */
  116076. isVisible: boolean;
  116077. /**
  116078. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116079. */
  116080. isPickable: boolean;
  116081. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116082. showSubMeshesBoundingBox: boolean;
  116083. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116084. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116085. */
  116086. isBlocker: boolean;
  116087. /**
  116088. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116089. */
  116090. enablePointerMoveEvents: boolean;
  116091. private _renderingGroupId;
  116092. /**
  116093. * Specifies the rendering group id for this mesh (0 by default)
  116094. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116095. */
  116096. get renderingGroupId(): number;
  116097. set renderingGroupId(value: number);
  116098. private _material;
  116099. /** Gets or sets current material */
  116100. get material(): Nullable<Material>;
  116101. set material(value: Nullable<Material>);
  116102. /**
  116103. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116104. * @see https://doc.babylonjs.com/babylon101/shadows
  116105. */
  116106. get receiveShadows(): boolean;
  116107. set receiveShadows(value: boolean);
  116108. /** Defines color to use when rendering outline */
  116109. outlineColor: Color3;
  116110. /** Define width to use when rendering outline */
  116111. outlineWidth: number;
  116112. /** Defines color to use when rendering overlay */
  116113. overlayColor: Color3;
  116114. /** Defines alpha to use when rendering overlay */
  116115. overlayAlpha: number;
  116116. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116117. get hasVertexAlpha(): boolean;
  116118. set hasVertexAlpha(value: boolean);
  116119. /** 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) */
  116120. get useVertexColors(): boolean;
  116121. set useVertexColors(value: boolean);
  116122. /**
  116123. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116124. */
  116125. get computeBonesUsingShaders(): boolean;
  116126. set computeBonesUsingShaders(value: boolean);
  116127. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116128. get numBoneInfluencers(): number;
  116129. set numBoneInfluencers(value: number);
  116130. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116131. get applyFog(): boolean;
  116132. set applyFog(value: boolean);
  116133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116134. useOctreeForRenderingSelection: boolean;
  116135. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116136. useOctreeForPicking: boolean;
  116137. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116138. useOctreeForCollisions: boolean;
  116139. /**
  116140. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116141. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116142. */
  116143. get layerMask(): number;
  116144. set layerMask(value: number);
  116145. /**
  116146. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116147. */
  116148. alwaysSelectAsActiveMesh: boolean;
  116149. /**
  116150. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116151. */
  116152. doNotSyncBoundingInfo: boolean;
  116153. /**
  116154. * Gets or sets the current action manager
  116155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116156. */
  116157. actionManager: Nullable<AbstractActionManager>;
  116158. private _meshCollisionData;
  116159. /**
  116160. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116161. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116162. */
  116163. ellipsoid: Vector3;
  116164. /**
  116165. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116166. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116167. */
  116168. ellipsoidOffset: Vector3;
  116169. /**
  116170. * Gets or sets a collision mask used to mask collisions (default is -1).
  116171. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116172. */
  116173. get collisionMask(): number;
  116174. set collisionMask(mask: number);
  116175. /**
  116176. * Gets or sets a collision response flag (default is true).
  116177. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116178. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116179. * to respond to the collision.
  116180. */
  116181. get collisionResponse(): boolean;
  116182. set collisionResponse(response: boolean);
  116183. /**
  116184. * Gets or sets the current collision group mask (-1 by default).
  116185. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116186. */
  116187. get collisionGroup(): number;
  116188. set collisionGroup(mask: number);
  116189. /**
  116190. * Gets or sets current surrounding meshes (null by default).
  116191. *
  116192. * By default collision detection is tested against every mesh in the scene.
  116193. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116194. * meshes will be tested for the collision.
  116195. *
  116196. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116197. */
  116198. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116199. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116200. /**
  116201. * Defines edge width used when edgesRenderer is enabled
  116202. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116203. */
  116204. edgesWidth: number;
  116205. /**
  116206. * Defines edge color used when edgesRenderer is enabled
  116207. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116208. */
  116209. edgesColor: Color4;
  116210. /** @hidden */
  116211. _edgesRenderer: Nullable<IEdgesRenderer>;
  116212. /** @hidden */
  116213. _masterMesh: Nullable<AbstractMesh>;
  116214. /** @hidden */
  116215. _boundingInfo: Nullable<BoundingInfo>;
  116216. /** @hidden */
  116217. _renderId: number;
  116218. /**
  116219. * Gets or sets the list of subMeshes
  116220. * @see https://doc.babylonjs.com/how_to/multi_materials
  116221. */
  116222. subMeshes: SubMesh[];
  116223. /** @hidden */
  116224. _intersectionsInProgress: AbstractMesh[];
  116225. /** @hidden */
  116226. _unIndexed: boolean;
  116227. /** @hidden */
  116228. _lightSources: Light[];
  116229. /** Gets the list of lights affecting that mesh */
  116230. get lightSources(): Light[];
  116231. /** @hidden */
  116232. get _positions(): Nullable<Vector3[]>;
  116233. /** @hidden */
  116234. _waitingData: {
  116235. lods: Nullable<any>;
  116236. actions: Nullable<any>;
  116237. freezeWorldMatrix: Nullable<boolean>;
  116238. };
  116239. /** @hidden */
  116240. _bonesTransformMatrices: Nullable<Float32Array>;
  116241. /** @hidden */
  116242. _transformMatrixTexture: Nullable<RawTexture>;
  116243. /**
  116244. * Gets or sets a skeleton to apply skining transformations
  116245. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116246. */
  116247. set skeleton(value: Nullable<Skeleton>);
  116248. get skeleton(): Nullable<Skeleton>;
  116249. /**
  116250. * An event triggered when the mesh is rebuilt.
  116251. */
  116252. onRebuildObservable: Observable<AbstractMesh>;
  116253. /**
  116254. * Creates a new AbstractMesh
  116255. * @param name defines the name of the mesh
  116256. * @param scene defines the hosting scene
  116257. */
  116258. constructor(name: string, scene?: Nullable<Scene>);
  116259. /**
  116260. * Returns the string "AbstractMesh"
  116261. * @returns "AbstractMesh"
  116262. */
  116263. getClassName(): string;
  116264. /**
  116265. * Gets a string representation of the current mesh
  116266. * @param fullDetails defines a boolean indicating if full details must be included
  116267. * @returns a string representation of the current mesh
  116268. */
  116269. toString(fullDetails?: boolean): string;
  116270. /**
  116271. * @hidden
  116272. */
  116273. protected _getEffectiveParent(): Nullable<Node>;
  116274. /** @hidden */
  116275. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116276. /** @hidden */
  116277. _rebuild(): void;
  116278. /** @hidden */
  116279. _resyncLightSources(): void;
  116280. /** @hidden */
  116281. _resyncLightSource(light: Light): void;
  116282. /** @hidden */
  116283. _unBindEffect(): void;
  116284. /** @hidden */
  116285. _removeLightSource(light: Light, dispose: boolean): void;
  116286. private _markSubMeshesAsDirty;
  116287. /** @hidden */
  116288. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116289. /** @hidden */
  116290. _markSubMeshesAsAttributesDirty(): void;
  116291. /** @hidden */
  116292. _markSubMeshesAsMiscDirty(): void;
  116293. /**
  116294. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116295. */
  116296. get scaling(): Vector3;
  116297. set scaling(newScaling: Vector3);
  116298. /**
  116299. * Returns true if the mesh is blocked. Implemented by child classes
  116300. */
  116301. get isBlocked(): boolean;
  116302. /**
  116303. * Returns the mesh itself by default. Implemented by child classes
  116304. * @param camera defines the camera to use to pick the right LOD level
  116305. * @returns the currentAbstractMesh
  116306. */
  116307. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116308. /**
  116309. * Returns 0 by default. Implemented by child classes
  116310. * @returns an integer
  116311. */
  116312. getTotalVertices(): number;
  116313. /**
  116314. * Returns a positive integer : the total number of indices in this mesh geometry.
  116315. * @returns the numner of indices or zero if the mesh has no geometry.
  116316. */
  116317. getTotalIndices(): number;
  116318. /**
  116319. * Returns null by default. Implemented by child classes
  116320. * @returns null
  116321. */
  116322. getIndices(): Nullable<IndicesArray>;
  116323. /**
  116324. * Returns the array of the requested vertex data kind. Implemented by child classes
  116325. * @param kind defines the vertex data kind to use
  116326. * @returns null
  116327. */
  116328. getVerticesData(kind: string): Nullable<FloatArray>;
  116329. /**
  116330. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116331. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116332. * Note that a new underlying VertexBuffer object is created each call.
  116333. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116334. * @param kind defines vertex data kind:
  116335. * * VertexBuffer.PositionKind
  116336. * * VertexBuffer.UVKind
  116337. * * VertexBuffer.UV2Kind
  116338. * * VertexBuffer.UV3Kind
  116339. * * VertexBuffer.UV4Kind
  116340. * * VertexBuffer.UV5Kind
  116341. * * VertexBuffer.UV6Kind
  116342. * * VertexBuffer.ColorKind
  116343. * * VertexBuffer.MatricesIndicesKind
  116344. * * VertexBuffer.MatricesIndicesExtraKind
  116345. * * VertexBuffer.MatricesWeightsKind
  116346. * * VertexBuffer.MatricesWeightsExtraKind
  116347. * @param data defines the data source
  116348. * @param updatable defines if the data must be flagged as updatable (or static)
  116349. * @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
  116350. * @returns the current mesh
  116351. */
  116352. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116353. /**
  116354. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116355. * If the mesh has no geometry, it is simply returned as it is.
  116356. * @param kind defines vertex data kind:
  116357. * * VertexBuffer.PositionKind
  116358. * * VertexBuffer.UVKind
  116359. * * VertexBuffer.UV2Kind
  116360. * * VertexBuffer.UV3Kind
  116361. * * VertexBuffer.UV4Kind
  116362. * * VertexBuffer.UV5Kind
  116363. * * VertexBuffer.UV6Kind
  116364. * * VertexBuffer.ColorKind
  116365. * * VertexBuffer.MatricesIndicesKind
  116366. * * VertexBuffer.MatricesIndicesExtraKind
  116367. * * VertexBuffer.MatricesWeightsKind
  116368. * * VertexBuffer.MatricesWeightsExtraKind
  116369. * @param data defines the data source
  116370. * @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
  116371. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116372. * @returns the current mesh
  116373. */
  116374. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116375. /**
  116376. * Sets the mesh indices,
  116377. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116378. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116379. * @param totalVertices Defines the total number of vertices
  116380. * @returns the current mesh
  116381. */
  116382. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116383. /**
  116384. * Gets a boolean indicating if specific vertex data is present
  116385. * @param kind defines the vertex data kind to use
  116386. * @returns true is data kind is present
  116387. */
  116388. isVerticesDataPresent(kind: string): boolean;
  116389. /**
  116390. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116391. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116392. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116393. * @returns a BoundingInfo
  116394. */
  116395. getBoundingInfo(): BoundingInfo;
  116396. /**
  116397. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116398. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116399. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116400. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116401. * @returns the current mesh
  116402. */
  116403. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116404. /**
  116405. * Overwrite the current bounding info
  116406. * @param boundingInfo defines the new bounding info
  116407. * @returns the current mesh
  116408. */
  116409. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116410. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116411. get useBones(): boolean;
  116412. /** @hidden */
  116413. _preActivate(): void;
  116414. /** @hidden */
  116415. _preActivateForIntermediateRendering(renderId: number): void;
  116416. /** @hidden */
  116417. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116418. /** @hidden */
  116419. _postActivate(): void;
  116420. /** @hidden */
  116421. _freeze(): void;
  116422. /** @hidden */
  116423. _unFreeze(): void;
  116424. /**
  116425. * Gets the current world matrix
  116426. * @returns a Matrix
  116427. */
  116428. getWorldMatrix(): Matrix;
  116429. /** @hidden */
  116430. _getWorldMatrixDeterminant(): number;
  116431. /**
  116432. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116433. */
  116434. get isAnInstance(): boolean;
  116435. /**
  116436. * Gets a boolean indicating if this mesh has instances
  116437. */
  116438. get hasInstances(): boolean;
  116439. /**
  116440. * Gets a boolean indicating if this mesh has thin instances
  116441. */
  116442. get hasThinInstances(): boolean;
  116443. /**
  116444. * Perform relative position change from the point of view of behind the front of the mesh.
  116445. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116446. * Supports definition of mesh facing forward or backward
  116447. * @param amountRight defines the distance on the right axis
  116448. * @param amountUp defines the distance on the up axis
  116449. * @param amountForward defines the distance on the forward axis
  116450. * @returns the current mesh
  116451. */
  116452. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116453. /**
  116454. * Calculate relative position change from the point of view of behind the front of the mesh.
  116455. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116456. * Supports definition of mesh facing forward or backward
  116457. * @param amountRight defines the distance on the right axis
  116458. * @param amountUp defines the distance on the up axis
  116459. * @param amountForward defines the distance on the forward axis
  116460. * @returns the new displacement vector
  116461. */
  116462. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116463. /**
  116464. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116465. * Supports definition of mesh facing forward or backward
  116466. * @param flipBack defines the flip
  116467. * @param twirlClockwise defines the twirl
  116468. * @param tiltRight defines the tilt
  116469. * @returns the current mesh
  116470. */
  116471. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116472. /**
  116473. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116474. * Supports definition of mesh facing forward or backward.
  116475. * @param flipBack defines the flip
  116476. * @param twirlClockwise defines the twirl
  116477. * @param tiltRight defines the tilt
  116478. * @returns the new rotation vector
  116479. */
  116480. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116481. /**
  116482. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116483. * This means the mesh underlying bounding box and sphere are recomputed.
  116484. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116485. * @returns the current mesh
  116486. */
  116487. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116488. /** @hidden */
  116489. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116490. /** @hidden */
  116491. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116492. /** @hidden */
  116493. _updateBoundingInfo(): AbstractMesh;
  116494. /** @hidden */
  116495. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116496. /** @hidden */
  116497. protected _afterComputeWorldMatrix(): void;
  116498. /** @hidden */
  116499. get _effectiveMesh(): AbstractMesh;
  116500. /**
  116501. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116502. * A mesh is in the frustum if its bounding box intersects the frustum
  116503. * @param frustumPlanes defines the frustum to test
  116504. * @returns true if the mesh is in the frustum planes
  116505. */
  116506. isInFrustum(frustumPlanes: Plane[]): boolean;
  116507. /**
  116508. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116509. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116510. * @param frustumPlanes defines the frustum to test
  116511. * @returns true if the mesh is completely in the frustum planes
  116512. */
  116513. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116514. /**
  116515. * True if the mesh intersects another mesh or a SolidParticle object
  116516. * @param mesh defines a target mesh or SolidParticle to test
  116517. * @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)
  116518. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116519. * @returns true if there is an intersection
  116520. */
  116521. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116522. /**
  116523. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116524. * @param point defines the point to test
  116525. * @returns true if there is an intersection
  116526. */
  116527. intersectsPoint(point: Vector3): boolean;
  116528. /**
  116529. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116530. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116531. */
  116532. get checkCollisions(): boolean;
  116533. set checkCollisions(collisionEnabled: boolean);
  116534. /**
  116535. * Gets Collider object used to compute collisions (not physics)
  116536. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116537. */
  116538. get collider(): Nullable<Collider>;
  116539. /**
  116540. * Move the mesh using collision engine
  116541. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116542. * @param displacement defines the requested displacement vector
  116543. * @returns the current mesh
  116544. */
  116545. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116546. private _onCollisionPositionChange;
  116547. /** @hidden */
  116548. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116549. /** @hidden */
  116550. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116551. /** @hidden */
  116552. _checkCollision(collider: Collider): AbstractMesh;
  116553. /** @hidden */
  116554. _generatePointsArray(): boolean;
  116555. /**
  116556. * Checks if the passed Ray intersects with the mesh
  116557. * @param ray defines the ray to use
  116558. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116559. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116560. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116561. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116562. * @returns the picking info
  116563. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116564. */
  116565. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116566. /**
  116567. * Clones the current mesh
  116568. * @param name defines the mesh name
  116569. * @param newParent defines the new mesh parent
  116570. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116571. * @returns the new mesh
  116572. */
  116573. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116574. /**
  116575. * Disposes all the submeshes of the current meshnp
  116576. * @returns the current mesh
  116577. */
  116578. releaseSubMeshes(): AbstractMesh;
  116579. /**
  116580. * Releases resources associated with this abstract mesh.
  116581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116583. */
  116584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116585. /**
  116586. * Adds the passed mesh as a child to the current mesh
  116587. * @param mesh defines the child mesh
  116588. * @returns the current mesh
  116589. */
  116590. addChild(mesh: AbstractMesh): AbstractMesh;
  116591. /**
  116592. * Removes the passed mesh from the current mesh children list
  116593. * @param mesh defines the child mesh
  116594. * @returns the current mesh
  116595. */
  116596. removeChild(mesh: AbstractMesh): AbstractMesh;
  116597. /** @hidden */
  116598. private _initFacetData;
  116599. /**
  116600. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116601. * This method can be called within the render loop.
  116602. * 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
  116603. * @returns the current mesh
  116604. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116605. */
  116606. updateFacetData(): AbstractMesh;
  116607. /**
  116608. * Returns the facetLocalNormals array.
  116609. * The normals are expressed in the mesh local spac
  116610. * @returns an array of Vector3
  116611. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116612. */
  116613. getFacetLocalNormals(): Vector3[];
  116614. /**
  116615. * Returns the facetLocalPositions array.
  116616. * The facet positions are expressed in the mesh local space
  116617. * @returns an array of Vector3
  116618. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116619. */
  116620. getFacetLocalPositions(): Vector3[];
  116621. /**
  116622. * Returns the facetLocalPartioning array
  116623. * @returns an array of array of numbers
  116624. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116625. */
  116626. getFacetLocalPartitioning(): number[][];
  116627. /**
  116628. * Returns the i-th facet position in the world system.
  116629. * This method allocates a new Vector3 per call
  116630. * @param i defines the facet index
  116631. * @returns a new Vector3
  116632. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116633. */
  116634. getFacetPosition(i: number): Vector3;
  116635. /**
  116636. * Sets the reference Vector3 with the i-th facet position in the world system
  116637. * @param i defines the facet index
  116638. * @param ref defines the target vector
  116639. * @returns the current mesh
  116640. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116641. */
  116642. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116643. /**
  116644. * Returns the i-th facet normal in the world system.
  116645. * This method allocates a new Vector3 per call
  116646. * @param i defines the facet index
  116647. * @returns a new Vector3
  116648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116649. */
  116650. getFacetNormal(i: number): Vector3;
  116651. /**
  116652. * Sets the reference Vector3 with the i-th facet normal in the world system
  116653. * @param i defines the facet index
  116654. * @param ref defines the target vector
  116655. * @returns the current mesh
  116656. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116657. */
  116658. getFacetNormalToRef(i: number, ref: Vector3): this;
  116659. /**
  116660. * 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)
  116661. * @param x defines x coordinate
  116662. * @param y defines y coordinate
  116663. * @param z defines z coordinate
  116664. * @returns the array of facet indexes
  116665. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116666. */
  116667. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116668. /**
  116669. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116670. * @param projected sets as the (x,y,z) world projection on the facet
  116671. * @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
  116672. * @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
  116673. * @param x defines x coordinate
  116674. * @param y defines y coordinate
  116675. * @param z defines z coordinate
  116676. * @returns the face index if found (or null instead)
  116677. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116678. */
  116679. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116680. /**
  116681. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116682. * @param projected sets as the (x,y,z) local projection on the facet
  116683. * @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
  116684. * @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
  116685. * @param x defines x coordinate
  116686. * @param y defines y coordinate
  116687. * @param z defines z coordinate
  116688. * @returns the face index if found (or null instead)
  116689. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116690. */
  116691. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116692. /**
  116693. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116694. * @returns the parameters
  116695. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116696. */
  116697. getFacetDataParameters(): any;
  116698. /**
  116699. * Disables the feature FacetData and frees the related memory
  116700. * @returns the current mesh
  116701. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116702. */
  116703. disableFacetData(): AbstractMesh;
  116704. /**
  116705. * Updates the AbstractMesh indices array
  116706. * @param indices defines the data source
  116707. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116708. * @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)
  116709. * @returns the current mesh
  116710. */
  116711. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116712. /**
  116713. * Creates new normals data for the mesh
  116714. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116715. * @returns the current mesh
  116716. */
  116717. createNormals(updatable: boolean): AbstractMesh;
  116718. /**
  116719. * Align the mesh with a normal
  116720. * @param normal defines the normal to use
  116721. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116722. * @returns the current mesh
  116723. */
  116724. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116725. /** @hidden */
  116726. _checkOcclusionQuery(): boolean;
  116727. /**
  116728. * Disables the mesh edge rendering mode
  116729. * @returns the currentAbstractMesh
  116730. */
  116731. disableEdgesRendering(): AbstractMesh;
  116732. /**
  116733. * Enables the edge rendering mode on the mesh.
  116734. * This mode makes the mesh edges visible
  116735. * @param epsilon defines the maximal distance between two angles to detect a face
  116736. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116737. * @returns the currentAbstractMesh
  116738. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116739. */
  116740. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116741. /**
  116742. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116743. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116744. */
  116745. getConnectedParticleSystems(): IParticleSystem[];
  116746. }
  116747. }
  116748. declare module BABYLON {
  116749. /**
  116750. * Interface used to define ActionEvent
  116751. */
  116752. export interface IActionEvent {
  116753. /** The mesh or sprite that triggered the action */
  116754. source: any;
  116755. /** The X mouse cursor position at the time of the event */
  116756. pointerX: number;
  116757. /** The Y mouse cursor position at the time of the event */
  116758. pointerY: number;
  116759. /** The mesh that is currently pointed at (can be null) */
  116760. meshUnderPointer: Nullable<AbstractMesh>;
  116761. /** the original (browser) event that triggered the ActionEvent */
  116762. sourceEvent?: any;
  116763. /** additional data for the event */
  116764. additionalData?: any;
  116765. }
  116766. /**
  116767. * ActionEvent is the event being sent when an action is triggered.
  116768. */
  116769. export class ActionEvent implements IActionEvent {
  116770. /** The mesh or sprite that triggered the action */
  116771. source: any;
  116772. /** The X mouse cursor position at the time of the event */
  116773. pointerX: number;
  116774. /** The Y mouse cursor position at the time of the event */
  116775. pointerY: number;
  116776. /** The mesh that is currently pointed at (can be null) */
  116777. meshUnderPointer: Nullable<AbstractMesh>;
  116778. /** the original (browser) event that triggered the ActionEvent */
  116779. sourceEvent?: any;
  116780. /** additional data for the event */
  116781. additionalData?: any;
  116782. /**
  116783. * Creates a new ActionEvent
  116784. * @param source The mesh or sprite that triggered the action
  116785. * @param pointerX The X mouse cursor position at the time of the event
  116786. * @param pointerY The Y mouse cursor position at the time of the event
  116787. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116788. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116789. * @param additionalData additional data for the event
  116790. */
  116791. constructor(
  116792. /** The mesh or sprite that triggered the action */
  116793. source: any,
  116794. /** The X mouse cursor position at the time of the event */
  116795. pointerX: number,
  116796. /** The Y mouse cursor position at the time of the event */
  116797. pointerY: number,
  116798. /** The mesh that is currently pointed at (can be null) */
  116799. meshUnderPointer: Nullable<AbstractMesh>,
  116800. /** the original (browser) event that triggered the ActionEvent */
  116801. sourceEvent?: any,
  116802. /** additional data for the event */
  116803. additionalData?: any);
  116804. /**
  116805. * Helper function to auto-create an ActionEvent from a source mesh.
  116806. * @param source The source mesh that triggered the event
  116807. * @param evt The original (browser) event
  116808. * @param additionalData additional data for the event
  116809. * @returns the new ActionEvent
  116810. */
  116811. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116812. /**
  116813. * Helper function to auto-create an ActionEvent from a source sprite
  116814. * @param source The source sprite that triggered the event
  116815. * @param scene Scene associated with the sprite
  116816. * @param evt The original (browser) event
  116817. * @param additionalData additional data for the event
  116818. * @returns the new ActionEvent
  116819. */
  116820. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116821. /**
  116822. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116823. * @param scene the scene where the event occurred
  116824. * @param evt The original (browser) event
  116825. * @returns the new ActionEvent
  116826. */
  116827. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116828. /**
  116829. * Helper function to auto-create an ActionEvent from a primitive
  116830. * @param prim defines the target primitive
  116831. * @param pointerPos defines the pointer position
  116832. * @param evt The original (browser) event
  116833. * @param additionalData additional data for the event
  116834. * @returns the new ActionEvent
  116835. */
  116836. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116837. }
  116838. }
  116839. declare module BABYLON {
  116840. /**
  116841. * Abstract class used to decouple action Manager from scene and meshes.
  116842. * Do not instantiate.
  116843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116844. */
  116845. export abstract class AbstractActionManager implements IDisposable {
  116846. /** Gets the list of active triggers */
  116847. static Triggers: {
  116848. [key: string]: number;
  116849. };
  116850. /** Gets the cursor to use when hovering items */
  116851. hoverCursor: string;
  116852. /** Gets the list of actions */
  116853. actions: IAction[];
  116854. /**
  116855. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116856. */
  116857. isRecursive: boolean;
  116858. /**
  116859. * Releases all associated resources
  116860. */
  116861. abstract dispose(): void;
  116862. /**
  116863. * Does this action manager has pointer triggers
  116864. */
  116865. abstract get hasPointerTriggers(): boolean;
  116866. /**
  116867. * Does this action manager has pick triggers
  116868. */
  116869. abstract get hasPickTriggers(): boolean;
  116870. /**
  116871. * Process a specific trigger
  116872. * @param trigger defines the trigger to process
  116873. * @param evt defines the event details to be processed
  116874. */
  116875. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116876. /**
  116877. * Does this action manager handles actions of any of the given triggers
  116878. * @param triggers defines the triggers to be tested
  116879. * @return a boolean indicating whether one (or more) of the triggers is handled
  116880. */
  116881. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116882. /**
  116883. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116884. * speed.
  116885. * @param triggerA defines the trigger to be tested
  116886. * @param triggerB defines the trigger to be tested
  116887. * @return a boolean indicating whether one (or more) of the triggers is handled
  116888. */
  116889. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116890. /**
  116891. * Does this action manager handles actions of a given trigger
  116892. * @param trigger defines the trigger to be tested
  116893. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116894. * @return whether the trigger is handled
  116895. */
  116896. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116897. /**
  116898. * Serialize this manager to a JSON object
  116899. * @param name defines the property name to store this manager
  116900. * @returns a JSON representation of this manager
  116901. */
  116902. abstract serialize(name: string): any;
  116903. /**
  116904. * Registers an action to this action manager
  116905. * @param action defines the action to be registered
  116906. * @return the action amended (prepared) after registration
  116907. */
  116908. abstract registerAction(action: IAction): Nullable<IAction>;
  116909. /**
  116910. * Unregisters an action to this action manager
  116911. * @param action defines the action to be unregistered
  116912. * @return a boolean indicating whether the action has been unregistered
  116913. */
  116914. abstract unregisterAction(action: IAction): Boolean;
  116915. /**
  116916. * Does exist one action manager with at least one trigger
  116917. **/
  116918. static get HasTriggers(): boolean;
  116919. /**
  116920. * Does exist one action manager with at least one pick trigger
  116921. **/
  116922. static get HasPickTriggers(): boolean;
  116923. /**
  116924. * Does exist one action manager that handles actions of a given trigger
  116925. * @param trigger defines the trigger to be tested
  116926. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116927. **/
  116928. static HasSpecificTrigger(trigger: number): boolean;
  116929. }
  116930. }
  116931. declare module BABYLON {
  116932. /**
  116933. * Defines how a node can be built from a string name.
  116934. */
  116935. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116936. /**
  116937. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116938. */
  116939. export class Node implements IBehaviorAware<Node> {
  116940. /** @hidden */
  116941. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116942. private static _NodeConstructors;
  116943. /**
  116944. * Add a new node constructor
  116945. * @param type defines the type name of the node to construct
  116946. * @param constructorFunc defines the constructor function
  116947. */
  116948. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116949. /**
  116950. * Returns a node constructor based on type name
  116951. * @param type defines the type name
  116952. * @param name defines the new node name
  116953. * @param scene defines the hosting scene
  116954. * @param options defines optional options to transmit to constructors
  116955. * @returns the new constructor or null
  116956. */
  116957. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116958. /**
  116959. * Gets or sets the name of the node
  116960. */
  116961. name: string;
  116962. /**
  116963. * Gets or sets the id of the node
  116964. */
  116965. id: string;
  116966. /**
  116967. * Gets or sets the unique id of the node
  116968. */
  116969. uniqueId: number;
  116970. /**
  116971. * Gets or sets a string used to store user defined state for the node
  116972. */
  116973. state: string;
  116974. /**
  116975. * Gets or sets an object used to store user defined information for the node
  116976. */
  116977. metadata: any;
  116978. /**
  116979. * For internal use only. Please do not use.
  116980. */
  116981. reservedDataStore: any;
  116982. /**
  116983. * List of inspectable custom properties (used by the Inspector)
  116984. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  116985. */
  116986. inspectableCustomProperties: IInspectable[];
  116987. private _doNotSerialize;
  116988. /**
  116989. * Gets or sets a boolean used to define if the node must be serialized
  116990. */
  116991. get doNotSerialize(): boolean;
  116992. set doNotSerialize(value: boolean);
  116993. /** @hidden */
  116994. _isDisposed: boolean;
  116995. /**
  116996. * Gets a list of Animations associated with the node
  116997. */
  116998. animations: Animation[];
  116999. protected _ranges: {
  117000. [name: string]: Nullable<AnimationRange>;
  117001. };
  117002. /**
  117003. * Callback raised when the node is ready to be used
  117004. */
  117005. onReady: Nullable<(node: Node) => void>;
  117006. private _isEnabled;
  117007. private _isParentEnabled;
  117008. private _isReady;
  117009. /** @hidden */
  117010. _currentRenderId: number;
  117011. private _parentUpdateId;
  117012. /** @hidden */
  117013. _childUpdateId: number;
  117014. /** @hidden */
  117015. _waitingParentId: Nullable<string>;
  117016. /** @hidden */
  117017. _scene: Scene;
  117018. /** @hidden */
  117019. _cache: any;
  117020. private _parentNode;
  117021. private _children;
  117022. /** @hidden */
  117023. _worldMatrix: Matrix;
  117024. /** @hidden */
  117025. _worldMatrixDeterminant: number;
  117026. /** @hidden */
  117027. _worldMatrixDeterminantIsDirty: boolean;
  117028. /** @hidden */
  117029. private _sceneRootNodesIndex;
  117030. /**
  117031. * Gets a boolean indicating if the node has been disposed
  117032. * @returns true if the node was disposed
  117033. */
  117034. isDisposed(): boolean;
  117035. /**
  117036. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117037. * @see https://doc.babylonjs.com/how_to/parenting
  117038. */
  117039. set parent(parent: Nullable<Node>);
  117040. get parent(): Nullable<Node>;
  117041. /** @hidden */
  117042. _addToSceneRootNodes(): void;
  117043. /** @hidden */
  117044. _removeFromSceneRootNodes(): void;
  117045. private _animationPropertiesOverride;
  117046. /**
  117047. * Gets or sets the animation properties override
  117048. */
  117049. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117050. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117051. /**
  117052. * Gets a string identifying the name of the class
  117053. * @returns "Node" string
  117054. */
  117055. getClassName(): string;
  117056. /** @hidden */
  117057. readonly _isNode: boolean;
  117058. /**
  117059. * An event triggered when the mesh is disposed
  117060. */
  117061. onDisposeObservable: Observable<Node>;
  117062. private _onDisposeObserver;
  117063. /**
  117064. * Sets a callback that will be raised when the node will be disposed
  117065. */
  117066. set onDispose(callback: () => void);
  117067. /**
  117068. * Creates a new Node
  117069. * @param name the name and id to be given to this node
  117070. * @param scene the scene this node will be added to
  117071. */
  117072. constructor(name: string, scene?: Nullable<Scene>);
  117073. /**
  117074. * Gets the scene of the node
  117075. * @returns a scene
  117076. */
  117077. getScene(): Scene;
  117078. /**
  117079. * Gets the engine of the node
  117080. * @returns a Engine
  117081. */
  117082. getEngine(): Engine;
  117083. private _behaviors;
  117084. /**
  117085. * Attach a behavior to the node
  117086. * @see https://doc.babylonjs.com/features/behaviour
  117087. * @param behavior defines the behavior to attach
  117088. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117089. * @returns the current Node
  117090. */
  117091. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117092. /**
  117093. * Remove an attached behavior
  117094. * @see https://doc.babylonjs.com/features/behaviour
  117095. * @param behavior defines the behavior to attach
  117096. * @returns the current Node
  117097. */
  117098. removeBehavior(behavior: Behavior<Node>): Node;
  117099. /**
  117100. * Gets the list of attached behaviors
  117101. * @see https://doc.babylonjs.com/features/behaviour
  117102. */
  117103. get behaviors(): Behavior<Node>[];
  117104. /**
  117105. * Gets an attached behavior by name
  117106. * @param name defines the name of the behavior to look for
  117107. * @see https://doc.babylonjs.com/features/behaviour
  117108. * @returns null if behavior was not found else the requested behavior
  117109. */
  117110. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117111. /**
  117112. * Returns the latest update of the World matrix
  117113. * @returns a Matrix
  117114. */
  117115. getWorldMatrix(): Matrix;
  117116. /** @hidden */
  117117. _getWorldMatrixDeterminant(): number;
  117118. /**
  117119. * Returns directly the latest state of the mesh World matrix.
  117120. * A Matrix is returned.
  117121. */
  117122. get worldMatrixFromCache(): Matrix;
  117123. /** @hidden */
  117124. _initCache(): void;
  117125. /** @hidden */
  117126. updateCache(force?: boolean): void;
  117127. /** @hidden */
  117128. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117129. /** @hidden */
  117130. _updateCache(ignoreParentClass?: boolean): void;
  117131. /** @hidden */
  117132. _isSynchronized(): boolean;
  117133. /** @hidden */
  117134. _markSyncedWithParent(): void;
  117135. /** @hidden */
  117136. isSynchronizedWithParent(): boolean;
  117137. /** @hidden */
  117138. isSynchronized(): boolean;
  117139. /**
  117140. * Is this node ready to be used/rendered
  117141. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117142. * @return true if the node is ready
  117143. */
  117144. isReady(completeCheck?: boolean): boolean;
  117145. /**
  117146. * Is this node enabled?
  117147. * 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
  117148. * @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
  117149. * @return whether this node (and its parent) is enabled
  117150. */
  117151. isEnabled(checkAncestors?: boolean): boolean;
  117152. /** @hidden */
  117153. protected _syncParentEnabledState(): void;
  117154. /**
  117155. * Set the enabled state of this node
  117156. * @param value defines the new enabled state
  117157. */
  117158. setEnabled(value: boolean): void;
  117159. /**
  117160. * Is this node a descendant of the given node?
  117161. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117162. * @param ancestor defines the parent node to inspect
  117163. * @returns a boolean indicating if this node is a descendant of the given node
  117164. */
  117165. isDescendantOf(ancestor: Node): boolean;
  117166. /** @hidden */
  117167. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117168. /**
  117169. * Will return all nodes that have this node as ascendant
  117170. * @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
  117171. * @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
  117172. * @return all children nodes of all types
  117173. */
  117174. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117175. /**
  117176. * Get all child-meshes of this node
  117177. * @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)
  117178. * @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
  117179. * @returns an array of AbstractMesh
  117180. */
  117181. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117182. /**
  117183. * Get all direct children of this node
  117184. * @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
  117185. * @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)
  117186. * @returns an array of Node
  117187. */
  117188. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117189. /** @hidden */
  117190. _setReady(state: boolean): void;
  117191. /**
  117192. * Get an animation by name
  117193. * @param name defines the name of the animation to look for
  117194. * @returns null if not found else the requested animation
  117195. */
  117196. getAnimationByName(name: string): Nullable<Animation>;
  117197. /**
  117198. * Creates an animation range for this node
  117199. * @param name defines the name of the range
  117200. * @param from defines the starting key
  117201. * @param to defines the end key
  117202. */
  117203. createAnimationRange(name: string, from: number, to: number): void;
  117204. /**
  117205. * Delete a specific animation range
  117206. * @param name defines the name of the range to delete
  117207. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117208. */
  117209. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117210. /**
  117211. * Get an animation range by name
  117212. * @param name defines the name of the animation range to look for
  117213. * @returns null if not found else the requested animation range
  117214. */
  117215. getAnimationRange(name: string): Nullable<AnimationRange>;
  117216. /**
  117217. * Gets the list of all animation ranges defined on this node
  117218. * @returns an array
  117219. */
  117220. getAnimationRanges(): Nullable<AnimationRange>[];
  117221. /**
  117222. * Will start the animation sequence
  117223. * @param name defines the range frames for animation sequence
  117224. * @param loop defines if the animation should loop (false by default)
  117225. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117226. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117227. * @returns the object created for this animation. If range does not exist, it will return null
  117228. */
  117229. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117230. /**
  117231. * Serialize animation ranges into a JSON compatible object
  117232. * @returns serialization object
  117233. */
  117234. serializeAnimationRanges(): any;
  117235. /**
  117236. * Computes the world matrix of the node
  117237. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117238. * @returns the world matrix
  117239. */
  117240. computeWorldMatrix(force?: boolean): Matrix;
  117241. /**
  117242. * Releases resources associated with this node.
  117243. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117244. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117245. */
  117246. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117247. /**
  117248. * Parse animation range data from a serialization object and store them into a given node
  117249. * @param node defines where to store the animation ranges
  117250. * @param parsedNode defines the serialization object to read data from
  117251. * @param scene defines the hosting scene
  117252. */
  117253. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117254. /**
  117255. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117256. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117257. * @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
  117258. * @returns the new bounding vectors
  117259. */
  117260. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117261. min: Vector3;
  117262. max: Vector3;
  117263. };
  117264. }
  117265. }
  117266. declare module BABYLON {
  117267. /**
  117268. * @hidden
  117269. */
  117270. export class _IAnimationState {
  117271. key: number;
  117272. repeatCount: number;
  117273. workValue?: any;
  117274. loopMode?: number;
  117275. offsetValue?: any;
  117276. highLimitValue?: any;
  117277. }
  117278. /**
  117279. * Class used to store any kind of animation
  117280. */
  117281. export class Animation {
  117282. /**Name of the animation */
  117283. name: string;
  117284. /**Property to animate */
  117285. targetProperty: string;
  117286. /**The frames per second of the animation */
  117287. framePerSecond: number;
  117288. /**The data type of the animation */
  117289. dataType: number;
  117290. /**The loop mode of the animation */
  117291. loopMode?: number | undefined;
  117292. /**Specifies if blending should be enabled */
  117293. enableBlending?: boolean | undefined;
  117294. /**
  117295. * Use matrix interpolation instead of using direct key value when animating matrices
  117296. */
  117297. static AllowMatricesInterpolation: boolean;
  117298. /**
  117299. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117300. */
  117301. static AllowMatrixDecomposeForInterpolation: boolean;
  117302. /** Define the Url to load snippets */
  117303. static SnippetUrl: string;
  117304. /** Snippet ID if the animation was created from the snippet server */
  117305. snippetId: string;
  117306. /**
  117307. * Stores the key frames of the animation
  117308. */
  117309. private _keys;
  117310. /**
  117311. * Stores the easing function of the animation
  117312. */
  117313. private _easingFunction;
  117314. /**
  117315. * @hidden Internal use only
  117316. */
  117317. _runtimeAnimations: RuntimeAnimation[];
  117318. /**
  117319. * The set of event that will be linked to this animation
  117320. */
  117321. private _events;
  117322. /**
  117323. * Stores an array of target property paths
  117324. */
  117325. targetPropertyPath: string[];
  117326. /**
  117327. * Stores the blending speed of the animation
  117328. */
  117329. blendingSpeed: number;
  117330. /**
  117331. * Stores the animation ranges for the animation
  117332. */
  117333. private _ranges;
  117334. /**
  117335. * @hidden Internal use
  117336. */
  117337. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117338. /**
  117339. * Sets up an animation
  117340. * @param property The property to animate
  117341. * @param animationType The animation type to apply
  117342. * @param framePerSecond The frames per second of the animation
  117343. * @param easingFunction The easing function used in the animation
  117344. * @returns The created animation
  117345. */
  117346. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117347. /**
  117348. * Create and start an animation on a node
  117349. * @param name defines the name of the global animation that will be run on all nodes
  117350. * @param node defines the root node where the animation will take place
  117351. * @param targetProperty defines property to animate
  117352. * @param framePerSecond defines the number of frame per second yo use
  117353. * @param totalFrame defines the number of frames in total
  117354. * @param from defines the initial value
  117355. * @param to defines the final value
  117356. * @param loopMode defines which loop mode you want to use (off by default)
  117357. * @param easingFunction defines the easing function to use (linear by default)
  117358. * @param onAnimationEnd defines the callback to call when animation end
  117359. * @returns the animatable created for this animation
  117360. */
  117361. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117362. /**
  117363. * Create and start an animation on a node and its descendants
  117364. * @param name defines the name of the global animation that will be run on all nodes
  117365. * @param node defines the root node where the animation will take place
  117366. * @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
  117367. * @param targetProperty defines property to animate
  117368. * @param framePerSecond defines the number of frame per second to use
  117369. * @param totalFrame defines the number of frames in total
  117370. * @param from defines the initial value
  117371. * @param to defines the final value
  117372. * @param loopMode defines which loop mode you want to use (off by default)
  117373. * @param easingFunction defines the easing function to use (linear by default)
  117374. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117375. * @returns the list of animatables created for all nodes
  117376. * @example https://www.babylonjs-playground.com/#MH0VLI
  117377. */
  117378. 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[]>;
  117379. /**
  117380. * Creates a new animation, merges it with the existing animations and starts it
  117381. * @param name Name of the animation
  117382. * @param node Node which contains the scene that begins the animations
  117383. * @param targetProperty Specifies which property to animate
  117384. * @param framePerSecond The frames per second of the animation
  117385. * @param totalFrame The total number of frames
  117386. * @param from The frame at the beginning of the animation
  117387. * @param to The frame at the end of the animation
  117388. * @param loopMode Specifies the loop mode of the animation
  117389. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117390. * @param onAnimationEnd Callback to run once the animation is complete
  117391. * @returns Nullable animation
  117392. */
  117393. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117394. /**
  117395. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117396. * @param sourceAnimation defines the Animation containing keyframes to convert
  117397. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117398. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117399. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117400. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117401. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117402. */
  117403. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117404. /**
  117405. * Transition property of an host to the target Value
  117406. * @param property The property to transition
  117407. * @param targetValue The target Value of the property
  117408. * @param host The object where the property to animate belongs
  117409. * @param scene Scene used to run the animation
  117410. * @param frameRate Framerate (in frame/s) to use
  117411. * @param transition The transition type we want to use
  117412. * @param duration The duration of the animation, in milliseconds
  117413. * @param onAnimationEnd Callback trigger at the end of the animation
  117414. * @returns Nullable animation
  117415. */
  117416. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117417. /**
  117418. * Return the array of runtime animations currently using this animation
  117419. */
  117420. get runtimeAnimations(): RuntimeAnimation[];
  117421. /**
  117422. * Specifies if any of the runtime animations are currently running
  117423. */
  117424. get hasRunningRuntimeAnimations(): boolean;
  117425. /**
  117426. * Initializes the animation
  117427. * @param name Name of the animation
  117428. * @param targetProperty Property to animate
  117429. * @param framePerSecond The frames per second of the animation
  117430. * @param dataType The data type of the animation
  117431. * @param loopMode The loop mode of the animation
  117432. * @param enableBlending Specifies if blending should be enabled
  117433. */
  117434. constructor(
  117435. /**Name of the animation */
  117436. name: string,
  117437. /**Property to animate */
  117438. targetProperty: string,
  117439. /**The frames per second of the animation */
  117440. framePerSecond: number,
  117441. /**The data type of the animation */
  117442. dataType: number,
  117443. /**The loop mode of the animation */
  117444. loopMode?: number | undefined,
  117445. /**Specifies if blending should be enabled */
  117446. enableBlending?: boolean | undefined);
  117447. /**
  117448. * Converts the animation to a string
  117449. * @param fullDetails support for multiple levels of logging within scene loading
  117450. * @returns String form of the animation
  117451. */
  117452. toString(fullDetails?: boolean): string;
  117453. /**
  117454. * Add an event to this animation
  117455. * @param event Event to add
  117456. */
  117457. addEvent(event: AnimationEvent): void;
  117458. /**
  117459. * Remove all events found at the given frame
  117460. * @param frame The frame to remove events from
  117461. */
  117462. removeEvents(frame: number): void;
  117463. /**
  117464. * Retrieves all the events from the animation
  117465. * @returns Events from the animation
  117466. */
  117467. getEvents(): AnimationEvent[];
  117468. /**
  117469. * Creates an animation range
  117470. * @param name Name of the animation range
  117471. * @param from Starting frame of the animation range
  117472. * @param to Ending frame of the animation
  117473. */
  117474. createRange(name: string, from: number, to: number): void;
  117475. /**
  117476. * Deletes an animation range by name
  117477. * @param name Name of the animation range to delete
  117478. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117479. */
  117480. deleteRange(name: string, deleteFrames?: boolean): void;
  117481. /**
  117482. * Gets the animation range by name, or null if not defined
  117483. * @param name Name of the animation range
  117484. * @returns Nullable animation range
  117485. */
  117486. getRange(name: string): Nullable<AnimationRange>;
  117487. /**
  117488. * Gets the key frames from the animation
  117489. * @returns The key frames of the animation
  117490. */
  117491. getKeys(): Array<IAnimationKey>;
  117492. /**
  117493. * Gets the highest frame rate of the animation
  117494. * @returns Highest frame rate of the animation
  117495. */
  117496. getHighestFrame(): number;
  117497. /**
  117498. * Gets the easing function of the animation
  117499. * @returns Easing function of the animation
  117500. */
  117501. getEasingFunction(): IEasingFunction;
  117502. /**
  117503. * Sets the easing function of the animation
  117504. * @param easingFunction A custom mathematical formula for animation
  117505. */
  117506. setEasingFunction(easingFunction: EasingFunction): void;
  117507. /**
  117508. * Interpolates a scalar linearly
  117509. * @param startValue Start value of the animation curve
  117510. * @param endValue End value of the animation curve
  117511. * @param gradient Scalar amount to interpolate
  117512. * @returns Interpolated scalar value
  117513. */
  117514. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117515. /**
  117516. * Interpolates a scalar cubically
  117517. * @param startValue Start value of the animation curve
  117518. * @param outTangent End tangent of the animation
  117519. * @param endValue End value of the animation curve
  117520. * @param inTangent Start tangent of the animation curve
  117521. * @param gradient Scalar amount to interpolate
  117522. * @returns Interpolated scalar value
  117523. */
  117524. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117525. /**
  117526. * Interpolates a quaternion using a spherical linear interpolation
  117527. * @param startValue Start value of the animation curve
  117528. * @param endValue End value of the animation curve
  117529. * @param gradient Scalar amount to interpolate
  117530. * @returns Interpolated quaternion value
  117531. */
  117532. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117533. /**
  117534. * Interpolates a quaternion cubically
  117535. * @param startValue Start value of the animation curve
  117536. * @param outTangent End tangent of the animation curve
  117537. * @param endValue End value of the animation curve
  117538. * @param inTangent Start tangent of the animation curve
  117539. * @param gradient Scalar amount to interpolate
  117540. * @returns Interpolated quaternion value
  117541. */
  117542. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117543. /**
  117544. * Interpolates a Vector3 linearl
  117545. * @param startValue Start value of the animation curve
  117546. * @param endValue End value of the animation curve
  117547. * @param gradient Scalar amount to interpolate
  117548. * @returns Interpolated scalar value
  117549. */
  117550. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117551. /**
  117552. * Interpolates a Vector3 cubically
  117553. * @param startValue Start value of the animation curve
  117554. * @param outTangent End tangent of the animation
  117555. * @param endValue End value of the animation curve
  117556. * @param inTangent Start tangent of the animation curve
  117557. * @param gradient Scalar amount to interpolate
  117558. * @returns InterpolatedVector3 value
  117559. */
  117560. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117561. /**
  117562. * Interpolates a Vector2 linearly
  117563. * @param startValue Start value of the animation curve
  117564. * @param endValue End value of the animation curve
  117565. * @param gradient Scalar amount to interpolate
  117566. * @returns Interpolated Vector2 value
  117567. */
  117568. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117569. /**
  117570. * Interpolates a Vector2 cubically
  117571. * @param startValue Start value of the animation curve
  117572. * @param outTangent End tangent of the animation
  117573. * @param endValue End value of the animation curve
  117574. * @param inTangent Start tangent of the animation curve
  117575. * @param gradient Scalar amount to interpolate
  117576. * @returns Interpolated Vector2 value
  117577. */
  117578. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117579. /**
  117580. * Interpolates a size linearly
  117581. * @param startValue Start value of the animation curve
  117582. * @param endValue End value of the animation curve
  117583. * @param gradient Scalar amount to interpolate
  117584. * @returns Interpolated Size value
  117585. */
  117586. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117587. /**
  117588. * Interpolates a Color3 linearly
  117589. * @param startValue Start value of the animation curve
  117590. * @param endValue End value of the animation curve
  117591. * @param gradient Scalar amount to interpolate
  117592. * @returns Interpolated Color3 value
  117593. */
  117594. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117595. /**
  117596. * Interpolates a Color4 linearly
  117597. * @param startValue Start value of the animation curve
  117598. * @param endValue End value of the animation curve
  117599. * @param gradient Scalar amount to interpolate
  117600. * @returns Interpolated Color3 value
  117601. */
  117602. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117603. /**
  117604. * @hidden Internal use only
  117605. */
  117606. _getKeyValue(value: any): any;
  117607. /**
  117608. * @hidden Internal use only
  117609. */
  117610. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117611. /**
  117612. * Defines the function to use to interpolate matrices
  117613. * @param startValue defines the start matrix
  117614. * @param endValue defines the end matrix
  117615. * @param gradient defines the gradient between both matrices
  117616. * @param result defines an optional target matrix where to store the interpolation
  117617. * @returns the interpolated matrix
  117618. */
  117619. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117620. /**
  117621. * Makes a copy of the animation
  117622. * @returns Cloned animation
  117623. */
  117624. clone(): Animation;
  117625. /**
  117626. * Sets the key frames of the animation
  117627. * @param values The animation key frames to set
  117628. */
  117629. setKeys(values: Array<IAnimationKey>): void;
  117630. /**
  117631. * Serializes the animation to an object
  117632. * @returns Serialized object
  117633. */
  117634. serialize(): any;
  117635. /**
  117636. * Float animation type
  117637. */
  117638. static readonly ANIMATIONTYPE_FLOAT: number;
  117639. /**
  117640. * Vector3 animation type
  117641. */
  117642. static readonly ANIMATIONTYPE_VECTOR3: number;
  117643. /**
  117644. * Quaternion animation type
  117645. */
  117646. static readonly ANIMATIONTYPE_QUATERNION: number;
  117647. /**
  117648. * Matrix animation type
  117649. */
  117650. static readonly ANIMATIONTYPE_MATRIX: number;
  117651. /**
  117652. * Color3 animation type
  117653. */
  117654. static readonly ANIMATIONTYPE_COLOR3: number;
  117655. /**
  117656. * Color3 animation type
  117657. */
  117658. static readonly ANIMATIONTYPE_COLOR4: number;
  117659. /**
  117660. * Vector2 animation type
  117661. */
  117662. static readonly ANIMATIONTYPE_VECTOR2: number;
  117663. /**
  117664. * Size animation type
  117665. */
  117666. static readonly ANIMATIONTYPE_SIZE: number;
  117667. /**
  117668. * Relative Loop Mode
  117669. */
  117670. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117671. /**
  117672. * Cycle Loop Mode
  117673. */
  117674. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117675. /**
  117676. * Constant Loop Mode
  117677. */
  117678. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117679. /** @hidden */
  117680. static _UniversalLerp(left: any, right: any, amount: number): any;
  117681. /**
  117682. * Parses an animation object and creates an animation
  117683. * @param parsedAnimation Parsed animation object
  117684. * @returns Animation object
  117685. */
  117686. static Parse(parsedAnimation: any): Animation;
  117687. /**
  117688. * Appends the serialized animations from the source animations
  117689. * @param source Source containing the animations
  117690. * @param destination Target to store the animations
  117691. */
  117692. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117693. /**
  117694. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117695. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117696. * @param url defines the url to load from
  117697. * @returns a promise that will resolve to the new animation or an array of animations
  117698. */
  117699. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117700. /**
  117701. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117702. * @param snippetId defines the snippet to load
  117703. * @returns a promise that will resolve to the new animation or a new array of animations
  117704. */
  117705. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117706. }
  117707. }
  117708. declare module BABYLON {
  117709. /**
  117710. * Interface containing an array of animations
  117711. */
  117712. export interface IAnimatable {
  117713. /**
  117714. * Array of animations
  117715. */
  117716. animations: Nullable<Array<Animation>>;
  117717. }
  117718. }
  117719. declare module BABYLON {
  117720. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117721. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117722. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117723. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117724. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117725. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117726. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117727. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117728. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117729. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117730. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117731. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117732. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117733. /**
  117734. * Decorator used to define property that can be serialized as reference to a camera
  117735. * @param sourceName defines the name of the property to decorate
  117736. */
  117737. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117738. /**
  117739. * Class used to help serialization objects
  117740. */
  117741. export class SerializationHelper {
  117742. /** @hidden */
  117743. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117744. /** @hidden */
  117745. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117746. /** @hidden */
  117747. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117748. /** @hidden */
  117749. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117750. /**
  117751. * Appends the serialized animations from the source animations
  117752. * @param source Source containing the animations
  117753. * @param destination Target to store the animations
  117754. */
  117755. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117756. /**
  117757. * Static function used to serialized a specific entity
  117758. * @param entity defines the entity to serialize
  117759. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117760. * @returns a JSON compatible object representing the serialization of the entity
  117761. */
  117762. static Serialize<T>(entity: T, serializationObject?: any): any;
  117763. /**
  117764. * Creates a new entity from a serialization data object
  117765. * @param creationFunction defines a function used to instanciated the new entity
  117766. * @param source defines the source serialization data
  117767. * @param scene defines the hosting scene
  117768. * @param rootUrl defines the root url for resources
  117769. * @returns a new entity
  117770. */
  117771. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117772. /**
  117773. * Clones an object
  117774. * @param creationFunction defines the function used to instanciate the new object
  117775. * @param source defines the source object
  117776. * @returns the cloned object
  117777. */
  117778. static Clone<T>(creationFunction: () => T, source: T): T;
  117779. /**
  117780. * Instanciates a new object based on a source one (some data will be shared between both object)
  117781. * @param creationFunction defines the function used to instanciate the new object
  117782. * @param source defines the source object
  117783. * @returns the new object
  117784. */
  117785. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117786. }
  117787. }
  117788. declare module BABYLON {
  117789. /**
  117790. * Base class of all the textures in babylon.
  117791. * It groups all the common properties the materials, post process, lights... might need
  117792. * in order to make a correct use of the texture.
  117793. */
  117794. export class BaseTexture implements IAnimatable {
  117795. /**
  117796. * Default anisotropic filtering level for the application.
  117797. * It is set to 4 as a good tradeoff between perf and quality.
  117798. */
  117799. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117800. /**
  117801. * Gets or sets the unique id of the texture
  117802. */
  117803. uniqueId: number;
  117804. /**
  117805. * Define the name of the texture.
  117806. */
  117807. name: string;
  117808. /**
  117809. * Gets or sets an object used to store user defined information.
  117810. */
  117811. metadata: any;
  117812. /**
  117813. * For internal use only. Please do not use.
  117814. */
  117815. reservedDataStore: any;
  117816. private _hasAlpha;
  117817. /**
  117818. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117819. */
  117820. set hasAlpha(value: boolean);
  117821. get hasAlpha(): boolean;
  117822. /**
  117823. * Defines if the alpha value should be determined via the rgb values.
  117824. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117825. */
  117826. getAlphaFromRGB: boolean;
  117827. /**
  117828. * Intensity or strength of the texture.
  117829. * It is commonly used by materials to fine tune the intensity of the texture
  117830. */
  117831. level: number;
  117832. /**
  117833. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117834. * This is part of the texture as textures usually maps to one uv set.
  117835. */
  117836. coordinatesIndex: number;
  117837. protected _coordinatesMode: number;
  117838. /**
  117839. * How a texture is mapped.
  117840. *
  117841. * | Value | Type | Description |
  117842. * | ----- | ----------------------------------- | ----------- |
  117843. * | 0 | EXPLICIT_MODE | |
  117844. * | 1 | SPHERICAL_MODE | |
  117845. * | 2 | PLANAR_MODE | |
  117846. * | 3 | CUBIC_MODE | |
  117847. * | 4 | PROJECTION_MODE | |
  117848. * | 5 | SKYBOX_MODE | |
  117849. * | 6 | INVCUBIC_MODE | |
  117850. * | 7 | EQUIRECTANGULAR_MODE | |
  117851. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117852. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117853. */
  117854. set coordinatesMode(value: number);
  117855. get coordinatesMode(): number;
  117856. private _wrapU;
  117857. /**
  117858. * | Value | Type | Description |
  117859. * | ----- | ------------------ | ----------- |
  117860. * | 0 | CLAMP_ADDRESSMODE | |
  117861. * | 1 | WRAP_ADDRESSMODE | |
  117862. * | 2 | MIRROR_ADDRESSMODE | |
  117863. */
  117864. get wrapU(): number;
  117865. set wrapU(value: number);
  117866. private _wrapV;
  117867. /**
  117868. * | Value | Type | Description |
  117869. * | ----- | ------------------ | ----------- |
  117870. * | 0 | CLAMP_ADDRESSMODE | |
  117871. * | 1 | WRAP_ADDRESSMODE | |
  117872. * | 2 | MIRROR_ADDRESSMODE | |
  117873. */
  117874. get wrapV(): number;
  117875. set wrapV(value: number);
  117876. /**
  117877. * | Value | Type | Description |
  117878. * | ----- | ------------------ | ----------- |
  117879. * | 0 | CLAMP_ADDRESSMODE | |
  117880. * | 1 | WRAP_ADDRESSMODE | |
  117881. * | 2 | MIRROR_ADDRESSMODE | |
  117882. */
  117883. wrapR: number;
  117884. /**
  117885. * With compliant hardware and browser (supporting anisotropic filtering)
  117886. * this defines the level of anisotropic filtering in the texture.
  117887. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117888. */
  117889. anisotropicFilteringLevel: number;
  117890. /**
  117891. * Define if the texture is a cube texture or if false a 2d texture.
  117892. */
  117893. get isCube(): boolean;
  117894. set isCube(value: boolean);
  117895. /**
  117896. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117897. */
  117898. get is3D(): boolean;
  117899. set is3D(value: boolean);
  117900. /**
  117901. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117902. */
  117903. get is2DArray(): boolean;
  117904. set is2DArray(value: boolean);
  117905. private _gammaSpace;
  117906. /**
  117907. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117908. * HDR texture are usually stored in linear space.
  117909. * This only impacts the PBR and Background materials
  117910. */
  117911. get gammaSpace(): boolean;
  117912. set gammaSpace(gamma: boolean);
  117913. /**
  117914. * Gets or sets whether or not the texture contains RGBD data.
  117915. */
  117916. get isRGBD(): boolean;
  117917. set isRGBD(value: boolean);
  117918. /**
  117919. * Is Z inverted in the texture (useful in a cube texture).
  117920. */
  117921. invertZ: boolean;
  117922. /**
  117923. * Are mip maps generated for this texture or not.
  117924. */
  117925. get noMipmap(): boolean;
  117926. /**
  117927. * @hidden
  117928. */
  117929. lodLevelInAlpha: boolean;
  117930. /**
  117931. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117932. */
  117933. get lodGenerationOffset(): number;
  117934. set lodGenerationOffset(value: number);
  117935. /**
  117936. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117937. */
  117938. get lodGenerationScale(): number;
  117939. set lodGenerationScale(value: number);
  117940. /**
  117941. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117942. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117943. * average roughness values.
  117944. */
  117945. get linearSpecularLOD(): boolean;
  117946. set linearSpecularLOD(value: boolean);
  117947. /**
  117948. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117949. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117950. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117951. */
  117952. get irradianceTexture(): Nullable<BaseTexture>;
  117953. set irradianceTexture(value: Nullable<BaseTexture>);
  117954. /**
  117955. * Define if the texture is a render target.
  117956. */
  117957. isRenderTarget: boolean;
  117958. /**
  117959. * Define the unique id of the texture in the scene.
  117960. */
  117961. get uid(): string;
  117962. /** @hidden */
  117963. _prefiltered: boolean;
  117964. /**
  117965. * Return a string representation of the texture.
  117966. * @returns the texture as a string
  117967. */
  117968. toString(): string;
  117969. /**
  117970. * Get the class name of the texture.
  117971. * @returns "BaseTexture"
  117972. */
  117973. getClassName(): string;
  117974. /**
  117975. * Define the list of animation attached to the texture.
  117976. */
  117977. animations: Animation[];
  117978. /**
  117979. * An event triggered when the texture is disposed.
  117980. */
  117981. onDisposeObservable: Observable<BaseTexture>;
  117982. private _onDisposeObserver;
  117983. /**
  117984. * Callback triggered when the texture has been disposed.
  117985. * Kept for back compatibility, you can use the onDisposeObservable instead.
  117986. */
  117987. set onDispose(callback: () => void);
  117988. /**
  117989. * Define the current state of the loading sequence when in delayed load mode.
  117990. */
  117991. delayLoadState: number;
  117992. protected _scene: Nullable<Scene>;
  117993. protected _engine: Nullable<ThinEngine>;
  117994. /** @hidden */
  117995. _texture: Nullable<InternalTexture>;
  117996. private _uid;
  117997. /**
  117998. * Define if the texture is preventinga material to render or not.
  117999. * If not and the texture is not ready, the engine will use a default black texture instead.
  118000. */
  118001. get isBlocking(): boolean;
  118002. /**
  118003. * Instantiates a new BaseTexture.
  118004. * Base class of all the textures in babylon.
  118005. * It groups all the common properties the materials, post process, lights... might need
  118006. * in order to make a correct use of the texture.
  118007. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118008. */
  118009. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118010. /**
  118011. * Get the scene the texture belongs to.
  118012. * @returns the scene or null if undefined
  118013. */
  118014. getScene(): Nullable<Scene>;
  118015. /** @hidden */
  118016. protected _getEngine(): Nullable<ThinEngine>;
  118017. /**
  118018. * Checks if the texture has the same transform matrix than another texture
  118019. * @param texture texture to check against
  118020. * @returns true if the transforms are the same, else false
  118021. */
  118022. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118023. /**
  118024. * Get the texture transform matrix used to offset tile the texture for istance.
  118025. * @returns the transformation matrix
  118026. */
  118027. getTextureMatrix(): Matrix;
  118028. /**
  118029. * Get the texture reflection matrix used to rotate/transform the reflection.
  118030. * @returns the reflection matrix
  118031. */
  118032. getReflectionTextureMatrix(): Matrix;
  118033. /**
  118034. * Get the underlying lower level texture from Babylon.
  118035. * @returns the insternal texture
  118036. */
  118037. getInternalTexture(): Nullable<InternalTexture>;
  118038. /**
  118039. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118040. * @returns true if ready or not blocking
  118041. */
  118042. isReadyOrNotBlocking(): boolean;
  118043. /**
  118044. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118045. * @returns true if fully ready
  118046. */
  118047. isReady(): boolean;
  118048. private _cachedSize;
  118049. /**
  118050. * Get the size of the texture.
  118051. * @returns the texture size.
  118052. */
  118053. getSize(): ISize;
  118054. /**
  118055. * Get the base size of the texture.
  118056. * It can be different from the size if the texture has been resized for POT for instance
  118057. * @returns the base size
  118058. */
  118059. getBaseSize(): ISize;
  118060. /**
  118061. * Update the sampling mode of the texture.
  118062. * Default is Trilinear mode.
  118063. *
  118064. * | Value | Type | Description |
  118065. * | ----- | ------------------ | ----------- |
  118066. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118067. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118068. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118069. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118070. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118071. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118072. * | 7 | NEAREST_LINEAR | |
  118073. * | 8 | NEAREST_NEAREST | |
  118074. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118075. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118076. * | 11 | LINEAR_LINEAR | |
  118077. * | 12 | LINEAR_NEAREST | |
  118078. *
  118079. * > _mag_: magnification filter (close to the viewer)
  118080. * > _min_: minification filter (far from the viewer)
  118081. * > _mip_: filter used between mip map levels
  118082. *@param samplingMode Define the new sampling mode of the texture
  118083. */
  118084. updateSamplingMode(samplingMode: number): void;
  118085. /**
  118086. * Scales the texture if is `canRescale()`
  118087. * @param ratio the resize factor we want to use to rescale
  118088. */
  118089. scale(ratio: number): void;
  118090. /**
  118091. * Get if the texture can rescale.
  118092. */
  118093. get canRescale(): boolean;
  118094. /** @hidden */
  118095. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118096. /** @hidden */
  118097. _rebuild(): void;
  118098. /**
  118099. * Triggers the load sequence in delayed load mode.
  118100. */
  118101. delayLoad(): void;
  118102. /**
  118103. * Clones the texture.
  118104. * @returns the cloned texture
  118105. */
  118106. clone(): Nullable<BaseTexture>;
  118107. /**
  118108. * Get the texture underlying type (INT, FLOAT...)
  118109. */
  118110. get textureType(): number;
  118111. /**
  118112. * Get the texture underlying format (RGB, RGBA...)
  118113. */
  118114. get textureFormat(): number;
  118115. /**
  118116. * Indicates that textures need to be re-calculated for all materials
  118117. */
  118118. protected _markAllSubMeshesAsTexturesDirty(): void;
  118119. /**
  118120. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118121. * This will returns an RGBA array buffer containing either in values (0-255) or
  118122. * float values (0-1) depending of the underlying buffer type.
  118123. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118124. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118125. * @param buffer defines a user defined buffer to fill with data (can be null)
  118126. * @returns The Array buffer containing the pixels data.
  118127. */
  118128. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118129. /**
  118130. * Release and destroy the underlying lower level texture aka internalTexture.
  118131. */
  118132. releaseInternalTexture(): void;
  118133. /** @hidden */
  118134. get _lodTextureHigh(): Nullable<BaseTexture>;
  118135. /** @hidden */
  118136. get _lodTextureMid(): Nullable<BaseTexture>;
  118137. /** @hidden */
  118138. get _lodTextureLow(): Nullable<BaseTexture>;
  118139. /**
  118140. * Dispose the texture and release its associated resources.
  118141. */
  118142. dispose(): void;
  118143. /**
  118144. * Serialize the texture into a JSON representation that can be parsed later on.
  118145. * @returns the JSON representation of the texture
  118146. */
  118147. serialize(): any;
  118148. /**
  118149. * Helper function to be called back once a list of texture contains only ready textures.
  118150. * @param textures Define the list of textures to wait for
  118151. * @param callback Define the callback triggered once the entire list will be ready
  118152. */
  118153. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118154. private static _isScene;
  118155. }
  118156. }
  118157. declare module BABYLON {
  118158. /**
  118159. * Options to be used when creating an effect.
  118160. */
  118161. export interface IEffectCreationOptions {
  118162. /**
  118163. * Atrributes that will be used in the shader.
  118164. */
  118165. attributes: string[];
  118166. /**
  118167. * Uniform varible names that will be set in the shader.
  118168. */
  118169. uniformsNames: string[];
  118170. /**
  118171. * Uniform buffer variable names that will be set in the shader.
  118172. */
  118173. uniformBuffersNames: string[];
  118174. /**
  118175. * Sampler texture variable names that will be set in the shader.
  118176. */
  118177. samplers: string[];
  118178. /**
  118179. * Define statements that will be set in the shader.
  118180. */
  118181. defines: any;
  118182. /**
  118183. * Possible fallbacks for this effect to improve performance when needed.
  118184. */
  118185. fallbacks: Nullable<IEffectFallbacks>;
  118186. /**
  118187. * Callback that will be called when the shader is compiled.
  118188. */
  118189. onCompiled: Nullable<(effect: Effect) => void>;
  118190. /**
  118191. * Callback that will be called if an error occurs during shader compilation.
  118192. */
  118193. onError: Nullable<(effect: Effect, errors: string) => void>;
  118194. /**
  118195. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118196. */
  118197. indexParameters?: any;
  118198. /**
  118199. * Max number of lights that can be used in the shader.
  118200. */
  118201. maxSimultaneousLights?: number;
  118202. /**
  118203. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118204. */
  118205. transformFeedbackVaryings?: Nullable<string[]>;
  118206. /**
  118207. * 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
  118208. */
  118209. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118210. /**
  118211. * Is this effect rendering to several color attachments ?
  118212. */
  118213. multiTarget?: boolean;
  118214. }
  118215. /**
  118216. * Effect containing vertex and fragment shader that can be executed on an object.
  118217. */
  118218. export class Effect implements IDisposable {
  118219. /**
  118220. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118221. */
  118222. static ShadersRepository: string;
  118223. /**
  118224. * Enable logging of the shader code when a compilation error occurs
  118225. */
  118226. static LogShaderCodeOnCompilationError: boolean;
  118227. /**
  118228. * Name of the effect.
  118229. */
  118230. name: any;
  118231. /**
  118232. * String container all the define statements that should be set on the shader.
  118233. */
  118234. defines: string;
  118235. /**
  118236. * Callback that will be called when the shader is compiled.
  118237. */
  118238. onCompiled: Nullable<(effect: Effect) => void>;
  118239. /**
  118240. * Callback that will be called if an error occurs during shader compilation.
  118241. */
  118242. onError: Nullable<(effect: Effect, errors: string) => void>;
  118243. /**
  118244. * Callback that will be called when effect is bound.
  118245. */
  118246. onBind: Nullable<(effect: Effect) => void>;
  118247. /**
  118248. * Unique ID of the effect.
  118249. */
  118250. uniqueId: number;
  118251. /**
  118252. * Observable that will be called when the shader is compiled.
  118253. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118254. */
  118255. onCompileObservable: Observable<Effect>;
  118256. /**
  118257. * Observable that will be called if an error occurs during shader compilation.
  118258. */
  118259. onErrorObservable: Observable<Effect>;
  118260. /** @hidden */
  118261. _onBindObservable: Nullable<Observable<Effect>>;
  118262. /**
  118263. * @hidden
  118264. * Specifies if the effect was previously ready
  118265. */
  118266. _wasPreviouslyReady: boolean;
  118267. /**
  118268. * Observable that will be called when effect is bound.
  118269. */
  118270. get onBindObservable(): Observable<Effect>;
  118271. /** @hidden */
  118272. _bonesComputationForcedToCPU: boolean;
  118273. /** @hidden */
  118274. _multiTarget: boolean;
  118275. private static _uniqueIdSeed;
  118276. private _engine;
  118277. private _uniformBuffersNames;
  118278. private _uniformBuffersNamesList;
  118279. private _uniformsNames;
  118280. private _samplerList;
  118281. private _samplers;
  118282. private _isReady;
  118283. private _compilationError;
  118284. private _allFallbacksProcessed;
  118285. private _attributesNames;
  118286. private _attributes;
  118287. private _attributeLocationByName;
  118288. private _uniforms;
  118289. /**
  118290. * Key for the effect.
  118291. * @hidden
  118292. */
  118293. _key: string;
  118294. private _indexParameters;
  118295. private _fallbacks;
  118296. private _vertexSourceCode;
  118297. private _fragmentSourceCode;
  118298. private _vertexSourceCodeOverride;
  118299. private _fragmentSourceCodeOverride;
  118300. private _transformFeedbackVaryings;
  118301. /**
  118302. * Compiled shader to webGL program.
  118303. * @hidden
  118304. */
  118305. _pipelineContext: Nullable<IPipelineContext>;
  118306. private _valueCache;
  118307. private static _baseCache;
  118308. /**
  118309. * Instantiates an effect.
  118310. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118311. * @param baseName Name of the effect.
  118312. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118313. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118314. * @param samplers List of sampler variables that will be passed to the shader.
  118315. * @param engine Engine to be used to render the effect
  118316. * @param defines Define statements to be added to the shader.
  118317. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118318. * @param onCompiled Callback that will be called when the shader is compiled.
  118319. * @param onError Callback that will be called if an error occurs during shader compilation.
  118320. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118321. */
  118322. 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);
  118323. private _useFinalCode;
  118324. /**
  118325. * Unique key for this effect
  118326. */
  118327. get key(): string;
  118328. /**
  118329. * If the effect has been compiled and prepared.
  118330. * @returns if the effect is compiled and prepared.
  118331. */
  118332. isReady(): boolean;
  118333. private _isReadyInternal;
  118334. /**
  118335. * The engine the effect was initialized with.
  118336. * @returns the engine.
  118337. */
  118338. getEngine(): Engine;
  118339. /**
  118340. * The pipeline context for this effect
  118341. * @returns the associated pipeline context
  118342. */
  118343. getPipelineContext(): Nullable<IPipelineContext>;
  118344. /**
  118345. * The set of names of attribute variables for the shader.
  118346. * @returns An array of attribute names.
  118347. */
  118348. getAttributesNames(): string[];
  118349. /**
  118350. * Returns the attribute at the given index.
  118351. * @param index The index of the attribute.
  118352. * @returns The location of the attribute.
  118353. */
  118354. getAttributeLocation(index: number): number;
  118355. /**
  118356. * Returns the attribute based on the name of the variable.
  118357. * @param name of the attribute to look up.
  118358. * @returns the attribute location.
  118359. */
  118360. getAttributeLocationByName(name: string): number;
  118361. /**
  118362. * The number of attributes.
  118363. * @returns the numnber of attributes.
  118364. */
  118365. getAttributesCount(): number;
  118366. /**
  118367. * Gets the index of a uniform variable.
  118368. * @param uniformName of the uniform to look up.
  118369. * @returns the index.
  118370. */
  118371. getUniformIndex(uniformName: string): number;
  118372. /**
  118373. * Returns the attribute based on the name of the variable.
  118374. * @param uniformName of the uniform to look up.
  118375. * @returns the location of the uniform.
  118376. */
  118377. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118378. /**
  118379. * Returns an array of sampler variable names
  118380. * @returns The array of sampler variable names.
  118381. */
  118382. getSamplers(): string[];
  118383. /**
  118384. * Returns an array of uniform variable names
  118385. * @returns The array of uniform variable names.
  118386. */
  118387. getUniformNames(): string[];
  118388. /**
  118389. * Returns an array of uniform buffer variable names
  118390. * @returns The array of uniform buffer variable names.
  118391. */
  118392. getUniformBuffersNames(): string[];
  118393. /**
  118394. * Returns the index parameters used to create the effect
  118395. * @returns The index parameters object
  118396. */
  118397. getIndexParameters(): any;
  118398. /**
  118399. * The error from the last compilation.
  118400. * @returns the error string.
  118401. */
  118402. getCompilationError(): string;
  118403. /**
  118404. * Gets a boolean indicating that all fallbacks were used during compilation
  118405. * @returns true if all fallbacks were used
  118406. */
  118407. allFallbacksProcessed(): boolean;
  118408. /**
  118409. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118410. * @param func The callback to be used.
  118411. */
  118412. executeWhenCompiled(func: (effect: Effect) => void): void;
  118413. private _checkIsReady;
  118414. private _loadShader;
  118415. /**
  118416. * Gets the vertex shader source code of this effect
  118417. */
  118418. get vertexSourceCode(): string;
  118419. /**
  118420. * Gets the fragment shader source code of this effect
  118421. */
  118422. get fragmentSourceCode(): string;
  118423. /**
  118424. * Recompiles the webGL program
  118425. * @param vertexSourceCode The source code for the vertex shader.
  118426. * @param fragmentSourceCode The source code for the fragment shader.
  118427. * @param onCompiled Callback called when completed.
  118428. * @param onError Callback called on error.
  118429. * @hidden
  118430. */
  118431. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118432. /**
  118433. * Prepares the effect
  118434. * @hidden
  118435. */
  118436. _prepareEffect(): void;
  118437. private _getShaderCodeAndErrorLine;
  118438. private _processCompilationErrors;
  118439. /**
  118440. * Checks if the effect is supported. (Must be called after compilation)
  118441. */
  118442. get isSupported(): boolean;
  118443. /**
  118444. * Binds a texture to the engine to be used as output of the shader.
  118445. * @param channel Name of the output variable.
  118446. * @param texture Texture to bind.
  118447. * @hidden
  118448. */
  118449. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118450. /**
  118451. * Sets a texture on the engine to be used in the shader.
  118452. * @param channel Name of the sampler variable.
  118453. * @param texture Texture to set.
  118454. */
  118455. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118456. /**
  118457. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118458. * @param channel Name of the sampler variable.
  118459. * @param texture Texture to set.
  118460. */
  118461. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118462. /**
  118463. * Sets an array of textures on the engine to be used in the shader.
  118464. * @param channel Name of the variable.
  118465. * @param textures Textures to set.
  118466. */
  118467. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118468. /**
  118469. * 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)
  118470. * @param channel Name of the sampler variable.
  118471. * @param postProcess Post process to get the input texture from.
  118472. */
  118473. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118474. /**
  118475. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118476. * 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)
  118477. * @param channel Name of the sampler variable.
  118478. * @param postProcess Post process to get the output texture from.
  118479. */
  118480. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118481. /** @hidden */
  118482. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118483. /** @hidden */
  118484. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118485. /** @hidden */
  118486. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118487. /** @hidden */
  118488. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118489. /**
  118490. * Binds a buffer to a uniform.
  118491. * @param buffer Buffer to bind.
  118492. * @param name Name of the uniform variable to bind to.
  118493. */
  118494. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118495. /**
  118496. * Binds block to a uniform.
  118497. * @param blockName Name of the block to bind.
  118498. * @param index Index to bind.
  118499. */
  118500. bindUniformBlock(blockName: string, index: number): void;
  118501. /**
  118502. * Sets an interger value on a uniform variable.
  118503. * @param uniformName Name of the variable.
  118504. * @param value Value to be set.
  118505. * @returns this effect.
  118506. */
  118507. setInt(uniformName: string, value: number): Effect;
  118508. /**
  118509. * Sets an int array on a uniform variable.
  118510. * @param uniformName Name of the variable.
  118511. * @param array array to be set.
  118512. * @returns this effect.
  118513. */
  118514. setIntArray(uniformName: string, array: Int32Array): Effect;
  118515. /**
  118516. * 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)
  118517. * @param uniformName Name of the variable.
  118518. * @param array array to be set.
  118519. * @returns this effect.
  118520. */
  118521. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118522. /**
  118523. * 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)
  118524. * @param uniformName Name of the variable.
  118525. * @param array array to be set.
  118526. * @returns this effect.
  118527. */
  118528. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118529. /**
  118530. * 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)
  118531. * @param uniformName Name of the variable.
  118532. * @param array array to be set.
  118533. * @returns this effect.
  118534. */
  118535. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118536. /**
  118537. * Sets an float array on a uniform variable.
  118538. * @param uniformName Name of the variable.
  118539. * @param array array to be set.
  118540. * @returns this effect.
  118541. */
  118542. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118543. /**
  118544. * 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)
  118545. * @param uniformName Name of the variable.
  118546. * @param array array to be set.
  118547. * @returns this effect.
  118548. */
  118549. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118550. /**
  118551. * 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)
  118552. * @param uniformName Name of the variable.
  118553. * @param array array to be set.
  118554. * @returns this effect.
  118555. */
  118556. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118557. /**
  118558. * 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)
  118559. * @param uniformName Name of the variable.
  118560. * @param array array to be set.
  118561. * @returns this effect.
  118562. */
  118563. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118564. /**
  118565. * Sets an array on a uniform variable.
  118566. * @param uniformName Name of the variable.
  118567. * @param array array to be set.
  118568. * @returns this effect.
  118569. */
  118570. setArray(uniformName: string, array: number[]): Effect;
  118571. /**
  118572. * 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)
  118573. * @param uniformName Name of the variable.
  118574. * @param array array to be set.
  118575. * @returns this effect.
  118576. */
  118577. setArray2(uniformName: string, array: number[]): Effect;
  118578. /**
  118579. * 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)
  118580. * @param uniformName Name of the variable.
  118581. * @param array array to be set.
  118582. * @returns this effect.
  118583. */
  118584. setArray3(uniformName: string, array: number[]): Effect;
  118585. /**
  118586. * 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)
  118587. * @param uniformName Name of the variable.
  118588. * @param array array to be set.
  118589. * @returns this effect.
  118590. */
  118591. setArray4(uniformName: string, array: number[]): Effect;
  118592. /**
  118593. * Sets matrices on a uniform variable.
  118594. * @param uniformName Name of the variable.
  118595. * @param matrices matrices to be set.
  118596. * @returns this effect.
  118597. */
  118598. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118599. /**
  118600. * Sets matrix on a uniform variable.
  118601. * @param uniformName Name of the variable.
  118602. * @param matrix matrix to be set.
  118603. * @returns this effect.
  118604. */
  118605. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118606. /**
  118607. * 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)
  118608. * @param uniformName Name of the variable.
  118609. * @param matrix matrix to be set.
  118610. * @returns this effect.
  118611. */
  118612. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118613. /**
  118614. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118615. * @param uniformName Name of the variable.
  118616. * @param matrix matrix to be set.
  118617. * @returns this effect.
  118618. */
  118619. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118620. /**
  118621. * Sets a float on a uniform variable.
  118622. * @param uniformName Name of the variable.
  118623. * @param value value to be set.
  118624. * @returns this effect.
  118625. */
  118626. setFloat(uniformName: string, value: number): Effect;
  118627. /**
  118628. * Sets a boolean on a uniform variable.
  118629. * @param uniformName Name of the variable.
  118630. * @param bool value to be set.
  118631. * @returns this effect.
  118632. */
  118633. setBool(uniformName: string, bool: boolean): Effect;
  118634. /**
  118635. * Sets a Vector2 on a uniform variable.
  118636. * @param uniformName Name of the variable.
  118637. * @param vector2 vector2 to be set.
  118638. * @returns this effect.
  118639. */
  118640. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118641. /**
  118642. * Sets a float2 on a uniform variable.
  118643. * @param uniformName Name of the variable.
  118644. * @param x First float in float2.
  118645. * @param y Second float in float2.
  118646. * @returns this effect.
  118647. */
  118648. setFloat2(uniformName: string, x: number, y: number): Effect;
  118649. /**
  118650. * Sets a Vector3 on a uniform variable.
  118651. * @param uniformName Name of the variable.
  118652. * @param vector3 Value to be set.
  118653. * @returns this effect.
  118654. */
  118655. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118656. /**
  118657. * Sets a float3 on a uniform variable.
  118658. * @param uniformName Name of the variable.
  118659. * @param x First float in float3.
  118660. * @param y Second float in float3.
  118661. * @param z Third float in float3.
  118662. * @returns this effect.
  118663. */
  118664. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118665. /**
  118666. * Sets a Vector4 on a uniform variable.
  118667. * @param uniformName Name of the variable.
  118668. * @param vector4 Value to be set.
  118669. * @returns this effect.
  118670. */
  118671. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118672. /**
  118673. * Sets a float4 on a uniform variable.
  118674. * @param uniformName Name of the variable.
  118675. * @param x First float in float4.
  118676. * @param y Second float in float4.
  118677. * @param z Third float in float4.
  118678. * @param w Fourth float in float4.
  118679. * @returns this effect.
  118680. */
  118681. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118682. /**
  118683. * Sets a Color3 on a uniform variable.
  118684. * @param uniformName Name of the variable.
  118685. * @param color3 Value to be set.
  118686. * @returns this effect.
  118687. */
  118688. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118689. /**
  118690. * Sets a Color4 on a uniform variable.
  118691. * @param uniformName Name of the variable.
  118692. * @param color3 Value to be set.
  118693. * @param alpha Alpha value to be set.
  118694. * @returns this effect.
  118695. */
  118696. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118697. /**
  118698. * Sets a Color4 on a uniform variable
  118699. * @param uniformName defines the name of the variable
  118700. * @param color4 defines the value to be set
  118701. * @returns this effect.
  118702. */
  118703. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118704. /** Release all associated resources */
  118705. dispose(): void;
  118706. /**
  118707. * This function will add a new shader to the shader store
  118708. * @param name the name of the shader
  118709. * @param pixelShader optional pixel shader content
  118710. * @param vertexShader optional vertex shader content
  118711. */
  118712. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118713. /**
  118714. * Store of each shader (The can be looked up using effect.key)
  118715. */
  118716. static ShadersStore: {
  118717. [key: string]: string;
  118718. };
  118719. /**
  118720. * Store of each included file for a shader (The can be looked up using effect.key)
  118721. */
  118722. static IncludesShadersStore: {
  118723. [key: string]: string;
  118724. };
  118725. /**
  118726. * Resets the cache of effects.
  118727. */
  118728. static ResetCache(): void;
  118729. }
  118730. }
  118731. declare module BABYLON {
  118732. /**
  118733. * Interface used to describe the capabilities of the engine relatively to the current browser
  118734. */
  118735. export interface EngineCapabilities {
  118736. /** Maximum textures units per fragment shader */
  118737. maxTexturesImageUnits: number;
  118738. /** Maximum texture units per vertex shader */
  118739. maxVertexTextureImageUnits: number;
  118740. /** Maximum textures units in the entire pipeline */
  118741. maxCombinedTexturesImageUnits: number;
  118742. /** Maximum texture size */
  118743. maxTextureSize: number;
  118744. /** Maximum texture samples */
  118745. maxSamples?: number;
  118746. /** Maximum cube texture size */
  118747. maxCubemapTextureSize: number;
  118748. /** Maximum render texture size */
  118749. maxRenderTextureSize: number;
  118750. /** Maximum number of vertex attributes */
  118751. maxVertexAttribs: number;
  118752. /** Maximum number of varyings */
  118753. maxVaryingVectors: number;
  118754. /** Maximum number of uniforms per vertex shader */
  118755. maxVertexUniformVectors: number;
  118756. /** Maximum number of uniforms per fragment shader */
  118757. maxFragmentUniformVectors: number;
  118758. /** Defines if standard derivates (dx/dy) are supported */
  118759. standardDerivatives: boolean;
  118760. /** Defines if s3tc texture compression is supported */
  118761. s3tc?: WEBGL_compressed_texture_s3tc;
  118762. /** Defines if pvrtc texture compression is supported */
  118763. pvrtc: any;
  118764. /** Defines if etc1 texture compression is supported */
  118765. etc1: any;
  118766. /** Defines if etc2 texture compression is supported */
  118767. etc2: any;
  118768. /** Defines if astc texture compression is supported */
  118769. astc: any;
  118770. /** Defines if bptc texture compression is supported */
  118771. bptc: any;
  118772. /** Defines if float textures are supported */
  118773. textureFloat: boolean;
  118774. /** Defines if vertex array objects are supported */
  118775. vertexArrayObject: boolean;
  118776. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118777. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118778. /** Gets the maximum level of anisotropy supported */
  118779. maxAnisotropy: number;
  118780. /** Defines if instancing is supported */
  118781. instancedArrays: boolean;
  118782. /** Defines if 32 bits indices are supported */
  118783. uintIndices: boolean;
  118784. /** Defines if high precision shaders are supported */
  118785. highPrecisionShaderSupported: boolean;
  118786. /** Defines if depth reading in the fragment shader is supported */
  118787. fragmentDepthSupported: boolean;
  118788. /** Defines if float texture linear filtering is supported*/
  118789. textureFloatLinearFiltering: boolean;
  118790. /** Defines if rendering to float textures is supported */
  118791. textureFloatRender: boolean;
  118792. /** Defines if half float textures are supported*/
  118793. textureHalfFloat: boolean;
  118794. /** Defines if half float texture linear filtering is supported*/
  118795. textureHalfFloatLinearFiltering: boolean;
  118796. /** Defines if rendering to half float textures is supported */
  118797. textureHalfFloatRender: boolean;
  118798. /** Defines if textureLOD shader command is supported */
  118799. textureLOD: boolean;
  118800. /** Defines if draw buffers extension is supported */
  118801. drawBuffersExtension: boolean;
  118802. /** Defines if depth textures are supported */
  118803. depthTextureExtension: boolean;
  118804. /** Defines if float color buffer are supported */
  118805. colorBufferFloat: boolean;
  118806. /** Gets disjoint timer query extension (null if not supported) */
  118807. timerQuery?: EXT_disjoint_timer_query;
  118808. /** Defines if timestamp can be used with timer query */
  118809. canUseTimestampForTimerQuery: boolean;
  118810. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118811. multiview?: any;
  118812. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118813. oculusMultiview?: any;
  118814. /** Function used to let the system compiles shaders in background */
  118815. parallelShaderCompile?: {
  118816. COMPLETION_STATUS_KHR: number;
  118817. };
  118818. /** Max number of texture samples for MSAA */
  118819. maxMSAASamples: number;
  118820. /** Defines if the blend min max extension is supported */
  118821. blendMinMax: boolean;
  118822. }
  118823. }
  118824. declare module BABYLON {
  118825. /**
  118826. * @hidden
  118827. **/
  118828. export class DepthCullingState {
  118829. private _isDepthTestDirty;
  118830. private _isDepthMaskDirty;
  118831. private _isDepthFuncDirty;
  118832. private _isCullFaceDirty;
  118833. private _isCullDirty;
  118834. private _isZOffsetDirty;
  118835. private _isFrontFaceDirty;
  118836. private _depthTest;
  118837. private _depthMask;
  118838. private _depthFunc;
  118839. private _cull;
  118840. private _cullFace;
  118841. private _zOffset;
  118842. private _frontFace;
  118843. /**
  118844. * Initializes the state.
  118845. */
  118846. constructor();
  118847. get isDirty(): boolean;
  118848. get zOffset(): number;
  118849. set zOffset(value: number);
  118850. get cullFace(): Nullable<number>;
  118851. set cullFace(value: Nullable<number>);
  118852. get cull(): Nullable<boolean>;
  118853. set cull(value: Nullable<boolean>);
  118854. get depthFunc(): Nullable<number>;
  118855. set depthFunc(value: Nullable<number>);
  118856. get depthMask(): boolean;
  118857. set depthMask(value: boolean);
  118858. get depthTest(): boolean;
  118859. set depthTest(value: boolean);
  118860. get frontFace(): Nullable<number>;
  118861. set frontFace(value: Nullable<number>);
  118862. reset(): void;
  118863. apply(gl: WebGLRenderingContext): void;
  118864. }
  118865. }
  118866. declare module BABYLON {
  118867. /**
  118868. * @hidden
  118869. **/
  118870. export class StencilState {
  118871. /** 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 */
  118872. static readonly ALWAYS: number;
  118873. /** Passed to stencilOperation to specify that stencil value must be kept */
  118874. static readonly KEEP: number;
  118875. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118876. static readonly REPLACE: number;
  118877. private _isStencilTestDirty;
  118878. private _isStencilMaskDirty;
  118879. private _isStencilFuncDirty;
  118880. private _isStencilOpDirty;
  118881. private _stencilTest;
  118882. private _stencilMask;
  118883. private _stencilFunc;
  118884. private _stencilFuncRef;
  118885. private _stencilFuncMask;
  118886. private _stencilOpStencilFail;
  118887. private _stencilOpDepthFail;
  118888. private _stencilOpStencilDepthPass;
  118889. get isDirty(): boolean;
  118890. get stencilFunc(): number;
  118891. set stencilFunc(value: number);
  118892. get stencilFuncRef(): number;
  118893. set stencilFuncRef(value: number);
  118894. get stencilFuncMask(): number;
  118895. set stencilFuncMask(value: number);
  118896. get stencilOpStencilFail(): number;
  118897. set stencilOpStencilFail(value: number);
  118898. get stencilOpDepthFail(): number;
  118899. set stencilOpDepthFail(value: number);
  118900. get stencilOpStencilDepthPass(): number;
  118901. set stencilOpStencilDepthPass(value: number);
  118902. get stencilMask(): number;
  118903. set stencilMask(value: number);
  118904. get stencilTest(): boolean;
  118905. set stencilTest(value: boolean);
  118906. constructor();
  118907. reset(): void;
  118908. apply(gl: WebGLRenderingContext): void;
  118909. }
  118910. }
  118911. declare module BABYLON {
  118912. /**
  118913. * @hidden
  118914. **/
  118915. export class AlphaState {
  118916. private _isAlphaBlendDirty;
  118917. private _isBlendFunctionParametersDirty;
  118918. private _isBlendEquationParametersDirty;
  118919. private _isBlendConstantsDirty;
  118920. private _alphaBlend;
  118921. private _blendFunctionParameters;
  118922. private _blendEquationParameters;
  118923. private _blendConstants;
  118924. /**
  118925. * Initializes the state.
  118926. */
  118927. constructor();
  118928. get isDirty(): boolean;
  118929. get alphaBlend(): boolean;
  118930. set alphaBlend(value: boolean);
  118931. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118932. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118933. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118934. reset(): void;
  118935. apply(gl: WebGLRenderingContext): void;
  118936. }
  118937. }
  118938. declare module BABYLON {
  118939. /** @hidden */
  118940. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118941. attributeProcessor(attribute: string): string;
  118942. varyingProcessor(varying: string, isFragment: boolean): string;
  118943. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118944. }
  118945. }
  118946. declare module BABYLON {
  118947. /**
  118948. * Interface for attribute information associated with buffer instanciation
  118949. */
  118950. export interface InstancingAttributeInfo {
  118951. /**
  118952. * Name of the GLSL attribute
  118953. * if attribute index is not specified, this is used to retrieve the index from the effect
  118954. */
  118955. attributeName: string;
  118956. /**
  118957. * Index/offset of the attribute in the vertex shader
  118958. * if not specified, this will be computes from the name.
  118959. */
  118960. index?: number;
  118961. /**
  118962. * size of the attribute, 1, 2, 3 or 4
  118963. */
  118964. attributeSize: number;
  118965. /**
  118966. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118967. */
  118968. offset: number;
  118969. /**
  118970. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118971. * default to 1
  118972. */
  118973. divisor?: number;
  118974. /**
  118975. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118976. * default is FLOAT
  118977. */
  118978. attributeType?: number;
  118979. /**
  118980. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  118981. */
  118982. normalized?: boolean;
  118983. }
  118984. }
  118985. declare module BABYLON {
  118986. interface ThinEngine {
  118987. /**
  118988. * Update a video texture
  118989. * @param texture defines the texture to update
  118990. * @param video defines the video element to use
  118991. * @param invertY defines if data must be stored with Y axis inverted
  118992. */
  118993. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  118994. }
  118995. }
  118996. declare module BABYLON {
  118997. interface ThinEngine {
  118998. /**
  118999. * Creates a dynamic texture
  119000. * @param width defines the width of the texture
  119001. * @param height defines the height of the texture
  119002. * @param generateMipMaps defines if the engine should generate the mip levels
  119003. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119004. * @returns the dynamic texture inside an InternalTexture
  119005. */
  119006. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119007. /**
  119008. * Update the content of a dynamic texture
  119009. * @param texture defines the texture to update
  119010. * @param canvas defines the canvas containing the source
  119011. * @param invertY defines if data must be stored with Y axis inverted
  119012. * @param premulAlpha defines if alpha is stored as premultiplied
  119013. * @param format defines the format of the data
  119014. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119015. */
  119016. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119017. }
  119018. }
  119019. declare module BABYLON {
  119020. /**
  119021. * Settings for finer control over video usage
  119022. */
  119023. export interface VideoTextureSettings {
  119024. /**
  119025. * Applies `autoplay` to video, if specified
  119026. */
  119027. autoPlay?: boolean;
  119028. /**
  119029. * Applies `muted` to video, if specified
  119030. */
  119031. muted?: boolean;
  119032. /**
  119033. * Applies `loop` to video, if specified
  119034. */
  119035. loop?: boolean;
  119036. /**
  119037. * Automatically updates internal texture from video at every frame in the render loop
  119038. */
  119039. autoUpdateTexture: boolean;
  119040. /**
  119041. * Image src displayed during the video loading or until the user interacts with the video.
  119042. */
  119043. poster?: string;
  119044. }
  119045. /**
  119046. * If you want to display a video in your scene, this is the special texture for that.
  119047. * This special texture works similar to other textures, with the exception of a few parameters.
  119048. * @see https://doc.babylonjs.com/how_to/video_texture
  119049. */
  119050. export class VideoTexture extends Texture {
  119051. /**
  119052. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119053. */
  119054. readonly autoUpdateTexture: boolean;
  119055. /**
  119056. * The video instance used by the texture internally
  119057. */
  119058. readonly video: HTMLVideoElement;
  119059. private _onUserActionRequestedObservable;
  119060. /**
  119061. * Event triggerd when a dom action is required by the user to play the video.
  119062. * This happens due to recent changes in browser policies preventing video to auto start.
  119063. */
  119064. get onUserActionRequestedObservable(): Observable<Texture>;
  119065. private _generateMipMaps;
  119066. private _stillImageCaptured;
  119067. private _displayingPosterTexture;
  119068. private _settings;
  119069. private _createInternalTextureOnEvent;
  119070. private _frameId;
  119071. private _currentSrc;
  119072. /**
  119073. * Creates a video texture.
  119074. * If you want to display a video in your scene, this is the special texture for that.
  119075. * This special texture works similar to other textures, with the exception of a few parameters.
  119076. * @see https://doc.babylonjs.com/how_to/video_texture
  119077. * @param name optional name, will detect from video source, if not defined
  119078. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119079. * @param scene is obviously the current scene.
  119080. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119081. * @param invertY is false by default but can be used to invert video on Y axis
  119082. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119083. * @param settings allows finer control over video usage
  119084. */
  119085. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119086. private _getName;
  119087. private _getVideo;
  119088. private _createInternalTexture;
  119089. private reset;
  119090. /**
  119091. * @hidden Internal method to initiate `update`.
  119092. */
  119093. _rebuild(): void;
  119094. /**
  119095. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119096. */
  119097. update(): void;
  119098. /**
  119099. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119100. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119101. */
  119102. updateTexture(isVisible: boolean): void;
  119103. protected _updateInternalTexture: () => void;
  119104. /**
  119105. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119106. * @param url New url.
  119107. */
  119108. updateURL(url: string): void;
  119109. /**
  119110. * Clones the texture.
  119111. * @returns the cloned texture
  119112. */
  119113. clone(): VideoTexture;
  119114. /**
  119115. * Dispose the texture and release its associated resources.
  119116. */
  119117. dispose(): void;
  119118. /**
  119119. * Creates a video texture straight from a stream.
  119120. * @param scene Define the scene the texture should be created in
  119121. * @param stream Define the stream the texture should be created from
  119122. * @returns The created video texture as a promise
  119123. */
  119124. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119125. /**
  119126. * Creates a video texture straight from your WebCam video feed.
  119127. * @param scene Define the scene the texture should be created in
  119128. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119129. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119130. * @returns The created video texture as a promise
  119131. */
  119132. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119133. minWidth: number;
  119134. maxWidth: number;
  119135. minHeight: number;
  119136. maxHeight: number;
  119137. deviceId: string;
  119138. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119139. /**
  119140. * Creates a video texture straight from your WebCam video feed.
  119141. * @param scene Define the scene the texture should be created in
  119142. * @param onReady Define a callback to triggered once the texture will be ready
  119143. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119144. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119145. */
  119146. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119147. minWidth: number;
  119148. maxWidth: number;
  119149. minHeight: number;
  119150. maxHeight: number;
  119151. deviceId: string;
  119152. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119153. }
  119154. }
  119155. declare module BABYLON {
  119156. /**
  119157. * Defines the interface used by objects working like Scene
  119158. * @hidden
  119159. */
  119160. export interface ISceneLike {
  119161. _addPendingData(data: any): void;
  119162. _removePendingData(data: any): void;
  119163. offlineProvider: IOfflineProvider;
  119164. }
  119165. /**
  119166. * Information about the current host
  119167. */
  119168. export interface HostInformation {
  119169. /**
  119170. * Defines if the current host is a mobile
  119171. */
  119172. isMobile: boolean;
  119173. }
  119174. /** Interface defining initialization parameters for Engine class */
  119175. export interface EngineOptions extends WebGLContextAttributes {
  119176. /**
  119177. * Defines if the engine should no exceed a specified device ratio
  119178. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119179. */
  119180. limitDeviceRatio?: number;
  119181. /**
  119182. * Defines if webvr should be enabled automatically
  119183. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119184. */
  119185. autoEnableWebVR?: boolean;
  119186. /**
  119187. * Defines if webgl2 should be turned off even if supported
  119188. * @see https://doc.babylonjs.com/features/webgl2
  119189. */
  119190. disableWebGL2Support?: boolean;
  119191. /**
  119192. * Defines if webaudio should be initialized as well
  119193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119194. */
  119195. audioEngine?: boolean;
  119196. /**
  119197. * Defines if animations should run using a deterministic lock step
  119198. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119199. */
  119200. deterministicLockstep?: boolean;
  119201. /** Defines the maximum steps to use with deterministic lock step mode */
  119202. lockstepMaxSteps?: number;
  119203. /** Defines the seconds between each deterministic lock step */
  119204. timeStep?: number;
  119205. /**
  119206. * Defines that engine should ignore context lost events
  119207. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119208. */
  119209. doNotHandleContextLost?: boolean;
  119210. /**
  119211. * Defines that engine should ignore modifying touch action attribute and style
  119212. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119213. */
  119214. doNotHandleTouchAction?: boolean;
  119215. /**
  119216. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119217. */
  119218. useHighPrecisionFloats?: boolean;
  119219. /**
  119220. * Make the canvas XR Compatible for XR sessions
  119221. */
  119222. xrCompatible?: boolean;
  119223. /**
  119224. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119225. */
  119226. useHighPrecisionMatrix?: boolean;
  119227. /**
  119228. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119229. */
  119230. failIfMajorPerformanceCaveat?: boolean;
  119231. }
  119232. /**
  119233. * The base engine class (root of all engines)
  119234. */
  119235. export class ThinEngine {
  119236. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119237. static ExceptionList: ({
  119238. key: string;
  119239. capture: string;
  119240. captureConstraint: number;
  119241. targets: string[];
  119242. } | {
  119243. key: string;
  119244. capture: null;
  119245. captureConstraint: null;
  119246. targets: string[];
  119247. })[];
  119248. /** @hidden */
  119249. static _TextureLoaders: IInternalTextureLoader[];
  119250. /**
  119251. * Returns the current npm package of the sdk
  119252. */
  119253. static get NpmPackage(): string;
  119254. /**
  119255. * Returns the current version of the framework
  119256. */
  119257. static get Version(): string;
  119258. /**
  119259. * Returns a string describing the current engine
  119260. */
  119261. get description(): string;
  119262. /**
  119263. * Gets or sets the epsilon value used by collision engine
  119264. */
  119265. static CollisionsEpsilon: number;
  119266. /**
  119267. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119268. */
  119269. static get ShadersRepository(): string;
  119270. static set ShadersRepository(value: string);
  119271. /** @hidden */
  119272. _shaderProcessor: IShaderProcessor;
  119273. /**
  119274. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119275. */
  119276. forcePOTTextures: boolean;
  119277. /**
  119278. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119279. */
  119280. isFullscreen: boolean;
  119281. /**
  119282. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119283. */
  119284. cullBackFaces: boolean;
  119285. /**
  119286. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119287. */
  119288. renderEvenInBackground: boolean;
  119289. /**
  119290. * Gets or sets a boolean indicating that cache can be kept between frames
  119291. */
  119292. preventCacheWipeBetweenFrames: boolean;
  119293. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119294. validateShaderPrograms: boolean;
  119295. /**
  119296. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119297. * This can provide greater z depth for distant objects.
  119298. */
  119299. useReverseDepthBuffer: boolean;
  119300. /**
  119301. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119302. */
  119303. disableUniformBuffers: boolean;
  119304. /** @hidden */
  119305. _uniformBuffers: UniformBuffer[];
  119306. /**
  119307. * Gets a boolean indicating that the engine supports uniform buffers
  119308. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119309. */
  119310. get supportsUniformBuffers(): boolean;
  119311. /** @hidden */
  119312. _gl: WebGLRenderingContext;
  119313. /** @hidden */
  119314. _webGLVersion: number;
  119315. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119316. protected _windowIsBackground: boolean;
  119317. protected _creationOptions: EngineOptions;
  119318. protected _highPrecisionShadersAllowed: boolean;
  119319. /** @hidden */
  119320. get _shouldUseHighPrecisionShader(): boolean;
  119321. /**
  119322. * Gets a boolean indicating that only power of 2 textures are supported
  119323. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119324. */
  119325. get needPOTTextures(): boolean;
  119326. /** @hidden */
  119327. _badOS: boolean;
  119328. /** @hidden */
  119329. _badDesktopOS: boolean;
  119330. private _hardwareScalingLevel;
  119331. /** @hidden */
  119332. _caps: EngineCapabilities;
  119333. private _isStencilEnable;
  119334. private _glVersion;
  119335. private _glRenderer;
  119336. private _glVendor;
  119337. /** @hidden */
  119338. _videoTextureSupported: boolean;
  119339. protected _renderingQueueLaunched: boolean;
  119340. protected _activeRenderLoops: (() => void)[];
  119341. /**
  119342. * Observable signaled when a context lost event is raised
  119343. */
  119344. onContextLostObservable: Observable<ThinEngine>;
  119345. /**
  119346. * Observable signaled when a context restored event is raised
  119347. */
  119348. onContextRestoredObservable: Observable<ThinEngine>;
  119349. private _onContextLost;
  119350. private _onContextRestored;
  119351. protected _contextWasLost: boolean;
  119352. /** @hidden */
  119353. _doNotHandleContextLost: boolean;
  119354. /**
  119355. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119357. */
  119358. get doNotHandleContextLost(): boolean;
  119359. set doNotHandleContextLost(value: boolean);
  119360. /**
  119361. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119362. */
  119363. disableVertexArrayObjects: boolean;
  119364. /** @hidden */
  119365. protected _colorWrite: boolean;
  119366. /** @hidden */
  119367. protected _colorWriteChanged: boolean;
  119368. /** @hidden */
  119369. protected _depthCullingState: DepthCullingState;
  119370. /** @hidden */
  119371. protected _stencilState: StencilState;
  119372. /** @hidden */
  119373. _alphaState: AlphaState;
  119374. /** @hidden */
  119375. _alphaMode: number;
  119376. /** @hidden */
  119377. _alphaEquation: number;
  119378. /** @hidden */
  119379. _internalTexturesCache: InternalTexture[];
  119380. /** @hidden */
  119381. protected _activeChannel: number;
  119382. private _currentTextureChannel;
  119383. /** @hidden */
  119384. protected _boundTexturesCache: {
  119385. [key: string]: Nullable<InternalTexture>;
  119386. };
  119387. /** @hidden */
  119388. protected _currentEffect: Nullable<Effect>;
  119389. /** @hidden */
  119390. protected _currentProgram: Nullable<WebGLProgram>;
  119391. private _compiledEffects;
  119392. private _vertexAttribArraysEnabled;
  119393. /** @hidden */
  119394. protected _cachedViewport: Nullable<IViewportLike>;
  119395. private _cachedVertexArrayObject;
  119396. /** @hidden */
  119397. protected _cachedVertexBuffers: any;
  119398. /** @hidden */
  119399. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119400. /** @hidden */
  119401. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119402. /** @hidden */
  119403. _currentRenderTarget: Nullable<InternalTexture>;
  119404. private _uintIndicesCurrentlySet;
  119405. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119406. /** @hidden */
  119407. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119408. /** @hidden */
  119409. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119410. private _currentBufferPointers;
  119411. private _currentInstanceLocations;
  119412. private _currentInstanceBuffers;
  119413. private _textureUnits;
  119414. /** @hidden */
  119415. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119416. /** @hidden */
  119417. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119418. /** @hidden */
  119419. _boundRenderFunction: any;
  119420. private _vaoRecordInProgress;
  119421. private _mustWipeVertexAttributes;
  119422. private _emptyTexture;
  119423. private _emptyCubeTexture;
  119424. private _emptyTexture3D;
  119425. private _emptyTexture2DArray;
  119426. /** @hidden */
  119427. _frameHandler: number;
  119428. private _nextFreeTextureSlots;
  119429. private _maxSimultaneousTextures;
  119430. private _activeRequests;
  119431. /** @hidden */
  119432. _transformTextureUrl: Nullable<(url: string) => string>;
  119433. /**
  119434. * Gets information about the current host
  119435. */
  119436. hostInformation: HostInformation;
  119437. protected get _supportsHardwareTextureRescaling(): boolean;
  119438. private _framebufferDimensionsObject;
  119439. /**
  119440. * sets the object from which width and height will be taken from when getting render width and height
  119441. * Will fallback to the gl object
  119442. * @param dimensions the framebuffer width and height that will be used.
  119443. */
  119444. set framebufferDimensionsObject(dimensions: Nullable<{
  119445. framebufferWidth: number;
  119446. framebufferHeight: number;
  119447. }>);
  119448. /**
  119449. * Gets the current viewport
  119450. */
  119451. get currentViewport(): Nullable<IViewportLike>;
  119452. /**
  119453. * Gets the default empty texture
  119454. */
  119455. get emptyTexture(): InternalTexture;
  119456. /**
  119457. * Gets the default empty 3D texture
  119458. */
  119459. get emptyTexture3D(): InternalTexture;
  119460. /**
  119461. * Gets the default empty 2D array texture
  119462. */
  119463. get emptyTexture2DArray(): InternalTexture;
  119464. /**
  119465. * Gets the default empty cube texture
  119466. */
  119467. get emptyCubeTexture(): InternalTexture;
  119468. /**
  119469. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119470. */
  119471. readonly premultipliedAlpha: boolean;
  119472. /**
  119473. * Observable event triggered before each texture is initialized
  119474. */
  119475. onBeforeTextureInitObservable: Observable<Texture>;
  119476. /**
  119477. * Creates a new engine
  119478. * @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
  119479. * @param antialias defines enable antialiasing (default: false)
  119480. * @param options defines further options to be sent to the getContext() function
  119481. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119482. */
  119483. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119484. private _rebuildInternalTextures;
  119485. private _rebuildEffects;
  119486. /**
  119487. * Gets a boolean indicating if all created effects are ready
  119488. * @returns true if all effects are ready
  119489. */
  119490. areAllEffectsReady(): boolean;
  119491. protected _rebuildBuffers(): void;
  119492. protected _initGLContext(): void;
  119493. /**
  119494. * Gets version of the current webGL context
  119495. */
  119496. get webGLVersion(): number;
  119497. /**
  119498. * Gets a string identifying the name of the class
  119499. * @returns "Engine" string
  119500. */
  119501. getClassName(): string;
  119502. /**
  119503. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119504. */
  119505. get isStencilEnable(): boolean;
  119506. /** @hidden */
  119507. _prepareWorkingCanvas(): void;
  119508. /**
  119509. * Reset the texture cache to empty state
  119510. */
  119511. resetTextureCache(): void;
  119512. /**
  119513. * Gets an object containing information about the current webGL context
  119514. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119515. */
  119516. getGlInfo(): {
  119517. vendor: string;
  119518. renderer: string;
  119519. version: string;
  119520. };
  119521. /**
  119522. * Defines the hardware scaling level.
  119523. * By default the hardware scaling level is computed from the window device ratio.
  119524. * 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.
  119525. * @param level defines the level to use
  119526. */
  119527. setHardwareScalingLevel(level: number): void;
  119528. /**
  119529. * Gets the current hardware scaling level.
  119530. * By default the hardware scaling level is computed from the window device ratio.
  119531. * 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.
  119532. * @returns a number indicating the current hardware scaling level
  119533. */
  119534. getHardwareScalingLevel(): number;
  119535. /**
  119536. * Gets the list of loaded textures
  119537. * @returns an array containing all loaded textures
  119538. */
  119539. getLoadedTexturesCache(): InternalTexture[];
  119540. /**
  119541. * Gets the object containing all engine capabilities
  119542. * @returns the EngineCapabilities object
  119543. */
  119544. getCaps(): EngineCapabilities;
  119545. /**
  119546. * stop executing a render loop function and remove it from the execution array
  119547. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119548. */
  119549. stopRenderLoop(renderFunction?: () => void): void;
  119550. /** @hidden */
  119551. _renderLoop(): void;
  119552. /**
  119553. * Gets the HTML canvas attached with the current webGL context
  119554. * @returns a HTML canvas
  119555. */
  119556. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119557. /**
  119558. * Gets host window
  119559. * @returns the host window object
  119560. */
  119561. getHostWindow(): Nullable<Window>;
  119562. /**
  119563. * Gets the current render width
  119564. * @param useScreen defines if screen size must be used (or the current render target if any)
  119565. * @returns a number defining the current render width
  119566. */
  119567. getRenderWidth(useScreen?: boolean): number;
  119568. /**
  119569. * Gets the current render height
  119570. * @param useScreen defines if screen size must be used (or the current render target if any)
  119571. * @returns a number defining the current render height
  119572. */
  119573. getRenderHeight(useScreen?: boolean): number;
  119574. /**
  119575. * Can be used to override the current requestAnimationFrame requester.
  119576. * @hidden
  119577. */
  119578. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119579. /**
  119580. * Register and execute a render loop. The engine can have more than one render function
  119581. * @param renderFunction defines the function to continuously execute
  119582. */
  119583. runRenderLoop(renderFunction: () => void): void;
  119584. /**
  119585. * Clear the current render buffer or the current render target (if any is set up)
  119586. * @param color defines the color to use
  119587. * @param backBuffer defines if the back buffer must be cleared
  119588. * @param depth defines if the depth buffer must be cleared
  119589. * @param stencil defines if the stencil buffer must be cleared
  119590. */
  119591. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119592. private _viewportCached;
  119593. /** @hidden */
  119594. _viewport(x: number, y: number, width: number, height: number): void;
  119595. /**
  119596. * Set the WebGL's viewport
  119597. * @param viewport defines the viewport element to be used
  119598. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119599. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119600. */
  119601. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119602. /**
  119603. * Begin a new frame
  119604. */
  119605. beginFrame(): void;
  119606. /**
  119607. * Enf the current frame
  119608. */
  119609. endFrame(): void;
  119610. /**
  119611. * Resize the view according to the canvas' size
  119612. */
  119613. resize(): void;
  119614. /**
  119615. * Force a specific size of the canvas
  119616. * @param width defines the new canvas' width
  119617. * @param height defines the new canvas' height
  119618. * @returns true if the size was changed
  119619. */
  119620. setSize(width: number, height: number): boolean;
  119621. /**
  119622. * Binds the frame buffer to the specified texture.
  119623. * @param texture The texture to render to or null for the default canvas
  119624. * @param faceIndex The face of the texture to render to in case of cube texture
  119625. * @param requiredWidth The width of the target to render to
  119626. * @param requiredHeight The height of the target to render to
  119627. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119628. * @param lodLevel defines the lod level to bind to the frame buffer
  119629. * @param layer defines the 2d array index to bind to frame buffer to
  119630. */
  119631. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119632. /** @hidden */
  119633. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119634. /**
  119635. * Unbind the current render target texture from the webGL context
  119636. * @param texture defines the render target texture to unbind
  119637. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119638. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119639. */
  119640. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119641. /**
  119642. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119643. */
  119644. flushFramebuffer(): void;
  119645. /**
  119646. * Unbind the current render target and bind the default framebuffer
  119647. */
  119648. restoreDefaultFramebuffer(): void;
  119649. /** @hidden */
  119650. protected _resetVertexBufferBinding(): void;
  119651. /**
  119652. * Creates a vertex buffer
  119653. * @param data the data for the vertex buffer
  119654. * @returns the new WebGL static buffer
  119655. */
  119656. createVertexBuffer(data: DataArray): DataBuffer;
  119657. private _createVertexBuffer;
  119658. /**
  119659. * Creates a dynamic vertex buffer
  119660. * @param data the data for the dynamic vertex buffer
  119661. * @returns the new WebGL dynamic buffer
  119662. */
  119663. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119664. protected _resetIndexBufferBinding(): void;
  119665. /**
  119666. * Creates a new index buffer
  119667. * @param indices defines the content of the index buffer
  119668. * @param updatable defines if the index buffer must be updatable
  119669. * @returns a new webGL buffer
  119670. */
  119671. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119672. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119673. /**
  119674. * Bind a webGL buffer to the webGL context
  119675. * @param buffer defines the buffer to bind
  119676. */
  119677. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119678. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119679. private bindBuffer;
  119680. /**
  119681. * update the bound buffer with the given data
  119682. * @param data defines the data to update
  119683. */
  119684. updateArrayBuffer(data: Float32Array): void;
  119685. private _vertexAttribPointer;
  119686. /** @hidden */
  119687. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119688. private _bindVertexBuffersAttributes;
  119689. /**
  119690. * Records a vertex array object
  119691. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119692. * @param vertexBuffers defines the list of vertex buffers to store
  119693. * @param indexBuffer defines the index buffer to store
  119694. * @param effect defines the effect to store
  119695. * @returns the new vertex array object
  119696. */
  119697. recordVertexArrayObject(vertexBuffers: {
  119698. [key: string]: VertexBuffer;
  119699. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119700. /**
  119701. * Bind a specific vertex array object
  119702. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119703. * @param vertexArrayObject defines the vertex array object to bind
  119704. * @param indexBuffer defines the index buffer to bind
  119705. */
  119706. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119707. /**
  119708. * Bind webGl buffers directly to the webGL context
  119709. * @param vertexBuffer defines the vertex buffer to bind
  119710. * @param indexBuffer defines the index buffer to bind
  119711. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119712. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119713. * @param effect defines the effect associated with the vertex buffer
  119714. */
  119715. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119716. private _unbindVertexArrayObject;
  119717. /**
  119718. * Bind a list of vertex buffers to the webGL context
  119719. * @param vertexBuffers defines the list of vertex buffers to bind
  119720. * @param indexBuffer defines the index buffer to bind
  119721. * @param effect defines the effect associated with the vertex buffers
  119722. */
  119723. bindBuffers(vertexBuffers: {
  119724. [key: string]: Nullable<VertexBuffer>;
  119725. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119726. /**
  119727. * Unbind all instance attributes
  119728. */
  119729. unbindInstanceAttributes(): void;
  119730. /**
  119731. * Release and free the memory of a vertex array object
  119732. * @param vao defines the vertex array object to delete
  119733. */
  119734. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119735. /** @hidden */
  119736. _releaseBuffer(buffer: DataBuffer): boolean;
  119737. protected _deleteBuffer(buffer: DataBuffer): void;
  119738. /**
  119739. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119740. * @param instancesBuffer defines the webGL buffer to update and bind
  119741. * @param data defines the data to store in the buffer
  119742. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119743. */
  119744. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119745. /**
  119746. * Bind the content of a webGL buffer used with instantiation
  119747. * @param instancesBuffer defines the webGL buffer to bind
  119748. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119749. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119750. */
  119751. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119752. /**
  119753. * Disable the instance attribute corresponding to the name in parameter
  119754. * @param name defines the name of the attribute to disable
  119755. */
  119756. disableInstanceAttributeByName(name: string): void;
  119757. /**
  119758. * Disable the instance attribute corresponding to the location in parameter
  119759. * @param attributeLocation defines the attribute location of the attribute to disable
  119760. */
  119761. disableInstanceAttribute(attributeLocation: number): void;
  119762. /**
  119763. * Disable the attribute corresponding to the location in parameter
  119764. * @param attributeLocation defines the attribute location of the attribute to disable
  119765. */
  119766. disableAttributeByIndex(attributeLocation: number): void;
  119767. /**
  119768. * Send a draw order
  119769. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119770. * @param indexStart defines the starting index
  119771. * @param indexCount defines the number of index to draw
  119772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119773. */
  119774. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119775. /**
  119776. * Draw a list of points
  119777. * @param verticesStart defines the index of first vertex to draw
  119778. * @param verticesCount defines the count of vertices to draw
  119779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119780. */
  119781. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119782. /**
  119783. * Draw a list of unindexed primitives
  119784. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119785. * @param verticesStart defines the index of first vertex to draw
  119786. * @param verticesCount defines the count of vertices to draw
  119787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119788. */
  119789. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119790. /**
  119791. * Draw a list of indexed primitives
  119792. * @param fillMode defines the primitive to use
  119793. * @param indexStart defines the starting index
  119794. * @param indexCount defines the number of index to draw
  119795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119796. */
  119797. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119798. /**
  119799. * Draw a list of unindexed primitives
  119800. * @param fillMode defines the primitive to use
  119801. * @param verticesStart defines the index of first vertex to draw
  119802. * @param verticesCount defines the count of vertices to draw
  119803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119804. */
  119805. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119806. private _drawMode;
  119807. /** @hidden */
  119808. protected _reportDrawCall(): void;
  119809. /** @hidden */
  119810. _releaseEffect(effect: Effect): void;
  119811. /** @hidden */
  119812. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119813. /**
  119814. * Create a new effect (used to store vertex/fragment shaders)
  119815. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119816. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119817. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119818. * @param samplers defines an array of string used to represent textures
  119819. * @param defines defines the string containing the defines to use to compile the shaders
  119820. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119821. * @param onCompiled defines a function to call when the effect creation is successful
  119822. * @param onError defines a function to call when the effect creation has failed
  119823. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119824. * @returns the new Effect
  119825. */
  119826. 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;
  119827. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119828. private _compileShader;
  119829. private _compileRawShader;
  119830. /** @hidden */
  119831. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119832. /**
  119833. * Directly creates a webGL program
  119834. * @param pipelineContext defines the pipeline context to attach to
  119835. * @param vertexCode defines the vertex shader code to use
  119836. * @param fragmentCode defines the fragment shader code to use
  119837. * @param context defines the webGL context to use (if not set, the current one will be used)
  119838. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119839. * @returns the new webGL program
  119840. */
  119841. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119842. /**
  119843. * Creates a webGL program
  119844. * @param pipelineContext defines the pipeline context to attach to
  119845. * @param vertexCode defines the vertex shader code to use
  119846. * @param fragmentCode defines the fragment shader code to use
  119847. * @param defines defines the string containing the defines to use to compile the shaders
  119848. * @param context defines the webGL context to use (if not set, the current one will be used)
  119849. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119850. * @returns the new webGL program
  119851. */
  119852. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119853. /**
  119854. * Creates a new pipeline context
  119855. * @returns the new pipeline
  119856. */
  119857. createPipelineContext(): IPipelineContext;
  119858. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119859. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119860. /** @hidden */
  119861. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119862. /** @hidden */
  119863. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119864. /** @hidden */
  119865. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119866. /**
  119867. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119868. * @param pipelineContext defines the pipeline context to use
  119869. * @param uniformsNames defines the list of uniform names
  119870. * @returns an array of webGL uniform locations
  119871. */
  119872. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119873. /**
  119874. * Gets the lsit of active attributes for a given webGL program
  119875. * @param pipelineContext defines the pipeline context to use
  119876. * @param attributesNames defines the list of attribute names to get
  119877. * @returns an array of indices indicating the offset of each attribute
  119878. */
  119879. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119880. /**
  119881. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119882. * @param effect defines the effect to activate
  119883. */
  119884. enableEffect(effect: Nullable<Effect>): void;
  119885. /**
  119886. * Set the value of an uniform to a number (int)
  119887. * @param uniform defines the webGL uniform location where to store the value
  119888. * @param value defines the int number to store
  119889. * @returns true if the value was set
  119890. */
  119891. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119892. /**
  119893. * Set the value of an uniform to an array of int32
  119894. * @param uniform defines the webGL uniform location where to store the value
  119895. * @param array defines the array of int32 to store
  119896. * @returns true if the value was set
  119897. */
  119898. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119899. /**
  119900. * Set the value of an uniform to an array of int32 (stored as vec2)
  119901. * @param uniform defines the webGL uniform location where to store the value
  119902. * @param array defines the array of int32 to store
  119903. * @returns true if the value was set
  119904. */
  119905. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119906. /**
  119907. * Set the value of an uniform to an array of int32 (stored as vec3)
  119908. * @param uniform defines the webGL uniform location where to store the value
  119909. * @param array defines the array of int32 to store
  119910. * @returns true if the value was set
  119911. */
  119912. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119913. /**
  119914. * Set the value of an uniform to an array of int32 (stored as vec4)
  119915. * @param uniform defines the webGL uniform location where to store the value
  119916. * @param array defines the array of int32 to store
  119917. * @returns true if the value was set
  119918. */
  119919. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119920. /**
  119921. * Set the value of an uniform to an array of number
  119922. * @param uniform defines the webGL uniform location where to store the value
  119923. * @param array defines the array of number to store
  119924. * @returns true if the value was set
  119925. */
  119926. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119927. /**
  119928. * Set the value of an uniform to an array of number (stored as vec2)
  119929. * @param uniform defines the webGL uniform location where to store the value
  119930. * @param array defines the array of number to store
  119931. * @returns true if the value was set
  119932. */
  119933. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119934. /**
  119935. * Set the value of an uniform to an array of number (stored as vec3)
  119936. * @param uniform defines the webGL uniform location where to store the value
  119937. * @param array defines the array of number to store
  119938. * @returns true if the value was set
  119939. */
  119940. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119941. /**
  119942. * Set the value of an uniform to an array of number (stored as vec4)
  119943. * @param uniform defines the webGL uniform location where to store the value
  119944. * @param array defines the array of number to store
  119945. * @returns true if the value was set
  119946. */
  119947. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119948. /**
  119949. * Set the value of an uniform to an array of float32 (stored as matrices)
  119950. * @param uniform defines the webGL uniform location where to store the value
  119951. * @param matrices defines the array of float32 to store
  119952. * @returns true if the value was set
  119953. */
  119954. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119955. /**
  119956. * Set the value of an uniform to a matrix (3x3)
  119957. * @param uniform defines the webGL uniform location where to store the value
  119958. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119959. * @returns true if the value was set
  119960. */
  119961. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119962. /**
  119963. * Set the value of an uniform to a matrix (2x2)
  119964. * @param uniform defines the webGL uniform location where to store the value
  119965. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119966. * @returns true if the value was set
  119967. */
  119968. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119969. /**
  119970. * Set the value of an uniform to a number (float)
  119971. * @param uniform defines the webGL uniform location where to store the value
  119972. * @param value defines the float number to store
  119973. * @returns true if the value was transfered
  119974. */
  119975. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119976. /**
  119977. * Set the value of an uniform to a vec2
  119978. * @param uniform defines the webGL uniform location where to store the value
  119979. * @param x defines the 1st component of the value
  119980. * @param y defines the 2nd component of the value
  119981. * @returns true if the value was set
  119982. */
  119983. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  119984. /**
  119985. * Set the value of an uniform to a vec3
  119986. * @param uniform defines the webGL uniform location where to store the value
  119987. * @param x defines the 1st component of the value
  119988. * @param y defines the 2nd component of the value
  119989. * @param z defines the 3rd component of the value
  119990. * @returns true if the value was set
  119991. */
  119992. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  119993. /**
  119994. * Set the value of an uniform to a vec4
  119995. * @param uniform defines the webGL uniform location where to store the value
  119996. * @param x defines the 1st component of the value
  119997. * @param y defines the 2nd component of the value
  119998. * @param z defines the 3rd component of the value
  119999. * @param w defines the 4th component of the value
  120000. * @returns true if the value was set
  120001. */
  120002. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120003. /**
  120004. * Apply all cached states (depth, culling, stencil and alpha)
  120005. */
  120006. applyStates(): void;
  120007. /**
  120008. * Enable or disable color writing
  120009. * @param enable defines the state to set
  120010. */
  120011. setColorWrite(enable: boolean): void;
  120012. /**
  120013. * Gets a boolean indicating if color writing is enabled
  120014. * @returns the current color writing state
  120015. */
  120016. getColorWrite(): boolean;
  120017. /**
  120018. * Gets the depth culling state manager
  120019. */
  120020. get depthCullingState(): DepthCullingState;
  120021. /**
  120022. * Gets the alpha state manager
  120023. */
  120024. get alphaState(): AlphaState;
  120025. /**
  120026. * Gets the stencil state manager
  120027. */
  120028. get stencilState(): StencilState;
  120029. /**
  120030. * Clears the list of texture accessible through engine.
  120031. * This can help preventing texture load conflict due to name collision.
  120032. */
  120033. clearInternalTexturesCache(): void;
  120034. /**
  120035. * Force the entire cache to be cleared
  120036. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120037. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120038. */
  120039. wipeCaches(bruteForce?: boolean): void;
  120040. /** @hidden */
  120041. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120042. min: number;
  120043. mag: number;
  120044. };
  120045. /** @hidden */
  120046. _createTexture(): WebGLTexture;
  120047. /**
  120048. * Usually called from Texture.ts.
  120049. * Passed information to create a WebGLTexture
  120050. * @param url defines a value which contains one of the following:
  120051. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120052. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120053. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120055. * @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)
  120056. * @param scene needed for loading to the correct scene
  120057. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120058. * @param onLoad optional callback to be called upon successful completion
  120059. * @param onError optional callback to be called upon failure
  120060. * @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
  120061. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120062. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120063. * @param forcedExtension defines the extension to use to pick the right loader
  120064. * @param mimeType defines an optional mime type
  120065. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120066. */
  120067. 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;
  120068. /**
  120069. * Loads an image as an HTMLImageElement.
  120070. * @param input url string, ArrayBuffer, or Blob to load
  120071. * @param onLoad callback called when the image successfully loads
  120072. * @param onError callback called when the image fails to load
  120073. * @param offlineProvider offline provider for caching
  120074. * @param mimeType optional mime type
  120075. * @returns the HTMLImageElement of the loaded image
  120076. * @hidden
  120077. */
  120078. 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>;
  120079. /**
  120080. * @hidden
  120081. */
  120082. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120083. private _unpackFlipYCached;
  120084. /**
  120085. * In case you are sharing the context with other applications, it might
  120086. * be interested to not cache the unpack flip y state to ensure a consistent
  120087. * value would be set.
  120088. */
  120089. enableUnpackFlipYCached: boolean;
  120090. /** @hidden */
  120091. _unpackFlipY(value: boolean): void;
  120092. /** @hidden */
  120093. _getUnpackAlignement(): number;
  120094. private _getTextureTarget;
  120095. /**
  120096. * Update the sampling mode of a given texture
  120097. * @param samplingMode defines the required sampling mode
  120098. * @param texture defines the texture to update
  120099. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120100. */
  120101. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120102. /**
  120103. * Update the sampling mode of a given texture
  120104. * @param texture defines the texture to update
  120105. * @param wrapU defines the texture wrap mode of the u coordinates
  120106. * @param wrapV defines the texture wrap mode of the v coordinates
  120107. * @param wrapR defines the texture wrap mode of the r coordinates
  120108. */
  120109. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120110. /** @hidden */
  120111. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120112. width: number;
  120113. height: number;
  120114. layers?: number;
  120115. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120116. /** @hidden */
  120117. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120118. /** @hidden */
  120119. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120120. /**
  120121. * Update a portion of an internal texture
  120122. * @param texture defines the texture to update
  120123. * @param imageData defines the data to store into the texture
  120124. * @param xOffset defines the x coordinates of the update rectangle
  120125. * @param yOffset defines the y coordinates of the update rectangle
  120126. * @param width defines the width of the update rectangle
  120127. * @param height defines the height of the update rectangle
  120128. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120129. * @param lod defines the lod level to update (0 by default)
  120130. */
  120131. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120132. /** @hidden */
  120133. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120134. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120135. private _prepareWebGLTexture;
  120136. /** @hidden */
  120137. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120138. private _getDepthStencilBuffer;
  120139. /** @hidden */
  120140. _releaseFramebufferObjects(texture: InternalTexture): void;
  120141. /** @hidden */
  120142. _releaseTexture(texture: InternalTexture): void;
  120143. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120144. protected _setProgram(program: WebGLProgram): void;
  120145. protected _boundUniforms: {
  120146. [key: number]: WebGLUniformLocation;
  120147. };
  120148. /**
  120149. * Binds an effect to the webGL context
  120150. * @param effect defines the effect to bind
  120151. */
  120152. bindSamplers(effect: Effect): void;
  120153. private _activateCurrentTexture;
  120154. /** @hidden */
  120155. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120156. /** @hidden */
  120157. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120158. /**
  120159. * Unbind all textures from the webGL context
  120160. */
  120161. unbindAllTextures(): void;
  120162. /**
  120163. * Sets a texture to the according uniform.
  120164. * @param channel The texture channel
  120165. * @param uniform The uniform to set
  120166. * @param texture The texture to apply
  120167. */
  120168. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120169. private _bindSamplerUniformToChannel;
  120170. private _getTextureWrapMode;
  120171. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120172. /**
  120173. * Sets an array of texture to the webGL context
  120174. * @param channel defines the channel where the texture array must be set
  120175. * @param uniform defines the associated uniform location
  120176. * @param textures defines the array of textures to bind
  120177. */
  120178. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120179. /** @hidden */
  120180. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120181. private _setTextureParameterFloat;
  120182. private _setTextureParameterInteger;
  120183. /**
  120184. * Unbind all vertex attributes from the webGL context
  120185. */
  120186. unbindAllAttributes(): void;
  120187. /**
  120188. * 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
  120189. */
  120190. releaseEffects(): void;
  120191. /**
  120192. * Dispose and release all associated resources
  120193. */
  120194. dispose(): void;
  120195. /**
  120196. * Attach a new callback raised when context lost event is fired
  120197. * @param callback defines the callback to call
  120198. */
  120199. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120200. /**
  120201. * Attach a new callback raised when context restored event is fired
  120202. * @param callback defines the callback to call
  120203. */
  120204. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120205. /**
  120206. * Get the current error code of the webGL context
  120207. * @returns the error code
  120208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120209. */
  120210. getError(): number;
  120211. private _canRenderToFloatFramebuffer;
  120212. private _canRenderToHalfFloatFramebuffer;
  120213. private _canRenderToFramebuffer;
  120214. /** @hidden */
  120215. _getWebGLTextureType(type: number): number;
  120216. /** @hidden */
  120217. _getInternalFormat(format: number): number;
  120218. /** @hidden */
  120219. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120220. /** @hidden */
  120221. _getRGBAMultiSampleBufferFormat(type: number): number;
  120222. /** @hidden */
  120223. _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;
  120224. /**
  120225. * Loads a file from a url
  120226. * @param url url to load
  120227. * @param onSuccess callback called when the file successfully loads
  120228. * @param onProgress callback called while file is loading (if the server supports this mode)
  120229. * @param offlineProvider defines the offline provider for caching
  120230. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120231. * @param onError callback called when the file fails to load
  120232. * @returns a file request object
  120233. * @hidden
  120234. */
  120235. 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;
  120236. /**
  120237. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120238. * @param x defines the x coordinate of the rectangle where pixels must be read
  120239. * @param y defines the y coordinate of the rectangle where pixels must be read
  120240. * @param width defines the width of the rectangle where pixels must be read
  120241. * @param height defines the height of the rectangle where pixels must be read
  120242. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120243. * @returns a Uint8Array containing RGBA colors
  120244. */
  120245. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120246. private static _IsSupported;
  120247. private static _HasMajorPerformanceCaveat;
  120248. /**
  120249. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120250. */
  120251. static get IsSupported(): boolean;
  120252. /**
  120253. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120254. * @returns true if the engine can be created
  120255. * @ignorenaming
  120256. */
  120257. static isSupported(): boolean;
  120258. /**
  120259. * 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)
  120260. */
  120261. static get HasMajorPerformanceCaveat(): boolean;
  120262. /**
  120263. * Find the next highest power of two.
  120264. * @param x Number to start search from.
  120265. * @return Next highest power of two.
  120266. */
  120267. static CeilingPOT(x: number): number;
  120268. /**
  120269. * Find the next lowest power of two.
  120270. * @param x Number to start search from.
  120271. * @return Next lowest power of two.
  120272. */
  120273. static FloorPOT(x: number): number;
  120274. /**
  120275. * Find the nearest power of two.
  120276. * @param x Number to start search from.
  120277. * @return Next nearest power of two.
  120278. */
  120279. static NearestPOT(x: number): number;
  120280. /**
  120281. * Get the closest exponent of two
  120282. * @param value defines the value to approximate
  120283. * @param max defines the maximum value to return
  120284. * @param mode defines how to define the closest value
  120285. * @returns closest exponent of two of the given value
  120286. */
  120287. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120288. /**
  120289. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120290. * @param func - the function to be called
  120291. * @param requester - the object that will request the next frame. Falls back to window.
  120292. * @returns frame number
  120293. */
  120294. static QueueNewFrame(func: () => void, requester?: any): number;
  120295. /**
  120296. * Gets host document
  120297. * @returns the host document object
  120298. */
  120299. getHostDocument(): Nullable<Document>;
  120300. }
  120301. }
  120302. declare module BABYLON {
  120303. /**
  120304. * Defines the source of the internal texture
  120305. */
  120306. export enum InternalTextureSource {
  120307. /**
  120308. * The source of the texture data is unknown
  120309. */
  120310. Unknown = 0,
  120311. /**
  120312. * Texture data comes from an URL
  120313. */
  120314. Url = 1,
  120315. /**
  120316. * Texture data is only used for temporary storage
  120317. */
  120318. Temp = 2,
  120319. /**
  120320. * Texture data comes from raw data (ArrayBuffer)
  120321. */
  120322. Raw = 3,
  120323. /**
  120324. * Texture content is dynamic (video or dynamic texture)
  120325. */
  120326. Dynamic = 4,
  120327. /**
  120328. * Texture content is generated by rendering to it
  120329. */
  120330. RenderTarget = 5,
  120331. /**
  120332. * Texture content is part of a multi render target process
  120333. */
  120334. MultiRenderTarget = 6,
  120335. /**
  120336. * Texture data comes from a cube data file
  120337. */
  120338. Cube = 7,
  120339. /**
  120340. * Texture data comes from a raw cube data
  120341. */
  120342. CubeRaw = 8,
  120343. /**
  120344. * Texture data come from a prefiltered cube data file
  120345. */
  120346. CubePrefiltered = 9,
  120347. /**
  120348. * Texture content is raw 3D data
  120349. */
  120350. Raw3D = 10,
  120351. /**
  120352. * Texture content is raw 2D array data
  120353. */
  120354. Raw2DArray = 11,
  120355. /**
  120356. * Texture content is a depth texture
  120357. */
  120358. Depth = 12,
  120359. /**
  120360. * Texture data comes from a raw cube data encoded with RGBD
  120361. */
  120362. CubeRawRGBD = 13
  120363. }
  120364. /**
  120365. * Class used to store data associated with WebGL texture data for the engine
  120366. * This class should not be used directly
  120367. */
  120368. export class InternalTexture {
  120369. /** @hidden */
  120370. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120371. /**
  120372. * Defines if the texture is ready
  120373. */
  120374. isReady: boolean;
  120375. /**
  120376. * Defines if the texture is a cube texture
  120377. */
  120378. isCube: boolean;
  120379. /**
  120380. * Defines if the texture contains 3D data
  120381. */
  120382. is3D: boolean;
  120383. /**
  120384. * Defines if the texture contains 2D array data
  120385. */
  120386. is2DArray: boolean;
  120387. /**
  120388. * Defines if the texture contains multiview data
  120389. */
  120390. isMultiview: boolean;
  120391. /**
  120392. * Gets the URL used to load this texture
  120393. */
  120394. url: string;
  120395. /**
  120396. * Gets the sampling mode of the texture
  120397. */
  120398. samplingMode: number;
  120399. /**
  120400. * Gets a boolean indicating if the texture needs mipmaps generation
  120401. */
  120402. generateMipMaps: boolean;
  120403. /**
  120404. * Gets the number of samples used by the texture (WebGL2+ only)
  120405. */
  120406. samples: number;
  120407. /**
  120408. * Gets the type of the texture (int, float...)
  120409. */
  120410. type: number;
  120411. /**
  120412. * Gets the format of the texture (RGB, RGBA...)
  120413. */
  120414. format: number;
  120415. /**
  120416. * Observable called when the texture is loaded
  120417. */
  120418. onLoadedObservable: Observable<InternalTexture>;
  120419. /**
  120420. * Gets the width of the texture
  120421. */
  120422. width: number;
  120423. /**
  120424. * Gets the height of the texture
  120425. */
  120426. height: number;
  120427. /**
  120428. * Gets the depth of the texture
  120429. */
  120430. depth: number;
  120431. /**
  120432. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120433. */
  120434. baseWidth: number;
  120435. /**
  120436. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120437. */
  120438. baseHeight: number;
  120439. /**
  120440. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120441. */
  120442. baseDepth: number;
  120443. /**
  120444. * Gets a boolean indicating if the texture is inverted on Y axis
  120445. */
  120446. invertY: boolean;
  120447. /** @hidden */
  120448. _invertVScale: boolean;
  120449. /** @hidden */
  120450. _associatedChannel: number;
  120451. /** @hidden */
  120452. _source: InternalTextureSource;
  120453. /** @hidden */
  120454. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120455. /** @hidden */
  120456. _bufferView: Nullable<ArrayBufferView>;
  120457. /** @hidden */
  120458. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120459. /** @hidden */
  120460. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120461. /** @hidden */
  120462. _size: number;
  120463. /** @hidden */
  120464. _extension: string;
  120465. /** @hidden */
  120466. _files: Nullable<string[]>;
  120467. /** @hidden */
  120468. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120469. /** @hidden */
  120470. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120471. /** @hidden */
  120472. _framebuffer: Nullable<WebGLFramebuffer>;
  120473. /** @hidden */
  120474. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120475. /** @hidden */
  120476. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120477. /** @hidden */
  120478. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120479. /** @hidden */
  120480. _attachments: Nullable<number[]>;
  120481. /** @hidden */
  120482. _textureArray: Nullable<InternalTexture[]>;
  120483. /** @hidden */
  120484. _cachedCoordinatesMode: Nullable<number>;
  120485. /** @hidden */
  120486. _cachedWrapU: Nullable<number>;
  120487. /** @hidden */
  120488. _cachedWrapV: Nullable<number>;
  120489. /** @hidden */
  120490. _cachedWrapR: Nullable<number>;
  120491. /** @hidden */
  120492. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120493. /** @hidden */
  120494. _isDisabled: boolean;
  120495. /** @hidden */
  120496. _compression: Nullable<string>;
  120497. /** @hidden */
  120498. _generateStencilBuffer: boolean;
  120499. /** @hidden */
  120500. _generateDepthBuffer: boolean;
  120501. /** @hidden */
  120502. _comparisonFunction: number;
  120503. /** @hidden */
  120504. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120505. /** @hidden */
  120506. _lodGenerationScale: number;
  120507. /** @hidden */
  120508. _lodGenerationOffset: number;
  120509. /** @hidden */
  120510. _depthStencilTexture: Nullable<InternalTexture>;
  120511. /** @hidden */
  120512. _colorTextureArray: Nullable<WebGLTexture>;
  120513. /** @hidden */
  120514. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120515. /** @hidden */
  120516. _lodTextureHigh: Nullable<BaseTexture>;
  120517. /** @hidden */
  120518. _lodTextureMid: Nullable<BaseTexture>;
  120519. /** @hidden */
  120520. _lodTextureLow: Nullable<BaseTexture>;
  120521. /** @hidden */
  120522. _isRGBD: boolean;
  120523. /** @hidden */
  120524. _linearSpecularLOD: boolean;
  120525. /** @hidden */
  120526. _irradianceTexture: Nullable<BaseTexture>;
  120527. /** @hidden */
  120528. _webGLTexture: Nullable<WebGLTexture>;
  120529. /** @hidden */
  120530. _references: number;
  120531. /** @hidden */
  120532. _gammaSpace: Nullable<boolean>;
  120533. private _engine;
  120534. /**
  120535. * Gets the Engine the texture belongs to.
  120536. * @returns The babylon engine
  120537. */
  120538. getEngine(): ThinEngine;
  120539. /**
  120540. * Gets the data source type of the texture
  120541. */
  120542. get source(): InternalTextureSource;
  120543. /**
  120544. * Creates a new InternalTexture
  120545. * @param engine defines the engine to use
  120546. * @param source defines the type of data that will be used
  120547. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120548. */
  120549. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120550. /**
  120551. * Increments the number of references (ie. the number of Texture that point to it)
  120552. */
  120553. incrementReferences(): void;
  120554. /**
  120555. * Change the size of the texture (not the size of the content)
  120556. * @param width defines the new width
  120557. * @param height defines the new height
  120558. * @param depth defines the new depth (1 by default)
  120559. */
  120560. updateSize(width: int, height: int, depth?: int): void;
  120561. /** @hidden */
  120562. _rebuild(): void;
  120563. /** @hidden */
  120564. _swapAndDie(target: InternalTexture): void;
  120565. /**
  120566. * Dispose the current allocated resources
  120567. */
  120568. dispose(): void;
  120569. }
  120570. }
  120571. declare module BABYLON {
  120572. /**
  120573. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120574. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120575. */
  120576. export class Analyser {
  120577. /**
  120578. * Gets or sets the smoothing
  120579. * @ignorenaming
  120580. */
  120581. SMOOTHING: number;
  120582. /**
  120583. * Gets or sets the FFT table size
  120584. * @ignorenaming
  120585. */
  120586. FFT_SIZE: number;
  120587. /**
  120588. * Gets or sets the bar graph amplitude
  120589. * @ignorenaming
  120590. */
  120591. BARGRAPHAMPLITUDE: number;
  120592. /**
  120593. * Gets or sets the position of the debug canvas
  120594. * @ignorenaming
  120595. */
  120596. DEBUGCANVASPOS: {
  120597. x: number;
  120598. y: number;
  120599. };
  120600. /**
  120601. * Gets or sets the debug canvas size
  120602. * @ignorenaming
  120603. */
  120604. DEBUGCANVASSIZE: {
  120605. width: number;
  120606. height: number;
  120607. };
  120608. private _byteFreqs;
  120609. private _byteTime;
  120610. private _floatFreqs;
  120611. private _webAudioAnalyser;
  120612. private _debugCanvas;
  120613. private _debugCanvasContext;
  120614. private _scene;
  120615. private _registerFunc;
  120616. private _audioEngine;
  120617. /**
  120618. * Creates a new analyser
  120619. * @param scene defines hosting scene
  120620. */
  120621. constructor(scene: Scene);
  120622. /**
  120623. * Get the number of data values you will have to play with for the visualization
  120624. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120625. * @returns a number
  120626. */
  120627. getFrequencyBinCount(): number;
  120628. /**
  120629. * Gets the current frequency data as a byte array
  120630. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120631. * @returns a Uint8Array
  120632. */
  120633. getByteFrequencyData(): Uint8Array;
  120634. /**
  120635. * Gets the current waveform as a byte array
  120636. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120637. * @returns a Uint8Array
  120638. */
  120639. getByteTimeDomainData(): Uint8Array;
  120640. /**
  120641. * Gets the current frequency data as a float array
  120642. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120643. * @returns a Float32Array
  120644. */
  120645. getFloatFrequencyData(): Float32Array;
  120646. /**
  120647. * Renders the debug canvas
  120648. */
  120649. drawDebugCanvas(): void;
  120650. /**
  120651. * Stops rendering the debug canvas and removes it
  120652. */
  120653. stopDebugCanvas(): void;
  120654. /**
  120655. * Connects two audio nodes
  120656. * @param inputAudioNode defines first node to connect
  120657. * @param outputAudioNode defines second node to connect
  120658. */
  120659. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120660. /**
  120661. * Releases all associated resources
  120662. */
  120663. dispose(): void;
  120664. }
  120665. }
  120666. declare module BABYLON {
  120667. /**
  120668. * This represents an audio engine and it is responsible
  120669. * to play, synchronize and analyse sounds throughout the application.
  120670. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120671. */
  120672. export interface IAudioEngine extends IDisposable {
  120673. /**
  120674. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120675. */
  120676. readonly canUseWebAudio: boolean;
  120677. /**
  120678. * Gets the current AudioContext if available.
  120679. */
  120680. readonly audioContext: Nullable<AudioContext>;
  120681. /**
  120682. * The master gain node defines the global audio volume of your audio engine.
  120683. */
  120684. readonly masterGain: GainNode;
  120685. /**
  120686. * Gets whether or not mp3 are supported by your browser.
  120687. */
  120688. readonly isMP3supported: boolean;
  120689. /**
  120690. * Gets whether or not ogg are supported by your browser.
  120691. */
  120692. readonly isOGGsupported: boolean;
  120693. /**
  120694. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120695. * @ignoreNaming
  120696. */
  120697. WarnedWebAudioUnsupported: boolean;
  120698. /**
  120699. * Defines if the audio engine relies on a custom unlocked button.
  120700. * In this case, the embedded button will not be displayed.
  120701. */
  120702. useCustomUnlockedButton: boolean;
  120703. /**
  120704. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120705. */
  120706. readonly unlocked: boolean;
  120707. /**
  120708. * Event raised when audio has been unlocked on the browser.
  120709. */
  120710. onAudioUnlockedObservable: Observable<AudioEngine>;
  120711. /**
  120712. * Event raised when audio has been locked on the browser.
  120713. */
  120714. onAudioLockedObservable: Observable<AudioEngine>;
  120715. /**
  120716. * Flags the audio engine in Locked state.
  120717. * This happens due to new browser policies preventing audio to autoplay.
  120718. */
  120719. lock(): void;
  120720. /**
  120721. * Unlocks the audio engine once a user action has been done on the dom.
  120722. * This is helpful to resume play once browser policies have been satisfied.
  120723. */
  120724. unlock(): void;
  120725. /**
  120726. * Gets the global volume sets on the master gain.
  120727. * @returns the global volume if set or -1 otherwise
  120728. */
  120729. getGlobalVolume(): number;
  120730. /**
  120731. * Sets the global volume of your experience (sets on the master gain).
  120732. * @param newVolume Defines the new global volume of the application
  120733. */
  120734. setGlobalVolume(newVolume: number): void;
  120735. /**
  120736. * Connect the audio engine to an audio analyser allowing some amazing
  120737. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120739. * @param analyser The analyser to connect to the engine
  120740. */
  120741. connectToAnalyser(analyser: Analyser): void;
  120742. }
  120743. /**
  120744. * This represents the default audio engine used in babylon.
  120745. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120746. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120747. */
  120748. export class AudioEngine implements IAudioEngine {
  120749. private _audioContext;
  120750. private _audioContextInitialized;
  120751. private _muteButton;
  120752. private _hostElement;
  120753. /**
  120754. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120755. */
  120756. canUseWebAudio: boolean;
  120757. /**
  120758. * The master gain node defines the global audio volume of your audio engine.
  120759. */
  120760. masterGain: GainNode;
  120761. /**
  120762. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120763. * @ignoreNaming
  120764. */
  120765. WarnedWebAudioUnsupported: boolean;
  120766. /**
  120767. * Gets whether or not mp3 are supported by your browser.
  120768. */
  120769. isMP3supported: boolean;
  120770. /**
  120771. * Gets whether or not ogg are supported by your browser.
  120772. */
  120773. isOGGsupported: boolean;
  120774. /**
  120775. * Gets whether audio has been unlocked on the device.
  120776. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120777. * a user interaction has happened.
  120778. */
  120779. unlocked: boolean;
  120780. /**
  120781. * Defines if the audio engine relies on a custom unlocked button.
  120782. * In this case, the embedded button will not be displayed.
  120783. */
  120784. useCustomUnlockedButton: boolean;
  120785. /**
  120786. * Event raised when audio has been unlocked on the browser.
  120787. */
  120788. onAudioUnlockedObservable: Observable<AudioEngine>;
  120789. /**
  120790. * Event raised when audio has been locked on the browser.
  120791. */
  120792. onAudioLockedObservable: Observable<AudioEngine>;
  120793. /**
  120794. * Gets the current AudioContext if available.
  120795. */
  120796. get audioContext(): Nullable<AudioContext>;
  120797. private _connectedAnalyser;
  120798. /**
  120799. * Instantiates a new audio engine.
  120800. *
  120801. * There should be only one per page as some browsers restrict the number
  120802. * of audio contexts you can create.
  120803. * @param hostElement defines the host element where to display the mute icon if necessary
  120804. */
  120805. constructor(hostElement?: Nullable<HTMLElement>);
  120806. /**
  120807. * Flags the audio engine in Locked state.
  120808. * This happens due to new browser policies preventing audio to autoplay.
  120809. */
  120810. lock(): void;
  120811. /**
  120812. * Unlocks the audio engine once a user action has been done on the dom.
  120813. * This is helpful to resume play once browser policies have been satisfied.
  120814. */
  120815. unlock(): void;
  120816. private _resumeAudioContext;
  120817. private _initializeAudioContext;
  120818. private _tryToRun;
  120819. private _triggerRunningState;
  120820. private _triggerSuspendedState;
  120821. private _displayMuteButton;
  120822. private _moveButtonToTopLeft;
  120823. private _onResize;
  120824. private _hideMuteButton;
  120825. /**
  120826. * Destroy and release the resources associated with the audio ccontext.
  120827. */
  120828. dispose(): void;
  120829. /**
  120830. * Gets the global volume sets on the master gain.
  120831. * @returns the global volume if set or -1 otherwise
  120832. */
  120833. getGlobalVolume(): number;
  120834. /**
  120835. * Sets the global volume of your experience (sets on the master gain).
  120836. * @param newVolume Defines the new global volume of the application
  120837. */
  120838. setGlobalVolume(newVolume: number): void;
  120839. /**
  120840. * Connect the audio engine to an audio analyser allowing some amazing
  120841. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120843. * @param analyser The analyser to connect to the engine
  120844. */
  120845. connectToAnalyser(analyser: Analyser): void;
  120846. }
  120847. }
  120848. declare module BABYLON {
  120849. /**
  120850. * Interface used to present a loading screen while loading a scene
  120851. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120852. */
  120853. export interface ILoadingScreen {
  120854. /**
  120855. * Function called to display the loading screen
  120856. */
  120857. displayLoadingUI: () => void;
  120858. /**
  120859. * Function called to hide the loading screen
  120860. */
  120861. hideLoadingUI: () => void;
  120862. /**
  120863. * Gets or sets the color to use for the background
  120864. */
  120865. loadingUIBackgroundColor: string;
  120866. /**
  120867. * Gets or sets the text to display while loading
  120868. */
  120869. loadingUIText: string;
  120870. }
  120871. /**
  120872. * Class used for the default loading screen
  120873. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120874. */
  120875. export class DefaultLoadingScreen implements ILoadingScreen {
  120876. private _renderingCanvas;
  120877. private _loadingText;
  120878. private _loadingDivBackgroundColor;
  120879. private _loadingDiv;
  120880. private _loadingTextDiv;
  120881. /** Gets or sets the logo url to use for the default loading screen */
  120882. static DefaultLogoUrl: string;
  120883. /** Gets or sets the spinner url to use for the default loading screen */
  120884. static DefaultSpinnerUrl: string;
  120885. /**
  120886. * Creates a new default loading screen
  120887. * @param _renderingCanvas defines the canvas used to render the scene
  120888. * @param _loadingText defines the default text to display
  120889. * @param _loadingDivBackgroundColor defines the default background color
  120890. */
  120891. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120892. /**
  120893. * Function called to display the loading screen
  120894. */
  120895. displayLoadingUI(): void;
  120896. /**
  120897. * Function called to hide the loading screen
  120898. */
  120899. hideLoadingUI(): void;
  120900. /**
  120901. * Gets or sets the text to display while loading
  120902. */
  120903. set loadingUIText(text: string);
  120904. get loadingUIText(): string;
  120905. /**
  120906. * Gets or sets the color to use for the background
  120907. */
  120908. get loadingUIBackgroundColor(): string;
  120909. set loadingUIBackgroundColor(color: string);
  120910. private _resizeLoadingUI;
  120911. }
  120912. }
  120913. declare module BABYLON {
  120914. /**
  120915. * Interface for any object that can request an animation frame
  120916. */
  120917. export interface ICustomAnimationFrameRequester {
  120918. /**
  120919. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120920. */
  120921. renderFunction?: Function;
  120922. /**
  120923. * Called to request the next frame to render to
  120924. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120925. */
  120926. requestAnimationFrame: Function;
  120927. /**
  120928. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120929. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120930. */
  120931. requestID?: number;
  120932. }
  120933. }
  120934. declare module BABYLON {
  120935. /**
  120936. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120937. */
  120938. export class PerformanceMonitor {
  120939. private _enabled;
  120940. private _rollingFrameTime;
  120941. private _lastFrameTimeMs;
  120942. /**
  120943. * constructor
  120944. * @param frameSampleSize The number of samples required to saturate the sliding window
  120945. */
  120946. constructor(frameSampleSize?: number);
  120947. /**
  120948. * Samples current frame
  120949. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120950. */
  120951. sampleFrame(timeMs?: number): void;
  120952. /**
  120953. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120954. */
  120955. get averageFrameTime(): number;
  120956. /**
  120957. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120958. */
  120959. get averageFrameTimeVariance(): number;
  120960. /**
  120961. * Returns the frame time of the most recent frame
  120962. */
  120963. get instantaneousFrameTime(): number;
  120964. /**
  120965. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120966. */
  120967. get averageFPS(): number;
  120968. /**
  120969. * Returns the average framerate in frames per second using the most recent frame time
  120970. */
  120971. get instantaneousFPS(): number;
  120972. /**
  120973. * Returns true if enough samples have been taken to completely fill the sliding window
  120974. */
  120975. get isSaturated(): boolean;
  120976. /**
  120977. * Enables contributions to the sliding window sample set
  120978. */
  120979. enable(): void;
  120980. /**
  120981. * Disables contributions to the sliding window sample set
  120982. * Samples will not be interpolated over the disabled period
  120983. */
  120984. disable(): void;
  120985. /**
  120986. * Returns true if sampling is enabled
  120987. */
  120988. get isEnabled(): boolean;
  120989. /**
  120990. * Resets performance monitor
  120991. */
  120992. reset(): void;
  120993. }
  120994. /**
  120995. * RollingAverage
  120996. *
  120997. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  120998. */
  120999. export class RollingAverage {
  121000. /**
  121001. * Current average
  121002. */
  121003. average: number;
  121004. /**
  121005. * Current variance
  121006. */
  121007. variance: number;
  121008. protected _samples: Array<number>;
  121009. protected _sampleCount: number;
  121010. protected _pos: number;
  121011. protected _m2: number;
  121012. /**
  121013. * constructor
  121014. * @param length The number of samples required to saturate the sliding window
  121015. */
  121016. constructor(length: number);
  121017. /**
  121018. * Adds a sample to the sample set
  121019. * @param v The sample value
  121020. */
  121021. add(v: number): void;
  121022. /**
  121023. * Returns previously added values or null if outside of history or outside the sliding window domain
  121024. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121025. * @return Value previously recorded with add() or null if outside of range
  121026. */
  121027. history(i: number): number;
  121028. /**
  121029. * Returns true if enough samples have been taken to completely fill the sliding window
  121030. * @return true if sample-set saturated
  121031. */
  121032. isSaturated(): boolean;
  121033. /**
  121034. * Resets the rolling average (equivalent to 0 samples taken so far)
  121035. */
  121036. reset(): void;
  121037. /**
  121038. * Wraps a value around the sample range boundaries
  121039. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121040. * @return Wrapped position in sample range
  121041. */
  121042. protected _wrapPosition(i: number): number;
  121043. }
  121044. }
  121045. declare module BABYLON {
  121046. /**
  121047. * This class is used to track a performance counter which is number based.
  121048. * The user has access to many properties which give statistics of different nature.
  121049. *
  121050. * The implementer can track two kinds of Performance Counter: time and count.
  121051. * 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.
  121052. * 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.
  121053. */
  121054. export class PerfCounter {
  121055. /**
  121056. * Gets or sets a global boolean to turn on and off all the counters
  121057. */
  121058. static Enabled: boolean;
  121059. /**
  121060. * Returns the smallest value ever
  121061. */
  121062. get min(): number;
  121063. /**
  121064. * Returns the biggest value ever
  121065. */
  121066. get max(): number;
  121067. /**
  121068. * Returns the average value since the performance counter is running
  121069. */
  121070. get average(): number;
  121071. /**
  121072. * Returns the average value of the last second the counter was monitored
  121073. */
  121074. get lastSecAverage(): number;
  121075. /**
  121076. * Returns the current value
  121077. */
  121078. get current(): number;
  121079. /**
  121080. * Gets the accumulated total
  121081. */
  121082. get total(): number;
  121083. /**
  121084. * Gets the total value count
  121085. */
  121086. get count(): number;
  121087. /**
  121088. * Creates a new counter
  121089. */
  121090. constructor();
  121091. /**
  121092. * Call this method to start monitoring a new frame.
  121093. * 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.
  121094. */
  121095. fetchNewFrame(): void;
  121096. /**
  121097. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121098. * @param newCount the count value to add to the monitored count
  121099. * @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.
  121100. */
  121101. addCount(newCount: number, fetchResult: boolean): void;
  121102. /**
  121103. * Start monitoring this performance counter
  121104. */
  121105. beginMonitoring(): void;
  121106. /**
  121107. * Compute the time lapsed since the previous beginMonitoring() call.
  121108. * @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
  121109. */
  121110. endMonitoring(newFrame?: boolean): void;
  121111. private _fetchResult;
  121112. private _startMonitoringTime;
  121113. private _min;
  121114. private _max;
  121115. private _average;
  121116. private _current;
  121117. private _totalValueCount;
  121118. private _totalAccumulated;
  121119. private _lastSecAverage;
  121120. private _lastSecAccumulated;
  121121. private _lastSecTime;
  121122. private _lastSecValueCount;
  121123. }
  121124. }
  121125. declare module BABYLON {
  121126. interface ThinEngine {
  121127. /** @hidden */
  121128. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121129. }
  121130. }
  121131. declare module BABYLON {
  121132. /**
  121133. * Defines the interface used by display changed events
  121134. */
  121135. export interface IDisplayChangedEventArgs {
  121136. /** Gets the vrDisplay object (if any) */
  121137. vrDisplay: Nullable<any>;
  121138. /** Gets a boolean indicating if webVR is supported */
  121139. vrSupported: boolean;
  121140. }
  121141. /**
  121142. * Defines the interface used by objects containing a viewport (like a camera)
  121143. */
  121144. interface IViewportOwnerLike {
  121145. /**
  121146. * Gets or sets the viewport
  121147. */
  121148. viewport: IViewportLike;
  121149. }
  121150. /**
  121151. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121152. */
  121153. export class Engine extends ThinEngine {
  121154. /** Defines that alpha blending is disabled */
  121155. static readonly ALPHA_DISABLE: number;
  121156. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121157. static readonly ALPHA_ADD: number;
  121158. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121159. static readonly ALPHA_COMBINE: number;
  121160. /** Defines that alpha blending to DEST - SRC * DEST */
  121161. static readonly ALPHA_SUBTRACT: number;
  121162. /** Defines that alpha blending to SRC * DEST */
  121163. static readonly ALPHA_MULTIPLY: number;
  121164. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121165. static readonly ALPHA_MAXIMIZED: number;
  121166. /** Defines that alpha blending to SRC + DEST */
  121167. static readonly ALPHA_ONEONE: number;
  121168. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121169. static readonly ALPHA_PREMULTIPLIED: number;
  121170. /**
  121171. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121172. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121173. */
  121174. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121175. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121176. static readonly ALPHA_INTERPOLATE: number;
  121177. /**
  121178. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121179. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121180. */
  121181. static readonly ALPHA_SCREENMODE: number;
  121182. /** Defines that the ressource is not delayed*/
  121183. static readonly DELAYLOADSTATE_NONE: number;
  121184. /** Defines that the ressource was successfully delay loaded */
  121185. static readonly DELAYLOADSTATE_LOADED: number;
  121186. /** Defines that the ressource is currently delay loading */
  121187. static readonly DELAYLOADSTATE_LOADING: number;
  121188. /** Defines that the ressource is delayed and has not started loading */
  121189. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121190. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121191. static readonly NEVER: number;
  121192. /** 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 */
  121193. static readonly ALWAYS: number;
  121194. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121195. static readonly LESS: number;
  121196. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121197. static readonly EQUAL: number;
  121198. /** 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 */
  121199. static readonly LEQUAL: number;
  121200. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121201. static readonly GREATER: number;
  121202. /** 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 */
  121203. static readonly GEQUAL: number;
  121204. /** 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 */
  121205. static readonly NOTEQUAL: number;
  121206. /** Passed to stencilOperation to specify that stencil value must be kept */
  121207. static readonly KEEP: number;
  121208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121209. static readonly REPLACE: number;
  121210. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121211. static readonly INCR: number;
  121212. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121213. static readonly DECR: number;
  121214. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121215. static readonly INVERT: number;
  121216. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121217. static readonly INCR_WRAP: number;
  121218. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121219. static readonly DECR_WRAP: number;
  121220. /** Texture is not repeating outside of 0..1 UVs */
  121221. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121222. /** Texture is repeating outside of 0..1 UVs */
  121223. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121224. /** Texture is repeating and mirrored */
  121225. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121226. /** ALPHA */
  121227. static readonly TEXTUREFORMAT_ALPHA: number;
  121228. /** LUMINANCE */
  121229. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121230. /** LUMINANCE_ALPHA */
  121231. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121232. /** RGB */
  121233. static readonly TEXTUREFORMAT_RGB: number;
  121234. /** RGBA */
  121235. static readonly TEXTUREFORMAT_RGBA: number;
  121236. /** RED */
  121237. static readonly TEXTUREFORMAT_RED: number;
  121238. /** RED (2nd reference) */
  121239. static readonly TEXTUREFORMAT_R: number;
  121240. /** RG */
  121241. static readonly TEXTUREFORMAT_RG: number;
  121242. /** RED_INTEGER */
  121243. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121244. /** RED_INTEGER (2nd reference) */
  121245. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121246. /** RG_INTEGER */
  121247. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121248. /** RGB_INTEGER */
  121249. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121250. /** RGBA_INTEGER */
  121251. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121252. /** UNSIGNED_BYTE */
  121253. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121254. /** UNSIGNED_BYTE (2nd reference) */
  121255. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121256. /** FLOAT */
  121257. static readonly TEXTURETYPE_FLOAT: number;
  121258. /** HALF_FLOAT */
  121259. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121260. /** BYTE */
  121261. static readonly TEXTURETYPE_BYTE: number;
  121262. /** SHORT */
  121263. static readonly TEXTURETYPE_SHORT: number;
  121264. /** UNSIGNED_SHORT */
  121265. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121266. /** INT */
  121267. static readonly TEXTURETYPE_INT: number;
  121268. /** UNSIGNED_INT */
  121269. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121270. /** UNSIGNED_SHORT_4_4_4_4 */
  121271. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121272. /** UNSIGNED_SHORT_5_5_5_1 */
  121273. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121274. /** UNSIGNED_SHORT_5_6_5 */
  121275. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121276. /** UNSIGNED_INT_2_10_10_10_REV */
  121277. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121278. /** UNSIGNED_INT_24_8 */
  121279. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121280. /** UNSIGNED_INT_10F_11F_11F_REV */
  121281. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121282. /** UNSIGNED_INT_5_9_9_9_REV */
  121283. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121284. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121285. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121286. /** nearest is mag = nearest and min = nearest and mip = linear */
  121287. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121288. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121289. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121290. /** Trilinear is mag = linear and min = linear and mip = linear */
  121291. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121292. /** nearest is mag = nearest and min = nearest and mip = linear */
  121293. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121294. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121295. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121296. /** Trilinear is mag = linear and min = linear and mip = linear */
  121297. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121298. /** mag = nearest and min = nearest and mip = nearest */
  121299. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121300. /** mag = nearest and min = linear and mip = nearest */
  121301. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121302. /** mag = nearest and min = linear and mip = linear */
  121303. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121304. /** mag = nearest and min = linear and mip = none */
  121305. static readonly TEXTURE_NEAREST_LINEAR: number;
  121306. /** mag = nearest and min = nearest and mip = none */
  121307. static readonly TEXTURE_NEAREST_NEAREST: number;
  121308. /** mag = linear and min = nearest and mip = nearest */
  121309. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121310. /** mag = linear and min = nearest and mip = linear */
  121311. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121312. /** mag = linear and min = linear and mip = none */
  121313. static readonly TEXTURE_LINEAR_LINEAR: number;
  121314. /** mag = linear and min = nearest and mip = none */
  121315. static readonly TEXTURE_LINEAR_NEAREST: number;
  121316. /** Explicit coordinates mode */
  121317. static readonly TEXTURE_EXPLICIT_MODE: number;
  121318. /** Spherical coordinates mode */
  121319. static readonly TEXTURE_SPHERICAL_MODE: number;
  121320. /** Planar coordinates mode */
  121321. static readonly TEXTURE_PLANAR_MODE: number;
  121322. /** Cubic coordinates mode */
  121323. static readonly TEXTURE_CUBIC_MODE: number;
  121324. /** Projection coordinates mode */
  121325. static readonly TEXTURE_PROJECTION_MODE: number;
  121326. /** Skybox coordinates mode */
  121327. static readonly TEXTURE_SKYBOX_MODE: number;
  121328. /** Inverse Cubic coordinates mode */
  121329. static readonly TEXTURE_INVCUBIC_MODE: number;
  121330. /** Equirectangular coordinates mode */
  121331. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121332. /** Equirectangular Fixed coordinates mode */
  121333. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121334. /** Equirectangular Fixed Mirrored coordinates mode */
  121335. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121336. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121337. static readonly SCALEMODE_FLOOR: number;
  121338. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121339. static readonly SCALEMODE_NEAREST: number;
  121340. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121341. static readonly SCALEMODE_CEILING: number;
  121342. /**
  121343. * Returns the current npm package of the sdk
  121344. */
  121345. static get NpmPackage(): string;
  121346. /**
  121347. * Returns the current version of the framework
  121348. */
  121349. static get Version(): string;
  121350. /** Gets the list of created engines */
  121351. static get Instances(): Engine[];
  121352. /**
  121353. * Gets the latest created engine
  121354. */
  121355. static get LastCreatedEngine(): Nullable<Engine>;
  121356. /**
  121357. * Gets the latest created scene
  121358. */
  121359. static get LastCreatedScene(): Nullable<Scene>;
  121360. /**
  121361. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121362. * @param flag defines which part of the materials must be marked as dirty
  121363. * @param predicate defines a predicate used to filter which materials should be affected
  121364. */
  121365. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121366. /**
  121367. * Method called to create the default loading screen.
  121368. * This can be overriden in your own app.
  121369. * @param canvas The rendering canvas element
  121370. * @returns The loading screen
  121371. */
  121372. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121373. /**
  121374. * Method called to create the default rescale post process on each engine.
  121375. */
  121376. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121377. /**
  121378. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121379. **/
  121380. enableOfflineSupport: boolean;
  121381. /**
  121382. * 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)
  121383. **/
  121384. disableManifestCheck: boolean;
  121385. /**
  121386. * Gets the list of created scenes
  121387. */
  121388. scenes: Scene[];
  121389. /**
  121390. * Event raised when a new scene is created
  121391. */
  121392. onNewSceneAddedObservable: Observable<Scene>;
  121393. /**
  121394. * Gets the list of created postprocesses
  121395. */
  121396. postProcesses: PostProcess[];
  121397. /**
  121398. * Gets a boolean indicating if the pointer is currently locked
  121399. */
  121400. isPointerLock: boolean;
  121401. /**
  121402. * Observable event triggered each time the rendering canvas is resized
  121403. */
  121404. onResizeObservable: Observable<Engine>;
  121405. /**
  121406. * Observable event triggered each time the canvas loses focus
  121407. */
  121408. onCanvasBlurObservable: Observable<Engine>;
  121409. /**
  121410. * Observable event triggered each time the canvas gains focus
  121411. */
  121412. onCanvasFocusObservable: Observable<Engine>;
  121413. /**
  121414. * Observable event triggered each time the canvas receives pointerout event
  121415. */
  121416. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121417. /**
  121418. * Observable raised when the engine begins a new frame
  121419. */
  121420. onBeginFrameObservable: Observable<Engine>;
  121421. /**
  121422. * If set, will be used to request the next animation frame for the render loop
  121423. */
  121424. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121425. /**
  121426. * Observable raised when the engine ends the current frame
  121427. */
  121428. onEndFrameObservable: Observable<Engine>;
  121429. /**
  121430. * Observable raised when the engine is about to compile a shader
  121431. */
  121432. onBeforeShaderCompilationObservable: Observable<Engine>;
  121433. /**
  121434. * Observable raised when the engine has jsut compiled a shader
  121435. */
  121436. onAfterShaderCompilationObservable: Observable<Engine>;
  121437. /**
  121438. * Gets the audio engine
  121439. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121440. * @ignorenaming
  121441. */
  121442. static audioEngine: IAudioEngine;
  121443. /**
  121444. * Default AudioEngine factory responsible of creating the Audio Engine.
  121445. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121446. */
  121447. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121448. /**
  121449. * Default offline support factory responsible of creating a tool used to store data locally.
  121450. * By default, this will create a Database object if the workload has been embedded.
  121451. */
  121452. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121453. private _loadingScreen;
  121454. private _pointerLockRequested;
  121455. private _rescalePostProcess;
  121456. private _deterministicLockstep;
  121457. private _lockstepMaxSteps;
  121458. private _timeStep;
  121459. protected get _supportsHardwareTextureRescaling(): boolean;
  121460. private _fps;
  121461. private _deltaTime;
  121462. /** @hidden */
  121463. _drawCalls: PerfCounter;
  121464. /** 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 */
  121465. canvasTabIndex: number;
  121466. /**
  121467. * Turn this value on if you want to pause FPS computation when in background
  121468. */
  121469. disablePerformanceMonitorInBackground: boolean;
  121470. private _performanceMonitor;
  121471. /**
  121472. * Gets the performance monitor attached to this engine
  121473. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121474. */
  121475. get performanceMonitor(): PerformanceMonitor;
  121476. private _onFocus;
  121477. private _onBlur;
  121478. private _onCanvasPointerOut;
  121479. private _onCanvasBlur;
  121480. private _onCanvasFocus;
  121481. private _onFullscreenChange;
  121482. private _onPointerLockChange;
  121483. /**
  121484. * Gets the HTML element used to attach event listeners
  121485. * @returns a HTML element
  121486. */
  121487. getInputElement(): Nullable<HTMLElement>;
  121488. /**
  121489. * Creates a new engine
  121490. * @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
  121491. * @param antialias defines enable antialiasing (default: false)
  121492. * @param options defines further options to be sent to the getContext() function
  121493. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121494. */
  121495. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121496. /**
  121497. * Gets current aspect ratio
  121498. * @param viewportOwner defines the camera to use to get the aspect ratio
  121499. * @param useScreen defines if screen size must be used (or the current render target if any)
  121500. * @returns a number defining the aspect ratio
  121501. */
  121502. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121503. /**
  121504. * Gets current screen aspect ratio
  121505. * @returns a number defining the aspect ratio
  121506. */
  121507. getScreenAspectRatio(): number;
  121508. /**
  121509. * Gets the client rect of the HTML canvas attached with the current webGL context
  121510. * @returns a client rectanglee
  121511. */
  121512. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121513. /**
  121514. * Gets the client rect of the HTML element used for events
  121515. * @returns a client rectanglee
  121516. */
  121517. getInputElementClientRect(): Nullable<ClientRect>;
  121518. /**
  121519. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121520. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121521. * @returns true if engine is in deterministic lock step mode
  121522. */
  121523. isDeterministicLockStep(): boolean;
  121524. /**
  121525. * Gets the max steps when engine is running in deterministic lock step
  121526. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121527. * @returns the max steps
  121528. */
  121529. getLockstepMaxSteps(): number;
  121530. /**
  121531. * Returns the time in ms between steps when using deterministic lock step.
  121532. * @returns time step in (ms)
  121533. */
  121534. getTimeStep(): number;
  121535. /**
  121536. * Force the mipmap generation for the given render target texture
  121537. * @param texture defines the render target texture to use
  121538. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121539. */
  121540. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121541. /** States */
  121542. /**
  121543. * Set various states to the webGL context
  121544. * @param culling defines backface culling state
  121545. * @param zOffset defines the value to apply to zOffset (0 by default)
  121546. * @param force defines if states must be applied even if cache is up to date
  121547. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121548. */
  121549. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121550. /**
  121551. * Set the z offset to apply to current rendering
  121552. * @param value defines the offset to apply
  121553. */
  121554. setZOffset(value: number): void;
  121555. /**
  121556. * Gets the current value of the zOffset
  121557. * @returns the current zOffset state
  121558. */
  121559. getZOffset(): number;
  121560. /**
  121561. * Enable or disable depth buffering
  121562. * @param enable defines the state to set
  121563. */
  121564. setDepthBuffer(enable: boolean): void;
  121565. /**
  121566. * Gets a boolean indicating if depth writing is enabled
  121567. * @returns the current depth writing state
  121568. */
  121569. getDepthWrite(): boolean;
  121570. /**
  121571. * Enable or disable depth writing
  121572. * @param enable defines the state to set
  121573. */
  121574. setDepthWrite(enable: boolean): void;
  121575. /**
  121576. * Gets a boolean indicating if stencil buffer is enabled
  121577. * @returns the current stencil buffer state
  121578. */
  121579. getStencilBuffer(): boolean;
  121580. /**
  121581. * Enable or disable the stencil buffer
  121582. * @param enable defines if the stencil buffer must be enabled or disabled
  121583. */
  121584. setStencilBuffer(enable: boolean): void;
  121585. /**
  121586. * Gets the current stencil mask
  121587. * @returns a number defining the new stencil mask to use
  121588. */
  121589. getStencilMask(): number;
  121590. /**
  121591. * Sets the current stencil mask
  121592. * @param mask defines the new stencil mask to use
  121593. */
  121594. setStencilMask(mask: number): void;
  121595. /**
  121596. * Gets the current stencil function
  121597. * @returns a number defining the stencil function to use
  121598. */
  121599. getStencilFunction(): number;
  121600. /**
  121601. * Gets the current stencil reference value
  121602. * @returns a number defining the stencil reference value to use
  121603. */
  121604. getStencilFunctionReference(): number;
  121605. /**
  121606. * Gets the current stencil mask
  121607. * @returns a number defining the stencil mask to use
  121608. */
  121609. getStencilFunctionMask(): number;
  121610. /**
  121611. * Sets the current stencil function
  121612. * @param stencilFunc defines the new stencil function to use
  121613. */
  121614. setStencilFunction(stencilFunc: number): void;
  121615. /**
  121616. * Sets the current stencil reference
  121617. * @param reference defines the new stencil reference to use
  121618. */
  121619. setStencilFunctionReference(reference: number): void;
  121620. /**
  121621. * Sets the current stencil mask
  121622. * @param mask defines the new stencil mask to use
  121623. */
  121624. setStencilFunctionMask(mask: number): void;
  121625. /**
  121626. * Gets the current stencil operation when stencil fails
  121627. * @returns a number defining stencil operation to use when stencil fails
  121628. */
  121629. getStencilOperationFail(): number;
  121630. /**
  121631. * Gets the current stencil operation when depth fails
  121632. * @returns a number defining stencil operation to use when depth fails
  121633. */
  121634. getStencilOperationDepthFail(): number;
  121635. /**
  121636. * Gets the current stencil operation when stencil passes
  121637. * @returns a number defining stencil operation to use when stencil passes
  121638. */
  121639. getStencilOperationPass(): number;
  121640. /**
  121641. * Sets the stencil operation to use when stencil fails
  121642. * @param operation defines the stencil operation to use when stencil fails
  121643. */
  121644. setStencilOperationFail(operation: number): void;
  121645. /**
  121646. * Sets the stencil operation to use when depth fails
  121647. * @param operation defines the stencil operation to use when depth fails
  121648. */
  121649. setStencilOperationDepthFail(operation: number): void;
  121650. /**
  121651. * Sets the stencil operation to use when stencil passes
  121652. * @param operation defines the stencil operation to use when stencil passes
  121653. */
  121654. setStencilOperationPass(operation: number): void;
  121655. /**
  121656. * Sets a boolean indicating if the dithering state is enabled or disabled
  121657. * @param value defines the dithering state
  121658. */
  121659. setDitheringState(value: boolean): void;
  121660. /**
  121661. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121662. * @param value defines the rasterizer state
  121663. */
  121664. setRasterizerState(value: boolean): void;
  121665. /**
  121666. * Gets the current depth function
  121667. * @returns a number defining the depth function
  121668. */
  121669. getDepthFunction(): Nullable<number>;
  121670. /**
  121671. * Sets the current depth function
  121672. * @param depthFunc defines the function to use
  121673. */
  121674. setDepthFunction(depthFunc: number): void;
  121675. /**
  121676. * Sets the current depth function to GREATER
  121677. */
  121678. setDepthFunctionToGreater(): void;
  121679. /**
  121680. * Sets the current depth function to GEQUAL
  121681. */
  121682. setDepthFunctionToGreaterOrEqual(): void;
  121683. /**
  121684. * Sets the current depth function to LESS
  121685. */
  121686. setDepthFunctionToLess(): void;
  121687. /**
  121688. * Sets the current depth function to LEQUAL
  121689. */
  121690. setDepthFunctionToLessOrEqual(): void;
  121691. private _cachedStencilBuffer;
  121692. private _cachedStencilFunction;
  121693. private _cachedStencilMask;
  121694. private _cachedStencilOperationPass;
  121695. private _cachedStencilOperationFail;
  121696. private _cachedStencilOperationDepthFail;
  121697. private _cachedStencilReference;
  121698. /**
  121699. * Caches the the state of the stencil buffer
  121700. */
  121701. cacheStencilState(): void;
  121702. /**
  121703. * Restores the state of the stencil buffer
  121704. */
  121705. restoreStencilState(): void;
  121706. /**
  121707. * Directly set the WebGL Viewport
  121708. * @param x defines the x coordinate of the viewport (in screen space)
  121709. * @param y defines the y coordinate of the viewport (in screen space)
  121710. * @param width defines the width of the viewport (in screen space)
  121711. * @param height defines the height of the viewport (in screen space)
  121712. * @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
  121713. */
  121714. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121715. /**
  121716. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121717. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121718. * @param y defines the y-coordinate of the corner of the clear rectangle
  121719. * @param width defines the width of the clear rectangle
  121720. * @param height defines the height of the clear rectangle
  121721. * @param clearColor defines the clear color
  121722. */
  121723. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121724. /**
  121725. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121726. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121727. * @param y defines the y-coordinate of the corner of the clear rectangle
  121728. * @param width defines the width of the clear rectangle
  121729. * @param height defines the height of the clear rectangle
  121730. */
  121731. enableScissor(x: number, y: number, width: number, height: number): void;
  121732. /**
  121733. * Disable previously set scissor test rectangle
  121734. */
  121735. disableScissor(): void;
  121736. protected _reportDrawCall(): void;
  121737. /**
  121738. * Initializes a webVR display and starts listening to display change events
  121739. * The onVRDisplayChangedObservable will be notified upon these changes
  121740. * @returns The onVRDisplayChangedObservable
  121741. */
  121742. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121743. /** @hidden */
  121744. _prepareVRComponent(): void;
  121745. /** @hidden */
  121746. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121747. /** @hidden */
  121748. _submitVRFrame(): void;
  121749. /**
  121750. * Call this function to leave webVR mode
  121751. * Will do nothing if webVR is not supported or if there is no webVR device
  121752. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121753. */
  121754. disableVR(): void;
  121755. /**
  121756. * Gets a boolean indicating that the system is in VR mode and is presenting
  121757. * @returns true if VR mode is engaged
  121758. */
  121759. isVRPresenting(): boolean;
  121760. /** @hidden */
  121761. _requestVRFrame(): void;
  121762. /** @hidden */
  121763. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121764. /**
  121765. * Gets the source code of the vertex shader associated with a specific webGL program
  121766. * @param program defines the program to use
  121767. * @returns a string containing the source code of the vertex shader associated with the program
  121768. */
  121769. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121770. /**
  121771. * Gets the source code of the fragment shader associated with a specific webGL program
  121772. * @param program defines the program to use
  121773. * @returns a string containing the source code of the fragment shader associated with the program
  121774. */
  121775. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121776. /**
  121777. * Sets a depth stencil texture from a render target to the according uniform.
  121778. * @param channel The texture channel
  121779. * @param uniform The uniform to set
  121780. * @param texture The render target texture containing the depth stencil texture to apply
  121781. */
  121782. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121783. /**
  121784. * Sets a texture to the webGL context from a postprocess
  121785. * @param channel defines the channel to use
  121786. * @param postProcess defines the source postprocess
  121787. */
  121788. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121789. /**
  121790. * Binds the output of the passed in post process to the texture channel specified
  121791. * @param channel The channel the texture should be bound to
  121792. * @param postProcess The post process which's output should be bound
  121793. */
  121794. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121795. protected _rebuildBuffers(): void;
  121796. /** @hidden */
  121797. _renderFrame(): void;
  121798. _renderLoop(): void;
  121799. /** @hidden */
  121800. _renderViews(): boolean;
  121801. /**
  121802. * Toggle full screen mode
  121803. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121804. */
  121805. switchFullscreen(requestPointerLock: boolean): void;
  121806. /**
  121807. * Enters full screen mode
  121808. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121809. */
  121810. enterFullscreen(requestPointerLock: boolean): void;
  121811. /**
  121812. * Exits full screen mode
  121813. */
  121814. exitFullscreen(): void;
  121815. /**
  121816. * Enters Pointerlock mode
  121817. */
  121818. enterPointerlock(): void;
  121819. /**
  121820. * Exits Pointerlock mode
  121821. */
  121822. exitPointerlock(): void;
  121823. /**
  121824. * Begin a new frame
  121825. */
  121826. beginFrame(): void;
  121827. /**
  121828. * Enf the current frame
  121829. */
  121830. endFrame(): void;
  121831. resize(): void;
  121832. /**
  121833. * Force a specific size of the canvas
  121834. * @param width defines the new canvas' width
  121835. * @param height defines the new canvas' height
  121836. * @returns true if the size was changed
  121837. */
  121838. setSize(width: number, height: number): boolean;
  121839. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121840. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121841. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121842. _releaseTexture(texture: InternalTexture): void;
  121843. /**
  121844. * @hidden
  121845. * Rescales a texture
  121846. * @param source input texutre
  121847. * @param destination destination texture
  121848. * @param scene scene to use to render the resize
  121849. * @param internalFormat format to use when resizing
  121850. * @param onComplete callback to be called when resize has completed
  121851. */
  121852. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121853. /**
  121854. * Gets the current framerate
  121855. * @returns a number representing the framerate
  121856. */
  121857. getFps(): number;
  121858. /**
  121859. * Gets the time spent between current and previous frame
  121860. * @returns a number representing the delta time in ms
  121861. */
  121862. getDeltaTime(): number;
  121863. private _measureFps;
  121864. /** @hidden */
  121865. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121866. /**
  121867. * Updates the sample count of a render target texture
  121868. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121869. * @param texture defines the texture to update
  121870. * @param samples defines the sample count to set
  121871. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121872. */
  121873. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121874. /**
  121875. * Updates a depth texture Comparison Mode and Function.
  121876. * If the comparison Function is equal to 0, the mode will be set to none.
  121877. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121878. * @param texture The texture to set the comparison function for
  121879. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121880. */
  121881. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121882. /**
  121883. * Creates a webGL buffer to use with instanciation
  121884. * @param capacity defines the size of the buffer
  121885. * @returns the webGL buffer
  121886. */
  121887. createInstancesBuffer(capacity: number): DataBuffer;
  121888. /**
  121889. * Delete a webGL buffer used with instanciation
  121890. * @param buffer defines the webGL buffer to delete
  121891. */
  121892. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121893. private _clientWaitAsync;
  121894. /** @hidden */
  121895. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121896. dispose(): void;
  121897. private _disableTouchAction;
  121898. /**
  121899. * Display the loading screen
  121900. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121901. */
  121902. displayLoadingUI(): void;
  121903. /**
  121904. * Hide the loading screen
  121905. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121906. */
  121907. hideLoadingUI(): void;
  121908. /**
  121909. * Gets the current loading screen object
  121910. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121911. */
  121912. get loadingScreen(): ILoadingScreen;
  121913. /**
  121914. * Sets the current loading screen object
  121915. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121916. */
  121917. set loadingScreen(loadingScreen: ILoadingScreen);
  121918. /**
  121919. * Sets the current loading screen text
  121920. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121921. */
  121922. set loadingUIText(text: string);
  121923. /**
  121924. * Sets the current loading screen background color
  121925. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121926. */
  121927. set loadingUIBackgroundColor(color: string);
  121928. /** Pointerlock and fullscreen */
  121929. /**
  121930. * Ask the browser to promote the current element to pointerlock mode
  121931. * @param element defines the DOM element to promote
  121932. */
  121933. static _RequestPointerlock(element: HTMLElement): void;
  121934. /**
  121935. * Asks the browser to exit pointerlock mode
  121936. */
  121937. static _ExitPointerlock(): void;
  121938. /**
  121939. * Ask the browser to promote the current element to fullscreen rendering mode
  121940. * @param element defines the DOM element to promote
  121941. */
  121942. static _RequestFullscreen(element: HTMLElement): void;
  121943. /**
  121944. * Asks the browser to exit fullscreen mode
  121945. */
  121946. static _ExitFullscreen(): void;
  121947. }
  121948. }
  121949. declare module BABYLON {
  121950. /**
  121951. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121952. * during the life time of the application.
  121953. */
  121954. export class EngineStore {
  121955. /** Gets the list of created engines */
  121956. static Instances: Engine[];
  121957. /** @hidden */
  121958. static _LastCreatedScene: Nullable<Scene>;
  121959. /**
  121960. * Gets the latest created engine
  121961. */
  121962. static get LastCreatedEngine(): Nullable<Engine>;
  121963. /**
  121964. * Gets the latest created scene
  121965. */
  121966. static get LastCreatedScene(): Nullable<Scene>;
  121967. /**
  121968. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121969. * @ignorenaming
  121970. */
  121971. static UseFallbackTexture: boolean;
  121972. /**
  121973. * Texture content used if a texture cannot loaded
  121974. * @ignorenaming
  121975. */
  121976. static FallbackTexture: string;
  121977. }
  121978. }
  121979. declare module BABYLON {
  121980. /**
  121981. * Helper class that provides a small promise polyfill
  121982. */
  121983. export class PromisePolyfill {
  121984. /**
  121985. * Static function used to check if the polyfill is required
  121986. * If this is the case then the function will inject the polyfill to window.Promise
  121987. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  121988. */
  121989. static Apply(force?: boolean): void;
  121990. }
  121991. }
  121992. declare module BABYLON {
  121993. /**
  121994. * Interface for screenshot methods with describe argument called `size` as object with options
  121995. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  121996. */
  121997. export interface IScreenshotSize {
  121998. /**
  121999. * number in pixels for canvas height
  122000. */
  122001. height?: number;
  122002. /**
  122003. * multiplier allowing render at a higher or lower resolution
  122004. * If value is defined then height and width will be ignored and taken from camera
  122005. */
  122006. precision?: number;
  122007. /**
  122008. * number in pixels for canvas width
  122009. */
  122010. width?: number;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. interface IColor4Like {
  122015. r: float;
  122016. g: float;
  122017. b: float;
  122018. a: float;
  122019. }
  122020. /**
  122021. * Class containing a set of static utilities functions
  122022. */
  122023. export class Tools {
  122024. /**
  122025. * Gets or sets the base URL to use to load assets
  122026. */
  122027. static get BaseUrl(): string;
  122028. static set BaseUrl(value: string);
  122029. /**
  122030. * Enable/Disable Custom HTTP Request Headers globally.
  122031. * default = false
  122032. * @see CustomRequestHeaders
  122033. */
  122034. static UseCustomRequestHeaders: boolean;
  122035. /**
  122036. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122037. * i.e. when loading files, where the server/service expects an Authorization header
  122038. */
  122039. static CustomRequestHeaders: {
  122040. [key: string]: string;
  122041. };
  122042. /**
  122043. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122044. */
  122045. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122046. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122047. /**
  122048. * Default behaviour for cors in the application.
  122049. * It can be a string if the expected behavior is identical in the entire app.
  122050. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122051. */
  122052. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122053. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122054. /**
  122055. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122056. * @ignorenaming
  122057. */
  122058. static get UseFallbackTexture(): boolean;
  122059. static set UseFallbackTexture(value: boolean);
  122060. /**
  122061. * Use this object to register external classes like custom textures or material
  122062. * to allow the laoders to instantiate them
  122063. */
  122064. static get RegisteredExternalClasses(): {
  122065. [key: string]: Object;
  122066. };
  122067. static set RegisteredExternalClasses(classes: {
  122068. [key: string]: Object;
  122069. });
  122070. /**
  122071. * Texture content used if a texture cannot loaded
  122072. * @ignorenaming
  122073. */
  122074. static get fallbackTexture(): string;
  122075. static set fallbackTexture(value: string);
  122076. /**
  122077. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122078. * @param u defines the coordinate on X axis
  122079. * @param v defines the coordinate on Y axis
  122080. * @param width defines the width of the source data
  122081. * @param height defines the height of the source data
  122082. * @param pixels defines the source byte array
  122083. * @param color defines the output color
  122084. */
  122085. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122086. /**
  122087. * Interpolates between a and b via alpha
  122088. * @param a The lower value (returned when alpha = 0)
  122089. * @param b The upper value (returned when alpha = 1)
  122090. * @param alpha The interpolation-factor
  122091. * @return The mixed value
  122092. */
  122093. static Mix(a: number, b: number, alpha: number): number;
  122094. /**
  122095. * Tries to instantiate a new object from a given class name
  122096. * @param className defines the class name to instantiate
  122097. * @returns the new object or null if the system was not able to do the instantiation
  122098. */
  122099. static Instantiate(className: string): any;
  122100. /**
  122101. * Provides a slice function that will work even on IE
  122102. * @param data defines the array to slice
  122103. * @param start defines the start of the data (optional)
  122104. * @param end defines the end of the data (optional)
  122105. * @returns the new sliced array
  122106. */
  122107. static Slice<T>(data: T, start?: number, end?: number): T;
  122108. /**
  122109. * Polyfill for setImmediate
  122110. * @param action defines the action to execute after the current execution block
  122111. */
  122112. static SetImmediate(action: () => void): void;
  122113. /**
  122114. * Function indicating if a number is an exponent of 2
  122115. * @param value defines the value to test
  122116. * @returns true if the value is an exponent of 2
  122117. */
  122118. static IsExponentOfTwo(value: number): boolean;
  122119. private static _tmpFloatArray;
  122120. /**
  122121. * Returns the nearest 32-bit single precision float representation of a Number
  122122. * @param value A Number. If the parameter is of a different type, it will get converted
  122123. * to a number or to NaN if it cannot be converted
  122124. * @returns number
  122125. */
  122126. static FloatRound(value: number): number;
  122127. /**
  122128. * Extracts the filename from a path
  122129. * @param path defines the path to use
  122130. * @returns the filename
  122131. */
  122132. static GetFilename(path: string): string;
  122133. /**
  122134. * Extracts the "folder" part of a path (everything before the filename).
  122135. * @param uri The URI to extract the info from
  122136. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122137. * @returns The "folder" part of the path
  122138. */
  122139. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122140. /**
  122141. * Extracts text content from a DOM element hierarchy
  122142. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122143. */
  122144. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122145. /**
  122146. * Convert an angle in radians to degrees
  122147. * @param angle defines the angle to convert
  122148. * @returns the angle in degrees
  122149. */
  122150. static ToDegrees(angle: number): number;
  122151. /**
  122152. * Convert an angle in degrees to radians
  122153. * @param angle defines the angle to convert
  122154. * @returns the angle in radians
  122155. */
  122156. static ToRadians(angle: number): number;
  122157. /**
  122158. * Returns an array if obj is not an array
  122159. * @param obj defines the object to evaluate as an array
  122160. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122161. * @returns either obj directly if obj is an array or a new array containing obj
  122162. */
  122163. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122164. /**
  122165. * Gets the pointer prefix to use
  122166. * @param engine defines the engine we are finding the prefix for
  122167. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122168. */
  122169. static GetPointerPrefix(engine: Engine): string;
  122170. /**
  122171. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122172. * @param url define the url we are trying
  122173. * @param element define the dom element where to configure the cors policy
  122174. */
  122175. static SetCorsBehavior(url: string | string[], element: {
  122176. crossOrigin: string | null;
  122177. }): void;
  122178. /**
  122179. * Removes unwanted characters from an url
  122180. * @param url defines the url to clean
  122181. * @returns the cleaned url
  122182. */
  122183. static CleanUrl(url: string): string;
  122184. /**
  122185. * Gets or sets a function used to pre-process url before using them to load assets
  122186. */
  122187. static get PreprocessUrl(): (url: string) => string;
  122188. static set PreprocessUrl(processor: (url: string) => string);
  122189. /**
  122190. * Loads an image as an HTMLImageElement.
  122191. * @param input url string, ArrayBuffer, or Blob to load
  122192. * @param onLoad callback called when the image successfully loads
  122193. * @param onError callback called when the image fails to load
  122194. * @param offlineProvider offline provider for caching
  122195. * @param mimeType optional mime type
  122196. * @returns the HTMLImageElement of the loaded image
  122197. */
  122198. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122199. /**
  122200. * Loads a file from a url
  122201. * @param url url string, ArrayBuffer, or Blob to load
  122202. * @param onSuccess callback called when the file successfully loads
  122203. * @param onProgress callback called while file is loading (if the server supports this mode)
  122204. * @param offlineProvider defines the offline provider for caching
  122205. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122206. * @param onError callback called when the file fails to load
  122207. * @returns a file request object
  122208. */
  122209. 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;
  122210. /**
  122211. * Loads a file from a url
  122212. * @param url the file url to load
  122213. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122214. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122215. */
  122216. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122217. /**
  122218. * Load a script (identified by an url). When the url returns, the
  122219. * content of this file is added into a new script element, attached to the DOM (body element)
  122220. * @param scriptUrl defines the url of the script to laod
  122221. * @param onSuccess defines the callback called when the script is loaded
  122222. * @param onError defines the callback to call if an error occurs
  122223. * @param scriptId defines the id of the script element
  122224. */
  122225. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122226. /**
  122227. * Load an asynchronous script (identified by an url). When the url returns, the
  122228. * content of this file is added into a new script element, attached to the DOM (body element)
  122229. * @param scriptUrl defines the url of the script to laod
  122230. * @param scriptId defines the id of the script element
  122231. * @returns a promise request object
  122232. */
  122233. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122234. /**
  122235. * Loads a file from a blob
  122236. * @param fileToLoad defines the blob to use
  122237. * @param callback defines the callback to call when data is loaded
  122238. * @param progressCallback defines the callback to call during loading process
  122239. * @returns a file request object
  122240. */
  122241. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122242. /**
  122243. * Reads a file from a File object
  122244. * @param file defines the file to load
  122245. * @param onSuccess defines the callback to call when data is loaded
  122246. * @param onProgress defines the callback to call during loading process
  122247. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122248. * @param onError defines the callback to call when an error occurs
  122249. * @returns a file request object
  122250. */
  122251. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122252. /**
  122253. * Creates a data url from a given string content
  122254. * @param content defines the content to convert
  122255. * @returns the new data url link
  122256. */
  122257. static FileAsURL(content: string): string;
  122258. /**
  122259. * Format the given number to a specific decimal format
  122260. * @param value defines the number to format
  122261. * @param decimals defines the number of decimals to use
  122262. * @returns the formatted string
  122263. */
  122264. static Format(value: number, decimals?: number): string;
  122265. /**
  122266. * Tries to copy an object by duplicating every property
  122267. * @param source defines the source object
  122268. * @param destination defines the target object
  122269. * @param doNotCopyList defines a list of properties to avoid
  122270. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122271. */
  122272. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122273. /**
  122274. * Gets a boolean indicating if the given object has no own property
  122275. * @param obj defines the object to test
  122276. * @returns true if object has no own property
  122277. */
  122278. static IsEmpty(obj: any): boolean;
  122279. /**
  122280. * Function used to register events at window level
  122281. * @param windowElement defines the Window object to use
  122282. * @param events defines the events to register
  122283. */
  122284. static RegisterTopRootEvents(windowElement: Window, events: {
  122285. name: string;
  122286. handler: Nullable<(e: FocusEvent) => any>;
  122287. }[]): void;
  122288. /**
  122289. * Function used to unregister events from window level
  122290. * @param windowElement defines the Window object to use
  122291. * @param events defines the events to unregister
  122292. */
  122293. static UnregisterTopRootEvents(windowElement: Window, events: {
  122294. name: string;
  122295. handler: Nullable<(e: FocusEvent) => any>;
  122296. }[]): void;
  122297. /**
  122298. * @ignore
  122299. */
  122300. static _ScreenshotCanvas: HTMLCanvasElement;
  122301. /**
  122302. * Dumps the current bound framebuffer
  122303. * @param width defines the rendering width
  122304. * @param height defines the rendering height
  122305. * @param engine defines the hosting engine
  122306. * @param successCallback defines the callback triggered once the data are available
  122307. * @param mimeType defines the mime type of the result
  122308. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122309. */
  122310. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122311. /**
  122312. * Converts the canvas data to blob.
  122313. * This acts as a polyfill for browsers not supporting the to blob function.
  122314. * @param canvas Defines the canvas to extract the data from
  122315. * @param successCallback Defines the callback triggered once the data are available
  122316. * @param mimeType Defines the mime type of the result
  122317. */
  122318. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122319. /**
  122320. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122321. * @param successCallback defines the callback triggered once the data are available
  122322. * @param mimeType defines the mime type of the result
  122323. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122324. */
  122325. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122326. /**
  122327. * Downloads a blob in the browser
  122328. * @param blob defines the blob to download
  122329. * @param fileName defines the name of the downloaded file
  122330. */
  122331. static Download(blob: Blob, fileName: string): void;
  122332. /**
  122333. * Captures a screenshot of the current rendering
  122334. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122335. * @param engine defines the rendering engine
  122336. * @param camera defines the source camera
  122337. * @param size This parameter can be set to a single number or to an object with the
  122338. * following (optional) properties: precision, width, height. If a single number is passed,
  122339. * it will be used for both width and height. If an object is passed, the screenshot size
  122340. * will be derived from the parameters. The precision property is a multiplier allowing
  122341. * rendering at a higher or lower resolution
  122342. * @param successCallback defines the callback receives a single parameter which contains the
  122343. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122344. * src parameter of an <img> to display it
  122345. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122346. * Check your browser for supported MIME types
  122347. */
  122348. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122349. /**
  122350. * Captures a screenshot of the current rendering
  122351. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122352. * @param engine defines the rendering engine
  122353. * @param camera defines the source camera
  122354. * @param size This parameter can be set to a single number or to an object with the
  122355. * following (optional) properties: precision, width, height. If a single number is passed,
  122356. * it will be used for both width and height. If an object is passed, the screenshot size
  122357. * will be derived from the parameters. The precision property is a multiplier allowing
  122358. * rendering at a higher or lower resolution
  122359. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122360. * Check your browser for supported MIME types
  122361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122362. * to the src parameter of an <img> to display it
  122363. */
  122364. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122365. /**
  122366. * Generates an image screenshot from the specified camera.
  122367. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122368. * @param engine The engine to use for rendering
  122369. * @param camera The camera to use for rendering
  122370. * @param size This parameter can be set to a single number or to an object with the
  122371. * following (optional) properties: precision, width, height. If a single number is passed,
  122372. * it will be used for both width and height. If an object is passed, the screenshot size
  122373. * will be derived from the parameters. The precision property is a multiplier allowing
  122374. * rendering at a higher or lower resolution
  122375. * @param successCallback The callback receives a single parameter which contains the
  122376. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122377. * src parameter of an <img> to display it
  122378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122379. * Check your browser for supported MIME types
  122380. * @param samples Texture samples (default: 1)
  122381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122382. * @param fileName A name for for the downloaded file.
  122383. */
  122384. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122385. /**
  122386. * Generates an image screenshot from the specified camera.
  122387. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122388. * @param engine The engine to use for rendering
  122389. * @param camera The camera to use for rendering
  122390. * @param size This parameter can be set to a single number or to an object with the
  122391. * following (optional) properties: precision, width, height. If a single number is passed,
  122392. * it will be used for both width and height. If an object is passed, the screenshot size
  122393. * will be derived from the parameters. The precision property is a multiplier allowing
  122394. * rendering at a higher or lower resolution
  122395. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122396. * Check your browser for supported MIME types
  122397. * @param samples Texture samples (default: 1)
  122398. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122399. * @param fileName A name for for the downloaded file.
  122400. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122401. * to the src parameter of an <img> to display it
  122402. */
  122403. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122404. /**
  122405. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122406. * Be aware Math.random() could cause collisions, but:
  122407. * "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"
  122408. * @returns a pseudo random id
  122409. */
  122410. static RandomId(): string;
  122411. /**
  122412. * Test if the given uri is a base64 string
  122413. * @param uri The uri to test
  122414. * @return True if the uri is a base64 string or false otherwise
  122415. */
  122416. static IsBase64(uri: string): boolean;
  122417. /**
  122418. * Decode the given base64 uri.
  122419. * @param uri The uri to decode
  122420. * @return The decoded base64 data.
  122421. */
  122422. static DecodeBase64(uri: string): ArrayBuffer;
  122423. /**
  122424. * Gets the absolute url.
  122425. * @param url the input url
  122426. * @return the absolute url
  122427. */
  122428. static GetAbsoluteUrl(url: string): string;
  122429. /**
  122430. * No log
  122431. */
  122432. static readonly NoneLogLevel: number;
  122433. /**
  122434. * Only message logs
  122435. */
  122436. static readonly MessageLogLevel: number;
  122437. /**
  122438. * Only warning logs
  122439. */
  122440. static readonly WarningLogLevel: number;
  122441. /**
  122442. * Only error logs
  122443. */
  122444. static readonly ErrorLogLevel: number;
  122445. /**
  122446. * All logs
  122447. */
  122448. static readonly AllLogLevel: number;
  122449. /**
  122450. * Gets a value indicating the number of loading errors
  122451. * @ignorenaming
  122452. */
  122453. static get errorsCount(): number;
  122454. /**
  122455. * Callback called when a new log is added
  122456. */
  122457. static OnNewCacheEntry: (entry: string) => void;
  122458. /**
  122459. * Log a message to the console
  122460. * @param message defines the message to log
  122461. */
  122462. static Log(message: string): void;
  122463. /**
  122464. * Write a warning message to the console
  122465. * @param message defines the message to log
  122466. */
  122467. static Warn(message: string): void;
  122468. /**
  122469. * Write an error message to the console
  122470. * @param message defines the message to log
  122471. */
  122472. static Error(message: string): void;
  122473. /**
  122474. * Gets current log cache (list of logs)
  122475. */
  122476. static get LogCache(): string;
  122477. /**
  122478. * Clears the log cache
  122479. */
  122480. static ClearLogCache(): void;
  122481. /**
  122482. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122483. */
  122484. static set LogLevels(level: number);
  122485. /**
  122486. * Checks if the window object exists
  122487. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122488. */
  122489. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122490. /**
  122491. * No performance log
  122492. */
  122493. static readonly PerformanceNoneLogLevel: number;
  122494. /**
  122495. * Use user marks to log performance
  122496. */
  122497. static readonly PerformanceUserMarkLogLevel: number;
  122498. /**
  122499. * Log performance to the console
  122500. */
  122501. static readonly PerformanceConsoleLogLevel: number;
  122502. private static _performance;
  122503. /**
  122504. * Sets the current performance log level
  122505. */
  122506. static set PerformanceLogLevel(level: number);
  122507. private static _StartPerformanceCounterDisabled;
  122508. private static _EndPerformanceCounterDisabled;
  122509. private static _StartUserMark;
  122510. private static _EndUserMark;
  122511. private static _StartPerformanceConsole;
  122512. private static _EndPerformanceConsole;
  122513. /**
  122514. * Starts a performance counter
  122515. */
  122516. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122517. /**
  122518. * Ends a specific performance coutner
  122519. */
  122520. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122521. /**
  122522. * Gets either window.performance.now() if supported or Date.now() else
  122523. */
  122524. static get Now(): number;
  122525. /**
  122526. * This method will return the name of the class used to create the instance of the given object.
  122527. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122528. * @param object the object to get the class name from
  122529. * @param isType defines if the object is actually a type
  122530. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122531. */
  122532. static GetClassName(object: any, isType?: boolean): string;
  122533. /**
  122534. * Gets the first element of an array satisfying a given predicate
  122535. * @param array defines the array to browse
  122536. * @param predicate defines the predicate to use
  122537. * @returns null if not found or the element
  122538. */
  122539. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122540. /**
  122541. * This method will return the name of the full name of the class, including its owning module (if any).
  122542. * 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).
  122543. * @param object the object to get the class name from
  122544. * @param isType defines if the object is actually a type
  122545. * @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.
  122546. * @ignorenaming
  122547. */
  122548. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122549. /**
  122550. * Returns a promise that resolves after the given amount of time.
  122551. * @param delay Number of milliseconds to delay
  122552. * @returns Promise that resolves after the given amount of time
  122553. */
  122554. static DelayAsync(delay: number): Promise<void>;
  122555. /**
  122556. * Utility function to detect if the current user agent is Safari
  122557. * @returns whether or not the current user agent is safari
  122558. */
  122559. static IsSafari(): boolean;
  122560. }
  122561. /**
  122562. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122563. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122564. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122565. * @param name The name of the class, case should be preserved
  122566. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122567. */
  122568. export function className(name: string, module?: string): (target: Object) => void;
  122569. /**
  122570. * An implementation of a loop for asynchronous functions.
  122571. */
  122572. export class AsyncLoop {
  122573. /**
  122574. * Defines the number of iterations for the loop
  122575. */
  122576. iterations: number;
  122577. /**
  122578. * Defines the current index of the loop.
  122579. */
  122580. index: number;
  122581. private _done;
  122582. private _fn;
  122583. private _successCallback;
  122584. /**
  122585. * Constructor.
  122586. * @param iterations the number of iterations.
  122587. * @param func the function to run each iteration
  122588. * @param successCallback the callback that will be called upon succesful execution
  122589. * @param offset starting offset.
  122590. */
  122591. constructor(
  122592. /**
  122593. * Defines the number of iterations for the loop
  122594. */
  122595. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122596. /**
  122597. * Execute the next iteration. Must be called after the last iteration was finished.
  122598. */
  122599. executeNext(): void;
  122600. /**
  122601. * Break the loop and run the success callback.
  122602. */
  122603. breakLoop(): void;
  122604. /**
  122605. * Create and run an async loop.
  122606. * @param iterations the number of iterations.
  122607. * @param fn the function to run each iteration
  122608. * @param successCallback the callback that will be called upon succesful execution
  122609. * @param offset starting offset.
  122610. * @returns the created async loop object
  122611. */
  122612. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122613. /**
  122614. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122615. * @param iterations total number of iterations
  122616. * @param syncedIterations number of synchronous iterations in each async iteration.
  122617. * @param fn the function to call each iteration.
  122618. * @param callback a success call back that will be called when iterating stops.
  122619. * @param breakFunction a break condition (optional)
  122620. * @param timeout timeout settings for the setTimeout function. default - 0.
  122621. * @returns the created async loop object
  122622. */
  122623. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122624. }
  122625. }
  122626. declare module BABYLON {
  122627. /**
  122628. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122629. * The underlying implementation relies on an associative array to ensure the best performances.
  122630. * The value can be anything including 'null' but except 'undefined'
  122631. */
  122632. export class StringDictionary<T> {
  122633. /**
  122634. * This will clear this dictionary and copy the content from the 'source' one.
  122635. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122636. * @param source the dictionary to take the content from and copy to this dictionary
  122637. */
  122638. copyFrom(source: StringDictionary<T>): void;
  122639. /**
  122640. * Get a value based from its key
  122641. * @param key the given key to get the matching value from
  122642. * @return the value if found, otherwise undefined is returned
  122643. */
  122644. get(key: string): T | undefined;
  122645. /**
  122646. * Get a value from its key or add it if it doesn't exist.
  122647. * This method will ensure you that a given key/data will be present in the dictionary.
  122648. * @param key the given key to get the matching value from
  122649. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122650. * The factory will only be invoked if there's no data for the given key.
  122651. * @return the value corresponding to the key.
  122652. */
  122653. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122654. /**
  122655. * Get a value from its key if present in the dictionary otherwise add it
  122656. * @param key the key to get the value from
  122657. * @param val if there's no such key/value pair in the dictionary add it with this value
  122658. * @return the value corresponding to the key
  122659. */
  122660. getOrAdd(key: string, val: T): T;
  122661. /**
  122662. * Check if there's a given key in the dictionary
  122663. * @param key the key to check for
  122664. * @return true if the key is present, false otherwise
  122665. */
  122666. contains(key: string): boolean;
  122667. /**
  122668. * Add a new key and its corresponding value
  122669. * @param key the key to add
  122670. * @param value the value corresponding to the key
  122671. * @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
  122672. */
  122673. add(key: string, value: T): boolean;
  122674. /**
  122675. * Update a specific value associated to a key
  122676. * @param key defines the key to use
  122677. * @param value defines the value to store
  122678. * @returns true if the value was updated (or false if the key was not found)
  122679. */
  122680. set(key: string, value: T): boolean;
  122681. /**
  122682. * Get the element of the given key and remove it from the dictionary
  122683. * @param key defines the key to search
  122684. * @returns the value associated with the key or null if not found
  122685. */
  122686. getAndRemove(key: string): Nullable<T>;
  122687. /**
  122688. * Remove a key/value from the dictionary.
  122689. * @param key the key to remove
  122690. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122691. */
  122692. remove(key: string): boolean;
  122693. /**
  122694. * Clear the whole content of the dictionary
  122695. */
  122696. clear(): void;
  122697. /**
  122698. * Gets the current count
  122699. */
  122700. get count(): number;
  122701. /**
  122702. * Execute a callback on each key/val of the dictionary.
  122703. * Note that you can remove any element in this dictionary in the callback implementation
  122704. * @param callback the callback to execute on a given key/value pair
  122705. */
  122706. forEach(callback: (key: string, val: T) => void): void;
  122707. /**
  122708. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122709. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122710. * Note that you can remove any element in this dictionary in the callback implementation
  122711. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122712. * @returns the first item
  122713. */
  122714. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122715. private _count;
  122716. private _data;
  122717. }
  122718. }
  122719. declare module BABYLON {
  122720. /** @hidden */
  122721. export interface ICollisionCoordinator {
  122722. createCollider(): Collider;
  122723. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122724. init(scene: Scene): void;
  122725. }
  122726. /** @hidden */
  122727. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122728. private _scene;
  122729. private _scaledPosition;
  122730. private _scaledVelocity;
  122731. private _finalPosition;
  122732. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122733. createCollider(): Collider;
  122734. init(scene: Scene): void;
  122735. private _collideWithWorld;
  122736. }
  122737. }
  122738. declare module BABYLON {
  122739. /**
  122740. * Class used to manage all inputs for the scene.
  122741. */
  122742. export class InputManager {
  122743. /** The distance in pixel that you have to move to prevent some events */
  122744. static DragMovementThreshold: number;
  122745. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122746. static LongPressDelay: number;
  122747. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122748. static DoubleClickDelay: number;
  122749. /** If you need to check double click without raising a single click at first click, enable this flag */
  122750. static ExclusiveDoubleClickMode: boolean;
  122751. /** 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. */
  122752. private _alreadyAttached;
  122753. private _wheelEventName;
  122754. private _onPointerMove;
  122755. private _onPointerDown;
  122756. private _onPointerUp;
  122757. private _initClickEvent;
  122758. private _initActionManager;
  122759. private _delayedSimpleClick;
  122760. private _delayedSimpleClickTimeout;
  122761. private _previousDelayedSimpleClickTimeout;
  122762. private _meshPickProceed;
  122763. private _previousButtonPressed;
  122764. private _currentPickResult;
  122765. private _previousPickResult;
  122766. private _totalPointersPressed;
  122767. private _doubleClickOccured;
  122768. private _pointerOverMesh;
  122769. private _pickedDownMesh;
  122770. private _pickedUpMesh;
  122771. private _pointerX;
  122772. private _pointerY;
  122773. private _unTranslatedPointerX;
  122774. private _unTranslatedPointerY;
  122775. private _startingPointerPosition;
  122776. private _previousStartingPointerPosition;
  122777. private _startingPointerTime;
  122778. private _previousStartingPointerTime;
  122779. private _pointerCaptures;
  122780. private _meshUnderPointerId;
  122781. private _onKeyDown;
  122782. private _onKeyUp;
  122783. private _onCanvasFocusObserver;
  122784. private _onCanvasBlurObserver;
  122785. private _scene;
  122786. /**
  122787. * Creates a new InputManager
  122788. * @param scene defines the hosting scene
  122789. */
  122790. constructor(scene: Scene);
  122791. /**
  122792. * Gets the mesh that is currently under the pointer
  122793. */
  122794. get meshUnderPointer(): Nullable<AbstractMesh>;
  122795. /**
  122796. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122797. * @param pointerId the pointer id to use
  122798. * @returns The mesh under this pointer id or null if not found
  122799. */
  122800. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122801. /**
  122802. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122803. */
  122804. get unTranslatedPointer(): Vector2;
  122805. /**
  122806. * Gets or sets the current on-screen X position of the pointer
  122807. */
  122808. get pointerX(): number;
  122809. set pointerX(value: number);
  122810. /**
  122811. * Gets or sets the current on-screen Y position of the pointer
  122812. */
  122813. get pointerY(): number;
  122814. set pointerY(value: number);
  122815. private _updatePointerPosition;
  122816. private _processPointerMove;
  122817. private _setRayOnPointerInfo;
  122818. private _checkPrePointerObservable;
  122819. /**
  122820. * Use this method to simulate a pointer move on a mesh
  122821. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122822. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122823. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122824. */
  122825. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122826. /**
  122827. * Use this method to simulate a pointer down on a mesh
  122828. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122829. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122830. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122831. */
  122832. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122833. private _processPointerDown;
  122834. /** @hidden */
  122835. _isPointerSwiping(): boolean;
  122836. /**
  122837. * Use this method to simulate a pointer up on a mesh
  122838. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122839. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122840. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122841. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122842. */
  122843. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122844. private _processPointerUp;
  122845. /**
  122846. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122847. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122848. * @returns true if the pointer was captured
  122849. */
  122850. isPointerCaptured(pointerId?: number): boolean;
  122851. /**
  122852. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122853. * @param attachUp defines if you want to attach events to pointerup
  122854. * @param attachDown defines if you want to attach events to pointerdown
  122855. * @param attachMove defines if you want to attach events to pointermove
  122856. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122857. */
  122858. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122859. /**
  122860. * Detaches all event handlers
  122861. */
  122862. detachControl(): void;
  122863. /**
  122864. * Force the value of meshUnderPointer
  122865. * @param mesh defines the mesh to use
  122866. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122867. */
  122868. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122869. /**
  122870. * Gets the mesh under the pointer
  122871. * @returns a Mesh or null if no mesh is under the pointer
  122872. */
  122873. getPointerOverMesh(): Nullable<AbstractMesh>;
  122874. }
  122875. }
  122876. declare module BABYLON {
  122877. /**
  122878. * This class defines the direct association between an animation and a target
  122879. */
  122880. export class TargetedAnimation {
  122881. /**
  122882. * Animation to perform
  122883. */
  122884. animation: Animation;
  122885. /**
  122886. * Target to animate
  122887. */
  122888. target: any;
  122889. /**
  122890. * Returns the string "TargetedAnimation"
  122891. * @returns "TargetedAnimation"
  122892. */
  122893. getClassName(): string;
  122894. /**
  122895. * Serialize the object
  122896. * @returns the JSON object representing the current entity
  122897. */
  122898. serialize(): any;
  122899. }
  122900. /**
  122901. * Use this class to create coordinated animations on multiple targets
  122902. */
  122903. export class AnimationGroup implements IDisposable {
  122904. /** The name of the animation group */
  122905. name: string;
  122906. private _scene;
  122907. private _targetedAnimations;
  122908. private _animatables;
  122909. private _from;
  122910. private _to;
  122911. private _isStarted;
  122912. private _isPaused;
  122913. private _speedRatio;
  122914. private _loopAnimation;
  122915. private _isAdditive;
  122916. /**
  122917. * Gets or sets the unique id of the node
  122918. */
  122919. uniqueId: number;
  122920. /**
  122921. * This observable will notify when one animation have ended
  122922. */
  122923. onAnimationEndObservable: Observable<TargetedAnimation>;
  122924. /**
  122925. * Observer raised when one animation loops
  122926. */
  122927. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122928. /**
  122929. * Observer raised when all animations have looped
  122930. */
  122931. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122932. /**
  122933. * This observable will notify when all animations have ended.
  122934. */
  122935. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122936. /**
  122937. * This observable will notify when all animations have paused.
  122938. */
  122939. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122940. /**
  122941. * This observable will notify when all animations are playing.
  122942. */
  122943. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122944. /**
  122945. * Gets the first frame
  122946. */
  122947. get from(): number;
  122948. /**
  122949. * Gets the last frame
  122950. */
  122951. get to(): number;
  122952. /**
  122953. * Define if the animations are started
  122954. */
  122955. get isStarted(): boolean;
  122956. /**
  122957. * Gets a value indicating that the current group is playing
  122958. */
  122959. get isPlaying(): boolean;
  122960. /**
  122961. * Gets or sets the speed ratio to use for all animations
  122962. */
  122963. get speedRatio(): number;
  122964. /**
  122965. * Gets or sets the speed ratio to use for all animations
  122966. */
  122967. set speedRatio(value: number);
  122968. /**
  122969. * Gets or sets if all animations should loop or not
  122970. */
  122971. get loopAnimation(): boolean;
  122972. set loopAnimation(value: boolean);
  122973. /**
  122974. * Gets or sets if all animations should be evaluated additively
  122975. */
  122976. get isAdditive(): boolean;
  122977. set isAdditive(value: boolean);
  122978. /**
  122979. * Gets the targeted animations for this animation group
  122980. */
  122981. get targetedAnimations(): Array<TargetedAnimation>;
  122982. /**
  122983. * returning the list of animatables controlled by this animation group.
  122984. */
  122985. get animatables(): Array<Animatable>;
  122986. /**
  122987. * Gets the list of target animations
  122988. */
  122989. get children(): TargetedAnimation[];
  122990. /**
  122991. * Instantiates a new Animation Group.
  122992. * This helps managing several animations at once.
  122993. * @see https://doc.babylonjs.com/how_to/group
  122994. * @param name Defines the name of the group
  122995. * @param scene Defines the scene the group belongs to
  122996. */
  122997. constructor(
  122998. /** The name of the animation group */
  122999. name: string, scene?: Nullable<Scene>);
  123000. /**
  123001. * Add an animation (with its target) in the group
  123002. * @param animation defines the animation we want to add
  123003. * @param target defines the target of the animation
  123004. * @returns the TargetedAnimation object
  123005. */
  123006. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123007. /**
  123008. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123009. * It can add constant keys at begin or end
  123010. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123011. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123012. * @returns the animation group
  123013. */
  123014. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123015. private _animationLoopCount;
  123016. private _animationLoopFlags;
  123017. private _processLoop;
  123018. /**
  123019. * Start all animations on given targets
  123020. * @param loop defines if animations must loop
  123021. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123022. * @param from defines the from key (optional)
  123023. * @param to defines the to key (optional)
  123024. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123025. * @returns the current animation group
  123026. */
  123027. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123028. /**
  123029. * Pause all animations
  123030. * @returns the animation group
  123031. */
  123032. pause(): AnimationGroup;
  123033. /**
  123034. * Play all animations to initial state
  123035. * This function will start() the animations if they were not started or will restart() them if they were paused
  123036. * @param loop defines if animations must loop
  123037. * @returns the animation group
  123038. */
  123039. play(loop?: boolean): AnimationGroup;
  123040. /**
  123041. * Reset all animations to initial state
  123042. * @returns the animation group
  123043. */
  123044. reset(): AnimationGroup;
  123045. /**
  123046. * Restart animations from key 0
  123047. * @returns the animation group
  123048. */
  123049. restart(): AnimationGroup;
  123050. /**
  123051. * Stop all animations
  123052. * @returns the animation group
  123053. */
  123054. stop(): AnimationGroup;
  123055. /**
  123056. * Set animation weight for all animatables
  123057. * @param weight defines the weight to use
  123058. * @return the animationGroup
  123059. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123060. */
  123061. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123062. /**
  123063. * Synchronize and normalize all animatables with a source animatable
  123064. * @param root defines the root animatable to synchronize with
  123065. * @return the animationGroup
  123066. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123067. */
  123068. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123069. /**
  123070. * Goes to a specific frame in this animation group
  123071. * @param frame the frame number to go to
  123072. * @return the animationGroup
  123073. */
  123074. goToFrame(frame: number): AnimationGroup;
  123075. /**
  123076. * Dispose all associated resources
  123077. */
  123078. dispose(): void;
  123079. private _checkAnimationGroupEnded;
  123080. /**
  123081. * Clone the current animation group and returns a copy
  123082. * @param newName defines the name of the new group
  123083. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123084. * @returns the new aniamtion group
  123085. */
  123086. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123087. /**
  123088. * Serializes the animationGroup to an object
  123089. * @returns Serialized object
  123090. */
  123091. serialize(): any;
  123092. /**
  123093. * Returns a new AnimationGroup object parsed from the source provided.
  123094. * @param parsedAnimationGroup defines the source
  123095. * @param scene defines the scene that will receive the animationGroup
  123096. * @returns a new AnimationGroup
  123097. */
  123098. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123099. /**
  123100. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123101. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123102. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123103. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123104. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123105. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123106. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123107. */
  123108. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123109. /**
  123110. * Returns the string "AnimationGroup"
  123111. * @returns "AnimationGroup"
  123112. */
  123113. getClassName(): string;
  123114. /**
  123115. * Creates a detailled string about the object
  123116. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123117. * @returns a string representing the object
  123118. */
  123119. toString(fullDetails?: boolean): string;
  123120. }
  123121. }
  123122. declare module BABYLON {
  123123. /**
  123124. * Define an interface for all classes that will hold resources
  123125. */
  123126. export interface IDisposable {
  123127. /**
  123128. * Releases all held resources
  123129. */
  123130. dispose(): void;
  123131. }
  123132. /** Interface defining initialization parameters for Scene class */
  123133. export interface SceneOptions {
  123134. /**
  123135. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123136. * It will improve performance when the number of geometries becomes important.
  123137. */
  123138. useGeometryUniqueIdsMap?: boolean;
  123139. /**
  123140. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123141. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123142. */
  123143. useMaterialMeshMap?: boolean;
  123144. /**
  123145. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123146. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123147. */
  123148. useClonedMeshMap?: boolean;
  123149. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123150. virtual?: boolean;
  123151. }
  123152. /**
  123153. * Represents a scene to be rendered by the engine.
  123154. * @see https://doc.babylonjs.com/features/scene
  123155. */
  123156. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123157. /** The fog is deactivated */
  123158. static readonly FOGMODE_NONE: number;
  123159. /** The fog density is following an exponential function */
  123160. static readonly FOGMODE_EXP: number;
  123161. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123162. static readonly FOGMODE_EXP2: number;
  123163. /** The fog density is following a linear function. */
  123164. static readonly FOGMODE_LINEAR: number;
  123165. /**
  123166. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123168. */
  123169. static MinDeltaTime: number;
  123170. /**
  123171. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123172. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123173. */
  123174. static MaxDeltaTime: number;
  123175. /**
  123176. * Factory used to create the default material.
  123177. * @param name The name of the material to create
  123178. * @param scene The scene to create the material for
  123179. * @returns The default material
  123180. */
  123181. static DefaultMaterialFactory(scene: Scene): Material;
  123182. /**
  123183. * Factory used to create the a collision coordinator.
  123184. * @returns The collision coordinator
  123185. */
  123186. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123187. /** @hidden */
  123188. _inputManager: InputManager;
  123189. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123190. cameraToUseForPointers: Nullable<Camera>;
  123191. /** @hidden */
  123192. readonly _isScene: boolean;
  123193. /** @hidden */
  123194. _blockEntityCollection: boolean;
  123195. /**
  123196. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123197. */
  123198. autoClear: boolean;
  123199. /**
  123200. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123201. */
  123202. autoClearDepthAndStencil: boolean;
  123203. /**
  123204. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123205. */
  123206. clearColor: Color4;
  123207. /**
  123208. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123209. */
  123210. ambientColor: Color3;
  123211. /**
  123212. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123213. * It should only be one of the following (if not the default embedded one):
  123214. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123215. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123216. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123217. * The material properties need to be setup according to the type of texture in use.
  123218. */
  123219. environmentBRDFTexture: BaseTexture;
  123220. /**
  123221. * Texture used in all pbr material as the reflection texture.
  123222. * As in the majority of the scene they are the same (exception for multi room and so on),
  123223. * this is easier to reference from here than from all the materials.
  123224. */
  123225. get environmentTexture(): Nullable<BaseTexture>;
  123226. /**
  123227. * Texture used in all pbr material as the reflection texture.
  123228. * As in the majority of the scene they are the same (exception for multi room and so on),
  123229. * this is easier to set here than in all the materials.
  123230. */
  123231. set environmentTexture(value: Nullable<BaseTexture>);
  123232. /** @hidden */
  123233. protected _environmentIntensity: number;
  123234. /**
  123235. * Intensity of the environment in all pbr material.
  123236. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123237. * As in the majority of the scene they are the same (exception for multi room and so on),
  123238. * this is easier to reference from here than from all the materials.
  123239. */
  123240. get environmentIntensity(): number;
  123241. /**
  123242. * Intensity of the environment in all pbr material.
  123243. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123244. * As in the majority of the scene they are the same (exception for multi room and so on),
  123245. * this is easier to set here than in all the materials.
  123246. */
  123247. set environmentIntensity(value: number);
  123248. /** @hidden */
  123249. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123250. /**
  123251. * Default image processing configuration used either in the rendering
  123252. * Forward main pass or through the imageProcessingPostProcess if present.
  123253. * As in the majority of the scene they are the same (exception for multi camera),
  123254. * this is easier to reference from here than from all the materials and post process.
  123255. *
  123256. * No setter as we it is a shared configuration, you can set the values instead.
  123257. */
  123258. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123259. private _forceWireframe;
  123260. /**
  123261. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123262. */
  123263. set forceWireframe(value: boolean);
  123264. get forceWireframe(): boolean;
  123265. private _skipFrustumClipping;
  123266. /**
  123267. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123268. */
  123269. set skipFrustumClipping(value: boolean);
  123270. get skipFrustumClipping(): boolean;
  123271. private _forcePointsCloud;
  123272. /**
  123273. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123274. */
  123275. set forcePointsCloud(value: boolean);
  123276. get forcePointsCloud(): boolean;
  123277. /**
  123278. * Gets or sets the active clipplane 1
  123279. */
  123280. clipPlane: Nullable<Plane>;
  123281. /**
  123282. * Gets or sets the active clipplane 2
  123283. */
  123284. clipPlane2: Nullable<Plane>;
  123285. /**
  123286. * Gets or sets the active clipplane 3
  123287. */
  123288. clipPlane3: Nullable<Plane>;
  123289. /**
  123290. * Gets or sets the active clipplane 4
  123291. */
  123292. clipPlane4: Nullable<Plane>;
  123293. /**
  123294. * Gets or sets the active clipplane 5
  123295. */
  123296. clipPlane5: Nullable<Plane>;
  123297. /**
  123298. * Gets or sets the active clipplane 6
  123299. */
  123300. clipPlane6: Nullable<Plane>;
  123301. /**
  123302. * Gets or sets a boolean indicating if animations are enabled
  123303. */
  123304. animationsEnabled: boolean;
  123305. private _animationPropertiesOverride;
  123306. /**
  123307. * Gets or sets the animation properties override
  123308. */
  123309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123310. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123311. /**
  123312. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123313. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123314. */
  123315. useConstantAnimationDeltaTime: boolean;
  123316. /**
  123317. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123318. * Please note that it requires to run a ray cast through the scene on every frame
  123319. */
  123320. constantlyUpdateMeshUnderPointer: boolean;
  123321. /**
  123322. * Defines the HTML cursor to use when hovering over interactive elements
  123323. */
  123324. hoverCursor: string;
  123325. /**
  123326. * Defines the HTML default cursor to use (empty by default)
  123327. */
  123328. defaultCursor: string;
  123329. /**
  123330. * Defines whether cursors are handled by the scene.
  123331. */
  123332. doNotHandleCursors: boolean;
  123333. /**
  123334. * This is used to call preventDefault() on pointer down
  123335. * in order to block unwanted artifacts like system double clicks
  123336. */
  123337. preventDefaultOnPointerDown: boolean;
  123338. /**
  123339. * This is used to call preventDefault() on pointer up
  123340. * in order to block unwanted artifacts like system double clicks
  123341. */
  123342. preventDefaultOnPointerUp: boolean;
  123343. /**
  123344. * Gets or sets user defined metadata
  123345. */
  123346. metadata: any;
  123347. /**
  123348. * For internal use only. Please do not use.
  123349. */
  123350. reservedDataStore: any;
  123351. /**
  123352. * Gets the name of the plugin used to load this scene (null by default)
  123353. */
  123354. loadingPluginName: string;
  123355. /**
  123356. * Use this array to add regular expressions used to disable offline support for specific urls
  123357. */
  123358. disableOfflineSupportExceptionRules: RegExp[];
  123359. /**
  123360. * An event triggered when the scene is disposed.
  123361. */
  123362. onDisposeObservable: Observable<Scene>;
  123363. private _onDisposeObserver;
  123364. /** Sets a function to be executed when this scene is disposed. */
  123365. set onDispose(callback: () => void);
  123366. /**
  123367. * An event triggered before rendering the scene (right after animations and physics)
  123368. */
  123369. onBeforeRenderObservable: Observable<Scene>;
  123370. private _onBeforeRenderObserver;
  123371. /** Sets a function to be executed before rendering this scene */
  123372. set beforeRender(callback: Nullable<() => void>);
  123373. /**
  123374. * An event triggered after rendering the scene
  123375. */
  123376. onAfterRenderObservable: Observable<Scene>;
  123377. /**
  123378. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123379. */
  123380. onAfterRenderCameraObservable: Observable<Camera>;
  123381. private _onAfterRenderObserver;
  123382. /** Sets a function to be executed after rendering this scene */
  123383. set afterRender(callback: Nullable<() => void>);
  123384. /**
  123385. * An event triggered before animating the scene
  123386. */
  123387. onBeforeAnimationsObservable: Observable<Scene>;
  123388. /**
  123389. * An event triggered after animations processing
  123390. */
  123391. onAfterAnimationsObservable: Observable<Scene>;
  123392. /**
  123393. * An event triggered before draw calls are ready to be sent
  123394. */
  123395. onBeforeDrawPhaseObservable: Observable<Scene>;
  123396. /**
  123397. * An event triggered after draw calls have been sent
  123398. */
  123399. onAfterDrawPhaseObservable: Observable<Scene>;
  123400. /**
  123401. * An event triggered when the scene is ready
  123402. */
  123403. onReadyObservable: Observable<Scene>;
  123404. /**
  123405. * An event triggered before rendering a camera
  123406. */
  123407. onBeforeCameraRenderObservable: Observable<Camera>;
  123408. private _onBeforeCameraRenderObserver;
  123409. /** Sets a function to be executed before rendering a camera*/
  123410. set beforeCameraRender(callback: () => void);
  123411. /**
  123412. * An event triggered after rendering a camera
  123413. */
  123414. onAfterCameraRenderObservable: Observable<Camera>;
  123415. private _onAfterCameraRenderObserver;
  123416. /** Sets a function to be executed after rendering a camera*/
  123417. set afterCameraRender(callback: () => void);
  123418. /**
  123419. * An event triggered when active meshes evaluation is about to start
  123420. */
  123421. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123422. /**
  123423. * An event triggered when active meshes evaluation is done
  123424. */
  123425. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123426. /**
  123427. * An event triggered when particles rendering is about to start
  123428. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123429. */
  123430. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123431. /**
  123432. * An event triggered when particles rendering is done
  123433. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123434. */
  123435. onAfterParticlesRenderingObservable: Observable<Scene>;
  123436. /**
  123437. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123438. */
  123439. onDataLoadedObservable: Observable<Scene>;
  123440. /**
  123441. * An event triggered when a camera is created
  123442. */
  123443. onNewCameraAddedObservable: Observable<Camera>;
  123444. /**
  123445. * An event triggered when a camera is removed
  123446. */
  123447. onCameraRemovedObservable: Observable<Camera>;
  123448. /**
  123449. * An event triggered when a light is created
  123450. */
  123451. onNewLightAddedObservable: Observable<Light>;
  123452. /**
  123453. * An event triggered when a light is removed
  123454. */
  123455. onLightRemovedObservable: Observable<Light>;
  123456. /**
  123457. * An event triggered when a geometry is created
  123458. */
  123459. onNewGeometryAddedObservable: Observable<Geometry>;
  123460. /**
  123461. * An event triggered when a geometry is removed
  123462. */
  123463. onGeometryRemovedObservable: Observable<Geometry>;
  123464. /**
  123465. * An event triggered when a transform node is created
  123466. */
  123467. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123468. /**
  123469. * An event triggered when a transform node is removed
  123470. */
  123471. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123472. /**
  123473. * An event triggered when a mesh is created
  123474. */
  123475. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123476. /**
  123477. * An event triggered when a mesh is removed
  123478. */
  123479. onMeshRemovedObservable: Observable<AbstractMesh>;
  123480. /**
  123481. * An event triggered when a skeleton is created
  123482. */
  123483. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123484. /**
  123485. * An event triggered when a skeleton is removed
  123486. */
  123487. onSkeletonRemovedObservable: Observable<Skeleton>;
  123488. /**
  123489. * An event triggered when a material is created
  123490. */
  123491. onNewMaterialAddedObservable: Observable<Material>;
  123492. /**
  123493. * An event triggered when a material is removed
  123494. */
  123495. onMaterialRemovedObservable: Observable<Material>;
  123496. /**
  123497. * An event triggered when a texture is created
  123498. */
  123499. onNewTextureAddedObservable: Observable<BaseTexture>;
  123500. /**
  123501. * An event triggered when a texture is removed
  123502. */
  123503. onTextureRemovedObservable: Observable<BaseTexture>;
  123504. /**
  123505. * An event triggered when render targets are about to be rendered
  123506. * Can happen multiple times per frame.
  123507. */
  123508. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123509. /**
  123510. * An event triggered when render targets were rendered.
  123511. * Can happen multiple times per frame.
  123512. */
  123513. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123514. /**
  123515. * An event triggered before calculating deterministic simulation step
  123516. */
  123517. onBeforeStepObservable: Observable<Scene>;
  123518. /**
  123519. * An event triggered after calculating deterministic simulation step
  123520. */
  123521. onAfterStepObservable: Observable<Scene>;
  123522. /**
  123523. * An event triggered when the activeCamera property is updated
  123524. */
  123525. onActiveCameraChanged: Observable<Scene>;
  123526. /**
  123527. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123528. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123529. * 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)
  123530. */
  123531. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123532. /**
  123533. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123534. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123535. * 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)
  123536. */
  123537. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123538. /**
  123539. * This Observable will when a mesh has been imported into the scene.
  123540. */
  123541. onMeshImportedObservable: Observable<AbstractMesh>;
  123542. /**
  123543. * This Observable will when an animation file has been imported into the scene.
  123544. */
  123545. onAnimationFileImportedObservable: Observable<Scene>;
  123546. /**
  123547. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123548. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123549. */
  123550. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123551. /** @hidden */
  123552. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123553. /**
  123554. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123555. */
  123556. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123557. /**
  123558. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123559. */
  123560. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123561. /**
  123562. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123563. */
  123564. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123565. /** Callback called when a pointer move is detected */
  123566. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123567. /** Callback called when a pointer down is detected */
  123568. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123569. /** Callback called when a pointer up is detected */
  123570. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123571. /** Callback called when a pointer pick is detected */
  123572. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123573. /**
  123574. * 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).
  123575. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123576. */
  123577. onPrePointerObservable: Observable<PointerInfoPre>;
  123578. /**
  123579. * Observable event triggered each time an input event is received from the rendering canvas
  123580. */
  123581. onPointerObservable: Observable<PointerInfo>;
  123582. /**
  123583. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123584. */
  123585. get unTranslatedPointer(): Vector2;
  123586. /**
  123587. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123588. */
  123589. static get DragMovementThreshold(): number;
  123590. static set DragMovementThreshold(value: number);
  123591. /**
  123592. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123593. */
  123594. static get LongPressDelay(): number;
  123595. static set LongPressDelay(value: number);
  123596. /**
  123597. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123598. */
  123599. static get DoubleClickDelay(): number;
  123600. static set DoubleClickDelay(value: number);
  123601. /** If you need to check double click without raising a single click at first click, enable this flag */
  123602. static get ExclusiveDoubleClickMode(): boolean;
  123603. static set ExclusiveDoubleClickMode(value: boolean);
  123604. /** @hidden */
  123605. _mirroredCameraPosition: Nullable<Vector3>;
  123606. /**
  123607. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123608. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123609. */
  123610. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123611. /**
  123612. * Observable event triggered each time an keyboard event is received from the hosting window
  123613. */
  123614. onKeyboardObservable: Observable<KeyboardInfo>;
  123615. private _useRightHandedSystem;
  123616. /**
  123617. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123618. */
  123619. set useRightHandedSystem(value: boolean);
  123620. get useRightHandedSystem(): boolean;
  123621. private _timeAccumulator;
  123622. private _currentStepId;
  123623. private _currentInternalStep;
  123624. /**
  123625. * Sets the step Id used by deterministic lock step
  123626. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123627. * @param newStepId defines the step Id
  123628. */
  123629. setStepId(newStepId: number): void;
  123630. /**
  123631. * Gets the step Id used by deterministic lock step
  123632. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123633. * @returns the step Id
  123634. */
  123635. getStepId(): number;
  123636. /**
  123637. * Gets the internal step used by deterministic lock step
  123638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123639. * @returns the internal step
  123640. */
  123641. getInternalStep(): number;
  123642. private _fogEnabled;
  123643. /**
  123644. * Gets or sets a boolean indicating if fog is enabled on this scene
  123645. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123646. * (Default is true)
  123647. */
  123648. set fogEnabled(value: boolean);
  123649. get fogEnabled(): boolean;
  123650. private _fogMode;
  123651. /**
  123652. * Gets or sets the fog mode to use
  123653. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123654. * | mode | value |
  123655. * | --- | --- |
  123656. * | FOGMODE_NONE | 0 |
  123657. * | FOGMODE_EXP | 1 |
  123658. * | FOGMODE_EXP2 | 2 |
  123659. * | FOGMODE_LINEAR | 3 |
  123660. */
  123661. set fogMode(value: number);
  123662. get fogMode(): number;
  123663. /**
  123664. * Gets or sets the fog color to use
  123665. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123666. * (Default is Color3(0.2, 0.2, 0.3))
  123667. */
  123668. fogColor: Color3;
  123669. /**
  123670. * Gets or sets the fog density to use
  123671. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123672. * (Default is 0.1)
  123673. */
  123674. fogDensity: number;
  123675. /**
  123676. * Gets or sets the fog start distance to use
  123677. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123678. * (Default is 0)
  123679. */
  123680. fogStart: number;
  123681. /**
  123682. * Gets or sets the fog end distance to use
  123683. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123684. * (Default is 1000)
  123685. */
  123686. fogEnd: number;
  123687. /**
  123688. * Flag indicating that the frame buffer binding is handled by another component
  123689. */
  123690. prePass: boolean;
  123691. private _shadowsEnabled;
  123692. /**
  123693. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123694. */
  123695. set shadowsEnabled(value: boolean);
  123696. get shadowsEnabled(): boolean;
  123697. private _lightsEnabled;
  123698. /**
  123699. * Gets or sets a boolean indicating if lights are enabled on this scene
  123700. */
  123701. set lightsEnabled(value: boolean);
  123702. get lightsEnabled(): boolean;
  123703. /** All of the active cameras added to this scene. */
  123704. activeCameras: Camera[];
  123705. /** @hidden */
  123706. _activeCamera: Nullable<Camera>;
  123707. /** Gets or sets the current active camera */
  123708. get activeCamera(): Nullable<Camera>;
  123709. set activeCamera(value: Nullable<Camera>);
  123710. private _defaultMaterial;
  123711. /** The default material used on meshes when no material is affected */
  123712. get defaultMaterial(): Material;
  123713. /** The default material used on meshes when no material is affected */
  123714. set defaultMaterial(value: Material);
  123715. private _texturesEnabled;
  123716. /**
  123717. * Gets or sets a boolean indicating if textures are enabled on this scene
  123718. */
  123719. set texturesEnabled(value: boolean);
  123720. get texturesEnabled(): boolean;
  123721. /**
  123722. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123723. */
  123724. physicsEnabled: boolean;
  123725. /**
  123726. * Gets or sets a boolean indicating if particles are enabled on this scene
  123727. */
  123728. particlesEnabled: boolean;
  123729. /**
  123730. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123731. */
  123732. spritesEnabled: boolean;
  123733. private _skeletonsEnabled;
  123734. /**
  123735. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123736. */
  123737. set skeletonsEnabled(value: boolean);
  123738. get skeletonsEnabled(): boolean;
  123739. /**
  123740. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123741. */
  123742. lensFlaresEnabled: boolean;
  123743. /**
  123744. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123745. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123746. */
  123747. collisionsEnabled: boolean;
  123748. private _collisionCoordinator;
  123749. /** @hidden */
  123750. get collisionCoordinator(): ICollisionCoordinator;
  123751. /**
  123752. * Defines the gravity applied to this scene (used only for collisions)
  123753. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123754. */
  123755. gravity: Vector3;
  123756. /**
  123757. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123758. */
  123759. postProcessesEnabled: boolean;
  123760. /**
  123761. * Gets the current postprocess manager
  123762. */
  123763. postProcessManager: PostProcessManager;
  123764. /**
  123765. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123766. */
  123767. renderTargetsEnabled: boolean;
  123768. /**
  123769. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123770. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123771. */
  123772. dumpNextRenderTargets: boolean;
  123773. /**
  123774. * The list of user defined render targets added to the scene
  123775. */
  123776. customRenderTargets: RenderTargetTexture[];
  123777. /**
  123778. * Defines if texture loading must be delayed
  123779. * If true, textures will only be loaded when they need to be rendered
  123780. */
  123781. useDelayedTextureLoading: boolean;
  123782. /**
  123783. * Gets the list of meshes imported to the scene through SceneLoader
  123784. */
  123785. importedMeshesFiles: String[];
  123786. /**
  123787. * Gets or sets a boolean indicating if probes are enabled on this scene
  123788. */
  123789. probesEnabled: boolean;
  123790. /**
  123791. * Gets or sets the current offline provider to use to store scene data
  123792. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123793. */
  123794. offlineProvider: IOfflineProvider;
  123795. /**
  123796. * Gets or sets the action manager associated with the scene
  123797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123798. */
  123799. actionManager: AbstractActionManager;
  123800. private _meshesForIntersections;
  123801. /**
  123802. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123803. */
  123804. proceduralTexturesEnabled: boolean;
  123805. private _engine;
  123806. private _totalVertices;
  123807. /** @hidden */
  123808. _activeIndices: PerfCounter;
  123809. /** @hidden */
  123810. _activeParticles: PerfCounter;
  123811. /** @hidden */
  123812. _activeBones: PerfCounter;
  123813. private _animationRatio;
  123814. /** @hidden */
  123815. _animationTimeLast: number;
  123816. /** @hidden */
  123817. _animationTime: number;
  123818. /**
  123819. * Gets or sets a general scale for animation speed
  123820. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123821. */
  123822. animationTimeScale: number;
  123823. /** @hidden */
  123824. _cachedMaterial: Nullable<Material>;
  123825. /** @hidden */
  123826. _cachedEffect: Nullable<Effect>;
  123827. /** @hidden */
  123828. _cachedVisibility: Nullable<number>;
  123829. private _renderId;
  123830. private _frameId;
  123831. private _executeWhenReadyTimeoutId;
  123832. private _intermediateRendering;
  123833. private _viewUpdateFlag;
  123834. private _projectionUpdateFlag;
  123835. /** @hidden */
  123836. _toBeDisposed: Nullable<IDisposable>[];
  123837. private _activeRequests;
  123838. /** @hidden */
  123839. _pendingData: any[];
  123840. private _isDisposed;
  123841. /**
  123842. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123843. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123844. */
  123845. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123846. private _activeMeshes;
  123847. private _processedMaterials;
  123848. private _renderTargets;
  123849. /** @hidden */
  123850. _activeParticleSystems: SmartArray<IParticleSystem>;
  123851. private _activeSkeletons;
  123852. private _softwareSkinnedMeshes;
  123853. private _renderingManager;
  123854. /** @hidden */
  123855. _activeAnimatables: Animatable[];
  123856. private _transformMatrix;
  123857. private _sceneUbo;
  123858. /** @hidden */
  123859. _viewMatrix: Matrix;
  123860. private _projectionMatrix;
  123861. /** @hidden */
  123862. _forcedViewPosition: Nullable<Vector3>;
  123863. /** @hidden */
  123864. _frustumPlanes: Plane[];
  123865. /**
  123866. * Gets the list of frustum planes (built from the active camera)
  123867. */
  123868. get frustumPlanes(): Plane[];
  123869. /**
  123870. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123871. * This is useful if there are more lights that the maximum simulteanous authorized
  123872. */
  123873. requireLightSorting: boolean;
  123874. /** @hidden */
  123875. readonly useMaterialMeshMap: boolean;
  123876. /** @hidden */
  123877. readonly useClonedMeshMap: boolean;
  123878. private _externalData;
  123879. private _uid;
  123880. /**
  123881. * @hidden
  123882. * Backing store of defined scene components.
  123883. */
  123884. _components: ISceneComponent[];
  123885. /**
  123886. * @hidden
  123887. * Backing store of defined scene components.
  123888. */
  123889. _serializableComponents: ISceneSerializableComponent[];
  123890. /**
  123891. * List of components to register on the next registration step.
  123892. */
  123893. private _transientComponents;
  123894. /**
  123895. * Registers the transient components if needed.
  123896. */
  123897. private _registerTransientComponents;
  123898. /**
  123899. * @hidden
  123900. * Add a component to the scene.
  123901. * Note that the ccomponent could be registered on th next frame if this is called after
  123902. * the register component stage.
  123903. * @param component Defines the component to add to the scene
  123904. */
  123905. _addComponent(component: ISceneComponent): void;
  123906. /**
  123907. * @hidden
  123908. * Gets a component from the scene.
  123909. * @param name defines the name of the component to retrieve
  123910. * @returns the component or null if not present
  123911. */
  123912. _getComponent(name: string): Nullable<ISceneComponent>;
  123913. /**
  123914. * @hidden
  123915. * Defines the actions happening before camera updates.
  123916. */
  123917. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123918. /**
  123919. * @hidden
  123920. * Defines the actions happening before clear the canvas.
  123921. */
  123922. _beforeClearStage: Stage<SimpleStageAction>;
  123923. /**
  123924. * @hidden
  123925. * Defines the actions when collecting render targets for the frame.
  123926. */
  123927. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123928. /**
  123929. * @hidden
  123930. * Defines the actions happening for one camera in the frame.
  123931. */
  123932. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123933. /**
  123934. * @hidden
  123935. * Defines the actions happening during the per mesh ready checks.
  123936. */
  123937. _isReadyForMeshStage: Stage<MeshStageAction>;
  123938. /**
  123939. * @hidden
  123940. * Defines the actions happening before evaluate active mesh checks.
  123941. */
  123942. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123943. /**
  123944. * @hidden
  123945. * Defines the actions happening during the evaluate sub mesh checks.
  123946. */
  123947. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123948. /**
  123949. * @hidden
  123950. * Defines the actions happening during the active mesh stage.
  123951. */
  123952. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123953. /**
  123954. * @hidden
  123955. * Defines the actions happening during the per camera render target step.
  123956. */
  123957. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123958. /**
  123959. * @hidden
  123960. * Defines the actions happening just before the active camera is drawing.
  123961. */
  123962. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123963. /**
  123964. * @hidden
  123965. * Defines the actions happening just before a render target is drawing.
  123966. */
  123967. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123968. /**
  123969. * @hidden
  123970. * Defines the actions happening just before a rendering group is drawing.
  123971. */
  123972. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123973. /**
  123974. * @hidden
  123975. * Defines the actions happening just before a mesh is drawing.
  123976. */
  123977. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123978. /**
  123979. * @hidden
  123980. * Defines the actions happening just after a mesh has been drawn.
  123981. */
  123982. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123983. /**
  123984. * @hidden
  123985. * Defines the actions happening just after a rendering group has been drawn.
  123986. */
  123987. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123988. /**
  123989. * @hidden
  123990. * Defines the actions happening just after the active camera has been drawn.
  123991. */
  123992. _afterCameraDrawStage: Stage<CameraStageAction>;
  123993. /**
  123994. * @hidden
  123995. * Defines the actions happening just after a render target has been drawn.
  123996. */
  123997. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123998. /**
  123999. * @hidden
  124000. * Defines the actions happening just after rendering all cameras and computing intersections.
  124001. */
  124002. _afterRenderStage: Stage<SimpleStageAction>;
  124003. /**
  124004. * @hidden
  124005. * Defines the actions happening when a pointer move event happens.
  124006. */
  124007. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124008. /**
  124009. * @hidden
  124010. * Defines the actions happening when a pointer down event happens.
  124011. */
  124012. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124013. /**
  124014. * @hidden
  124015. * Defines the actions happening when a pointer up event happens.
  124016. */
  124017. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124018. /**
  124019. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124020. */
  124021. private geometriesByUniqueId;
  124022. /**
  124023. * Creates a new Scene
  124024. * @param engine defines the engine to use to render this scene
  124025. * @param options defines the scene options
  124026. */
  124027. constructor(engine: Engine, options?: SceneOptions);
  124028. /**
  124029. * Gets a string identifying the name of the class
  124030. * @returns "Scene" string
  124031. */
  124032. getClassName(): string;
  124033. private _defaultMeshCandidates;
  124034. /**
  124035. * @hidden
  124036. */
  124037. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124038. private _defaultSubMeshCandidates;
  124039. /**
  124040. * @hidden
  124041. */
  124042. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124043. /**
  124044. * Sets the default candidate providers for the scene.
  124045. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124046. * and getCollidingSubMeshCandidates to their default function
  124047. */
  124048. setDefaultCandidateProviders(): void;
  124049. /**
  124050. * Gets the mesh that is currently under the pointer
  124051. */
  124052. get meshUnderPointer(): Nullable<AbstractMesh>;
  124053. /**
  124054. * Gets or sets the current on-screen X position of the pointer
  124055. */
  124056. get pointerX(): number;
  124057. set pointerX(value: number);
  124058. /**
  124059. * Gets or sets the current on-screen Y position of the pointer
  124060. */
  124061. get pointerY(): number;
  124062. set pointerY(value: number);
  124063. /**
  124064. * Gets the cached material (ie. the latest rendered one)
  124065. * @returns the cached material
  124066. */
  124067. getCachedMaterial(): Nullable<Material>;
  124068. /**
  124069. * Gets the cached effect (ie. the latest rendered one)
  124070. * @returns the cached effect
  124071. */
  124072. getCachedEffect(): Nullable<Effect>;
  124073. /**
  124074. * Gets the cached visibility state (ie. the latest rendered one)
  124075. * @returns the cached visibility state
  124076. */
  124077. getCachedVisibility(): Nullable<number>;
  124078. /**
  124079. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124080. * @param material defines the current material
  124081. * @param effect defines the current effect
  124082. * @param visibility defines the current visibility state
  124083. * @returns true if one parameter is not cached
  124084. */
  124085. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124086. /**
  124087. * Gets the engine associated with the scene
  124088. * @returns an Engine
  124089. */
  124090. getEngine(): Engine;
  124091. /**
  124092. * Gets the total number of vertices rendered per frame
  124093. * @returns the total number of vertices rendered per frame
  124094. */
  124095. getTotalVertices(): number;
  124096. /**
  124097. * Gets the performance counter for total vertices
  124098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124099. */
  124100. get totalVerticesPerfCounter(): PerfCounter;
  124101. /**
  124102. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124103. * @returns the total number of active indices rendered per frame
  124104. */
  124105. getActiveIndices(): number;
  124106. /**
  124107. * Gets the performance counter for active indices
  124108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124109. */
  124110. get totalActiveIndicesPerfCounter(): PerfCounter;
  124111. /**
  124112. * Gets the total number of active particles rendered per frame
  124113. * @returns the total number of active particles rendered per frame
  124114. */
  124115. getActiveParticles(): number;
  124116. /**
  124117. * Gets the performance counter for active particles
  124118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124119. */
  124120. get activeParticlesPerfCounter(): PerfCounter;
  124121. /**
  124122. * Gets the total number of active bones rendered per frame
  124123. * @returns the total number of active bones rendered per frame
  124124. */
  124125. getActiveBones(): number;
  124126. /**
  124127. * Gets the performance counter for active bones
  124128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124129. */
  124130. get activeBonesPerfCounter(): PerfCounter;
  124131. /**
  124132. * Gets the array of active meshes
  124133. * @returns an array of AbstractMesh
  124134. */
  124135. getActiveMeshes(): SmartArray<AbstractMesh>;
  124136. /**
  124137. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124138. * @returns a number
  124139. */
  124140. getAnimationRatio(): number;
  124141. /**
  124142. * Gets an unique Id for the current render phase
  124143. * @returns a number
  124144. */
  124145. getRenderId(): number;
  124146. /**
  124147. * Gets an unique Id for the current frame
  124148. * @returns a number
  124149. */
  124150. getFrameId(): number;
  124151. /** Call this function if you want to manually increment the render Id*/
  124152. incrementRenderId(): void;
  124153. private _createUbo;
  124154. /**
  124155. * Use this method to simulate a pointer move on a mesh
  124156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124159. * @returns the current scene
  124160. */
  124161. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124162. /**
  124163. * Use this method to simulate a pointer down on a mesh
  124164. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124165. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124166. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124167. * @returns the current scene
  124168. */
  124169. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124170. /**
  124171. * Use this method to simulate a pointer up on a mesh
  124172. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124173. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124174. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124175. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124176. * @returns the current scene
  124177. */
  124178. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124179. /**
  124180. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124181. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124182. * @returns true if the pointer was captured
  124183. */
  124184. isPointerCaptured(pointerId?: number): boolean;
  124185. /**
  124186. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124187. * @param attachUp defines if you want to attach events to pointerup
  124188. * @param attachDown defines if you want to attach events to pointerdown
  124189. * @param attachMove defines if you want to attach events to pointermove
  124190. */
  124191. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124192. /** Detaches all event handlers*/
  124193. detachControl(): void;
  124194. /**
  124195. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124196. * Delay loaded resources are not taking in account
  124197. * @return true if all required resources are ready
  124198. */
  124199. isReady(): boolean;
  124200. /** Resets all cached information relative to material (including effect and visibility) */
  124201. resetCachedMaterial(): void;
  124202. /**
  124203. * Registers a function to be called before every frame render
  124204. * @param func defines the function to register
  124205. */
  124206. registerBeforeRender(func: () => void): void;
  124207. /**
  124208. * Unregisters a function called before every frame render
  124209. * @param func defines the function to unregister
  124210. */
  124211. unregisterBeforeRender(func: () => void): void;
  124212. /**
  124213. * Registers a function to be called after every frame render
  124214. * @param func defines the function to register
  124215. */
  124216. registerAfterRender(func: () => void): void;
  124217. /**
  124218. * Unregisters a function called after every frame render
  124219. * @param func defines the function to unregister
  124220. */
  124221. unregisterAfterRender(func: () => void): void;
  124222. private _executeOnceBeforeRender;
  124223. /**
  124224. * The provided function will run before render once and will be disposed afterwards.
  124225. * A timeout delay can be provided so that the function will be executed in N ms.
  124226. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124227. * @param func The function to be executed.
  124228. * @param timeout optional delay in ms
  124229. */
  124230. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124231. /** @hidden */
  124232. _addPendingData(data: any): void;
  124233. /** @hidden */
  124234. _removePendingData(data: any): void;
  124235. /**
  124236. * Returns the number of items waiting to be loaded
  124237. * @returns the number of items waiting to be loaded
  124238. */
  124239. getWaitingItemsCount(): number;
  124240. /**
  124241. * Returns a boolean indicating if the scene is still loading data
  124242. */
  124243. get isLoading(): boolean;
  124244. /**
  124245. * Registers a function to be executed when the scene is ready
  124246. * @param {Function} func - the function to be executed
  124247. */
  124248. executeWhenReady(func: () => void): void;
  124249. /**
  124250. * Returns a promise that resolves when the scene is ready
  124251. * @returns A promise that resolves when the scene is ready
  124252. */
  124253. whenReadyAsync(): Promise<void>;
  124254. /** @hidden */
  124255. _checkIsReady(): void;
  124256. /**
  124257. * Gets all animatable attached to the scene
  124258. */
  124259. get animatables(): Animatable[];
  124260. /**
  124261. * Resets the last animation time frame.
  124262. * Useful to override when animations start running when loading a scene for the first time.
  124263. */
  124264. resetLastAnimationTimeFrame(): void;
  124265. /**
  124266. * Gets the current view matrix
  124267. * @returns a Matrix
  124268. */
  124269. getViewMatrix(): Matrix;
  124270. /**
  124271. * Gets the current projection matrix
  124272. * @returns a Matrix
  124273. */
  124274. getProjectionMatrix(): Matrix;
  124275. /**
  124276. * Gets the current transform matrix
  124277. * @returns a Matrix made of View * Projection
  124278. */
  124279. getTransformMatrix(): Matrix;
  124280. /**
  124281. * Sets the current transform matrix
  124282. * @param viewL defines the View matrix to use
  124283. * @param projectionL defines the Projection matrix to use
  124284. * @param viewR defines the right View matrix to use (if provided)
  124285. * @param projectionR defines the right Projection matrix to use (if provided)
  124286. */
  124287. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124288. /**
  124289. * Gets the uniform buffer used to store scene data
  124290. * @returns a UniformBuffer
  124291. */
  124292. getSceneUniformBuffer(): UniformBuffer;
  124293. /**
  124294. * Gets an unique (relatively to the current scene) Id
  124295. * @returns an unique number for the scene
  124296. */
  124297. getUniqueId(): number;
  124298. /**
  124299. * Add a mesh to the list of scene's meshes
  124300. * @param newMesh defines the mesh to add
  124301. * @param recursive if all child meshes should also be added to the scene
  124302. */
  124303. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124304. /**
  124305. * Remove a mesh for the list of scene's meshes
  124306. * @param toRemove defines the mesh to remove
  124307. * @param recursive if all child meshes should also be removed from the scene
  124308. * @returns the index where the mesh was in the mesh list
  124309. */
  124310. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124311. /**
  124312. * Add a transform node to the list of scene's transform nodes
  124313. * @param newTransformNode defines the transform node to add
  124314. */
  124315. addTransformNode(newTransformNode: TransformNode): void;
  124316. /**
  124317. * Remove a transform node for the list of scene's transform nodes
  124318. * @param toRemove defines the transform node to remove
  124319. * @returns the index where the transform node was in the transform node list
  124320. */
  124321. removeTransformNode(toRemove: TransformNode): number;
  124322. /**
  124323. * Remove a skeleton for the list of scene's skeletons
  124324. * @param toRemove defines the skeleton to remove
  124325. * @returns the index where the skeleton was in the skeleton list
  124326. */
  124327. removeSkeleton(toRemove: Skeleton): number;
  124328. /**
  124329. * Remove a morph target for the list of scene's morph targets
  124330. * @param toRemove defines the morph target to remove
  124331. * @returns the index where the morph target was in the morph target list
  124332. */
  124333. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124334. /**
  124335. * Remove a light for the list of scene's lights
  124336. * @param toRemove defines the light to remove
  124337. * @returns the index where the light was in the light list
  124338. */
  124339. removeLight(toRemove: Light): number;
  124340. /**
  124341. * Remove a camera for the list of scene's cameras
  124342. * @param toRemove defines the camera to remove
  124343. * @returns the index where the camera was in the camera list
  124344. */
  124345. removeCamera(toRemove: Camera): number;
  124346. /**
  124347. * Remove a particle system for the list of scene's particle systems
  124348. * @param toRemove defines the particle system to remove
  124349. * @returns the index where the particle system was in the particle system list
  124350. */
  124351. removeParticleSystem(toRemove: IParticleSystem): number;
  124352. /**
  124353. * Remove a animation for the list of scene's animations
  124354. * @param toRemove defines the animation to remove
  124355. * @returns the index where the animation was in the animation list
  124356. */
  124357. removeAnimation(toRemove: Animation): number;
  124358. /**
  124359. * Will stop the animation of the given target
  124360. * @param target - the target
  124361. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124362. * @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)
  124363. */
  124364. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124365. /**
  124366. * Removes the given animation group from this scene.
  124367. * @param toRemove The animation group to remove
  124368. * @returns The index of the removed animation group
  124369. */
  124370. removeAnimationGroup(toRemove: AnimationGroup): number;
  124371. /**
  124372. * Removes the given multi-material from this scene.
  124373. * @param toRemove The multi-material to remove
  124374. * @returns The index of the removed multi-material
  124375. */
  124376. removeMultiMaterial(toRemove: MultiMaterial): number;
  124377. /**
  124378. * Removes the given material from this scene.
  124379. * @param toRemove The material to remove
  124380. * @returns The index of the removed material
  124381. */
  124382. removeMaterial(toRemove: Material): number;
  124383. /**
  124384. * Removes the given action manager from this scene.
  124385. * @param toRemove The action manager to remove
  124386. * @returns The index of the removed action manager
  124387. */
  124388. removeActionManager(toRemove: AbstractActionManager): number;
  124389. /**
  124390. * Removes the given texture from this scene.
  124391. * @param toRemove The texture to remove
  124392. * @returns The index of the removed texture
  124393. */
  124394. removeTexture(toRemove: BaseTexture): number;
  124395. /**
  124396. * Adds the given light to this scene
  124397. * @param newLight The light to add
  124398. */
  124399. addLight(newLight: Light): void;
  124400. /**
  124401. * Sorts the list list based on light priorities
  124402. */
  124403. sortLightsByPriority(): void;
  124404. /**
  124405. * Adds the given camera to this scene
  124406. * @param newCamera The camera to add
  124407. */
  124408. addCamera(newCamera: Camera): void;
  124409. /**
  124410. * Adds the given skeleton to this scene
  124411. * @param newSkeleton The skeleton to add
  124412. */
  124413. addSkeleton(newSkeleton: Skeleton): void;
  124414. /**
  124415. * Adds the given particle system to this scene
  124416. * @param newParticleSystem The particle system to add
  124417. */
  124418. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124419. /**
  124420. * Adds the given animation to this scene
  124421. * @param newAnimation The animation to add
  124422. */
  124423. addAnimation(newAnimation: Animation): void;
  124424. /**
  124425. * Adds the given animation group to this scene.
  124426. * @param newAnimationGroup The animation group to add
  124427. */
  124428. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124429. /**
  124430. * Adds the given multi-material to this scene
  124431. * @param newMultiMaterial The multi-material to add
  124432. */
  124433. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124434. /**
  124435. * Adds the given material to this scene
  124436. * @param newMaterial The material to add
  124437. */
  124438. addMaterial(newMaterial: Material): void;
  124439. /**
  124440. * Adds the given morph target to this scene
  124441. * @param newMorphTargetManager The morph target to add
  124442. */
  124443. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124444. /**
  124445. * Adds the given geometry to this scene
  124446. * @param newGeometry The geometry to add
  124447. */
  124448. addGeometry(newGeometry: Geometry): void;
  124449. /**
  124450. * Adds the given action manager to this scene
  124451. * @param newActionManager The action manager to add
  124452. */
  124453. addActionManager(newActionManager: AbstractActionManager): void;
  124454. /**
  124455. * Adds the given texture to this scene.
  124456. * @param newTexture The texture to add
  124457. */
  124458. addTexture(newTexture: BaseTexture): void;
  124459. /**
  124460. * Switch active camera
  124461. * @param newCamera defines the new active camera
  124462. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124463. */
  124464. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124465. /**
  124466. * sets the active camera of the scene using its ID
  124467. * @param id defines the camera's ID
  124468. * @return the new active camera or null if none found.
  124469. */
  124470. setActiveCameraByID(id: string): Nullable<Camera>;
  124471. /**
  124472. * sets the active camera of the scene using its name
  124473. * @param name defines the camera's name
  124474. * @returns the new active camera or null if none found.
  124475. */
  124476. setActiveCameraByName(name: string): Nullable<Camera>;
  124477. /**
  124478. * get an animation group using its name
  124479. * @param name defines the material's name
  124480. * @return the animation group or null if none found.
  124481. */
  124482. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124483. /**
  124484. * Get a material using its unique id
  124485. * @param uniqueId defines the material's unique id
  124486. * @return the material or null if none found.
  124487. */
  124488. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124489. /**
  124490. * get a material using its id
  124491. * @param id defines the material's ID
  124492. * @return the material or null if none found.
  124493. */
  124494. getMaterialByID(id: string): Nullable<Material>;
  124495. /**
  124496. * Gets a the last added material using a given id
  124497. * @param id defines the material's ID
  124498. * @return the last material with the given id or null if none found.
  124499. */
  124500. getLastMaterialByID(id: string): Nullable<Material>;
  124501. /**
  124502. * Gets a material using its name
  124503. * @param name defines the material's name
  124504. * @return the material or null if none found.
  124505. */
  124506. getMaterialByName(name: string): Nullable<Material>;
  124507. /**
  124508. * Get a texture using its unique id
  124509. * @param uniqueId defines the texture's unique id
  124510. * @return the texture or null if none found.
  124511. */
  124512. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124513. /**
  124514. * Gets a camera using its id
  124515. * @param id defines the id to look for
  124516. * @returns the camera or null if not found
  124517. */
  124518. getCameraByID(id: string): Nullable<Camera>;
  124519. /**
  124520. * Gets a camera using its unique id
  124521. * @param uniqueId defines the unique id to look for
  124522. * @returns the camera or null if not found
  124523. */
  124524. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124525. /**
  124526. * Gets a camera using its name
  124527. * @param name defines the camera's name
  124528. * @return the camera or null if none found.
  124529. */
  124530. getCameraByName(name: string): Nullable<Camera>;
  124531. /**
  124532. * Gets a bone using its id
  124533. * @param id defines the bone's id
  124534. * @return the bone or null if not found
  124535. */
  124536. getBoneByID(id: string): Nullable<Bone>;
  124537. /**
  124538. * Gets a bone using its id
  124539. * @param name defines the bone's name
  124540. * @return the bone or null if not found
  124541. */
  124542. getBoneByName(name: string): Nullable<Bone>;
  124543. /**
  124544. * Gets a light node using its name
  124545. * @param name defines the the light's name
  124546. * @return the light or null if none found.
  124547. */
  124548. getLightByName(name: string): Nullable<Light>;
  124549. /**
  124550. * Gets a light node using its id
  124551. * @param id defines the light's id
  124552. * @return the light or null if none found.
  124553. */
  124554. getLightByID(id: string): Nullable<Light>;
  124555. /**
  124556. * Gets a light node using its scene-generated unique ID
  124557. * @param uniqueId defines the light's unique id
  124558. * @return the light or null if none found.
  124559. */
  124560. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124561. /**
  124562. * Gets a particle system by id
  124563. * @param id defines the particle system id
  124564. * @return the corresponding system or null if none found
  124565. */
  124566. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124567. /**
  124568. * Gets a geometry using its ID
  124569. * @param id defines the geometry's id
  124570. * @return the geometry or null if none found.
  124571. */
  124572. getGeometryByID(id: string): Nullable<Geometry>;
  124573. private _getGeometryByUniqueID;
  124574. /**
  124575. * Add a new geometry to this scene
  124576. * @param geometry defines the geometry to be added to the scene.
  124577. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124578. * @return a boolean defining if the geometry was added or not
  124579. */
  124580. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124581. /**
  124582. * Removes an existing geometry
  124583. * @param geometry defines the geometry to be removed from the scene
  124584. * @return a boolean defining if the geometry was removed or not
  124585. */
  124586. removeGeometry(geometry: Geometry): boolean;
  124587. /**
  124588. * Gets the list of geometries attached to the scene
  124589. * @returns an array of Geometry
  124590. */
  124591. getGeometries(): Geometry[];
  124592. /**
  124593. * Gets the first added mesh found of a given ID
  124594. * @param id defines the id to search for
  124595. * @return the mesh found or null if not found at all
  124596. */
  124597. getMeshByID(id: string): Nullable<AbstractMesh>;
  124598. /**
  124599. * Gets a list of meshes using their id
  124600. * @param id defines the id to search for
  124601. * @returns a list of meshes
  124602. */
  124603. getMeshesByID(id: string): Array<AbstractMesh>;
  124604. /**
  124605. * Gets the first added transform node found of a given ID
  124606. * @param id defines the id to search for
  124607. * @return the found transform node or null if not found at all.
  124608. */
  124609. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124610. /**
  124611. * Gets a transform node with its auto-generated unique id
  124612. * @param uniqueId efines the unique id to search for
  124613. * @return the found transform node or null if not found at all.
  124614. */
  124615. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124616. /**
  124617. * Gets a list of transform nodes using their id
  124618. * @param id defines the id to search for
  124619. * @returns a list of transform nodes
  124620. */
  124621. getTransformNodesByID(id: string): Array<TransformNode>;
  124622. /**
  124623. * Gets a mesh with its auto-generated unique id
  124624. * @param uniqueId defines the unique id to search for
  124625. * @return the found mesh or null if not found at all.
  124626. */
  124627. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124628. /**
  124629. * Gets a the last added mesh using a given id
  124630. * @param id defines the id to search for
  124631. * @return the found mesh or null if not found at all.
  124632. */
  124633. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124634. /**
  124635. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124636. * @param id defines the id to search for
  124637. * @return the found node or null if not found at all
  124638. */
  124639. getLastEntryByID(id: string): Nullable<Node>;
  124640. /**
  124641. * Gets a node (Mesh, Camera, Light) using a given id
  124642. * @param id defines the id to search for
  124643. * @return the found node or null if not found at all
  124644. */
  124645. getNodeByID(id: string): Nullable<Node>;
  124646. /**
  124647. * Gets a node (Mesh, Camera, Light) using a given name
  124648. * @param name defines the name to search for
  124649. * @return the found node or null if not found at all.
  124650. */
  124651. getNodeByName(name: string): Nullable<Node>;
  124652. /**
  124653. * Gets a mesh using a given name
  124654. * @param name defines the name to search for
  124655. * @return the found mesh or null if not found at all.
  124656. */
  124657. getMeshByName(name: string): Nullable<AbstractMesh>;
  124658. /**
  124659. * Gets a transform node using a given name
  124660. * @param name defines the name to search for
  124661. * @return the found transform node or null if not found at all.
  124662. */
  124663. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124664. /**
  124665. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124666. * @param id defines the id to search for
  124667. * @return the found skeleton or null if not found at all.
  124668. */
  124669. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124670. /**
  124671. * Gets a skeleton using a given auto generated unique id
  124672. * @param uniqueId defines the unique id to search for
  124673. * @return the found skeleton or null if not found at all.
  124674. */
  124675. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124676. /**
  124677. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124678. * @param id defines the id to search for
  124679. * @return the found skeleton or null if not found at all.
  124680. */
  124681. getSkeletonById(id: string): Nullable<Skeleton>;
  124682. /**
  124683. * Gets a skeleton using a given name
  124684. * @param name defines the name to search for
  124685. * @return the found skeleton or null if not found at all.
  124686. */
  124687. getSkeletonByName(name: string): Nullable<Skeleton>;
  124688. /**
  124689. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124690. * @param id defines the id to search for
  124691. * @return the found morph target manager or null if not found at all.
  124692. */
  124693. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124694. /**
  124695. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124696. * @param id defines the id to search for
  124697. * @return the found morph target or null if not found at all.
  124698. */
  124699. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124700. /**
  124701. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124702. * @param name defines the name to search for
  124703. * @return the found morph target or null if not found at all.
  124704. */
  124705. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124706. /**
  124707. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124708. * @param name defines the name to search for
  124709. * @return the found post process or null if not found at all.
  124710. */
  124711. getPostProcessByName(name: string): Nullable<PostProcess>;
  124712. /**
  124713. * Gets a boolean indicating if the given mesh is active
  124714. * @param mesh defines the mesh to look for
  124715. * @returns true if the mesh is in the active list
  124716. */
  124717. isActiveMesh(mesh: AbstractMesh): boolean;
  124718. /**
  124719. * Return a unique id as a string which can serve as an identifier for the scene
  124720. */
  124721. get uid(): string;
  124722. /**
  124723. * Add an externaly attached data from its key.
  124724. * This method call will fail and return false, if such key already exists.
  124725. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124726. * @param key the unique key that identifies the data
  124727. * @param data the data object to associate to the key for this Engine instance
  124728. * @return true if no such key were already present and the data was added successfully, false otherwise
  124729. */
  124730. addExternalData<T>(key: string, data: T): boolean;
  124731. /**
  124732. * Get an externaly attached data from its key
  124733. * @param key the unique key that identifies the data
  124734. * @return the associated data, if present (can be null), or undefined if not present
  124735. */
  124736. getExternalData<T>(key: string): Nullable<T>;
  124737. /**
  124738. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124739. * @param key the unique key that identifies the data
  124740. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124741. * @return the associated data, can be null if the factory returned null.
  124742. */
  124743. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124744. /**
  124745. * Remove an externaly attached data from the Engine instance
  124746. * @param key the unique key that identifies the data
  124747. * @return true if the data was successfully removed, false if it doesn't exist
  124748. */
  124749. removeExternalData(key: string): boolean;
  124750. private _evaluateSubMesh;
  124751. /**
  124752. * Clear the processed materials smart array preventing retention point in material dispose.
  124753. */
  124754. freeProcessedMaterials(): void;
  124755. private _preventFreeActiveMeshesAndRenderingGroups;
  124756. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124757. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124758. * when disposing several meshes in a row or a hierarchy of meshes.
  124759. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124760. */
  124761. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124762. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124763. /**
  124764. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124765. */
  124766. freeActiveMeshes(): void;
  124767. /**
  124768. * Clear the info related to rendering groups preventing retention points during dispose.
  124769. */
  124770. freeRenderingGroups(): void;
  124771. /** @hidden */
  124772. _isInIntermediateRendering(): boolean;
  124773. /**
  124774. * Lambda returning the list of potentially active meshes.
  124775. */
  124776. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124777. /**
  124778. * Lambda returning the list of potentially active sub meshes.
  124779. */
  124780. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124781. /**
  124782. * Lambda returning the list of potentially intersecting sub meshes.
  124783. */
  124784. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124785. /**
  124786. * Lambda returning the list of potentially colliding sub meshes.
  124787. */
  124788. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124789. private _activeMeshesFrozen;
  124790. private _skipEvaluateActiveMeshesCompletely;
  124791. /**
  124792. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124793. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124794. * @param onSuccess optional success callback
  124795. * @param onError optional error callback
  124796. * @returns the current scene
  124797. */
  124798. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124799. /**
  124800. * Use this function to restart evaluating active meshes on every frame
  124801. * @returns the current scene
  124802. */
  124803. unfreezeActiveMeshes(): Scene;
  124804. private _evaluateActiveMeshes;
  124805. private _activeMesh;
  124806. /**
  124807. * Update the transform matrix to update from the current active camera
  124808. * @param force defines a boolean used to force the update even if cache is up to date
  124809. */
  124810. updateTransformMatrix(force?: boolean): void;
  124811. private _bindFrameBuffer;
  124812. /** @hidden */
  124813. _allowPostProcessClearColor: boolean;
  124814. /** @hidden */
  124815. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124816. private _processSubCameras;
  124817. private _checkIntersections;
  124818. /** @hidden */
  124819. _advancePhysicsEngineStep(step: number): void;
  124820. /**
  124821. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124822. */
  124823. getDeterministicFrameTime: () => number;
  124824. /** @hidden */
  124825. _animate(): void;
  124826. /** Execute all animations (for a frame) */
  124827. animate(): void;
  124828. /**
  124829. * Render the scene
  124830. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124831. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124832. */
  124833. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124834. /**
  124835. * Freeze all materials
  124836. * A frozen material will not be updatable but should be faster to render
  124837. */
  124838. freezeMaterials(): void;
  124839. /**
  124840. * Unfreeze all materials
  124841. * A frozen material will not be updatable but should be faster to render
  124842. */
  124843. unfreezeMaterials(): void;
  124844. /**
  124845. * Releases all held ressources
  124846. */
  124847. dispose(): void;
  124848. /**
  124849. * Gets if the scene is already disposed
  124850. */
  124851. get isDisposed(): boolean;
  124852. /**
  124853. * Call this function to reduce memory footprint of the scene.
  124854. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124855. */
  124856. clearCachedVertexData(): void;
  124857. /**
  124858. * This function will remove the local cached buffer data from texture.
  124859. * It will save memory but will prevent the texture from being rebuilt
  124860. */
  124861. cleanCachedTextureBuffer(): void;
  124862. /**
  124863. * Get the world extend vectors with an optional filter
  124864. *
  124865. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124866. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124867. */
  124868. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124869. min: Vector3;
  124870. max: Vector3;
  124871. };
  124872. /**
  124873. * Creates a ray that can be used to pick in the scene
  124874. * @param x defines the x coordinate of the origin (on-screen)
  124875. * @param y defines the y coordinate of the origin (on-screen)
  124876. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124877. * @param camera defines the camera to use for the picking
  124878. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124879. * @returns a Ray
  124880. */
  124881. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124882. /**
  124883. * Creates a ray that can be used to pick in the scene
  124884. * @param x defines the x coordinate of the origin (on-screen)
  124885. * @param y defines the y coordinate of the origin (on-screen)
  124886. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124887. * @param result defines the ray where to store the picking ray
  124888. * @param camera defines the camera to use for the picking
  124889. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124890. * @returns the current scene
  124891. */
  124892. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124893. /**
  124894. * Creates a ray that can be used to pick in the scene
  124895. * @param x defines the x coordinate of the origin (on-screen)
  124896. * @param y defines the y coordinate of the origin (on-screen)
  124897. * @param camera defines the camera to use for the picking
  124898. * @returns a Ray
  124899. */
  124900. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124901. /**
  124902. * Creates a ray that can be used to pick in the scene
  124903. * @param x defines the x coordinate of the origin (on-screen)
  124904. * @param y defines the y coordinate of the origin (on-screen)
  124905. * @param result defines the ray where to store the picking ray
  124906. * @param camera defines the camera to use for the picking
  124907. * @returns the current scene
  124908. */
  124909. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124910. /** Launch a ray to try to pick a mesh in the scene
  124911. * @param x position on screen
  124912. * @param y position on screen
  124913. * @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
  124914. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124915. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124916. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124917. * @returns a PickingInfo
  124918. */
  124919. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124920. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124921. * @param x position on screen
  124922. * @param y position on screen
  124923. * @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
  124924. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124925. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124926. * @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)
  124927. */
  124928. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124929. /** Use the given ray to pick a mesh in the scene
  124930. * @param ray The ray to use to pick meshes
  124931. * @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
  124932. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124933. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124934. * @returns a PickingInfo
  124935. */
  124936. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124937. /**
  124938. * Launch a ray to try to pick a mesh in the scene
  124939. * @param x X position on screen
  124940. * @param y Y position on screen
  124941. * @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
  124942. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124943. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124944. * @returns an array of PickingInfo
  124945. */
  124946. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124947. /**
  124948. * Launch a ray to try to pick a mesh in the scene
  124949. * @param ray Ray to use
  124950. * @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
  124951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124952. * @returns an array of PickingInfo
  124953. */
  124954. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124955. /**
  124956. * Force the value of meshUnderPointer
  124957. * @param mesh defines the mesh to use
  124958. * @param pointerId optional pointer id when using more than one pointer
  124959. */
  124960. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124961. /**
  124962. * Gets the mesh under the pointer
  124963. * @returns a Mesh or null if no mesh is under the pointer
  124964. */
  124965. getPointerOverMesh(): Nullable<AbstractMesh>;
  124966. /** @hidden */
  124967. _rebuildGeometries(): void;
  124968. /** @hidden */
  124969. _rebuildTextures(): void;
  124970. private _getByTags;
  124971. /**
  124972. * Get a list of meshes by tags
  124973. * @param tagsQuery defines the tags query to use
  124974. * @param forEach defines a predicate used to filter results
  124975. * @returns an array of Mesh
  124976. */
  124977. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  124978. /**
  124979. * Get a list of cameras by tags
  124980. * @param tagsQuery defines the tags query to use
  124981. * @param forEach defines a predicate used to filter results
  124982. * @returns an array of Camera
  124983. */
  124984. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  124985. /**
  124986. * Get a list of lights by tags
  124987. * @param tagsQuery defines the tags query to use
  124988. * @param forEach defines a predicate used to filter results
  124989. * @returns an array of Light
  124990. */
  124991. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  124992. /**
  124993. * Get a list of materials by tags
  124994. * @param tagsQuery defines the tags query to use
  124995. * @param forEach defines a predicate used to filter results
  124996. * @returns an array of Material
  124997. */
  124998. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  124999. /**
  125000. * Get a list of transform nodes by tags
  125001. * @param tagsQuery defines the tags query to use
  125002. * @param forEach defines a predicate used to filter results
  125003. * @returns an array of TransformNode
  125004. */
  125005. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125006. /**
  125007. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125008. * This allowed control for front to back rendering or reversly depending of the special needs.
  125009. *
  125010. * @param renderingGroupId The rendering group id corresponding to its index
  125011. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125012. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125013. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125014. */
  125015. 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;
  125016. /**
  125017. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125018. *
  125019. * @param renderingGroupId The rendering group id corresponding to its index
  125020. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125021. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125022. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125023. */
  125024. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125025. /**
  125026. * Gets the current auto clear configuration for one rendering group of the rendering
  125027. * manager.
  125028. * @param index the rendering group index to get the information for
  125029. * @returns The auto clear setup for the requested rendering group
  125030. */
  125031. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125032. private _blockMaterialDirtyMechanism;
  125033. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125034. get blockMaterialDirtyMechanism(): boolean;
  125035. set blockMaterialDirtyMechanism(value: boolean);
  125036. /**
  125037. * Will flag all materials as dirty to trigger new shader compilation
  125038. * @param flag defines the flag used to specify which material part must be marked as dirty
  125039. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125040. */
  125041. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125042. /** @hidden */
  125043. _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;
  125044. /** @hidden */
  125045. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125046. /** @hidden */
  125047. _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;
  125048. /** @hidden */
  125049. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125050. /** @hidden */
  125051. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125052. /** @hidden */
  125053. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125054. }
  125055. }
  125056. declare module BABYLON {
  125057. /**
  125058. * Set of assets to keep when moving a scene into an asset container.
  125059. */
  125060. export class KeepAssets extends AbstractScene {
  125061. }
  125062. /**
  125063. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125064. */
  125065. export class InstantiatedEntries {
  125066. /**
  125067. * List of new root nodes (eg. nodes with no parent)
  125068. */
  125069. rootNodes: TransformNode[];
  125070. /**
  125071. * List of new skeletons
  125072. */
  125073. skeletons: Skeleton[];
  125074. /**
  125075. * List of new animation groups
  125076. */
  125077. animationGroups: AnimationGroup[];
  125078. }
  125079. /**
  125080. * Container with a set of assets that can be added or removed from a scene.
  125081. */
  125082. export class AssetContainer extends AbstractScene {
  125083. private _wasAddedToScene;
  125084. /**
  125085. * The scene the AssetContainer belongs to.
  125086. */
  125087. scene: Scene;
  125088. /**
  125089. * Instantiates an AssetContainer.
  125090. * @param scene The scene the AssetContainer belongs to.
  125091. */
  125092. constructor(scene: Scene);
  125093. /**
  125094. * Instantiate or clone all meshes and add the new ones to the scene.
  125095. * Skeletons and animation groups will all be cloned
  125096. * @param nameFunction defines an optional function used to get new names for clones
  125097. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125098. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125099. */
  125100. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125101. /**
  125102. * Adds all the assets from the container to the scene.
  125103. */
  125104. addAllToScene(): void;
  125105. /**
  125106. * Removes all the assets in the container from the scene
  125107. */
  125108. removeAllFromScene(): void;
  125109. /**
  125110. * Disposes all the assets in the container
  125111. */
  125112. dispose(): void;
  125113. private _moveAssets;
  125114. /**
  125115. * Removes all the assets contained in the scene and adds them to the container.
  125116. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125117. */
  125118. moveAllFromScene(keepAssets?: KeepAssets): void;
  125119. /**
  125120. * 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.
  125121. * @returns the root mesh
  125122. */
  125123. createRootMesh(): Mesh;
  125124. /**
  125125. * Merge animations (direct and animation groups) from this asset container into a scene
  125126. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125127. * @param animatables set of animatables to retarget to a node from the scene
  125128. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125129. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125130. */
  125131. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125132. }
  125133. }
  125134. declare module BABYLON {
  125135. /**
  125136. * Defines how the parser contract is defined.
  125137. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125138. */
  125139. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125140. /**
  125141. * Defines how the individual parser contract is defined.
  125142. * These parser can parse an individual asset
  125143. */
  125144. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125145. /**
  125146. * Base class of the scene acting as a container for the different elements composing a scene.
  125147. * This class is dynamically extended by the different components of the scene increasing
  125148. * flexibility and reducing coupling
  125149. */
  125150. export abstract class AbstractScene {
  125151. /**
  125152. * Stores the list of available parsers in the application.
  125153. */
  125154. private static _BabylonFileParsers;
  125155. /**
  125156. * Stores the list of available individual parsers in the application.
  125157. */
  125158. private static _IndividualBabylonFileParsers;
  125159. /**
  125160. * Adds a parser in the list of available ones
  125161. * @param name Defines the name of the parser
  125162. * @param parser Defines the parser to add
  125163. */
  125164. static AddParser(name: string, parser: BabylonFileParser): void;
  125165. /**
  125166. * Gets a general parser from the list of avaialble ones
  125167. * @param name Defines the name of the parser
  125168. * @returns the requested parser or null
  125169. */
  125170. static GetParser(name: string): Nullable<BabylonFileParser>;
  125171. /**
  125172. * Adds n individual parser in the list of available ones
  125173. * @param name Defines the name of the parser
  125174. * @param parser Defines the parser to add
  125175. */
  125176. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125177. /**
  125178. * Gets an individual parser from the list of avaialble ones
  125179. * @param name Defines the name of the parser
  125180. * @returns the requested parser or null
  125181. */
  125182. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125183. /**
  125184. * Parser json data and populate both a scene and its associated container object
  125185. * @param jsonData Defines the data to parse
  125186. * @param scene Defines the scene to parse the data for
  125187. * @param container Defines the container attached to the parsing sequence
  125188. * @param rootUrl Defines the root url of the data
  125189. */
  125190. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125191. /**
  125192. * Gets the list of root nodes (ie. nodes with no parent)
  125193. */
  125194. rootNodes: Node[];
  125195. /** All of the cameras added to this scene
  125196. * @see https://doc.babylonjs.com/babylon101/cameras
  125197. */
  125198. cameras: Camera[];
  125199. /**
  125200. * All of the lights added to this scene
  125201. * @see https://doc.babylonjs.com/babylon101/lights
  125202. */
  125203. lights: Light[];
  125204. /**
  125205. * All of the (abstract) meshes added to this scene
  125206. */
  125207. meshes: AbstractMesh[];
  125208. /**
  125209. * The list of skeletons added to the scene
  125210. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125211. */
  125212. skeletons: Skeleton[];
  125213. /**
  125214. * All of the particle systems added to this scene
  125215. * @see https://doc.babylonjs.com/babylon101/particles
  125216. */
  125217. particleSystems: IParticleSystem[];
  125218. /**
  125219. * Gets a list of Animations associated with the scene
  125220. */
  125221. animations: Animation[];
  125222. /**
  125223. * All of the animation groups added to this scene
  125224. * @see https://doc.babylonjs.com/how_to/group
  125225. */
  125226. animationGroups: AnimationGroup[];
  125227. /**
  125228. * All of the multi-materials added to this scene
  125229. * @see https://doc.babylonjs.com/how_to/multi_materials
  125230. */
  125231. multiMaterials: MultiMaterial[];
  125232. /**
  125233. * All of the materials added to this scene
  125234. * In the context of a Scene, it is not supposed to be modified manually.
  125235. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125236. * Note also that the order of the Material within the array is not significant and might change.
  125237. * @see https://doc.babylonjs.com/babylon101/materials
  125238. */
  125239. materials: Material[];
  125240. /**
  125241. * The list of morph target managers added to the scene
  125242. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125243. */
  125244. morphTargetManagers: MorphTargetManager[];
  125245. /**
  125246. * The list of geometries used in the scene.
  125247. */
  125248. geometries: Geometry[];
  125249. /**
  125250. * All of the tranform nodes added to this scene
  125251. * In the context of a Scene, it is not supposed to be modified manually.
  125252. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125253. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125254. * @see https://doc.babylonjs.com/how_to/transformnode
  125255. */
  125256. transformNodes: TransformNode[];
  125257. /**
  125258. * ActionManagers available on the scene.
  125259. */
  125260. actionManagers: AbstractActionManager[];
  125261. /**
  125262. * Textures to keep.
  125263. */
  125264. textures: BaseTexture[];
  125265. /** @hidden */
  125266. protected _environmentTexture: Nullable<BaseTexture>;
  125267. /**
  125268. * Texture used in all pbr material as the reflection texture.
  125269. * As in the majority of the scene they are the same (exception for multi room and so on),
  125270. * this is easier to reference from here than from all the materials.
  125271. */
  125272. get environmentTexture(): Nullable<BaseTexture>;
  125273. set environmentTexture(value: Nullable<BaseTexture>);
  125274. /**
  125275. * The list of postprocesses added to the scene
  125276. */
  125277. postProcesses: PostProcess[];
  125278. /**
  125279. * @returns all meshes, lights, cameras, transformNodes and bones
  125280. */
  125281. getNodes(): Array<Node>;
  125282. }
  125283. }
  125284. declare module BABYLON {
  125285. /**
  125286. * Interface used to define options for Sound class
  125287. */
  125288. export interface ISoundOptions {
  125289. /**
  125290. * Does the sound autoplay once loaded.
  125291. */
  125292. autoplay?: boolean;
  125293. /**
  125294. * Does the sound loop after it finishes playing once.
  125295. */
  125296. loop?: boolean;
  125297. /**
  125298. * Sound's volume
  125299. */
  125300. volume?: number;
  125301. /**
  125302. * Is it a spatial sound?
  125303. */
  125304. spatialSound?: boolean;
  125305. /**
  125306. * Maximum distance to hear that sound
  125307. */
  125308. maxDistance?: number;
  125309. /**
  125310. * Uses user defined attenuation function
  125311. */
  125312. useCustomAttenuation?: boolean;
  125313. /**
  125314. * Define the roll off factor of spatial sounds.
  125315. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125316. */
  125317. rolloffFactor?: number;
  125318. /**
  125319. * Define the reference distance the sound should be heard perfectly.
  125320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125321. */
  125322. refDistance?: number;
  125323. /**
  125324. * Define the distance attenuation model the sound will follow.
  125325. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125326. */
  125327. distanceModel?: string;
  125328. /**
  125329. * Defines the playback speed (1 by default)
  125330. */
  125331. playbackRate?: number;
  125332. /**
  125333. * Defines if the sound is from a streaming source
  125334. */
  125335. streaming?: boolean;
  125336. /**
  125337. * Defines an optional length (in seconds) inside the sound file
  125338. */
  125339. length?: number;
  125340. /**
  125341. * Defines an optional offset (in seconds) inside the sound file
  125342. */
  125343. offset?: number;
  125344. /**
  125345. * If true, URLs will not be required to state the audio file codec to use.
  125346. */
  125347. skipCodecCheck?: boolean;
  125348. }
  125349. /**
  125350. * Defines a sound that can be played in the application.
  125351. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125352. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125353. */
  125354. export class Sound {
  125355. /**
  125356. * The name of the sound in the scene.
  125357. */
  125358. name: string;
  125359. /**
  125360. * Does the sound autoplay once loaded.
  125361. */
  125362. autoplay: boolean;
  125363. /**
  125364. * Does the sound loop after it finishes playing once.
  125365. */
  125366. loop: boolean;
  125367. /**
  125368. * Does the sound use a custom attenuation curve to simulate the falloff
  125369. * happening when the source gets further away from the camera.
  125370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125371. */
  125372. useCustomAttenuation: boolean;
  125373. /**
  125374. * The sound track id this sound belongs to.
  125375. */
  125376. soundTrackId: number;
  125377. /**
  125378. * Is this sound currently played.
  125379. */
  125380. isPlaying: boolean;
  125381. /**
  125382. * Is this sound currently paused.
  125383. */
  125384. isPaused: boolean;
  125385. /**
  125386. * Does this sound enables spatial sound.
  125387. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125388. */
  125389. spatialSound: boolean;
  125390. /**
  125391. * Define the reference distance the sound should be heard perfectly.
  125392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125393. */
  125394. refDistance: number;
  125395. /**
  125396. * Define the roll off factor of spatial sounds.
  125397. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125398. */
  125399. rolloffFactor: number;
  125400. /**
  125401. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125403. */
  125404. maxDistance: number;
  125405. /**
  125406. * Define the distance attenuation model the sound will follow.
  125407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125408. */
  125409. distanceModel: string;
  125410. /**
  125411. * @hidden
  125412. * Back Compat
  125413. **/
  125414. onended: () => any;
  125415. /**
  125416. * Gets or sets an object used to store user defined information for the sound.
  125417. */
  125418. metadata: any;
  125419. /**
  125420. * Observable event when the current playing sound finishes.
  125421. */
  125422. onEndedObservable: Observable<Sound>;
  125423. private _panningModel;
  125424. private _playbackRate;
  125425. private _streaming;
  125426. private _startTime;
  125427. private _startOffset;
  125428. private _position;
  125429. /** @hidden */
  125430. _positionInEmitterSpace: boolean;
  125431. private _localDirection;
  125432. private _volume;
  125433. private _isReadyToPlay;
  125434. private _isDirectional;
  125435. private _readyToPlayCallback;
  125436. private _audioBuffer;
  125437. private _soundSource;
  125438. private _streamingSource;
  125439. private _soundPanner;
  125440. private _soundGain;
  125441. private _inputAudioNode;
  125442. private _outputAudioNode;
  125443. private _coneInnerAngle;
  125444. private _coneOuterAngle;
  125445. private _coneOuterGain;
  125446. private _scene;
  125447. private _connectedTransformNode;
  125448. private _customAttenuationFunction;
  125449. private _registerFunc;
  125450. private _isOutputConnected;
  125451. private _htmlAudioElement;
  125452. private _urlType;
  125453. private _length?;
  125454. private _offset?;
  125455. /** @hidden */
  125456. static _SceneComponentInitialization: (scene: Scene) => void;
  125457. /**
  125458. * Create a sound and attach it to a scene
  125459. * @param name Name of your sound
  125460. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125461. * @param scene defines the scene the sound belongs to
  125462. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125463. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125464. */
  125465. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125466. /**
  125467. * Release the sound and its associated resources
  125468. */
  125469. dispose(): void;
  125470. /**
  125471. * Gets if the sounds is ready to be played or not.
  125472. * @returns true if ready, otherwise false
  125473. */
  125474. isReady(): boolean;
  125475. private _soundLoaded;
  125476. /**
  125477. * Sets the data of the sound from an audiobuffer
  125478. * @param audioBuffer The audioBuffer containing the data
  125479. */
  125480. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125481. /**
  125482. * Updates the current sounds options such as maxdistance, loop...
  125483. * @param options A JSON object containing values named as the object properties
  125484. */
  125485. updateOptions(options: ISoundOptions): void;
  125486. private _createSpatialParameters;
  125487. private _updateSpatialParameters;
  125488. /**
  125489. * Switch the panning model to HRTF:
  125490. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125491. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125492. */
  125493. switchPanningModelToHRTF(): void;
  125494. /**
  125495. * Switch the panning model to Equal Power:
  125496. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125498. */
  125499. switchPanningModelToEqualPower(): void;
  125500. private _switchPanningModel;
  125501. /**
  125502. * Connect this sound to a sound track audio node like gain...
  125503. * @param soundTrackAudioNode the sound track audio node to connect to
  125504. */
  125505. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125506. /**
  125507. * Transform this sound into a directional source
  125508. * @param coneInnerAngle Size of the inner cone in degree
  125509. * @param coneOuterAngle Size of the outer cone in degree
  125510. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125511. */
  125512. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125513. /**
  125514. * Gets or sets the inner angle for the directional cone.
  125515. */
  125516. get directionalConeInnerAngle(): number;
  125517. /**
  125518. * Gets or sets the inner angle for the directional cone.
  125519. */
  125520. set directionalConeInnerAngle(value: number);
  125521. /**
  125522. * Gets or sets the outer angle for the directional cone.
  125523. */
  125524. get directionalConeOuterAngle(): number;
  125525. /**
  125526. * Gets or sets the outer angle for the directional cone.
  125527. */
  125528. set directionalConeOuterAngle(value: number);
  125529. /**
  125530. * Sets the position of the emitter if spatial sound is enabled
  125531. * @param newPosition Defines the new posisiton
  125532. */
  125533. setPosition(newPosition: Vector3): void;
  125534. /**
  125535. * Sets the local direction of the emitter if spatial sound is enabled
  125536. * @param newLocalDirection Defines the new local direction
  125537. */
  125538. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125539. private _updateDirection;
  125540. /** @hidden */
  125541. updateDistanceFromListener(): void;
  125542. /**
  125543. * Sets a new custom attenuation function for the sound.
  125544. * @param callback Defines the function used for the attenuation
  125545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125546. */
  125547. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125548. /**
  125549. * Play the sound
  125550. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125551. * @param offset (optional) Start the sound at a specific time in seconds
  125552. * @param length (optional) Sound duration (in seconds)
  125553. */
  125554. play(time?: number, offset?: number, length?: number): void;
  125555. private _onended;
  125556. /**
  125557. * Stop the sound
  125558. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125559. */
  125560. stop(time?: number): void;
  125561. /**
  125562. * Put the sound in pause
  125563. */
  125564. pause(): void;
  125565. /**
  125566. * Sets a dedicated volume for this sounds
  125567. * @param newVolume Define the new volume of the sound
  125568. * @param time Define time for gradual change to new volume
  125569. */
  125570. setVolume(newVolume: number, time?: number): void;
  125571. /**
  125572. * Set the sound play back rate
  125573. * @param newPlaybackRate Define the playback rate the sound should be played at
  125574. */
  125575. setPlaybackRate(newPlaybackRate: number): void;
  125576. /**
  125577. * Gets the volume of the sound.
  125578. * @returns the volume of the sound
  125579. */
  125580. getVolume(): number;
  125581. /**
  125582. * Attach the sound to a dedicated mesh
  125583. * @param transformNode The transform node to connect the sound with
  125584. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125585. */
  125586. attachToMesh(transformNode: TransformNode): void;
  125587. /**
  125588. * Detach the sound from the previously attached mesh
  125589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125590. */
  125591. detachFromMesh(): void;
  125592. private _onRegisterAfterWorldMatrixUpdate;
  125593. /**
  125594. * Clone the current sound in the scene.
  125595. * @returns the new sound clone
  125596. */
  125597. clone(): Nullable<Sound>;
  125598. /**
  125599. * Gets the current underlying audio buffer containing the data
  125600. * @returns the audio buffer
  125601. */
  125602. getAudioBuffer(): Nullable<AudioBuffer>;
  125603. /**
  125604. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125605. * @returns the source node
  125606. */
  125607. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125608. /**
  125609. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125610. * @returns the gain node
  125611. */
  125612. getSoundGain(): Nullable<GainNode>;
  125613. /**
  125614. * Serializes the Sound in a JSON representation
  125615. * @returns the JSON representation of the sound
  125616. */
  125617. serialize(): any;
  125618. /**
  125619. * Parse a JSON representation of a sound to innstantiate in a given scene
  125620. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125621. * @param scene Define the scene the new parsed sound should be created in
  125622. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125623. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125624. * @returns the newly parsed sound
  125625. */
  125626. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125627. }
  125628. }
  125629. declare module BABYLON {
  125630. /**
  125631. * This defines an action helpful to play a defined sound on a triggered action.
  125632. */
  125633. export class PlaySoundAction extends Action {
  125634. private _sound;
  125635. /**
  125636. * Instantiate the action
  125637. * @param triggerOptions defines the trigger options
  125638. * @param sound defines the sound to play
  125639. * @param condition defines the trigger related conditions
  125640. */
  125641. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125642. /** @hidden */
  125643. _prepare(): void;
  125644. /**
  125645. * Execute the action and play the sound.
  125646. */
  125647. execute(): void;
  125648. /**
  125649. * Serializes the actions and its related information.
  125650. * @param parent defines the object to serialize in
  125651. * @returns the serialized object
  125652. */
  125653. serialize(parent: any): any;
  125654. }
  125655. /**
  125656. * This defines an action helpful to stop a defined sound on a triggered action.
  125657. */
  125658. export class StopSoundAction extends Action {
  125659. private _sound;
  125660. /**
  125661. * Instantiate the action
  125662. * @param triggerOptions defines the trigger options
  125663. * @param sound defines the sound to stop
  125664. * @param condition defines the trigger related conditions
  125665. */
  125666. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125667. /** @hidden */
  125668. _prepare(): void;
  125669. /**
  125670. * Execute the action and stop the sound.
  125671. */
  125672. execute(): void;
  125673. /**
  125674. * Serializes the actions and its related information.
  125675. * @param parent defines the object to serialize in
  125676. * @returns the serialized object
  125677. */
  125678. serialize(parent: any): any;
  125679. }
  125680. }
  125681. declare module BABYLON {
  125682. /**
  125683. * This defines an action responsible to change the value of a property
  125684. * by interpolating between its current value and the newly set one once triggered.
  125685. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125686. */
  125687. export class InterpolateValueAction extends Action {
  125688. /**
  125689. * Defines the path of the property where the value should be interpolated
  125690. */
  125691. propertyPath: string;
  125692. /**
  125693. * Defines the target value at the end of the interpolation.
  125694. */
  125695. value: any;
  125696. /**
  125697. * Defines the time it will take for the property to interpolate to the value.
  125698. */
  125699. duration: number;
  125700. /**
  125701. * Defines if the other scene animations should be stopped when the action has been triggered
  125702. */
  125703. stopOtherAnimations?: boolean;
  125704. /**
  125705. * Defines a callback raised once the interpolation animation has been done.
  125706. */
  125707. onInterpolationDone?: () => void;
  125708. /**
  125709. * Observable triggered once the interpolation animation has been done.
  125710. */
  125711. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125712. private _target;
  125713. private _effectiveTarget;
  125714. private _property;
  125715. /**
  125716. * Instantiate the action
  125717. * @param triggerOptions defines the trigger options
  125718. * @param target defines the object containing the value to interpolate
  125719. * @param propertyPath defines the path to the property in the target object
  125720. * @param value defines the target value at the end of the interpolation
  125721. * @param duration deines the time it will take for the property to interpolate to the value.
  125722. * @param condition defines the trigger related conditions
  125723. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125724. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125725. */
  125726. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125727. /** @hidden */
  125728. _prepare(): void;
  125729. /**
  125730. * Execute the action starts the value interpolation.
  125731. */
  125732. execute(): void;
  125733. /**
  125734. * Serializes the actions and its related information.
  125735. * @param parent defines the object to serialize in
  125736. * @returns the serialized object
  125737. */
  125738. serialize(parent: any): any;
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /**
  125743. * Options allowed during the creation of a sound track.
  125744. */
  125745. export interface ISoundTrackOptions {
  125746. /**
  125747. * The volume the sound track should take during creation
  125748. */
  125749. volume?: number;
  125750. /**
  125751. * Define if the sound track is the main sound track of the scene
  125752. */
  125753. mainTrack?: boolean;
  125754. }
  125755. /**
  125756. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125757. * It will be also used in a future release to apply effects on a specific track.
  125758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125759. */
  125760. export class SoundTrack {
  125761. /**
  125762. * The unique identifier of the sound track in the scene.
  125763. */
  125764. id: number;
  125765. /**
  125766. * The list of sounds included in the sound track.
  125767. */
  125768. soundCollection: Array<Sound>;
  125769. private _outputAudioNode;
  125770. private _scene;
  125771. private _connectedAnalyser;
  125772. private _options;
  125773. private _isInitialized;
  125774. /**
  125775. * Creates a new sound track.
  125776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125777. * @param scene Define the scene the sound track belongs to
  125778. * @param options
  125779. */
  125780. constructor(scene: Scene, options?: ISoundTrackOptions);
  125781. private _initializeSoundTrackAudioGraph;
  125782. /**
  125783. * Release the sound track and its associated resources
  125784. */
  125785. dispose(): void;
  125786. /**
  125787. * Adds a sound to this sound track
  125788. * @param sound define the cound to add
  125789. * @ignoreNaming
  125790. */
  125791. AddSound(sound: Sound): void;
  125792. /**
  125793. * Removes a sound to this sound track
  125794. * @param sound define the cound to remove
  125795. * @ignoreNaming
  125796. */
  125797. RemoveSound(sound: Sound): void;
  125798. /**
  125799. * Set a global volume for the full sound track.
  125800. * @param newVolume Define the new volume of the sound track
  125801. */
  125802. setVolume(newVolume: number): void;
  125803. /**
  125804. * Switch the panning model to HRTF:
  125805. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125806. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125807. */
  125808. switchPanningModelToHRTF(): void;
  125809. /**
  125810. * Switch the panning model to Equal Power:
  125811. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125812. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125813. */
  125814. switchPanningModelToEqualPower(): void;
  125815. /**
  125816. * Connect the sound track to an audio analyser allowing some amazing
  125817. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125818. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125819. * @param analyser The analyser to connect to the engine
  125820. */
  125821. connectToAnalyser(analyser: Analyser): void;
  125822. }
  125823. }
  125824. declare module BABYLON {
  125825. interface AbstractScene {
  125826. /**
  125827. * The list of sounds used in the scene.
  125828. */
  125829. sounds: Nullable<Array<Sound>>;
  125830. }
  125831. interface Scene {
  125832. /**
  125833. * @hidden
  125834. * Backing field
  125835. */
  125836. _mainSoundTrack: SoundTrack;
  125837. /**
  125838. * The main sound track played by the scene.
  125839. * It cotains your primary collection of sounds.
  125840. */
  125841. mainSoundTrack: SoundTrack;
  125842. /**
  125843. * The list of sound tracks added to the scene
  125844. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125845. */
  125846. soundTracks: Nullable<Array<SoundTrack>>;
  125847. /**
  125848. * Gets a sound using a given name
  125849. * @param name defines the name to search for
  125850. * @return the found sound or null if not found at all.
  125851. */
  125852. getSoundByName(name: string): Nullable<Sound>;
  125853. /**
  125854. * Gets or sets if audio support is enabled
  125855. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125856. */
  125857. audioEnabled: boolean;
  125858. /**
  125859. * Gets or sets if audio will be output to headphones
  125860. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125861. */
  125862. headphone: boolean;
  125863. /**
  125864. * Gets or sets custom audio listener position provider
  125865. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125866. */
  125867. audioListenerPositionProvider: Nullable<() => Vector3>;
  125868. /**
  125869. * Gets or sets a refresh rate when using 3D audio positioning
  125870. */
  125871. audioPositioningRefreshRate: number;
  125872. }
  125873. /**
  125874. * Defines the sound scene component responsible to manage any sounds
  125875. * in a given scene.
  125876. */
  125877. export class AudioSceneComponent implements ISceneSerializableComponent {
  125878. private static _CameraDirectionLH;
  125879. private static _CameraDirectionRH;
  125880. /**
  125881. * The component name helpfull to identify the component in the list of scene components.
  125882. */
  125883. readonly name: string;
  125884. /**
  125885. * The scene the component belongs to.
  125886. */
  125887. scene: Scene;
  125888. private _audioEnabled;
  125889. /**
  125890. * Gets whether audio is enabled or not.
  125891. * Please use related enable/disable method to switch state.
  125892. */
  125893. get audioEnabled(): boolean;
  125894. private _headphone;
  125895. /**
  125896. * Gets whether audio is outputing to headphone or not.
  125897. * Please use the according Switch methods to change output.
  125898. */
  125899. get headphone(): boolean;
  125900. /**
  125901. * Gets or sets a refresh rate when using 3D audio positioning
  125902. */
  125903. audioPositioningRefreshRate: number;
  125904. private _audioListenerPositionProvider;
  125905. /**
  125906. * Gets the current audio listener position provider
  125907. */
  125908. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125909. /**
  125910. * Sets a custom listener position for all sounds in the scene
  125911. * By default, this is the position of the first active camera
  125912. */
  125913. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125914. /**
  125915. * Creates a new instance of the component for the given scene
  125916. * @param scene Defines the scene to register the component in
  125917. */
  125918. constructor(scene: Scene);
  125919. /**
  125920. * Registers the component in a given scene
  125921. */
  125922. register(): void;
  125923. /**
  125924. * Rebuilds the elements related to this component in case of
  125925. * context lost for instance.
  125926. */
  125927. rebuild(): void;
  125928. /**
  125929. * Serializes the component data to the specified json object
  125930. * @param serializationObject The object to serialize to
  125931. */
  125932. serialize(serializationObject: any): void;
  125933. /**
  125934. * Adds all the elements from the container to the scene
  125935. * @param container the container holding the elements
  125936. */
  125937. addFromContainer(container: AbstractScene): void;
  125938. /**
  125939. * Removes all the elements in the container from the scene
  125940. * @param container contains the elements to remove
  125941. * @param dispose if the removed element should be disposed (default: false)
  125942. */
  125943. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125944. /**
  125945. * Disposes the component and the associated ressources.
  125946. */
  125947. dispose(): void;
  125948. /**
  125949. * Disables audio in the associated scene.
  125950. */
  125951. disableAudio(): void;
  125952. /**
  125953. * Enables audio in the associated scene.
  125954. */
  125955. enableAudio(): void;
  125956. /**
  125957. * Switch audio to headphone output.
  125958. */
  125959. switchAudioModeForHeadphones(): void;
  125960. /**
  125961. * Switch audio to normal speakers.
  125962. */
  125963. switchAudioModeForNormalSpeakers(): void;
  125964. private _cachedCameraDirection;
  125965. private _cachedCameraPosition;
  125966. private _lastCheck;
  125967. private _afterRender;
  125968. }
  125969. }
  125970. declare module BABYLON {
  125971. /**
  125972. * Wraps one or more Sound objects and selects one with random weight for playback.
  125973. */
  125974. export class WeightedSound {
  125975. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125976. loop: boolean;
  125977. private _coneInnerAngle;
  125978. private _coneOuterAngle;
  125979. private _volume;
  125980. /** A Sound is currently playing. */
  125981. isPlaying: boolean;
  125982. /** A Sound is currently paused. */
  125983. isPaused: boolean;
  125984. private _sounds;
  125985. private _weights;
  125986. private _currentIndex?;
  125987. /**
  125988. * Creates a new WeightedSound from the list of sounds given.
  125989. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  125990. * @param sounds Array of Sounds that will be selected from.
  125991. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  125992. */
  125993. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  125994. /**
  125995. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  125996. */
  125997. get directionalConeInnerAngle(): number;
  125998. /**
  125999. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126000. */
  126001. set directionalConeInnerAngle(value: number);
  126002. /**
  126003. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126004. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126005. */
  126006. get directionalConeOuterAngle(): number;
  126007. /**
  126008. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126009. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126010. */
  126011. set directionalConeOuterAngle(value: number);
  126012. /**
  126013. * Playback volume.
  126014. */
  126015. get volume(): number;
  126016. /**
  126017. * Playback volume.
  126018. */
  126019. set volume(value: number);
  126020. private _onended;
  126021. /**
  126022. * Suspend playback
  126023. */
  126024. pause(): void;
  126025. /**
  126026. * Stop playback
  126027. */
  126028. stop(): void;
  126029. /**
  126030. * Start playback.
  126031. * @param startOffset Position the clip head at a specific time in seconds.
  126032. */
  126033. play(startOffset?: number): void;
  126034. }
  126035. }
  126036. declare module BABYLON {
  126037. /**
  126038. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126039. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126040. */
  126041. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126042. /**
  126043. * Gets the name of the behavior.
  126044. */
  126045. get name(): string;
  126046. /**
  126047. * The easing function used by animations
  126048. */
  126049. static EasingFunction: BackEase;
  126050. /**
  126051. * The easing mode used by animations
  126052. */
  126053. static EasingMode: number;
  126054. /**
  126055. * The duration of the animation, in milliseconds
  126056. */
  126057. transitionDuration: number;
  126058. /**
  126059. * Length of the distance animated by the transition when lower radius is reached
  126060. */
  126061. lowerRadiusTransitionRange: number;
  126062. /**
  126063. * Length of the distance animated by the transition when upper radius is reached
  126064. */
  126065. upperRadiusTransitionRange: number;
  126066. private _autoTransitionRange;
  126067. /**
  126068. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126069. */
  126070. get autoTransitionRange(): boolean;
  126071. /**
  126072. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126073. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126074. */
  126075. set autoTransitionRange(value: boolean);
  126076. private _attachedCamera;
  126077. private _onAfterCheckInputsObserver;
  126078. private _onMeshTargetChangedObserver;
  126079. /**
  126080. * Initializes the behavior.
  126081. */
  126082. init(): void;
  126083. /**
  126084. * Attaches the behavior to its arc rotate camera.
  126085. * @param camera Defines the camera to attach the behavior to
  126086. */
  126087. attach(camera: ArcRotateCamera): void;
  126088. /**
  126089. * Detaches the behavior from its current arc rotate camera.
  126090. */
  126091. detach(): void;
  126092. private _radiusIsAnimating;
  126093. private _radiusBounceTransition;
  126094. private _animatables;
  126095. private _cachedWheelPrecision;
  126096. /**
  126097. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126098. * @param radiusLimit The limit to check against.
  126099. * @return Bool to indicate if at limit.
  126100. */
  126101. private _isRadiusAtLimit;
  126102. /**
  126103. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126104. * @param radiusDelta The delta by which to animate to. Can be negative.
  126105. */
  126106. private _applyBoundRadiusAnimation;
  126107. /**
  126108. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126109. */
  126110. protected _clearAnimationLocks(): void;
  126111. /**
  126112. * Stops and removes all animations that have been applied to the camera
  126113. */
  126114. stopAllAnimations(): void;
  126115. }
  126116. }
  126117. declare module BABYLON {
  126118. /**
  126119. * 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.
  126120. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126121. */
  126122. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126123. /**
  126124. * Gets the name of the behavior.
  126125. */
  126126. get name(): string;
  126127. private _mode;
  126128. private _radiusScale;
  126129. private _positionScale;
  126130. private _defaultElevation;
  126131. private _elevationReturnTime;
  126132. private _elevationReturnWaitTime;
  126133. private _zoomStopsAnimation;
  126134. private _framingTime;
  126135. /**
  126136. * The easing function used by animations
  126137. */
  126138. static EasingFunction: ExponentialEase;
  126139. /**
  126140. * The easing mode used by animations
  126141. */
  126142. static EasingMode: number;
  126143. /**
  126144. * Sets the current mode used by the behavior
  126145. */
  126146. set mode(mode: number);
  126147. /**
  126148. * Gets current mode used by the behavior.
  126149. */
  126150. get mode(): number;
  126151. /**
  126152. * Sets the scale applied to the radius (1 by default)
  126153. */
  126154. set radiusScale(radius: number);
  126155. /**
  126156. * Gets the scale applied to the radius
  126157. */
  126158. get radiusScale(): number;
  126159. /**
  126160. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126161. */
  126162. set positionScale(scale: number);
  126163. /**
  126164. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126165. */
  126166. get positionScale(): number;
  126167. /**
  126168. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126169. * behaviour is triggered, in radians.
  126170. */
  126171. set defaultElevation(elevation: number);
  126172. /**
  126173. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126174. * behaviour is triggered, in radians.
  126175. */
  126176. get defaultElevation(): number;
  126177. /**
  126178. * Sets the time (in milliseconds) taken to return to the default beta position.
  126179. * Negative value indicates camera should not return to default.
  126180. */
  126181. set elevationReturnTime(speed: number);
  126182. /**
  126183. * Gets the time (in milliseconds) taken to return to the default beta position.
  126184. * Negative value indicates camera should not return to default.
  126185. */
  126186. get elevationReturnTime(): number;
  126187. /**
  126188. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126189. */
  126190. set elevationReturnWaitTime(time: number);
  126191. /**
  126192. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126193. */
  126194. get elevationReturnWaitTime(): number;
  126195. /**
  126196. * Sets the flag that indicates if user zooming should stop animation.
  126197. */
  126198. set zoomStopsAnimation(flag: boolean);
  126199. /**
  126200. * Gets the flag that indicates if user zooming should stop animation.
  126201. */
  126202. get zoomStopsAnimation(): boolean;
  126203. /**
  126204. * Sets the transition time when framing the mesh, in milliseconds
  126205. */
  126206. set framingTime(time: number);
  126207. /**
  126208. * Gets the transition time when framing the mesh, in milliseconds
  126209. */
  126210. get framingTime(): number;
  126211. /**
  126212. * Define if the behavior should automatically change the configured
  126213. * camera limits and sensibilities.
  126214. */
  126215. autoCorrectCameraLimitsAndSensibility: boolean;
  126216. private _onPrePointerObservableObserver;
  126217. private _onAfterCheckInputsObserver;
  126218. private _onMeshTargetChangedObserver;
  126219. private _attachedCamera;
  126220. private _isPointerDown;
  126221. private _lastInteractionTime;
  126222. /**
  126223. * Initializes the behavior.
  126224. */
  126225. init(): void;
  126226. /**
  126227. * Attaches the behavior to its arc rotate camera.
  126228. * @param camera Defines the camera to attach the behavior to
  126229. */
  126230. attach(camera: ArcRotateCamera): void;
  126231. /**
  126232. * Detaches the behavior from its current arc rotate camera.
  126233. */
  126234. detach(): void;
  126235. private _animatables;
  126236. private _betaIsAnimating;
  126237. private _betaTransition;
  126238. private _radiusTransition;
  126239. private _vectorTransition;
  126240. /**
  126241. * Targets the given mesh and updates zoom level accordingly.
  126242. * @param mesh The mesh to target.
  126243. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126244. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126245. */
  126246. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126247. /**
  126248. * Targets the given mesh with its children and updates zoom level accordingly.
  126249. * @param mesh The mesh to target.
  126250. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126251. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126252. */
  126253. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126254. /**
  126255. * Targets the given meshes with their children and updates zoom level accordingly.
  126256. * @param meshes The mesh to target.
  126257. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126258. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126259. */
  126260. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126261. /**
  126262. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126263. * @param minimumWorld Determines the smaller position of the bounding box extend
  126264. * @param maximumWorld Determines the bigger position of the bounding box extend
  126265. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126266. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126267. */
  126268. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126269. /**
  126270. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126271. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126272. * frustum width.
  126273. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126274. * to fully enclose the mesh in the viewing frustum.
  126275. */
  126276. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126277. /**
  126278. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126279. * is automatically returned to its default position (expected to be above ground plane).
  126280. */
  126281. private _maintainCameraAboveGround;
  126282. /**
  126283. * Returns the frustum slope based on the canvas ratio and camera FOV
  126284. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126285. */
  126286. private _getFrustumSlope;
  126287. /**
  126288. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126289. */
  126290. private _clearAnimationLocks;
  126291. /**
  126292. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126293. */
  126294. private _applyUserInteraction;
  126295. /**
  126296. * Stops and removes all animations that have been applied to the camera
  126297. */
  126298. stopAllAnimations(): void;
  126299. /**
  126300. * Gets a value indicating if the user is moving the camera
  126301. */
  126302. get isUserIsMoving(): boolean;
  126303. /**
  126304. * The camera can move all the way towards the mesh.
  126305. */
  126306. static IgnoreBoundsSizeMode: number;
  126307. /**
  126308. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126309. */
  126310. static FitFrustumSidesMode: number;
  126311. }
  126312. }
  126313. declare module BABYLON {
  126314. /**
  126315. * Base class for Camera Pointer Inputs.
  126316. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126317. * for example usage.
  126318. */
  126319. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126320. /**
  126321. * Defines the camera the input is attached to.
  126322. */
  126323. abstract camera: Camera;
  126324. /**
  126325. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126326. */
  126327. protected _altKey: boolean;
  126328. protected _ctrlKey: boolean;
  126329. protected _metaKey: boolean;
  126330. protected _shiftKey: boolean;
  126331. /**
  126332. * Which mouse buttons were pressed at time of last mouse event.
  126333. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126334. */
  126335. protected _buttonsPressed: number;
  126336. /**
  126337. * Defines the buttons associated with the input to handle camera move.
  126338. */
  126339. buttons: number[];
  126340. /**
  126341. * Attach the input controls to a specific dom element to get the input from.
  126342. * @param element Defines the element the controls should be listened from
  126343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126344. */
  126345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126346. /**
  126347. * Detach the current controls from the specified dom element.
  126348. * @param element Defines the element to stop listening the inputs from
  126349. */
  126350. detachControl(element: Nullable<HTMLElement>): void;
  126351. /**
  126352. * Gets the class name of the current input.
  126353. * @returns the class name
  126354. */
  126355. getClassName(): string;
  126356. /**
  126357. * Get the friendly name associated with the input class.
  126358. * @returns the input friendly name
  126359. */
  126360. getSimpleName(): string;
  126361. /**
  126362. * Called on pointer POINTERDOUBLETAP event.
  126363. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126364. */
  126365. protected onDoubleTap(type: string): void;
  126366. /**
  126367. * Called on pointer POINTERMOVE event if only a single touch is active.
  126368. * Override this method to provide functionality.
  126369. */
  126370. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126371. /**
  126372. * Called on pointer POINTERMOVE event if multiple touches are active.
  126373. * Override this method to provide functionality.
  126374. */
  126375. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126376. /**
  126377. * Called on JS contextmenu event.
  126378. * Override this method to provide functionality.
  126379. */
  126380. protected onContextMenu(evt: PointerEvent): void;
  126381. /**
  126382. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126383. * press.
  126384. * Override this method to provide functionality.
  126385. */
  126386. protected onButtonDown(evt: PointerEvent): void;
  126387. /**
  126388. * Called each time a new POINTERUP event occurs. Ie, for each button
  126389. * release.
  126390. * Override this method to provide functionality.
  126391. */
  126392. protected onButtonUp(evt: PointerEvent): void;
  126393. /**
  126394. * Called when window becomes inactive.
  126395. * Override this method to provide functionality.
  126396. */
  126397. protected onLostFocus(): void;
  126398. private _pointerInput;
  126399. private _observer;
  126400. private _onLostFocus;
  126401. private pointA;
  126402. private pointB;
  126403. }
  126404. }
  126405. declare module BABYLON {
  126406. /**
  126407. * Manage the pointers inputs to control an arc rotate camera.
  126408. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126409. */
  126410. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126411. /**
  126412. * Defines the camera the input is attached to.
  126413. */
  126414. camera: ArcRotateCamera;
  126415. /**
  126416. * Gets the class name of the current input.
  126417. * @returns the class name
  126418. */
  126419. getClassName(): string;
  126420. /**
  126421. * Defines the buttons associated with the input to handle camera move.
  126422. */
  126423. buttons: number[];
  126424. /**
  126425. * Defines the pointer angular sensibility along the X axis or how fast is
  126426. * the camera rotating.
  126427. */
  126428. angularSensibilityX: number;
  126429. /**
  126430. * Defines the pointer angular sensibility along the Y axis or how fast is
  126431. * the camera rotating.
  126432. */
  126433. angularSensibilityY: number;
  126434. /**
  126435. * Defines the pointer pinch precision or how fast is the camera zooming.
  126436. */
  126437. pinchPrecision: number;
  126438. /**
  126439. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126440. * from 0.
  126441. * It defines the percentage of current camera.radius to use as delta when
  126442. * pinch zoom is used.
  126443. */
  126444. pinchDeltaPercentage: number;
  126445. /**
  126446. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126447. * that any object in the plane at the camera's target point will scale
  126448. * perfectly with finger motion.
  126449. * Overrides pinchDeltaPercentage and pinchPrecision.
  126450. */
  126451. useNaturalPinchZoom: boolean;
  126452. /**
  126453. * Defines the pointer panning sensibility or how fast is the camera moving.
  126454. */
  126455. panningSensibility: number;
  126456. /**
  126457. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126458. */
  126459. multiTouchPanning: boolean;
  126460. /**
  126461. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126462. * zoom (pinch) through multitouch.
  126463. */
  126464. multiTouchPanAndZoom: boolean;
  126465. /**
  126466. * Revers pinch action direction.
  126467. */
  126468. pinchInwards: boolean;
  126469. private _isPanClick;
  126470. private _twoFingerActivityCount;
  126471. private _isPinching;
  126472. /**
  126473. * Called on pointer POINTERMOVE event if only a single touch is active.
  126474. */
  126475. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126476. /**
  126477. * Called on pointer POINTERDOUBLETAP event.
  126478. */
  126479. protected onDoubleTap(type: string): void;
  126480. /**
  126481. * Called on pointer POINTERMOVE event if multiple touches are active.
  126482. */
  126483. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126484. /**
  126485. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126486. * press.
  126487. */
  126488. protected onButtonDown(evt: PointerEvent): void;
  126489. /**
  126490. * Called each time a new POINTERUP event occurs. Ie, for each button
  126491. * release.
  126492. */
  126493. protected onButtonUp(evt: PointerEvent): void;
  126494. /**
  126495. * Called when window becomes inactive.
  126496. */
  126497. protected onLostFocus(): void;
  126498. }
  126499. }
  126500. declare module BABYLON {
  126501. /**
  126502. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126504. */
  126505. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126506. /**
  126507. * Defines the camera the input is attached to.
  126508. */
  126509. camera: ArcRotateCamera;
  126510. /**
  126511. * Defines the list of key codes associated with the up action (increase alpha)
  126512. */
  126513. keysUp: number[];
  126514. /**
  126515. * Defines the list of key codes associated with the down action (decrease alpha)
  126516. */
  126517. keysDown: number[];
  126518. /**
  126519. * Defines the list of key codes associated with the left action (increase beta)
  126520. */
  126521. keysLeft: number[];
  126522. /**
  126523. * Defines the list of key codes associated with the right action (decrease beta)
  126524. */
  126525. keysRight: number[];
  126526. /**
  126527. * Defines the list of key codes associated with the reset action.
  126528. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126529. */
  126530. keysReset: number[];
  126531. /**
  126532. * Defines the panning sensibility of the inputs.
  126533. * (How fast is the camera panning)
  126534. */
  126535. panningSensibility: number;
  126536. /**
  126537. * Defines the zooming sensibility of the inputs.
  126538. * (How fast is the camera zooming)
  126539. */
  126540. zoomingSensibility: number;
  126541. /**
  126542. * Defines whether maintaining the alt key down switch the movement mode from
  126543. * orientation to zoom.
  126544. */
  126545. useAltToZoom: boolean;
  126546. /**
  126547. * Rotation speed of the camera
  126548. */
  126549. angularSpeed: number;
  126550. private _keys;
  126551. private _ctrlPressed;
  126552. private _altPressed;
  126553. private _onCanvasBlurObserver;
  126554. private _onKeyboardObserver;
  126555. private _engine;
  126556. private _scene;
  126557. /**
  126558. * Attach the input controls to a specific dom element to get the input from.
  126559. * @param element Defines the element the controls should be listened from
  126560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126561. */
  126562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126563. /**
  126564. * Detach the current controls from the specified dom element.
  126565. * @param element Defines the element to stop listening the inputs from
  126566. */
  126567. detachControl(element: Nullable<HTMLElement>): void;
  126568. /**
  126569. * Update the current camera state depending on the inputs that have been used this frame.
  126570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126571. */
  126572. checkInputs(): void;
  126573. /**
  126574. * Gets the class name of the current intput.
  126575. * @returns the class name
  126576. */
  126577. getClassName(): string;
  126578. /**
  126579. * Get the friendly name associated with the input class.
  126580. * @returns the input friendly name
  126581. */
  126582. getSimpleName(): string;
  126583. }
  126584. }
  126585. declare module BABYLON {
  126586. /**
  126587. * Manage the mouse wheel inputs to control an arc rotate camera.
  126588. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126589. */
  126590. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126591. /**
  126592. * Defines the camera the input is attached to.
  126593. */
  126594. camera: ArcRotateCamera;
  126595. /**
  126596. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126597. */
  126598. wheelPrecision: number;
  126599. /**
  126600. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126601. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126602. */
  126603. wheelDeltaPercentage: number;
  126604. private _wheel;
  126605. private _observer;
  126606. private computeDeltaFromMouseWheelLegacyEvent;
  126607. /**
  126608. * Attach the input controls to a specific dom element to get the input from.
  126609. * @param element Defines the element the controls should be listened from
  126610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126611. */
  126612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126613. /**
  126614. * Detach the current controls from the specified dom element.
  126615. * @param element Defines the element to stop listening the inputs from
  126616. */
  126617. detachControl(element: Nullable<HTMLElement>): void;
  126618. /**
  126619. * Gets the class name of the current intput.
  126620. * @returns the class name
  126621. */
  126622. getClassName(): string;
  126623. /**
  126624. * Get the friendly name associated with the input class.
  126625. * @returns the input friendly name
  126626. */
  126627. getSimpleName(): string;
  126628. }
  126629. }
  126630. declare module BABYLON {
  126631. /**
  126632. * Default Inputs manager for the ArcRotateCamera.
  126633. * It groups all the default supported inputs for ease of use.
  126634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126635. */
  126636. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126637. /**
  126638. * Instantiates a new ArcRotateCameraInputsManager.
  126639. * @param camera Defines the camera the inputs belong to
  126640. */
  126641. constructor(camera: ArcRotateCamera);
  126642. /**
  126643. * Add mouse wheel input support to the input manager.
  126644. * @returns the current input manager
  126645. */
  126646. addMouseWheel(): ArcRotateCameraInputsManager;
  126647. /**
  126648. * Add pointers input support to the input manager.
  126649. * @returns the current input manager
  126650. */
  126651. addPointers(): ArcRotateCameraInputsManager;
  126652. /**
  126653. * Add keyboard input support to the input manager.
  126654. * @returns the current input manager
  126655. */
  126656. addKeyboard(): ArcRotateCameraInputsManager;
  126657. }
  126658. }
  126659. declare module BABYLON {
  126660. /**
  126661. * This represents an orbital type of camera.
  126662. *
  126663. * 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.
  126664. * 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.
  126665. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126666. */
  126667. export class ArcRotateCamera extends TargetCamera {
  126668. /**
  126669. * Defines the rotation angle of the camera along the longitudinal axis.
  126670. */
  126671. alpha: number;
  126672. /**
  126673. * Defines the rotation angle of the camera along the latitudinal axis.
  126674. */
  126675. beta: number;
  126676. /**
  126677. * Defines the radius of the camera from it s target point.
  126678. */
  126679. radius: number;
  126680. protected _target: Vector3;
  126681. protected _targetHost: Nullable<AbstractMesh>;
  126682. /**
  126683. * Defines the target point of the camera.
  126684. * The camera looks towards it form the radius distance.
  126685. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126686. */
  126687. get target(): Vector3;
  126688. set target(value: Vector3);
  126689. /**
  126690. * Define the current local position of the camera in the scene
  126691. */
  126692. get position(): Vector3;
  126693. set position(newPosition: Vector3);
  126694. protected _upToYMatrix: Matrix;
  126695. protected _YToUpMatrix: Matrix;
  126696. /**
  126697. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126698. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126699. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126700. */
  126701. set upVector(vec: Vector3);
  126702. get upVector(): Vector3;
  126703. /**
  126704. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126705. */
  126706. setMatUp(): void;
  126707. /**
  126708. * Current inertia value on the longitudinal axis.
  126709. * The bigger this number the longer it will take for the camera to stop.
  126710. */
  126711. inertialAlphaOffset: number;
  126712. /**
  126713. * Current inertia value on the latitudinal axis.
  126714. * The bigger this number the longer it will take for the camera to stop.
  126715. */
  126716. inertialBetaOffset: number;
  126717. /**
  126718. * Current inertia value on the radius axis.
  126719. * The bigger this number the longer it will take for the camera to stop.
  126720. */
  126721. inertialRadiusOffset: number;
  126722. /**
  126723. * Minimum allowed angle on the longitudinal axis.
  126724. * This can help limiting how the Camera is able to move in the scene.
  126725. */
  126726. lowerAlphaLimit: Nullable<number>;
  126727. /**
  126728. * Maximum allowed angle on the longitudinal axis.
  126729. * This can help limiting how the Camera is able to move in the scene.
  126730. */
  126731. upperAlphaLimit: Nullable<number>;
  126732. /**
  126733. * Minimum allowed angle on the latitudinal axis.
  126734. * This can help limiting how the Camera is able to move in the scene.
  126735. */
  126736. lowerBetaLimit: number;
  126737. /**
  126738. * Maximum allowed angle on the latitudinal axis.
  126739. * This can help limiting how the Camera is able to move in the scene.
  126740. */
  126741. upperBetaLimit: number;
  126742. /**
  126743. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126744. * This can help limiting how the Camera is able to move in the scene.
  126745. */
  126746. lowerRadiusLimit: Nullable<number>;
  126747. /**
  126748. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126749. * This can help limiting how the Camera is able to move in the scene.
  126750. */
  126751. upperRadiusLimit: Nullable<number>;
  126752. /**
  126753. * Defines the current inertia value used during panning of the camera along the X axis.
  126754. */
  126755. inertialPanningX: number;
  126756. /**
  126757. * Defines the current inertia value used during panning of the camera along the Y axis.
  126758. */
  126759. inertialPanningY: number;
  126760. /**
  126761. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126762. * Basically if your fingers moves away from more than this distance you will be considered
  126763. * in pinch mode.
  126764. */
  126765. pinchToPanMaxDistance: number;
  126766. /**
  126767. * Defines the maximum distance the camera can pan.
  126768. * This could help keeping the cammera always in your scene.
  126769. */
  126770. panningDistanceLimit: Nullable<number>;
  126771. /**
  126772. * Defines the target of the camera before paning.
  126773. */
  126774. panningOriginTarget: Vector3;
  126775. /**
  126776. * Defines the value of the inertia used during panning.
  126777. * 0 would mean stop inertia and one would mean no decelleration at all.
  126778. */
  126779. panningInertia: number;
  126780. /**
  126781. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126782. */
  126783. get angularSensibilityX(): number;
  126784. set angularSensibilityX(value: number);
  126785. /**
  126786. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126787. */
  126788. get angularSensibilityY(): number;
  126789. set angularSensibilityY(value: number);
  126790. /**
  126791. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126792. */
  126793. get pinchPrecision(): number;
  126794. set pinchPrecision(value: number);
  126795. /**
  126796. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126797. * It will be used instead of pinchDeltaPrecision if different from 0.
  126798. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126799. */
  126800. get pinchDeltaPercentage(): number;
  126801. set pinchDeltaPercentage(value: number);
  126802. /**
  126803. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126804. * and pinch delta percentage.
  126805. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126806. * that any object in the plane at the camera's target point will scale
  126807. * perfectly with finger motion.
  126808. */
  126809. get useNaturalPinchZoom(): boolean;
  126810. set useNaturalPinchZoom(value: boolean);
  126811. /**
  126812. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126813. */
  126814. get panningSensibility(): number;
  126815. set panningSensibility(value: number);
  126816. /**
  126817. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126818. */
  126819. get keysUp(): number[];
  126820. set keysUp(value: number[]);
  126821. /**
  126822. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126823. */
  126824. get keysDown(): number[];
  126825. set keysDown(value: number[]);
  126826. /**
  126827. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126828. */
  126829. get keysLeft(): number[];
  126830. set keysLeft(value: number[]);
  126831. /**
  126832. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126833. */
  126834. get keysRight(): number[];
  126835. set keysRight(value: number[]);
  126836. /**
  126837. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126838. */
  126839. get wheelPrecision(): number;
  126840. set wheelPrecision(value: number);
  126841. /**
  126842. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126843. * It will be used instead of pinchDeltaPrecision if different from 0.
  126844. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126845. */
  126846. get wheelDeltaPercentage(): number;
  126847. set wheelDeltaPercentage(value: number);
  126848. /**
  126849. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126850. */
  126851. zoomOnFactor: number;
  126852. /**
  126853. * Defines a screen offset for the camera position.
  126854. */
  126855. targetScreenOffset: Vector2;
  126856. /**
  126857. * Allows the camera to be completely reversed.
  126858. * If false the camera can not arrive upside down.
  126859. */
  126860. allowUpsideDown: boolean;
  126861. /**
  126862. * Define if double tap/click is used to restore the previously saved state of the camera.
  126863. */
  126864. useInputToRestoreState: boolean;
  126865. /** @hidden */
  126866. _viewMatrix: Matrix;
  126867. /** @hidden */
  126868. _useCtrlForPanning: boolean;
  126869. /** @hidden */
  126870. _panningMouseButton: number;
  126871. /**
  126872. * Defines the input associated to the camera.
  126873. */
  126874. inputs: ArcRotateCameraInputsManager;
  126875. /** @hidden */
  126876. _reset: () => void;
  126877. /**
  126878. * Defines the allowed panning axis.
  126879. */
  126880. panningAxis: Vector3;
  126881. protected _localDirection: Vector3;
  126882. protected _transformedDirection: Vector3;
  126883. private _bouncingBehavior;
  126884. /**
  126885. * Gets the bouncing behavior of the camera if it has been enabled.
  126886. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126887. */
  126888. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126889. /**
  126890. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126891. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126892. */
  126893. get useBouncingBehavior(): boolean;
  126894. set useBouncingBehavior(value: boolean);
  126895. private _framingBehavior;
  126896. /**
  126897. * Gets the framing behavior of the camera if it has been enabled.
  126898. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126899. */
  126900. get framingBehavior(): Nullable<FramingBehavior>;
  126901. /**
  126902. * Defines if the framing behavior of the camera is enabled on the camera.
  126903. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126904. */
  126905. get useFramingBehavior(): boolean;
  126906. set useFramingBehavior(value: boolean);
  126907. private _autoRotationBehavior;
  126908. /**
  126909. * Gets the auto rotation behavior of the camera if it has been enabled.
  126910. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126911. */
  126912. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126913. /**
  126914. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126915. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126916. */
  126917. get useAutoRotationBehavior(): boolean;
  126918. set useAutoRotationBehavior(value: boolean);
  126919. /**
  126920. * Observable triggered when the mesh target has been changed on the camera.
  126921. */
  126922. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126923. /**
  126924. * Event raised when the camera is colliding with a mesh.
  126925. */
  126926. onCollide: (collidedMesh: AbstractMesh) => void;
  126927. /**
  126928. * Defines whether the camera should check collision with the objects oh the scene.
  126929. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126930. */
  126931. checkCollisions: boolean;
  126932. /**
  126933. * Defines the collision radius of the camera.
  126934. * This simulates a sphere around the camera.
  126935. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126936. */
  126937. collisionRadius: Vector3;
  126938. protected _collider: Collider;
  126939. protected _previousPosition: Vector3;
  126940. protected _collisionVelocity: Vector3;
  126941. protected _newPosition: Vector3;
  126942. protected _previousAlpha: number;
  126943. protected _previousBeta: number;
  126944. protected _previousRadius: number;
  126945. protected _collisionTriggered: boolean;
  126946. protected _targetBoundingCenter: Nullable<Vector3>;
  126947. private _computationVector;
  126948. /**
  126949. * Instantiates a new ArcRotateCamera in a given scene
  126950. * @param name Defines the name of the camera
  126951. * @param alpha Defines the camera rotation along the logitudinal axis
  126952. * @param beta Defines the camera rotation along the latitudinal axis
  126953. * @param radius Defines the camera distance from its target
  126954. * @param target Defines the camera target
  126955. * @param scene Defines the scene the camera belongs to
  126956. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126957. */
  126958. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126959. /** @hidden */
  126960. _initCache(): void;
  126961. /** @hidden */
  126962. _updateCache(ignoreParentClass?: boolean): void;
  126963. protected _getTargetPosition(): Vector3;
  126964. private _storedAlpha;
  126965. private _storedBeta;
  126966. private _storedRadius;
  126967. private _storedTarget;
  126968. private _storedTargetScreenOffset;
  126969. /**
  126970. * Stores the current state of the camera (alpha, beta, radius and target)
  126971. * @returns the camera itself
  126972. */
  126973. storeState(): Camera;
  126974. /**
  126975. * @hidden
  126976. * Restored camera state. You must call storeState() first
  126977. */
  126978. _restoreStateValues(): boolean;
  126979. /** @hidden */
  126980. _isSynchronizedViewMatrix(): boolean;
  126981. /**
  126982. * Attached controls to the current camera.
  126983. * @param element Defines the element the controls should be listened from
  126984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126985. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  126986. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  126987. */
  126988. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  126989. /**
  126990. * Detach the current controls from the camera.
  126991. * The camera will stop reacting to inputs.
  126992. * @param element Defines the element to stop listening the inputs from
  126993. */
  126994. detachControl(element: HTMLElement): void;
  126995. /** @hidden */
  126996. _checkInputs(): void;
  126997. protected _checkLimits(): void;
  126998. /**
  126999. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127000. */
  127001. rebuildAnglesAndRadius(): void;
  127002. /**
  127003. * Use a position to define the current camera related information like alpha, beta and radius
  127004. * @param position Defines the position to set the camera at
  127005. */
  127006. setPosition(position: Vector3): void;
  127007. /**
  127008. * Defines the target the camera should look at.
  127009. * This will automatically adapt alpha beta and radius to fit within the new target.
  127010. * @param target Defines the new target as a Vector or a mesh
  127011. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127012. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127013. */
  127014. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127015. /** @hidden */
  127016. _getViewMatrix(): Matrix;
  127017. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127018. /**
  127019. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127020. * @param meshes Defines the mesh to zoom on
  127021. * @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)
  127022. */
  127023. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127024. /**
  127025. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127026. * The target will be changed but the radius
  127027. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127028. * @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)
  127029. */
  127030. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127031. min: Vector3;
  127032. max: Vector3;
  127033. distance: number;
  127034. }, doNotUpdateMaxZ?: boolean): void;
  127035. /**
  127036. * @override
  127037. * Override Camera.createRigCamera
  127038. */
  127039. createRigCamera(name: string, cameraIndex: number): Camera;
  127040. /**
  127041. * @hidden
  127042. * @override
  127043. * Override Camera._updateRigCameras
  127044. */
  127045. _updateRigCameras(): void;
  127046. /**
  127047. * Destroy the camera and release the current resources hold by it.
  127048. */
  127049. dispose(): void;
  127050. /**
  127051. * Gets the current object class name.
  127052. * @return the class name
  127053. */
  127054. getClassName(): string;
  127055. }
  127056. }
  127057. declare module BABYLON {
  127058. /**
  127059. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127060. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127061. */
  127062. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127063. /**
  127064. * Gets the name of the behavior.
  127065. */
  127066. get name(): string;
  127067. private _zoomStopsAnimation;
  127068. private _idleRotationSpeed;
  127069. private _idleRotationWaitTime;
  127070. private _idleRotationSpinupTime;
  127071. /**
  127072. * Sets the flag that indicates if user zooming should stop animation.
  127073. */
  127074. set zoomStopsAnimation(flag: boolean);
  127075. /**
  127076. * Gets the flag that indicates if user zooming should stop animation.
  127077. */
  127078. get zoomStopsAnimation(): boolean;
  127079. /**
  127080. * Sets the default speed at which the camera rotates around the model.
  127081. */
  127082. set idleRotationSpeed(speed: number);
  127083. /**
  127084. * Gets the default speed at which the camera rotates around the model.
  127085. */
  127086. get idleRotationSpeed(): number;
  127087. /**
  127088. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127089. */
  127090. set idleRotationWaitTime(time: number);
  127091. /**
  127092. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127093. */
  127094. get idleRotationWaitTime(): number;
  127095. /**
  127096. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127097. */
  127098. set idleRotationSpinupTime(time: number);
  127099. /**
  127100. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127101. */
  127102. get idleRotationSpinupTime(): number;
  127103. /**
  127104. * Gets a value indicating if the camera is currently rotating because of this behavior
  127105. */
  127106. get rotationInProgress(): boolean;
  127107. private _onPrePointerObservableObserver;
  127108. private _onAfterCheckInputsObserver;
  127109. private _attachedCamera;
  127110. private _isPointerDown;
  127111. private _lastFrameTime;
  127112. private _lastInteractionTime;
  127113. private _cameraRotationSpeed;
  127114. /**
  127115. * Initializes the behavior.
  127116. */
  127117. init(): void;
  127118. /**
  127119. * Attaches the behavior to its arc rotate camera.
  127120. * @param camera Defines the camera to attach the behavior to
  127121. */
  127122. attach(camera: ArcRotateCamera): void;
  127123. /**
  127124. * Detaches the behavior from its current arc rotate camera.
  127125. */
  127126. detach(): void;
  127127. /**
  127128. * Returns true if user is scrolling.
  127129. * @return true if user is scrolling.
  127130. */
  127131. private _userIsZooming;
  127132. private _lastFrameRadius;
  127133. private _shouldAnimationStopForInteraction;
  127134. /**
  127135. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127136. */
  127137. private _applyUserInteraction;
  127138. private _userIsMoving;
  127139. }
  127140. }
  127141. declare module BABYLON {
  127142. /**
  127143. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127144. */
  127145. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127146. private ui;
  127147. /**
  127148. * The name of the behavior
  127149. */
  127150. name: string;
  127151. /**
  127152. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127153. */
  127154. distanceAwayFromFace: number;
  127155. /**
  127156. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127157. */
  127158. distanceAwayFromBottomOfFace: number;
  127159. private _faceVectors;
  127160. private _target;
  127161. private _scene;
  127162. private _onRenderObserver;
  127163. private _tmpMatrix;
  127164. private _tmpVector;
  127165. /**
  127166. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127167. * @param ui The transform node that should be attched to the mesh
  127168. */
  127169. constructor(ui: TransformNode);
  127170. /**
  127171. * Initializes the behavior
  127172. */
  127173. init(): void;
  127174. private _closestFace;
  127175. private _zeroVector;
  127176. private _lookAtTmpMatrix;
  127177. private _lookAtToRef;
  127178. /**
  127179. * Attaches the AttachToBoxBehavior to the passed in mesh
  127180. * @param target The mesh that the specified node will be attached to
  127181. */
  127182. attach(target: Mesh): void;
  127183. /**
  127184. * Detaches the behavior from the mesh
  127185. */
  127186. detach(): void;
  127187. }
  127188. }
  127189. declare module BABYLON {
  127190. /**
  127191. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127192. */
  127193. export class FadeInOutBehavior implements Behavior<Mesh> {
  127194. /**
  127195. * Time in milliseconds to delay before fading in (Default: 0)
  127196. */
  127197. delay: number;
  127198. /**
  127199. * Time in milliseconds for the mesh to fade in (Default: 300)
  127200. */
  127201. fadeInTime: number;
  127202. private _millisecondsPerFrame;
  127203. private _hovered;
  127204. private _hoverValue;
  127205. private _ownerNode;
  127206. /**
  127207. * Instatiates the FadeInOutBehavior
  127208. */
  127209. constructor();
  127210. /**
  127211. * The name of the behavior
  127212. */
  127213. get name(): string;
  127214. /**
  127215. * Initializes the behavior
  127216. */
  127217. init(): void;
  127218. /**
  127219. * Attaches the fade behavior on the passed in mesh
  127220. * @param ownerNode The mesh that will be faded in/out once attached
  127221. */
  127222. attach(ownerNode: Mesh): void;
  127223. /**
  127224. * Detaches the behavior from the mesh
  127225. */
  127226. detach(): void;
  127227. /**
  127228. * Triggers the mesh to begin fading in or out
  127229. * @param value if the object should fade in or out (true to fade in)
  127230. */
  127231. fadeIn(value: boolean): void;
  127232. private _update;
  127233. private _setAllVisibility;
  127234. }
  127235. }
  127236. declare module BABYLON {
  127237. /**
  127238. * Class containing a set of static utilities functions for managing Pivots
  127239. * @hidden
  127240. */
  127241. export class PivotTools {
  127242. private static _PivotCached;
  127243. private static _OldPivotPoint;
  127244. private static _PivotTranslation;
  127245. private static _PivotTmpVector;
  127246. private static _PivotPostMultiplyPivotMatrix;
  127247. /** @hidden */
  127248. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127249. /** @hidden */
  127250. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127251. }
  127252. }
  127253. declare module BABYLON {
  127254. /**
  127255. * Class containing static functions to help procedurally build meshes
  127256. */
  127257. export class PlaneBuilder {
  127258. /**
  127259. * Creates a plane mesh
  127260. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127261. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127262. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127266. * @param name defines the name of the mesh
  127267. * @param options defines the options used to create the mesh
  127268. * @param scene defines the hosting scene
  127269. * @returns the plane mesh
  127270. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127271. */
  127272. static CreatePlane(name: string, options: {
  127273. size?: number;
  127274. width?: number;
  127275. height?: number;
  127276. sideOrientation?: number;
  127277. frontUVs?: Vector4;
  127278. backUVs?: Vector4;
  127279. updatable?: boolean;
  127280. sourcePlane?: Plane;
  127281. }, scene?: Nullable<Scene>): Mesh;
  127282. }
  127283. }
  127284. declare module BABYLON {
  127285. /**
  127286. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127287. */
  127288. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127289. private static _AnyMouseID;
  127290. /**
  127291. * Abstract mesh the behavior is set on
  127292. */
  127293. attachedNode: AbstractMesh;
  127294. private _dragPlane;
  127295. private _scene;
  127296. private _pointerObserver;
  127297. private _beforeRenderObserver;
  127298. private static _planeScene;
  127299. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127300. /**
  127301. * 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)
  127302. */
  127303. maxDragAngle: number;
  127304. /**
  127305. * @hidden
  127306. */
  127307. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127308. /**
  127309. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127310. */
  127311. currentDraggingPointerID: number;
  127312. /**
  127313. * The last position where the pointer hit the drag plane in world space
  127314. */
  127315. lastDragPosition: Vector3;
  127316. /**
  127317. * If the behavior is currently in a dragging state
  127318. */
  127319. dragging: boolean;
  127320. /**
  127321. * 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)
  127322. */
  127323. dragDeltaRatio: number;
  127324. /**
  127325. * If the drag plane orientation should be updated during the dragging (Default: true)
  127326. */
  127327. updateDragPlane: boolean;
  127328. private _debugMode;
  127329. private _moving;
  127330. /**
  127331. * Fires each time the attached mesh is dragged with the pointer
  127332. * * delta between last drag position and current drag position in world space
  127333. * * dragDistance along the drag axis
  127334. * * dragPlaneNormal normal of the current drag plane used during the drag
  127335. * * dragPlanePoint in world space where the drag intersects the drag plane
  127336. */
  127337. onDragObservable: Observable<{
  127338. delta: Vector3;
  127339. dragPlanePoint: Vector3;
  127340. dragPlaneNormal: Vector3;
  127341. dragDistance: number;
  127342. pointerId: number;
  127343. }>;
  127344. /**
  127345. * Fires each time a drag begins (eg. mouse down on mesh)
  127346. */
  127347. onDragStartObservable: Observable<{
  127348. dragPlanePoint: Vector3;
  127349. pointerId: number;
  127350. }>;
  127351. /**
  127352. * Fires each time a drag ends (eg. mouse release after drag)
  127353. */
  127354. onDragEndObservable: Observable<{
  127355. dragPlanePoint: Vector3;
  127356. pointerId: number;
  127357. }>;
  127358. /**
  127359. * If the attached mesh should be moved when dragged
  127360. */
  127361. moveAttached: boolean;
  127362. /**
  127363. * If the drag behavior will react to drag events (Default: true)
  127364. */
  127365. enabled: boolean;
  127366. /**
  127367. * If pointer events should start and release the drag (Default: true)
  127368. */
  127369. startAndReleaseDragOnPointerEvents: boolean;
  127370. /**
  127371. * If camera controls should be detached during the drag
  127372. */
  127373. detachCameraControls: boolean;
  127374. /**
  127375. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127376. */
  127377. useObjectOrientationForDragging: boolean;
  127378. private _options;
  127379. /**
  127380. * Gets the options used by the behavior
  127381. */
  127382. get options(): {
  127383. dragAxis?: Vector3;
  127384. dragPlaneNormal?: Vector3;
  127385. };
  127386. /**
  127387. * Sets the options used by the behavior
  127388. */
  127389. set options(options: {
  127390. dragAxis?: Vector3;
  127391. dragPlaneNormal?: Vector3;
  127392. });
  127393. /**
  127394. * Creates a pointer drag behavior that can be attached to a mesh
  127395. * @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)
  127396. */
  127397. constructor(options?: {
  127398. dragAxis?: Vector3;
  127399. dragPlaneNormal?: Vector3;
  127400. });
  127401. /**
  127402. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127403. */
  127404. validateDrag: (targetPosition: Vector3) => boolean;
  127405. /**
  127406. * The name of the behavior
  127407. */
  127408. get name(): string;
  127409. /**
  127410. * Initializes the behavior
  127411. */
  127412. init(): void;
  127413. private _tmpVector;
  127414. private _alternatePickedPoint;
  127415. private _worldDragAxis;
  127416. private _targetPosition;
  127417. private _attachedElement;
  127418. /**
  127419. * Attaches the drag behavior the passed in mesh
  127420. * @param ownerNode The mesh that will be dragged around once attached
  127421. * @param predicate Predicate to use for pick filtering
  127422. */
  127423. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127424. /**
  127425. * Force relase the drag action by code.
  127426. */
  127427. releaseDrag(): void;
  127428. private _startDragRay;
  127429. private _lastPointerRay;
  127430. /**
  127431. * Simulates the start of a pointer drag event on the behavior
  127432. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127433. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127434. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127435. */
  127436. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127437. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127438. private _dragDelta;
  127439. protected _moveDrag(ray: Ray): void;
  127440. private _pickWithRayOnDragPlane;
  127441. private _pointA;
  127442. private _pointC;
  127443. private _localAxis;
  127444. private _lookAt;
  127445. private _updateDragPlanePosition;
  127446. /**
  127447. * Detaches the behavior from the mesh
  127448. */
  127449. detach(): void;
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /**
  127454. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127455. */
  127456. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127457. private _dragBehaviorA;
  127458. private _dragBehaviorB;
  127459. private _startDistance;
  127460. private _initialScale;
  127461. private _targetScale;
  127462. private _ownerNode;
  127463. private _sceneRenderObserver;
  127464. /**
  127465. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127466. */
  127467. constructor();
  127468. /**
  127469. * The name of the behavior
  127470. */
  127471. get name(): string;
  127472. /**
  127473. * Initializes the behavior
  127474. */
  127475. init(): void;
  127476. private _getCurrentDistance;
  127477. /**
  127478. * Attaches the scale behavior the passed in mesh
  127479. * @param ownerNode The mesh that will be scaled around once attached
  127480. */
  127481. attach(ownerNode: Mesh): void;
  127482. /**
  127483. * Detaches the behavior from the mesh
  127484. */
  127485. detach(): void;
  127486. }
  127487. }
  127488. declare module BABYLON {
  127489. /**
  127490. * 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
  127491. */
  127492. export class SixDofDragBehavior implements Behavior<Mesh> {
  127493. private static _virtualScene;
  127494. private _ownerNode;
  127495. private _sceneRenderObserver;
  127496. private _scene;
  127497. private _targetPosition;
  127498. private _virtualOriginMesh;
  127499. private _virtualDragMesh;
  127500. private _pointerObserver;
  127501. private _moving;
  127502. private _startingOrientation;
  127503. private _attachedElement;
  127504. /**
  127505. * 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)
  127506. */
  127507. private zDragFactor;
  127508. /**
  127509. * If the object should rotate to face the drag origin
  127510. */
  127511. rotateDraggedObject: boolean;
  127512. /**
  127513. * If the behavior is currently in a dragging state
  127514. */
  127515. dragging: boolean;
  127516. /**
  127517. * 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)
  127518. */
  127519. dragDeltaRatio: number;
  127520. /**
  127521. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127522. */
  127523. currentDraggingPointerID: number;
  127524. /**
  127525. * If camera controls should be detached during the drag
  127526. */
  127527. detachCameraControls: boolean;
  127528. /**
  127529. * Fires each time a drag starts
  127530. */
  127531. onDragStartObservable: Observable<{}>;
  127532. /**
  127533. * Fires each time a drag ends (eg. mouse release after drag)
  127534. */
  127535. onDragEndObservable: Observable<{}>;
  127536. /**
  127537. * 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
  127538. */
  127539. constructor();
  127540. /**
  127541. * The name of the behavior
  127542. */
  127543. get name(): string;
  127544. /**
  127545. * Initializes the behavior
  127546. */
  127547. init(): void;
  127548. /**
  127549. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127550. */
  127551. private get _pointerCamera();
  127552. /**
  127553. * Attaches the scale behavior the passed in mesh
  127554. * @param ownerNode The mesh that will be scaled around once attached
  127555. */
  127556. attach(ownerNode: Mesh): void;
  127557. /**
  127558. * Detaches the behavior from the mesh
  127559. */
  127560. detach(): void;
  127561. }
  127562. }
  127563. declare module BABYLON {
  127564. /**
  127565. * Class used to apply inverse kinematics to bones
  127566. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127567. */
  127568. export class BoneIKController {
  127569. private static _tmpVecs;
  127570. private static _tmpQuat;
  127571. private static _tmpMats;
  127572. /**
  127573. * Gets or sets the target mesh
  127574. */
  127575. targetMesh: AbstractMesh;
  127576. /** Gets or sets the mesh used as pole */
  127577. poleTargetMesh: AbstractMesh;
  127578. /**
  127579. * Gets or sets the bone used as pole
  127580. */
  127581. poleTargetBone: Nullable<Bone>;
  127582. /**
  127583. * Gets or sets the target position
  127584. */
  127585. targetPosition: Vector3;
  127586. /**
  127587. * Gets or sets the pole target position
  127588. */
  127589. poleTargetPosition: Vector3;
  127590. /**
  127591. * Gets or sets the pole target local offset
  127592. */
  127593. poleTargetLocalOffset: Vector3;
  127594. /**
  127595. * Gets or sets the pole angle
  127596. */
  127597. poleAngle: number;
  127598. /**
  127599. * Gets or sets the mesh associated with the controller
  127600. */
  127601. mesh: AbstractMesh;
  127602. /**
  127603. * 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)
  127604. */
  127605. slerpAmount: number;
  127606. private _bone1Quat;
  127607. private _bone1Mat;
  127608. private _bone2Ang;
  127609. private _bone1;
  127610. private _bone2;
  127611. private _bone1Length;
  127612. private _bone2Length;
  127613. private _maxAngle;
  127614. private _maxReach;
  127615. private _rightHandedSystem;
  127616. private _bendAxis;
  127617. private _slerping;
  127618. private _adjustRoll;
  127619. /**
  127620. * Gets or sets maximum allowed angle
  127621. */
  127622. get maxAngle(): number;
  127623. set maxAngle(value: number);
  127624. /**
  127625. * Creates a new BoneIKController
  127626. * @param mesh defines the mesh to control
  127627. * @param bone defines the bone to control
  127628. * @param options defines options to set up the controller
  127629. */
  127630. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127631. targetMesh?: AbstractMesh;
  127632. poleTargetMesh?: AbstractMesh;
  127633. poleTargetBone?: Bone;
  127634. poleTargetLocalOffset?: Vector3;
  127635. poleAngle?: number;
  127636. bendAxis?: Vector3;
  127637. maxAngle?: number;
  127638. slerpAmount?: number;
  127639. });
  127640. private _setMaxAngle;
  127641. /**
  127642. * Force the controller to update the bones
  127643. */
  127644. update(): void;
  127645. }
  127646. }
  127647. declare module BABYLON {
  127648. /**
  127649. * Class used to make a bone look toward a point in space
  127650. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127651. */
  127652. export class BoneLookController {
  127653. private static _tmpVecs;
  127654. private static _tmpQuat;
  127655. private static _tmpMats;
  127656. /**
  127657. * The target Vector3 that the bone will look at
  127658. */
  127659. target: Vector3;
  127660. /**
  127661. * The mesh that the bone is attached to
  127662. */
  127663. mesh: AbstractMesh;
  127664. /**
  127665. * The bone that will be looking to the target
  127666. */
  127667. bone: Bone;
  127668. /**
  127669. * The up axis of the coordinate system that is used when the bone is rotated
  127670. */
  127671. upAxis: Vector3;
  127672. /**
  127673. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127674. */
  127675. upAxisSpace: Space;
  127676. /**
  127677. * Used to make an adjustment to the yaw of the bone
  127678. */
  127679. adjustYaw: number;
  127680. /**
  127681. * Used to make an adjustment to the pitch of the bone
  127682. */
  127683. adjustPitch: number;
  127684. /**
  127685. * Used to make an adjustment to the roll of the bone
  127686. */
  127687. adjustRoll: number;
  127688. /**
  127689. * 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)
  127690. */
  127691. slerpAmount: number;
  127692. private _minYaw;
  127693. private _maxYaw;
  127694. private _minPitch;
  127695. private _maxPitch;
  127696. private _minYawSin;
  127697. private _minYawCos;
  127698. private _maxYawSin;
  127699. private _maxYawCos;
  127700. private _midYawConstraint;
  127701. private _minPitchTan;
  127702. private _maxPitchTan;
  127703. private _boneQuat;
  127704. private _slerping;
  127705. private _transformYawPitch;
  127706. private _transformYawPitchInv;
  127707. private _firstFrameSkipped;
  127708. private _yawRange;
  127709. private _fowardAxis;
  127710. /**
  127711. * Gets or sets the minimum yaw angle that the bone can look to
  127712. */
  127713. get minYaw(): number;
  127714. set minYaw(value: number);
  127715. /**
  127716. * Gets or sets the maximum yaw angle that the bone can look to
  127717. */
  127718. get maxYaw(): number;
  127719. set maxYaw(value: number);
  127720. /**
  127721. * Gets or sets the minimum pitch angle that the bone can look to
  127722. */
  127723. get minPitch(): number;
  127724. set minPitch(value: number);
  127725. /**
  127726. * Gets or sets the maximum pitch angle that the bone can look to
  127727. */
  127728. get maxPitch(): number;
  127729. set maxPitch(value: number);
  127730. /**
  127731. * Create a BoneLookController
  127732. * @param mesh the mesh that the bone belongs to
  127733. * @param bone the bone that will be looking to the target
  127734. * @param target the target Vector3 to look at
  127735. * @param options optional settings:
  127736. * * maxYaw: the maximum angle the bone will yaw to
  127737. * * minYaw: the minimum angle the bone will yaw to
  127738. * * maxPitch: the maximum angle the bone will pitch to
  127739. * * minPitch: the minimum angle the bone will yaw to
  127740. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127741. * * upAxis: the up axis of the coordinate system
  127742. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127743. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127744. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127745. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127746. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127747. * * adjustRoll: used to make an adjustment to the roll of the bone
  127748. **/
  127749. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127750. maxYaw?: number;
  127751. minYaw?: number;
  127752. maxPitch?: number;
  127753. minPitch?: number;
  127754. slerpAmount?: number;
  127755. upAxis?: Vector3;
  127756. upAxisSpace?: Space;
  127757. yawAxis?: Vector3;
  127758. pitchAxis?: Vector3;
  127759. adjustYaw?: number;
  127760. adjustPitch?: number;
  127761. adjustRoll?: number;
  127762. });
  127763. /**
  127764. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127765. */
  127766. update(): void;
  127767. private _getAngleDiff;
  127768. private _getAngleBetween;
  127769. private _isAngleBetween;
  127770. }
  127771. }
  127772. declare module BABYLON {
  127773. /**
  127774. * Manage the gamepad inputs to control an arc rotate camera.
  127775. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127776. */
  127777. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127778. /**
  127779. * Defines the camera the input is attached to.
  127780. */
  127781. camera: ArcRotateCamera;
  127782. /**
  127783. * Defines the gamepad the input is gathering event from.
  127784. */
  127785. gamepad: Nullable<Gamepad>;
  127786. /**
  127787. * Defines the gamepad rotation sensiblity.
  127788. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127789. */
  127790. gamepadRotationSensibility: number;
  127791. /**
  127792. * Defines the gamepad move sensiblity.
  127793. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127794. */
  127795. gamepadMoveSensibility: number;
  127796. private _yAxisScale;
  127797. /**
  127798. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127799. */
  127800. get invertYAxis(): boolean;
  127801. set invertYAxis(value: boolean);
  127802. private _onGamepadConnectedObserver;
  127803. private _onGamepadDisconnectedObserver;
  127804. /**
  127805. * Attach the input controls to a specific dom element to get the input from.
  127806. * @param element Defines the element the controls should be listened from
  127807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127808. */
  127809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127810. /**
  127811. * Detach the current controls from the specified dom element.
  127812. * @param element Defines the element to stop listening the inputs from
  127813. */
  127814. detachControl(element: Nullable<HTMLElement>): void;
  127815. /**
  127816. * Update the current camera state depending on the inputs that have been used this frame.
  127817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127818. */
  127819. checkInputs(): void;
  127820. /**
  127821. * Gets the class name of the current intput.
  127822. * @returns the class name
  127823. */
  127824. getClassName(): string;
  127825. /**
  127826. * Get the friendly name associated with the input class.
  127827. * @returns the input friendly name
  127828. */
  127829. getSimpleName(): string;
  127830. }
  127831. }
  127832. declare module BABYLON {
  127833. interface ArcRotateCameraInputsManager {
  127834. /**
  127835. * Add orientation input support to the input manager.
  127836. * @returns the current input manager
  127837. */
  127838. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127839. }
  127840. /**
  127841. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127842. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127843. */
  127844. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127845. /**
  127846. * Defines the camera the input is attached to.
  127847. */
  127848. camera: ArcRotateCamera;
  127849. /**
  127850. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127851. */
  127852. alphaCorrection: number;
  127853. /**
  127854. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127855. */
  127856. gammaCorrection: number;
  127857. private _alpha;
  127858. private _gamma;
  127859. private _dirty;
  127860. private _deviceOrientationHandler;
  127861. /**
  127862. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127863. */
  127864. constructor();
  127865. /**
  127866. * Attach the input controls to a specific dom element to get the input from.
  127867. * @param element Defines the element the controls should be listened from
  127868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127869. */
  127870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127871. /** @hidden */
  127872. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127873. /**
  127874. * Update the current camera state depending on the inputs that have been used this frame.
  127875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127876. */
  127877. checkInputs(): void;
  127878. /**
  127879. * Detach the current controls from the specified dom element.
  127880. * @param element Defines the element to stop listening the inputs from
  127881. */
  127882. detachControl(element: Nullable<HTMLElement>): void;
  127883. /**
  127884. * Gets the class name of the current intput.
  127885. * @returns the class name
  127886. */
  127887. getClassName(): string;
  127888. /**
  127889. * Get the friendly name associated with the input class.
  127890. * @returns the input friendly name
  127891. */
  127892. getSimpleName(): string;
  127893. }
  127894. }
  127895. declare module BABYLON {
  127896. /**
  127897. * Listen to mouse events to control the camera.
  127898. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127899. */
  127900. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127901. /**
  127902. * Defines the camera the input is attached to.
  127903. */
  127904. camera: FlyCamera;
  127905. /**
  127906. * Defines if touch is enabled. (Default is true.)
  127907. */
  127908. touchEnabled: boolean;
  127909. /**
  127910. * Defines the buttons associated with the input to handle camera rotation.
  127911. */
  127912. buttons: number[];
  127913. /**
  127914. * Assign buttons for Yaw control.
  127915. */
  127916. buttonsYaw: number[];
  127917. /**
  127918. * Assign buttons for Pitch control.
  127919. */
  127920. buttonsPitch: number[];
  127921. /**
  127922. * Assign buttons for Roll control.
  127923. */
  127924. buttonsRoll: number[];
  127925. /**
  127926. * Detect if any button is being pressed while mouse is moved.
  127927. * -1 = Mouse locked.
  127928. * 0 = Left button.
  127929. * 1 = Middle Button.
  127930. * 2 = Right Button.
  127931. */
  127932. activeButton: number;
  127933. /**
  127934. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127935. * Higher values reduce its sensitivity.
  127936. */
  127937. angularSensibility: number;
  127938. private _observer;
  127939. private _rollObserver;
  127940. private previousPosition;
  127941. private noPreventDefault;
  127942. private element;
  127943. /**
  127944. * Listen to mouse events to control the camera.
  127945. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127946. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127947. */
  127948. constructor(touchEnabled?: boolean);
  127949. /**
  127950. * Attach the mouse control to the HTML DOM element.
  127951. * @param element Defines the element that listens to the input events.
  127952. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127953. */
  127954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127955. /**
  127956. * Detach the current controls from the specified dom element.
  127957. * @param element Defines the element to stop listening the inputs from
  127958. */
  127959. detachControl(element: Nullable<HTMLElement>): void;
  127960. /**
  127961. * Gets the class name of the current input.
  127962. * @returns the class name.
  127963. */
  127964. getClassName(): string;
  127965. /**
  127966. * Get the friendly name associated with the input class.
  127967. * @returns the input's friendly name.
  127968. */
  127969. getSimpleName(): string;
  127970. private _pointerInput;
  127971. private _onMouseMove;
  127972. /**
  127973. * Rotate camera by mouse offset.
  127974. */
  127975. private rotateCamera;
  127976. }
  127977. }
  127978. declare module BABYLON {
  127979. /**
  127980. * Default Inputs manager for the FlyCamera.
  127981. * It groups all the default supported inputs for ease of use.
  127982. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127983. */
  127984. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  127985. /**
  127986. * Instantiates a new FlyCameraInputsManager.
  127987. * @param camera Defines the camera the inputs belong to.
  127988. */
  127989. constructor(camera: FlyCamera);
  127990. /**
  127991. * Add keyboard input support to the input manager.
  127992. * @returns the new FlyCameraKeyboardMoveInput().
  127993. */
  127994. addKeyboard(): FlyCameraInputsManager;
  127995. /**
  127996. * Add mouse input support to the input manager.
  127997. * @param touchEnabled Enable touch screen support.
  127998. * @returns the new FlyCameraMouseInput().
  127999. */
  128000. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128001. }
  128002. }
  128003. declare module BABYLON {
  128004. /**
  128005. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128006. * such as in a 3D Space Shooter or a Flight Simulator.
  128007. */
  128008. export class FlyCamera extends TargetCamera {
  128009. /**
  128010. * Define the collision ellipsoid of the camera.
  128011. * This is helpful for simulating a camera body, like a player's body.
  128012. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128013. */
  128014. ellipsoid: Vector3;
  128015. /**
  128016. * Define an offset for the position of the ellipsoid around the camera.
  128017. * This can be helpful if the camera is attached away from the player's body center,
  128018. * such as at its head.
  128019. */
  128020. ellipsoidOffset: Vector3;
  128021. /**
  128022. * Enable or disable collisions of the camera with the rest of the scene objects.
  128023. */
  128024. checkCollisions: boolean;
  128025. /**
  128026. * Enable or disable gravity on the camera.
  128027. */
  128028. applyGravity: boolean;
  128029. /**
  128030. * Define the current direction the camera is moving to.
  128031. */
  128032. cameraDirection: Vector3;
  128033. /**
  128034. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128035. * This overrides and empties cameraRotation.
  128036. */
  128037. rotationQuaternion: Quaternion;
  128038. /**
  128039. * Track Roll to maintain the wanted Rolling when looking around.
  128040. */
  128041. _trackRoll: number;
  128042. /**
  128043. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128044. */
  128045. rollCorrect: number;
  128046. /**
  128047. * Mimic a banked turn, Rolling the camera when Yawing.
  128048. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128049. */
  128050. bankedTurn: boolean;
  128051. /**
  128052. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128053. */
  128054. bankedTurnLimit: number;
  128055. /**
  128056. * Value of 0 disables the banked Roll.
  128057. * Value of 1 is equal to the Yaw angle in radians.
  128058. */
  128059. bankedTurnMultiplier: number;
  128060. /**
  128061. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128062. */
  128063. inputs: FlyCameraInputsManager;
  128064. /**
  128065. * Gets the input sensibility for mouse input.
  128066. * Higher values reduce sensitivity.
  128067. */
  128068. get angularSensibility(): number;
  128069. /**
  128070. * Sets the input sensibility for a mouse input.
  128071. * Higher values reduce sensitivity.
  128072. */
  128073. set angularSensibility(value: number);
  128074. /**
  128075. * Get the keys for camera movement forward.
  128076. */
  128077. get keysForward(): number[];
  128078. /**
  128079. * Set the keys for camera movement forward.
  128080. */
  128081. set keysForward(value: number[]);
  128082. /**
  128083. * Get the keys for camera movement backward.
  128084. */
  128085. get keysBackward(): number[];
  128086. set keysBackward(value: number[]);
  128087. /**
  128088. * Get the keys for camera movement up.
  128089. */
  128090. get keysUp(): number[];
  128091. /**
  128092. * Set the keys for camera movement up.
  128093. */
  128094. set keysUp(value: number[]);
  128095. /**
  128096. * Get the keys for camera movement down.
  128097. */
  128098. get keysDown(): number[];
  128099. /**
  128100. * Set the keys for camera movement down.
  128101. */
  128102. set keysDown(value: number[]);
  128103. /**
  128104. * Get the keys for camera movement left.
  128105. */
  128106. get keysLeft(): number[];
  128107. /**
  128108. * Set the keys for camera movement left.
  128109. */
  128110. set keysLeft(value: number[]);
  128111. /**
  128112. * Set the keys for camera movement right.
  128113. */
  128114. get keysRight(): number[];
  128115. /**
  128116. * Set the keys for camera movement right.
  128117. */
  128118. set keysRight(value: number[]);
  128119. /**
  128120. * Event raised when the camera collides with a mesh in the scene.
  128121. */
  128122. onCollide: (collidedMesh: AbstractMesh) => void;
  128123. private _collider;
  128124. private _needMoveForGravity;
  128125. private _oldPosition;
  128126. private _diffPosition;
  128127. private _newPosition;
  128128. /** @hidden */
  128129. _localDirection: Vector3;
  128130. /** @hidden */
  128131. _transformedDirection: Vector3;
  128132. /**
  128133. * Instantiates a FlyCamera.
  128134. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128135. * such as in a 3D Space Shooter or a Flight Simulator.
  128136. * @param name Define the name of the camera in the scene.
  128137. * @param position Define the starting position of the camera in the scene.
  128138. * @param scene Define the scene the camera belongs to.
  128139. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128140. */
  128141. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128142. /**
  128143. * Attach a control to the HTML DOM element.
  128144. * @param element Defines the element that listens to the input events.
  128145. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128146. */
  128147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128148. /**
  128149. * Detach a control from the HTML DOM element.
  128150. * The camera will stop reacting to that input.
  128151. * @param element Defines the element that listens to the input events.
  128152. */
  128153. detachControl(element: HTMLElement): void;
  128154. private _collisionMask;
  128155. /**
  128156. * Get the mask that the camera ignores in collision events.
  128157. */
  128158. get collisionMask(): number;
  128159. /**
  128160. * Set the mask that the camera ignores in collision events.
  128161. */
  128162. set collisionMask(mask: number);
  128163. /** @hidden */
  128164. _collideWithWorld(displacement: Vector3): void;
  128165. /** @hidden */
  128166. private _onCollisionPositionChange;
  128167. /** @hidden */
  128168. _checkInputs(): void;
  128169. /** @hidden */
  128170. _decideIfNeedsToMove(): boolean;
  128171. /** @hidden */
  128172. _updatePosition(): void;
  128173. /**
  128174. * Restore the Roll to its target value at the rate specified.
  128175. * @param rate - Higher means slower restoring.
  128176. * @hidden
  128177. */
  128178. restoreRoll(rate: number): void;
  128179. /**
  128180. * Destroy the camera and release the current resources held by it.
  128181. */
  128182. dispose(): void;
  128183. /**
  128184. * Get the current object class name.
  128185. * @returns the class name.
  128186. */
  128187. getClassName(): string;
  128188. }
  128189. }
  128190. declare module BABYLON {
  128191. /**
  128192. * Listen to keyboard events to control the camera.
  128193. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128194. */
  128195. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128196. /**
  128197. * Defines the camera the input is attached to.
  128198. */
  128199. camera: FlyCamera;
  128200. /**
  128201. * The list of keyboard keys used to control the forward move of the camera.
  128202. */
  128203. keysForward: number[];
  128204. /**
  128205. * The list of keyboard keys used to control the backward move of the camera.
  128206. */
  128207. keysBackward: number[];
  128208. /**
  128209. * The list of keyboard keys used to control the forward move of the camera.
  128210. */
  128211. keysUp: number[];
  128212. /**
  128213. * The list of keyboard keys used to control the backward move of the camera.
  128214. */
  128215. keysDown: number[];
  128216. /**
  128217. * The list of keyboard keys used to control the right strafe move of the camera.
  128218. */
  128219. keysRight: number[];
  128220. /**
  128221. * The list of keyboard keys used to control the left strafe move of the camera.
  128222. */
  128223. keysLeft: number[];
  128224. private _keys;
  128225. private _onCanvasBlurObserver;
  128226. private _onKeyboardObserver;
  128227. private _engine;
  128228. private _scene;
  128229. /**
  128230. * Attach the input controls to a specific dom element to get the input from.
  128231. * @param element Defines the element the controls should be listened from
  128232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128233. */
  128234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128235. /**
  128236. * Detach the current controls from the specified dom element.
  128237. * @param element Defines the element to stop listening the inputs from
  128238. */
  128239. detachControl(element: Nullable<HTMLElement>): void;
  128240. /**
  128241. * Gets the class name of the current intput.
  128242. * @returns the class name
  128243. */
  128244. getClassName(): string;
  128245. /** @hidden */
  128246. _onLostFocus(e: FocusEvent): void;
  128247. /**
  128248. * Get the friendly name associated with the input class.
  128249. * @returns the input friendly name
  128250. */
  128251. getSimpleName(): string;
  128252. /**
  128253. * Update the current camera state depending on the inputs that have been used this frame.
  128254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128255. */
  128256. checkInputs(): void;
  128257. }
  128258. }
  128259. declare module BABYLON {
  128260. /**
  128261. * Manage the mouse wheel inputs to control a follow camera.
  128262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128263. */
  128264. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128265. /**
  128266. * Defines the camera the input is attached to.
  128267. */
  128268. camera: FollowCamera;
  128269. /**
  128270. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128271. */
  128272. axisControlRadius: boolean;
  128273. /**
  128274. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128275. */
  128276. axisControlHeight: boolean;
  128277. /**
  128278. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128279. */
  128280. axisControlRotation: boolean;
  128281. /**
  128282. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128283. * relation to mouseWheel events.
  128284. */
  128285. wheelPrecision: number;
  128286. /**
  128287. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128288. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128289. */
  128290. wheelDeltaPercentage: number;
  128291. private _wheel;
  128292. private _observer;
  128293. /**
  128294. * Attach the input controls to a specific dom element to get the input from.
  128295. * @param element Defines the element the controls should be listened from
  128296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128297. */
  128298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128299. /**
  128300. * Detach the current controls from the specified dom element.
  128301. * @param element Defines the element to stop listening the inputs from
  128302. */
  128303. detachControl(element: Nullable<HTMLElement>): void;
  128304. /**
  128305. * Gets the class name of the current intput.
  128306. * @returns the class name
  128307. */
  128308. getClassName(): string;
  128309. /**
  128310. * Get the friendly name associated with the input class.
  128311. * @returns the input friendly name
  128312. */
  128313. getSimpleName(): string;
  128314. }
  128315. }
  128316. declare module BABYLON {
  128317. /**
  128318. * Manage the pointers inputs to control an follow camera.
  128319. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128320. */
  128321. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128322. /**
  128323. * Defines the camera the input is attached to.
  128324. */
  128325. camera: FollowCamera;
  128326. /**
  128327. * Gets the class name of the current input.
  128328. * @returns the class name
  128329. */
  128330. getClassName(): string;
  128331. /**
  128332. * Defines the pointer angular sensibility along the X axis or how fast is
  128333. * the camera rotating.
  128334. * A negative number will reverse the axis direction.
  128335. */
  128336. angularSensibilityX: number;
  128337. /**
  128338. * Defines the pointer angular sensibility along the Y axis or how fast is
  128339. * the camera rotating.
  128340. * A negative number will reverse the axis direction.
  128341. */
  128342. angularSensibilityY: number;
  128343. /**
  128344. * Defines the pointer pinch precision or how fast is the camera zooming.
  128345. * A negative number will reverse the axis direction.
  128346. */
  128347. pinchPrecision: number;
  128348. /**
  128349. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128350. * from 0.
  128351. * It defines the percentage of current camera.radius to use as delta when
  128352. * pinch zoom is used.
  128353. */
  128354. pinchDeltaPercentage: number;
  128355. /**
  128356. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128357. */
  128358. axisXControlRadius: boolean;
  128359. /**
  128360. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128361. */
  128362. axisXControlHeight: boolean;
  128363. /**
  128364. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128365. */
  128366. axisXControlRotation: boolean;
  128367. /**
  128368. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128369. */
  128370. axisYControlRadius: boolean;
  128371. /**
  128372. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128373. */
  128374. axisYControlHeight: boolean;
  128375. /**
  128376. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128377. */
  128378. axisYControlRotation: boolean;
  128379. /**
  128380. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128381. */
  128382. axisPinchControlRadius: boolean;
  128383. /**
  128384. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128385. */
  128386. axisPinchControlHeight: boolean;
  128387. /**
  128388. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128389. */
  128390. axisPinchControlRotation: boolean;
  128391. /**
  128392. * Log error messages if basic misconfiguration has occurred.
  128393. */
  128394. warningEnable: boolean;
  128395. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128396. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128397. private _warningCounter;
  128398. private _warning;
  128399. }
  128400. }
  128401. declare module BABYLON {
  128402. /**
  128403. * Default Inputs manager for the FollowCamera.
  128404. * It groups all the default supported inputs for ease of use.
  128405. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128406. */
  128407. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128408. /**
  128409. * Instantiates a new FollowCameraInputsManager.
  128410. * @param camera Defines the camera the inputs belong to
  128411. */
  128412. constructor(camera: FollowCamera);
  128413. /**
  128414. * Add keyboard input support to the input manager.
  128415. * @returns the current input manager
  128416. */
  128417. addKeyboard(): FollowCameraInputsManager;
  128418. /**
  128419. * Add mouse wheel input support to the input manager.
  128420. * @returns the current input manager
  128421. */
  128422. addMouseWheel(): FollowCameraInputsManager;
  128423. /**
  128424. * Add pointers input support to the input manager.
  128425. * @returns the current input manager
  128426. */
  128427. addPointers(): FollowCameraInputsManager;
  128428. /**
  128429. * Add orientation input support to the input manager.
  128430. * @returns the current input manager
  128431. */
  128432. addVRDeviceOrientation(): FollowCameraInputsManager;
  128433. }
  128434. }
  128435. declare module BABYLON {
  128436. /**
  128437. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128438. * an arc rotate version arcFollowCamera are available.
  128439. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128440. */
  128441. export class FollowCamera extends TargetCamera {
  128442. /**
  128443. * Distance the follow camera should follow an object at
  128444. */
  128445. radius: number;
  128446. /**
  128447. * Minimum allowed distance of the camera to the axis of rotation
  128448. * (The camera can not get closer).
  128449. * This can help limiting how the Camera is able to move in the scene.
  128450. */
  128451. lowerRadiusLimit: Nullable<number>;
  128452. /**
  128453. * Maximum allowed distance of the camera to the axis of rotation
  128454. * (The camera can not get further).
  128455. * This can help limiting how the Camera is able to move in the scene.
  128456. */
  128457. upperRadiusLimit: Nullable<number>;
  128458. /**
  128459. * Define a rotation offset between the camera and the object it follows
  128460. */
  128461. rotationOffset: number;
  128462. /**
  128463. * Minimum allowed angle to camera position relative to target object.
  128464. * This can help limiting how the Camera is able to move in the scene.
  128465. */
  128466. lowerRotationOffsetLimit: Nullable<number>;
  128467. /**
  128468. * Maximum allowed angle to camera position relative to target object.
  128469. * This can help limiting how the Camera is able to move in the scene.
  128470. */
  128471. upperRotationOffsetLimit: Nullable<number>;
  128472. /**
  128473. * Define a height offset between the camera and the object it follows.
  128474. * It can help following an object from the top (like a car chaing a plane)
  128475. */
  128476. heightOffset: number;
  128477. /**
  128478. * Minimum allowed height of camera position relative to target object.
  128479. * This can help limiting how the Camera is able to move in the scene.
  128480. */
  128481. lowerHeightOffsetLimit: Nullable<number>;
  128482. /**
  128483. * Maximum allowed height of camera position relative to target object.
  128484. * This can help limiting how the Camera is able to move in the scene.
  128485. */
  128486. upperHeightOffsetLimit: Nullable<number>;
  128487. /**
  128488. * Define how fast the camera can accelerate to follow it s target.
  128489. */
  128490. cameraAcceleration: number;
  128491. /**
  128492. * Define the speed limit of the camera following an object.
  128493. */
  128494. maxCameraSpeed: number;
  128495. /**
  128496. * Define the target of the camera.
  128497. */
  128498. lockedTarget: Nullable<AbstractMesh>;
  128499. /**
  128500. * Defines the input associated with the camera.
  128501. */
  128502. inputs: FollowCameraInputsManager;
  128503. /**
  128504. * Instantiates the follow camera.
  128505. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128506. * @param name Define the name of the camera in the scene
  128507. * @param position Define the position of the camera
  128508. * @param scene Define the scene the camera belong to
  128509. * @param lockedTarget Define the target of the camera
  128510. */
  128511. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128512. private _follow;
  128513. /**
  128514. * Attached controls to the current camera.
  128515. * @param element Defines the element the controls should be listened from
  128516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128517. */
  128518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128519. /**
  128520. * Detach the current controls from the camera.
  128521. * The camera will stop reacting to inputs.
  128522. * @param element Defines the element to stop listening the inputs from
  128523. */
  128524. detachControl(element: HTMLElement): void;
  128525. /** @hidden */
  128526. _checkInputs(): void;
  128527. private _checkLimits;
  128528. /**
  128529. * Gets the camera class name.
  128530. * @returns the class name
  128531. */
  128532. getClassName(): string;
  128533. }
  128534. /**
  128535. * Arc Rotate version of the follow camera.
  128536. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128537. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128538. */
  128539. export class ArcFollowCamera extends TargetCamera {
  128540. /** The longitudinal angle of the camera */
  128541. alpha: number;
  128542. /** The latitudinal angle of the camera */
  128543. beta: number;
  128544. /** The radius of the camera from its target */
  128545. radius: number;
  128546. private _cartesianCoordinates;
  128547. /** Define the camera target (the mesh it should follow) */
  128548. private _meshTarget;
  128549. /**
  128550. * Instantiates a new ArcFollowCamera
  128551. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128552. * @param name Define the name of the camera
  128553. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128554. * @param beta Define the rotation angle of the camera around the elevation axis
  128555. * @param radius Define the radius of the camera from its target point
  128556. * @param target Define the target of the camera
  128557. * @param scene Define the scene the camera belongs to
  128558. */
  128559. constructor(name: string,
  128560. /** The longitudinal angle of the camera */
  128561. alpha: number,
  128562. /** The latitudinal angle of the camera */
  128563. beta: number,
  128564. /** The radius of the camera from its target */
  128565. radius: number,
  128566. /** Define the camera target (the mesh it should follow) */
  128567. target: Nullable<AbstractMesh>, scene: Scene);
  128568. private _follow;
  128569. /** @hidden */
  128570. _checkInputs(): void;
  128571. /**
  128572. * Returns the class name of the object.
  128573. * It is mostly used internally for serialization purposes.
  128574. */
  128575. getClassName(): string;
  128576. }
  128577. }
  128578. declare module BABYLON {
  128579. /**
  128580. * Manage the keyboard inputs to control the movement of a follow camera.
  128581. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128582. */
  128583. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128584. /**
  128585. * Defines the camera the input is attached to.
  128586. */
  128587. camera: FollowCamera;
  128588. /**
  128589. * Defines the list of key codes associated with the up action (increase heightOffset)
  128590. */
  128591. keysHeightOffsetIncr: number[];
  128592. /**
  128593. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128594. */
  128595. keysHeightOffsetDecr: number[];
  128596. /**
  128597. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128598. */
  128599. keysHeightOffsetModifierAlt: boolean;
  128600. /**
  128601. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128602. */
  128603. keysHeightOffsetModifierCtrl: boolean;
  128604. /**
  128605. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128606. */
  128607. keysHeightOffsetModifierShift: boolean;
  128608. /**
  128609. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128610. */
  128611. keysRotationOffsetIncr: number[];
  128612. /**
  128613. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128614. */
  128615. keysRotationOffsetDecr: number[];
  128616. /**
  128617. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128618. */
  128619. keysRotationOffsetModifierAlt: boolean;
  128620. /**
  128621. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128622. */
  128623. keysRotationOffsetModifierCtrl: boolean;
  128624. /**
  128625. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128626. */
  128627. keysRotationOffsetModifierShift: boolean;
  128628. /**
  128629. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128630. */
  128631. keysRadiusIncr: number[];
  128632. /**
  128633. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128634. */
  128635. keysRadiusDecr: number[];
  128636. /**
  128637. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128638. */
  128639. keysRadiusModifierAlt: boolean;
  128640. /**
  128641. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128642. */
  128643. keysRadiusModifierCtrl: boolean;
  128644. /**
  128645. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128646. */
  128647. keysRadiusModifierShift: boolean;
  128648. /**
  128649. * Defines the rate of change of heightOffset.
  128650. */
  128651. heightSensibility: number;
  128652. /**
  128653. * Defines the rate of change of rotationOffset.
  128654. */
  128655. rotationSensibility: number;
  128656. /**
  128657. * Defines the rate of change of radius.
  128658. */
  128659. radiusSensibility: number;
  128660. private _keys;
  128661. private _ctrlPressed;
  128662. private _altPressed;
  128663. private _shiftPressed;
  128664. private _onCanvasBlurObserver;
  128665. private _onKeyboardObserver;
  128666. private _engine;
  128667. private _scene;
  128668. /**
  128669. * Attach the input controls to a specific dom element to get the input from.
  128670. * @param element Defines the element the controls should be listened from
  128671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128672. */
  128673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128674. /**
  128675. * Detach the current controls from the specified dom element.
  128676. * @param element Defines the element to stop listening the inputs from
  128677. */
  128678. detachControl(element: Nullable<HTMLElement>): void;
  128679. /**
  128680. * Update the current camera state depending on the inputs that have been used this frame.
  128681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128682. */
  128683. checkInputs(): void;
  128684. /**
  128685. * Gets the class name of the current input.
  128686. * @returns the class name
  128687. */
  128688. getClassName(): string;
  128689. /**
  128690. * Get the friendly name associated with the input class.
  128691. * @returns the input friendly name
  128692. */
  128693. getSimpleName(): string;
  128694. /**
  128695. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128696. * allow modification of the heightOffset value.
  128697. */
  128698. private _modifierHeightOffset;
  128699. /**
  128700. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128701. * allow modification of the rotationOffset value.
  128702. */
  128703. private _modifierRotationOffset;
  128704. /**
  128705. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128706. * allow modification of the radius value.
  128707. */
  128708. private _modifierRadius;
  128709. }
  128710. }
  128711. declare module BABYLON {
  128712. interface FreeCameraInputsManager {
  128713. /**
  128714. * @hidden
  128715. */
  128716. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128717. /**
  128718. * Add orientation input support to the input manager.
  128719. * @returns the current input manager
  128720. */
  128721. addDeviceOrientation(): FreeCameraInputsManager;
  128722. }
  128723. /**
  128724. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128725. * Screen rotation is taken into account.
  128726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128727. */
  128728. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128729. private _camera;
  128730. private _screenOrientationAngle;
  128731. private _constantTranform;
  128732. private _screenQuaternion;
  128733. private _alpha;
  128734. private _beta;
  128735. private _gamma;
  128736. /**
  128737. * Can be used to detect if a device orientation sensor is available on a device
  128738. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128739. * @returns a promise that will resolve on orientation change
  128740. */
  128741. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128742. /**
  128743. * @hidden
  128744. */
  128745. _onDeviceOrientationChangedObservable: Observable<void>;
  128746. /**
  128747. * Instantiates a new input
  128748. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128749. */
  128750. constructor();
  128751. /**
  128752. * Define the camera controlled by the input.
  128753. */
  128754. get camera(): FreeCamera;
  128755. set camera(camera: FreeCamera);
  128756. /**
  128757. * Attach the input controls to a specific dom element to get the input from.
  128758. * @param element Defines the element the controls should be listened from
  128759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128760. */
  128761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128762. private _orientationChanged;
  128763. private _deviceOrientation;
  128764. /**
  128765. * Detach the current controls from the specified dom element.
  128766. * @param element Defines the element to stop listening the inputs from
  128767. */
  128768. detachControl(element: Nullable<HTMLElement>): void;
  128769. /**
  128770. * Update the current camera state depending on the inputs that have been used this frame.
  128771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128772. */
  128773. checkInputs(): void;
  128774. /**
  128775. * Gets the class name of the current intput.
  128776. * @returns the class name
  128777. */
  128778. getClassName(): string;
  128779. /**
  128780. * Get the friendly name associated with the input class.
  128781. * @returns the input friendly name
  128782. */
  128783. getSimpleName(): string;
  128784. }
  128785. }
  128786. declare module BABYLON {
  128787. /**
  128788. * Manage the gamepad inputs to control a free camera.
  128789. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128790. */
  128791. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128792. /**
  128793. * Define the camera the input is attached to.
  128794. */
  128795. camera: FreeCamera;
  128796. /**
  128797. * Define the Gamepad controlling the input
  128798. */
  128799. gamepad: Nullable<Gamepad>;
  128800. /**
  128801. * Defines the gamepad rotation sensiblity.
  128802. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128803. */
  128804. gamepadAngularSensibility: number;
  128805. /**
  128806. * Defines the gamepad move sensiblity.
  128807. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128808. */
  128809. gamepadMoveSensibility: number;
  128810. private _yAxisScale;
  128811. /**
  128812. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128813. */
  128814. get invertYAxis(): boolean;
  128815. set invertYAxis(value: boolean);
  128816. private _onGamepadConnectedObserver;
  128817. private _onGamepadDisconnectedObserver;
  128818. private _cameraTransform;
  128819. private _deltaTransform;
  128820. private _vector3;
  128821. private _vector2;
  128822. /**
  128823. * Attach the input controls to a specific dom element to get the input from.
  128824. * @param element Defines the element the controls should be listened from
  128825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128826. */
  128827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128828. /**
  128829. * Detach the current controls from the specified dom element.
  128830. * @param element Defines the element to stop listening the inputs from
  128831. */
  128832. detachControl(element: Nullable<HTMLElement>): void;
  128833. /**
  128834. * Update the current camera state depending on the inputs that have been used this frame.
  128835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128836. */
  128837. checkInputs(): void;
  128838. /**
  128839. * Gets the class name of the current intput.
  128840. * @returns the class name
  128841. */
  128842. getClassName(): string;
  128843. /**
  128844. * Get the friendly name associated with the input class.
  128845. * @returns the input friendly name
  128846. */
  128847. getSimpleName(): string;
  128848. }
  128849. }
  128850. declare module BABYLON {
  128851. /**
  128852. * Defines the potential axis of a Joystick
  128853. */
  128854. export enum JoystickAxis {
  128855. /** X axis */
  128856. X = 0,
  128857. /** Y axis */
  128858. Y = 1,
  128859. /** Z axis */
  128860. Z = 2
  128861. }
  128862. /**
  128863. * Represents the different customization options available
  128864. * for VirtualJoystick
  128865. */
  128866. interface VirtualJoystickCustomizations {
  128867. /**
  128868. * Size of the joystick's puck
  128869. */
  128870. puckSize: number;
  128871. /**
  128872. * Size of the joystick's container
  128873. */
  128874. containerSize: number;
  128875. /**
  128876. * Color of the joystick && puck
  128877. */
  128878. color: string;
  128879. /**
  128880. * Image URL for the joystick's puck
  128881. */
  128882. puckImage?: string;
  128883. /**
  128884. * Image URL for the joystick's container
  128885. */
  128886. containerImage?: string;
  128887. /**
  128888. * Defines the unmoving position of the joystick container
  128889. */
  128890. position?: {
  128891. x: number;
  128892. y: number;
  128893. };
  128894. /**
  128895. * Defines whether or not the joystick container is always visible
  128896. */
  128897. alwaysVisible: boolean;
  128898. /**
  128899. * Defines whether or not to limit the movement of the puck to the joystick's container
  128900. */
  128901. limitToContainer: boolean;
  128902. }
  128903. /**
  128904. * Class used to define virtual joystick (used in touch mode)
  128905. */
  128906. export class VirtualJoystick {
  128907. /**
  128908. * Gets or sets a boolean indicating that left and right values must be inverted
  128909. */
  128910. reverseLeftRight: boolean;
  128911. /**
  128912. * Gets or sets a boolean indicating that up and down values must be inverted
  128913. */
  128914. reverseUpDown: boolean;
  128915. /**
  128916. * Gets the offset value for the position (ie. the change of the position value)
  128917. */
  128918. deltaPosition: Vector3;
  128919. /**
  128920. * Gets a boolean indicating if the virtual joystick was pressed
  128921. */
  128922. pressed: boolean;
  128923. /**
  128924. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128925. */
  128926. static Canvas: Nullable<HTMLCanvasElement>;
  128927. /**
  128928. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128929. */
  128930. limitToContainer: boolean;
  128931. private static _globalJoystickIndex;
  128932. private static _alwaysVisibleSticks;
  128933. private static vjCanvasContext;
  128934. private static vjCanvasWidth;
  128935. private static vjCanvasHeight;
  128936. private static halfWidth;
  128937. private static _GetDefaultOptions;
  128938. private _action;
  128939. private _axisTargetedByLeftAndRight;
  128940. private _axisTargetedByUpAndDown;
  128941. private _joystickSensibility;
  128942. private _inversedSensibility;
  128943. private _joystickPointerID;
  128944. private _joystickColor;
  128945. private _joystickPointerPos;
  128946. private _joystickPreviousPointerPos;
  128947. private _joystickPointerStartPos;
  128948. private _deltaJoystickVector;
  128949. private _leftJoystick;
  128950. private _touches;
  128951. private _joystickPosition;
  128952. private _alwaysVisible;
  128953. private _puckImage;
  128954. private _containerImage;
  128955. private _joystickPuckSize;
  128956. private _joystickContainerSize;
  128957. private _clearPuckSize;
  128958. private _clearContainerSize;
  128959. private _clearPuckSizeOffset;
  128960. private _clearContainerSizeOffset;
  128961. private _onPointerDownHandlerRef;
  128962. private _onPointerMoveHandlerRef;
  128963. private _onPointerUpHandlerRef;
  128964. private _onResize;
  128965. /**
  128966. * Creates a new virtual joystick
  128967. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128968. * @param customizations Defines the options we want to customize the VirtualJoystick
  128969. */
  128970. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128971. /**
  128972. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128973. * @param newJoystickSensibility defines the new sensibility
  128974. */
  128975. setJoystickSensibility(newJoystickSensibility: number): void;
  128976. private _onPointerDown;
  128977. private _onPointerMove;
  128978. private _onPointerUp;
  128979. /**
  128980. * Change the color of the virtual joystick
  128981. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  128982. */
  128983. setJoystickColor(newColor: string): void;
  128984. /**
  128985. * Size of the joystick's container
  128986. */
  128987. set containerSize(newSize: number);
  128988. get containerSize(): number;
  128989. /**
  128990. * Size of the joystick's puck
  128991. */
  128992. set puckSize(newSize: number);
  128993. get puckSize(): number;
  128994. /**
  128995. * Clears the set position of the joystick
  128996. */
  128997. clearPosition(): void;
  128998. /**
  128999. * Defines whether or not the joystick container is always visible
  129000. */
  129001. set alwaysVisible(value: boolean);
  129002. get alwaysVisible(): boolean;
  129003. /**
  129004. * Sets the constant position of the Joystick container
  129005. * @param x X axis coordinate
  129006. * @param y Y axis coordinate
  129007. */
  129008. setPosition(x: number, y: number): void;
  129009. /**
  129010. * Defines a callback to call when the joystick is touched
  129011. * @param action defines the callback
  129012. */
  129013. setActionOnTouch(action: () => any): void;
  129014. /**
  129015. * Defines which axis you'd like to control for left & right
  129016. * @param axis defines the axis to use
  129017. */
  129018. setAxisForLeftRight(axis: JoystickAxis): void;
  129019. /**
  129020. * Defines which axis you'd like to control for up & down
  129021. * @param axis defines the axis to use
  129022. */
  129023. setAxisForUpDown(axis: JoystickAxis): void;
  129024. /**
  129025. * Clears the canvas from the previous puck / container draw
  129026. */
  129027. private _clearPreviousDraw;
  129028. /**
  129029. * Loads `urlPath` to be used for the container's image
  129030. * @param urlPath defines the urlPath of an image to use
  129031. */
  129032. setContainerImage(urlPath: string): void;
  129033. /**
  129034. * Loads `urlPath` to be used for the puck's image
  129035. * @param urlPath defines the urlPath of an image to use
  129036. */
  129037. setPuckImage(urlPath: string): void;
  129038. /**
  129039. * Draws the Virtual Joystick's container
  129040. */
  129041. private _drawContainer;
  129042. /**
  129043. * Draws the Virtual Joystick's puck
  129044. */
  129045. private _drawPuck;
  129046. private _drawVirtualJoystick;
  129047. /**
  129048. * Release internal HTML canvas
  129049. */
  129050. releaseCanvas(): void;
  129051. }
  129052. }
  129053. declare module BABYLON {
  129054. interface FreeCameraInputsManager {
  129055. /**
  129056. * Add virtual joystick input support to the input manager.
  129057. * @returns the current input manager
  129058. */
  129059. addVirtualJoystick(): FreeCameraInputsManager;
  129060. }
  129061. /**
  129062. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129063. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129064. */
  129065. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129066. /**
  129067. * Defines the camera the input is attached to.
  129068. */
  129069. camera: FreeCamera;
  129070. private _leftjoystick;
  129071. private _rightjoystick;
  129072. /**
  129073. * Gets the left stick of the virtual joystick.
  129074. * @returns The virtual Joystick
  129075. */
  129076. getLeftJoystick(): VirtualJoystick;
  129077. /**
  129078. * Gets the right stick of the virtual joystick.
  129079. * @returns The virtual Joystick
  129080. */
  129081. getRightJoystick(): VirtualJoystick;
  129082. /**
  129083. * Update the current camera state depending on the inputs that have been used this frame.
  129084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129085. */
  129086. checkInputs(): void;
  129087. /**
  129088. * Attach the input controls to a specific dom element to get the input from.
  129089. * @param element Defines the element the controls should be listened from
  129090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129091. */
  129092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129093. /**
  129094. * Detach the current controls from the specified dom element.
  129095. * @param element Defines the element to stop listening the inputs from
  129096. */
  129097. detachControl(element: Nullable<HTMLElement>): void;
  129098. /**
  129099. * Gets the class name of the current intput.
  129100. * @returns the class name
  129101. */
  129102. getClassName(): string;
  129103. /**
  129104. * Get the friendly name associated with the input class.
  129105. * @returns the input friendly name
  129106. */
  129107. getSimpleName(): string;
  129108. }
  129109. }
  129110. declare module BABYLON {
  129111. /**
  129112. * This represents a FPS type of camera controlled by touch.
  129113. * This is like a universal camera minus the Gamepad controls.
  129114. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129115. */
  129116. export class TouchCamera extends FreeCamera {
  129117. /**
  129118. * Defines the touch sensibility for rotation.
  129119. * The higher the faster.
  129120. */
  129121. get touchAngularSensibility(): number;
  129122. set touchAngularSensibility(value: number);
  129123. /**
  129124. * Defines the touch sensibility for move.
  129125. * The higher the faster.
  129126. */
  129127. get touchMoveSensibility(): number;
  129128. set touchMoveSensibility(value: number);
  129129. /**
  129130. * Instantiates a new touch camera.
  129131. * This represents a FPS type of camera controlled by touch.
  129132. * This is like a universal camera minus the Gamepad controls.
  129133. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129134. * @param name Define the name of the camera in the scene
  129135. * @param position Define the start position of the camera in the scene
  129136. * @param scene Define the scene the camera belongs to
  129137. */
  129138. constructor(name: string, position: Vector3, scene: Scene);
  129139. /**
  129140. * Gets the current object class name.
  129141. * @return the class name
  129142. */
  129143. getClassName(): string;
  129144. /** @hidden */
  129145. _setupInputs(): void;
  129146. }
  129147. }
  129148. declare module BABYLON {
  129149. /**
  129150. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129151. * being tilted forward or back and left or right.
  129152. */
  129153. export class DeviceOrientationCamera extends FreeCamera {
  129154. private _initialQuaternion;
  129155. private _quaternionCache;
  129156. private _tmpDragQuaternion;
  129157. private _disablePointerInputWhenUsingDeviceOrientation;
  129158. /**
  129159. * Creates a new device orientation camera
  129160. * @param name The name of the camera
  129161. * @param position The start position camera
  129162. * @param scene The scene the camera belongs to
  129163. */
  129164. constructor(name: string, position: Vector3, scene: Scene);
  129165. /**
  129166. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129167. */
  129168. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129169. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129170. private _dragFactor;
  129171. /**
  129172. * Enabled turning on the y axis when the orientation sensor is active
  129173. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129174. */
  129175. enableHorizontalDragging(dragFactor?: number): void;
  129176. /**
  129177. * Gets the current instance class name ("DeviceOrientationCamera").
  129178. * This helps avoiding instanceof at run time.
  129179. * @returns the class name
  129180. */
  129181. getClassName(): string;
  129182. /**
  129183. * @hidden
  129184. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129185. */
  129186. _checkInputs(): void;
  129187. /**
  129188. * Reset the camera to its default orientation on the specified axis only.
  129189. * @param axis The axis to reset
  129190. */
  129191. resetToCurrentRotation(axis?: Axis): void;
  129192. }
  129193. }
  129194. declare module BABYLON {
  129195. /**
  129196. * Defines supported buttons for XBox360 compatible gamepads
  129197. */
  129198. export enum Xbox360Button {
  129199. /** A */
  129200. A = 0,
  129201. /** B */
  129202. B = 1,
  129203. /** X */
  129204. X = 2,
  129205. /** Y */
  129206. Y = 3,
  129207. /** Left button */
  129208. LB = 4,
  129209. /** Right button */
  129210. RB = 5,
  129211. /** Back */
  129212. Back = 8,
  129213. /** Start */
  129214. Start = 9,
  129215. /** Left stick */
  129216. LeftStick = 10,
  129217. /** Right stick */
  129218. RightStick = 11
  129219. }
  129220. /** Defines values for XBox360 DPad */
  129221. export enum Xbox360Dpad {
  129222. /** Up */
  129223. Up = 12,
  129224. /** Down */
  129225. Down = 13,
  129226. /** Left */
  129227. Left = 14,
  129228. /** Right */
  129229. Right = 15
  129230. }
  129231. /**
  129232. * Defines a XBox360 gamepad
  129233. */
  129234. export class Xbox360Pad extends Gamepad {
  129235. private _leftTrigger;
  129236. private _rightTrigger;
  129237. private _onlefttriggerchanged;
  129238. private _onrighttriggerchanged;
  129239. private _onbuttondown;
  129240. private _onbuttonup;
  129241. private _ondpaddown;
  129242. private _ondpadup;
  129243. /** Observable raised when a button is pressed */
  129244. onButtonDownObservable: Observable<Xbox360Button>;
  129245. /** Observable raised when a button is released */
  129246. onButtonUpObservable: Observable<Xbox360Button>;
  129247. /** Observable raised when a pad is pressed */
  129248. onPadDownObservable: Observable<Xbox360Dpad>;
  129249. /** Observable raised when a pad is released */
  129250. onPadUpObservable: Observable<Xbox360Dpad>;
  129251. private _buttonA;
  129252. private _buttonB;
  129253. private _buttonX;
  129254. private _buttonY;
  129255. private _buttonBack;
  129256. private _buttonStart;
  129257. private _buttonLB;
  129258. private _buttonRB;
  129259. private _buttonLeftStick;
  129260. private _buttonRightStick;
  129261. private _dPadUp;
  129262. private _dPadDown;
  129263. private _dPadLeft;
  129264. private _dPadRight;
  129265. private _isXboxOnePad;
  129266. /**
  129267. * Creates a new XBox360 gamepad object
  129268. * @param id defines the id of this gamepad
  129269. * @param index defines its index
  129270. * @param gamepad defines the internal HTML gamepad object
  129271. * @param xboxOne defines if it is a XBox One gamepad
  129272. */
  129273. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129274. /**
  129275. * Defines the callback to call when left trigger is pressed
  129276. * @param callback defines the callback to use
  129277. */
  129278. onlefttriggerchanged(callback: (value: number) => void): void;
  129279. /**
  129280. * Defines the callback to call when right trigger is pressed
  129281. * @param callback defines the callback to use
  129282. */
  129283. onrighttriggerchanged(callback: (value: number) => void): void;
  129284. /**
  129285. * Gets the left trigger value
  129286. */
  129287. get leftTrigger(): number;
  129288. /**
  129289. * Sets the left trigger value
  129290. */
  129291. set leftTrigger(newValue: number);
  129292. /**
  129293. * Gets the right trigger value
  129294. */
  129295. get rightTrigger(): number;
  129296. /**
  129297. * Sets the right trigger value
  129298. */
  129299. set rightTrigger(newValue: number);
  129300. /**
  129301. * Defines the callback to call when a button is pressed
  129302. * @param callback defines the callback to use
  129303. */
  129304. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129305. /**
  129306. * Defines the callback to call when a button is released
  129307. * @param callback defines the callback to use
  129308. */
  129309. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129310. /**
  129311. * Defines the callback to call when a pad is pressed
  129312. * @param callback defines the callback to use
  129313. */
  129314. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129315. /**
  129316. * Defines the callback to call when a pad is released
  129317. * @param callback defines the callback to use
  129318. */
  129319. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129320. private _setButtonValue;
  129321. private _setDPadValue;
  129322. /**
  129323. * Gets the value of the `A` button
  129324. */
  129325. get buttonA(): number;
  129326. /**
  129327. * Sets the value of the `A` button
  129328. */
  129329. set buttonA(value: number);
  129330. /**
  129331. * Gets the value of the `B` button
  129332. */
  129333. get buttonB(): number;
  129334. /**
  129335. * Sets the value of the `B` button
  129336. */
  129337. set buttonB(value: number);
  129338. /**
  129339. * Gets the value of the `X` button
  129340. */
  129341. get buttonX(): number;
  129342. /**
  129343. * Sets the value of the `X` button
  129344. */
  129345. set buttonX(value: number);
  129346. /**
  129347. * Gets the value of the `Y` button
  129348. */
  129349. get buttonY(): number;
  129350. /**
  129351. * Sets the value of the `Y` button
  129352. */
  129353. set buttonY(value: number);
  129354. /**
  129355. * Gets the value of the `Start` button
  129356. */
  129357. get buttonStart(): number;
  129358. /**
  129359. * Sets the value of the `Start` button
  129360. */
  129361. set buttonStart(value: number);
  129362. /**
  129363. * Gets the value of the `Back` button
  129364. */
  129365. get buttonBack(): number;
  129366. /**
  129367. * Sets the value of the `Back` button
  129368. */
  129369. set buttonBack(value: number);
  129370. /**
  129371. * Gets the value of the `Left` button
  129372. */
  129373. get buttonLB(): number;
  129374. /**
  129375. * Sets the value of the `Left` button
  129376. */
  129377. set buttonLB(value: number);
  129378. /**
  129379. * Gets the value of the `Right` button
  129380. */
  129381. get buttonRB(): number;
  129382. /**
  129383. * Sets the value of the `Right` button
  129384. */
  129385. set buttonRB(value: number);
  129386. /**
  129387. * Gets the value of the Left joystick
  129388. */
  129389. get buttonLeftStick(): number;
  129390. /**
  129391. * Sets the value of the Left joystick
  129392. */
  129393. set buttonLeftStick(value: number);
  129394. /**
  129395. * Gets the value of the Right joystick
  129396. */
  129397. get buttonRightStick(): number;
  129398. /**
  129399. * Sets the value of the Right joystick
  129400. */
  129401. set buttonRightStick(value: number);
  129402. /**
  129403. * Gets the value of D-pad up
  129404. */
  129405. get dPadUp(): number;
  129406. /**
  129407. * Sets the value of D-pad up
  129408. */
  129409. set dPadUp(value: number);
  129410. /**
  129411. * Gets the value of D-pad down
  129412. */
  129413. get dPadDown(): number;
  129414. /**
  129415. * Sets the value of D-pad down
  129416. */
  129417. set dPadDown(value: number);
  129418. /**
  129419. * Gets the value of D-pad left
  129420. */
  129421. get dPadLeft(): number;
  129422. /**
  129423. * Sets the value of D-pad left
  129424. */
  129425. set dPadLeft(value: number);
  129426. /**
  129427. * Gets the value of D-pad right
  129428. */
  129429. get dPadRight(): number;
  129430. /**
  129431. * Sets the value of D-pad right
  129432. */
  129433. set dPadRight(value: number);
  129434. /**
  129435. * Force the gamepad to synchronize with device values
  129436. */
  129437. update(): void;
  129438. /**
  129439. * Disposes the gamepad
  129440. */
  129441. dispose(): void;
  129442. }
  129443. }
  129444. declare module BABYLON {
  129445. /**
  129446. * Defines supported buttons for DualShock compatible gamepads
  129447. */
  129448. export enum DualShockButton {
  129449. /** Cross */
  129450. Cross = 0,
  129451. /** Circle */
  129452. Circle = 1,
  129453. /** Square */
  129454. Square = 2,
  129455. /** Triangle */
  129456. Triangle = 3,
  129457. /** L1 */
  129458. L1 = 4,
  129459. /** R1 */
  129460. R1 = 5,
  129461. /** Share */
  129462. Share = 8,
  129463. /** Options */
  129464. Options = 9,
  129465. /** Left stick */
  129466. LeftStick = 10,
  129467. /** Right stick */
  129468. RightStick = 11
  129469. }
  129470. /** Defines values for DualShock DPad */
  129471. export enum DualShockDpad {
  129472. /** Up */
  129473. Up = 12,
  129474. /** Down */
  129475. Down = 13,
  129476. /** Left */
  129477. Left = 14,
  129478. /** Right */
  129479. Right = 15
  129480. }
  129481. /**
  129482. * Defines a DualShock gamepad
  129483. */
  129484. export class DualShockPad extends Gamepad {
  129485. private _leftTrigger;
  129486. private _rightTrigger;
  129487. private _onlefttriggerchanged;
  129488. private _onrighttriggerchanged;
  129489. private _onbuttondown;
  129490. private _onbuttonup;
  129491. private _ondpaddown;
  129492. private _ondpadup;
  129493. /** Observable raised when a button is pressed */
  129494. onButtonDownObservable: Observable<DualShockButton>;
  129495. /** Observable raised when a button is released */
  129496. onButtonUpObservable: Observable<DualShockButton>;
  129497. /** Observable raised when a pad is pressed */
  129498. onPadDownObservable: Observable<DualShockDpad>;
  129499. /** Observable raised when a pad is released */
  129500. onPadUpObservable: Observable<DualShockDpad>;
  129501. private _buttonCross;
  129502. private _buttonCircle;
  129503. private _buttonSquare;
  129504. private _buttonTriangle;
  129505. private _buttonShare;
  129506. private _buttonOptions;
  129507. private _buttonL1;
  129508. private _buttonR1;
  129509. private _buttonLeftStick;
  129510. private _buttonRightStick;
  129511. private _dPadUp;
  129512. private _dPadDown;
  129513. private _dPadLeft;
  129514. private _dPadRight;
  129515. /**
  129516. * Creates a new DualShock gamepad object
  129517. * @param id defines the id of this gamepad
  129518. * @param index defines its index
  129519. * @param gamepad defines the internal HTML gamepad object
  129520. */
  129521. constructor(id: string, index: number, gamepad: any);
  129522. /**
  129523. * Defines the callback to call when left trigger is pressed
  129524. * @param callback defines the callback to use
  129525. */
  129526. onlefttriggerchanged(callback: (value: number) => void): void;
  129527. /**
  129528. * Defines the callback to call when right trigger is pressed
  129529. * @param callback defines the callback to use
  129530. */
  129531. onrighttriggerchanged(callback: (value: number) => void): void;
  129532. /**
  129533. * Gets the left trigger value
  129534. */
  129535. get leftTrigger(): number;
  129536. /**
  129537. * Sets the left trigger value
  129538. */
  129539. set leftTrigger(newValue: number);
  129540. /**
  129541. * Gets the right trigger value
  129542. */
  129543. get rightTrigger(): number;
  129544. /**
  129545. * Sets the right trigger value
  129546. */
  129547. set rightTrigger(newValue: number);
  129548. /**
  129549. * Defines the callback to call when a button is pressed
  129550. * @param callback defines the callback to use
  129551. */
  129552. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129553. /**
  129554. * Defines the callback to call when a button is released
  129555. * @param callback defines the callback to use
  129556. */
  129557. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129558. /**
  129559. * Defines the callback to call when a pad is pressed
  129560. * @param callback defines the callback to use
  129561. */
  129562. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129563. /**
  129564. * Defines the callback to call when a pad is released
  129565. * @param callback defines the callback to use
  129566. */
  129567. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129568. private _setButtonValue;
  129569. private _setDPadValue;
  129570. /**
  129571. * Gets the value of the `Cross` button
  129572. */
  129573. get buttonCross(): number;
  129574. /**
  129575. * Sets the value of the `Cross` button
  129576. */
  129577. set buttonCross(value: number);
  129578. /**
  129579. * Gets the value of the `Circle` button
  129580. */
  129581. get buttonCircle(): number;
  129582. /**
  129583. * Sets the value of the `Circle` button
  129584. */
  129585. set buttonCircle(value: number);
  129586. /**
  129587. * Gets the value of the `Square` button
  129588. */
  129589. get buttonSquare(): number;
  129590. /**
  129591. * Sets the value of the `Square` button
  129592. */
  129593. set buttonSquare(value: number);
  129594. /**
  129595. * Gets the value of the `Triangle` button
  129596. */
  129597. get buttonTriangle(): number;
  129598. /**
  129599. * Sets the value of the `Triangle` button
  129600. */
  129601. set buttonTriangle(value: number);
  129602. /**
  129603. * Gets the value of the `Options` button
  129604. */
  129605. get buttonOptions(): number;
  129606. /**
  129607. * Sets the value of the `Options` button
  129608. */
  129609. set buttonOptions(value: number);
  129610. /**
  129611. * Gets the value of the `Share` button
  129612. */
  129613. get buttonShare(): number;
  129614. /**
  129615. * Sets the value of the `Share` button
  129616. */
  129617. set buttonShare(value: number);
  129618. /**
  129619. * Gets the value of the `L1` button
  129620. */
  129621. get buttonL1(): number;
  129622. /**
  129623. * Sets the value of the `L1` button
  129624. */
  129625. set buttonL1(value: number);
  129626. /**
  129627. * Gets the value of the `R1` button
  129628. */
  129629. get buttonR1(): number;
  129630. /**
  129631. * Sets the value of the `R1` button
  129632. */
  129633. set buttonR1(value: number);
  129634. /**
  129635. * Gets the value of the Left joystick
  129636. */
  129637. get buttonLeftStick(): number;
  129638. /**
  129639. * Sets the value of the Left joystick
  129640. */
  129641. set buttonLeftStick(value: number);
  129642. /**
  129643. * Gets the value of the Right joystick
  129644. */
  129645. get buttonRightStick(): number;
  129646. /**
  129647. * Sets the value of the Right joystick
  129648. */
  129649. set buttonRightStick(value: number);
  129650. /**
  129651. * Gets the value of D-pad up
  129652. */
  129653. get dPadUp(): number;
  129654. /**
  129655. * Sets the value of D-pad up
  129656. */
  129657. set dPadUp(value: number);
  129658. /**
  129659. * Gets the value of D-pad down
  129660. */
  129661. get dPadDown(): number;
  129662. /**
  129663. * Sets the value of D-pad down
  129664. */
  129665. set dPadDown(value: number);
  129666. /**
  129667. * Gets the value of D-pad left
  129668. */
  129669. get dPadLeft(): number;
  129670. /**
  129671. * Sets the value of D-pad left
  129672. */
  129673. set dPadLeft(value: number);
  129674. /**
  129675. * Gets the value of D-pad right
  129676. */
  129677. get dPadRight(): number;
  129678. /**
  129679. * Sets the value of D-pad right
  129680. */
  129681. set dPadRight(value: number);
  129682. /**
  129683. * Force the gamepad to synchronize with device values
  129684. */
  129685. update(): void;
  129686. /**
  129687. * Disposes the gamepad
  129688. */
  129689. dispose(): void;
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. /**
  129694. * Manager for handling gamepads
  129695. */
  129696. export class GamepadManager {
  129697. private _scene?;
  129698. private _babylonGamepads;
  129699. private _oneGamepadConnected;
  129700. /** @hidden */
  129701. _isMonitoring: boolean;
  129702. private _gamepadEventSupported;
  129703. private _gamepadSupport?;
  129704. /**
  129705. * observable to be triggered when the gamepad controller has been connected
  129706. */
  129707. onGamepadConnectedObservable: Observable<Gamepad>;
  129708. /**
  129709. * observable to be triggered when the gamepad controller has been disconnected
  129710. */
  129711. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129712. private _onGamepadConnectedEvent;
  129713. private _onGamepadDisconnectedEvent;
  129714. /**
  129715. * Initializes the gamepad manager
  129716. * @param _scene BabylonJS scene
  129717. */
  129718. constructor(_scene?: Scene | undefined);
  129719. /**
  129720. * The gamepads in the game pad manager
  129721. */
  129722. get gamepads(): Gamepad[];
  129723. /**
  129724. * Get the gamepad controllers based on type
  129725. * @param type The type of gamepad controller
  129726. * @returns Nullable gamepad
  129727. */
  129728. getGamepadByType(type?: number): Nullable<Gamepad>;
  129729. /**
  129730. * Disposes the gamepad manager
  129731. */
  129732. dispose(): void;
  129733. private _addNewGamepad;
  129734. private _startMonitoringGamepads;
  129735. private _stopMonitoringGamepads;
  129736. /** @hidden */
  129737. _checkGamepadsStatus(): void;
  129738. private _updateGamepadObjects;
  129739. }
  129740. }
  129741. declare module BABYLON {
  129742. interface Scene {
  129743. /** @hidden */
  129744. _gamepadManager: Nullable<GamepadManager>;
  129745. /**
  129746. * Gets the gamepad manager associated with the scene
  129747. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129748. */
  129749. gamepadManager: GamepadManager;
  129750. }
  129751. /**
  129752. * Interface representing a free camera inputs manager
  129753. */
  129754. interface FreeCameraInputsManager {
  129755. /**
  129756. * Adds gamepad input support to the FreeCameraInputsManager.
  129757. * @returns the FreeCameraInputsManager
  129758. */
  129759. addGamepad(): FreeCameraInputsManager;
  129760. }
  129761. /**
  129762. * Interface representing an arc rotate camera inputs manager
  129763. */
  129764. interface ArcRotateCameraInputsManager {
  129765. /**
  129766. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129767. * @returns the camera inputs manager
  129768. */
  129769. addGamepad(): ArcRotateCameraInputsManager;
  129770. }
  129771. /**
  129772. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129773. */
  129774. export class GamepadSystemSceneComponent implements ISceneComponent {
  129775. /**
  129776. * The component name helpfull to identify the component in the list of scene components.
  129777. */
  129778. readonly name: string;
  129779. /**
  129780. * The scene the component belongs to.
  129781. */
  129782. scene: Scene;
  129783. /**
  129784. * Creates a new instance of the component for the given scene
  129785. * @param scene Defines the scene to register the component in
  129786. */
  129787. constructor(scene: Scene);
  129788. /**
  129789. * Registers the component in a given scene
  129790. */
  129791. register(): void;
  129792. /**
  129793. * Rebuilds the elements related to this component in case of
  129794. * context lost for instance.
  129795. */
  129796. rebuild(): void;
  129797. /**
  129798. * Disposes the component and the associated ressources
  129799. */
  129800. dispose(): void;
  129801. private _beforeCameraUpdate;
  129802. }
  129803. }
  129804. declare module BABYLON {
  129805. /**
  129806. * 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,
  129807. * which still works and will still be found in many Playgrounds.
  129808. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129809. */
  129810. export class UniversalCamera extends TouchCamera {
  129811. /**
  129812. * Defines the gamepad rotation sensiblity.
  129813. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129814. */
  129815. get gamepadAngularSensibility(): number;
  129816. set gamepadAngularSensibility(value: number);
  129817. /**
  129818. * Defines the gamepad move sensiblity.
  129819. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129820. */
  129821. get gamepadMoveSensibility(): number;
  129822. set gamepadMoveSensibility(value: number);
  129823. /**
  129824. * 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,
  129825. * which still works and will still be found in many Playgrounds.
  129826. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129827. * @param name Define the name of the camera in the scene
  129828. * @param position Define the start position of the camera in the scene
  129829. * @param scene Define the scene the camera belongs to
  129830. */
  129831. constructor(name: string, position: Vector3, scene: Scene);
  129832. /**
  129833. * Gets the current object class name.
  129834. * @return the class name
  129835. */
  129836. getClassName(): string;
  129837. }
  129838. }
  129839. declare module BABYLON {
  129840. /**
  129841. * This represents a FPS type of camera. This is only here for back compat purpose.
  129842. * Please use the UniversalCamera instead as both are identical.
  129843. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129844. */
  129845. export class GamepadCamera extends UniversalCamera {
  129846. /**
  129847. * Instantiates a new Gamepad Camera
  129848. * This represents a FPS type of camera. This is only here for back compat purpose.
  129849. * Please use the UniversalCamera instead as both are identical.
  129850. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129851. * @param name Define the name of the camera in the scene
  129852. * @param position Define the start position of the camera in the scene
  129853. * @param scene Define the scene the camera belongs to
  129854. */
  129855. constructor(name: string, position: Vector3, scene: Scene);
  129856. /**
  129857. * Gets the current object class name.
  129858. * @return the class name
  129859. */
  129860. getClassName(): string;
  129861. }
  129862. }
  129863. declare module BABYLON {
  129864. /** @hidden */
  129865. export var passPixelShader: {
  129866. name: string;
  129867. shader: string;
  129868. };
  129869. }
  129870. declare module BABYLON {
  129871. /** @hidden */
  129872. export var passCubePixelShader: {
  129873. name: string;
  129874. shader: string;
  129875. };
  129876. }
  129877. declare module BABYLON {
  129878. /**
  129879. * PassPostProcess which produces an output the same as it's input
  129880. */
  129881. export class PassPostProcess extends PostProcess {
  129882. /**
  129883. * Gets a string identifying the name of the class
  129884. * @returns "PassPostProcess" string
  129885. */
  129886. getClassName(): string;
  129887. /**
  129888. * Creates the PassPostProcess
  129889. * @param name The name of the effect.
  129890. * @param options The required width/height ratio to downsize to before computing the render pass.
  129891. * @param camera The camera to apply the render pass to.
  129892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129893. * @param engine The engine which the post process will be applied. (default: current engine)
  129894. * @param reusable If the post process can be reused on the same frame. (default: false)
  129895. * @param textureType The type of texture to be used when performing the post processing.
  129896. * @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)
  129897. */
  129898. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129899. /** @hidden */
  129900. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129901. }
  129902. /**
  129903. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129904. */
  129905. export class PassCubePostProcess extends PostProcess {
  129906. private _face;
  129907. /**
  129908. * Gets or sets the cube face to display.
  129909. * * 0 is +X
  129910. * * 1 is -X
  129911. * * 2 is +Y
  129912. * * 3 is -Y
  129913. * * 4 is +Z
  129914. * * 5 is -Z
  129915. */
  129916. get face(): number;
  129917. set face(value: number);
  129918. /**
  129919. * Gets a string identifying the name of the class
  129920. * @returns "PassCubePostProcess" string
  129921. */
  129922. getClassName(): string;
  129923. /**
  129924. * Creates the PassCubePostProcess
  129925. * @param name The name of the effect.
  129926. * @param options The required width/height ratio to downsize to before computing the render pass.
  129927. * @param camera The camera to apply the render pass to.
  129928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129929. * @param engine The engine which the post process will be applied. (default: current engine)
  129930. * @param reusable If the post process can be reused on the same frame. (default: false)
  129931. * @param textureType The type of texture to be used when performing the post processing.
  129932. * @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)
  129933. */
  129934. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129935. /** @hidden */
  129936. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129937. }
  129938. }
  129939. declare module BABYLON {
  129940. /** @hidden */
  129941. export var anaglyphPixelShader: {
  129942. name: string;
  129943. shader: string;
  129944. };
  129945. }
  129946. declare module BABYLON {
  129947. /**
  129948. * Postprocess used to generate anaglyphic rendering
  129949. */
  129950. export class AnaglyphPostProcess extends PostProcess {
  129951. private _passedProcess;
  129952. /**
  129953. * Gets a string identifying the name of the class
  129954. * @returns "AnaglyphPostProcess" string
  129955. */
  129956. getClassName(): string;
  129957. /**
  129958. * Creates a new AnaglyphPostProcess
  129959. * @param name defines postprocess name
  129960. * @param options defines creation options or target ratio scale
  129961. * @param rigCameras defines cameras using this postprocess
  129962. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129963. * @param engine defines hosting engine
  129964. * @param reusable defines if the postprocess will be reused multiple times per frame
  129965. */
  129966. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129967. }
  129968. }
  129969. declare module BABYLON {
  129970. /**
  129971. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129972. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129973. */
  129974. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129975. /**
  129976. * Creates a new AnaglyphArcRotateCamera
  129977. * @param name defines camera name
  129978. * @param alpha defines alpha angle (in radians)
  129979. * @param beta defines beta angle (in radians)
  129980. * @param radius defines radius
  129981. * @param target defines camera target
  129982. * @param interaxialDistance defines distance between each color axis
  129983. * @param scene defines the hosting scene
  129984. */
  129985. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  129986. /**
  129987. * Gets camera class name
  129988. * @returns AnaglyphArcRotateCamera
  129989. */
  129990. getClassName(): string;
  129991. }
  129992. }
  129993. declare module BABYLON {
  129994. /**
  129995. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  129996. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129997. */
  129998. export class AnaglyphFreeCamera extends FreeCamera {
  129999. /**
  130000. * Creates a new AnaglyphFreeCamera
  130001. * @param name defines camera name
  130002. * @param position defines initial position
  130003. * @param interaxialDistance defines distance between each color axis
  130004. * @param scene defines the hosting scene
  130005. */
  130006. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130007. /**
  130008. * Gets camera class name
  130009. * @returns AnaglyphFreeCamera
  130010. */
  130011. getClassName(): string;
  130012. }
  130013. }
  130014. declare module BABYLON {
  130015. /**
  130016. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130017. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130018. */
  130019. export class AnaglyphGamepadCamera extends GamepadCamera {
  130020. /**
  130021. * Creates a new AnaglyphGamepadCamera
  130022. * @param name defines camera name
  130023. * @param position defines initial position
  130024. * @param interaxialDistance defines distance between each color axis
  130025. * @param scene defines the hosting scene
  130026. */
  130027. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130028. /**
  130029. * Gets camera class name
  130030. * @returns AnaglyphGamepadCamera
  130031. */
  130032. getClassName(): string;
  130033. }
  130034. }
  130035. declare module BABYLON {
  130036. /**
  130037. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130038. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130039. */
  130040. export class AnaglyphUniversalCamera extends UniversalCamera {
  130041. /**
  130042. * Creates a new AnaglyphUniversalCamera
  130043. * @param name defines camera name
  130044. * @param position defines initial position
  130045. * @param interaxialDistance defines distance between each color axis
  130046. * @param scene defines the hosting scene
  130047. */
  130048. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130049. /**
  130050. * Gets camera class name
  130051. * @returns AnaglyphUniversalCamera
  130052. */
  130053. getClassName(): string;
  130054. }
  130055. }
  130056. declare module BABYLON {
  130057. /**
  130058. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130059. * @see https://doc.babylonjs.com/features/cameras
  130060. */
  130061. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130062. /**
  130063. * Creates a new StereoscopicArcRotateCamera
  130064. * @param name defines camera name
  130065. * @param alpha defines alpha angle (in radians)
  130066. * @param beta defines beta angle (in radians)
  130067. * @param radius defines radius
  130068. * @param target defines camera target
  130069. * @param interaxialDistance defines distance between each color axis
  130070. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130071. * @param scene defines the hosting scene
  130072. */
  130073. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130074. /**
  130075. * Gets camera class name
  130076. * @returns StereoscopicArcRotateCamera
  130077. */
  130078. getClassName(): string;
  130079. }
  130080. }
  130081. declare module BABYLON {
  130082. /**
  130083. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130084. * @see https://doc.babylonjs.com/features/cameras
  130085. */
  130086. export class StereoscopicFreeCamera extends FreeCamera {
  130087. /**
  130088. * Creates a new StereoscopicFreeCamera
  130089. * @param name defines camera name
  130090. * @param position defines initial position
  130091. * @param interaxialDistance defines distance between each color axis
  130092. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130093. * @param scene defines the hosting scene
  130094. */
  130095. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130096. /**
  130097. * Gets camera class name
  130098. * @returns StereoscopicFreeCamera
  130099. */
  130100. getClassName(): string;
  130101. }
  130102. }
  130103. declare module BABYLON {
  130104. /**
  130105. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130106. * @see https://doc.babylonjs.com/features/cameras
  130107. */
  130108. export class StereoscopicGamepadCamera extends GamepadCamera {
  130109. /**
  130110. * Creates a new StereoscopicGamepadCamera
  130111. * @param name defines camera name
  130112. * @param position defines initial position
  130113. * @param interaxialDistance defines distance between each color axis
  130114. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130115. * @param scene defines the hosting scene
  130116. */
  130117. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130118. /**
  130119. * Gets camera class name
  130120. * @returns StereoscopicGamepadCamera
  130121. */
  130122. getClassName(): string;
  130123. }
  130124. }
  130125. declare module BABYLON {
  130126. /**
  130127. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130128. * @see https://doc.babylonjs.com/features/cameras
  130129. */
  130130. export class StereoscopicUniversalCamera extends UniversalCamera {
  130131. /**
  130132. * Creates a new StereoscopicUniversalCamera
  130133. * @param name defines camera name
  130134. * @param position defines initial position
  130135. * @param interaxialDistance defines distance between each color axis
  130136. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130137. * @param scene defines the hosting scene
  130138. */
  130139. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130140. /**
  130141. * Gets camera class name
  130142. * @returns StereoscopicUniversalCamera
  130143. */
  130144. getClassName(): string;
  130145. }
  130146. }
  130147. declare module BABYLON {
  130148. /**
  130149. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130150. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130151. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130152. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130153. */
  130154. export class VirtualJoysticksCamera extends FreeCamera {
  130155. /**
  130156. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130157. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130158. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130159. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130160. * @param name Define the name of the camera in the scene
  130161. * @param position Define the start position of the camera in the scene
  130162. * @param scene Define the scene the camera belongs to
  130163. */
  130164. constructor(name: string, position: Vector3, scene: Scene);
  130165. /**
  130166. * Gets the current object class name.
  130167. * @return the class name
  130168. */
  130169. getClassName(): string;
  130170. }
  130171. }
  130172. declare module BABYLON {
  130173. /**
  130174. * This represents all the required metrics to create a VR camera.
  130175. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130176. */
  130177. export class VRCameraMetrics {
  130178. /**
  130179. * Define the horizontal resolution off the screen.
  130180. */
  130181. hResolution: number;
  130182. /**
  130183. * Define the vertical resolution off the screen.
  130184. */
  130185. vResolution: number;
  130186. /**
  130187. * Define the horizontal screen size.
  130188. */
  130189. hScreenSize: number;
  130190. /**
  130191. * Define the vertical screen size.
  130192. */
  130193. vScreenSize: number;
  130194. /**
  130195. * Define the vertical screen center position.
  130196. */
  130197. vScreenCenter: number;
  130198. /**
  130199. * Define the distance of the eyes to the screen.
  130200. */
  130201. eyeToScreenDistance: number;
  130202. /**
  130203. * Define the distance between both lenses
  130204. */
  130205. lensSeparationDistance: number;
  130206. /**
  130207. * Define the distance between both viewer's eyes.
  130208. */
  130209. interpupillaryDistance: number;
  130210. /**
  130211. * Define the distortion factor of the VR postprocess.
  130212. * Please, touch with care.
  130213. */
  130214. distortionK: number[];
  130215. /**
  130216. * Define the chromatic aberration correction factors for the VR post process.
  130217. */
  130218. chromaAbCorrection: number[];
  130219. /**
  130220. * Define the scale factor of the post process.
  130221. * The smaller the better but the slower.
  130222. */
  130223. postProcessScaleFactor: number;
  130224. /**
  130225. * Define an offset for the lens center.
  130226. */
  130227. lensCenterOffset: number;
  130228. /**
  130229. * Define if the current vr camera should compensate the distortion of the lense or not.
  130230. */
  130231. compensateDistortion: boolean;
  130232. /**
  130233. * Defines if multiview should be enabled when rendering (Default: false)
  130234. */
  130235. multiviewEnabled: boolean;
  130236. /**
  130237. * Gets the rendering aspect ratio based on the provided resolutions.
  130238. */
  130239. get aspectRatio(): number;
  130240. /**
  130241. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130242. */
  130243. get aspectRatioFov(): number;
  130244. /**
  130245. * @hidden
  130246. */
  130247. get leftHMatrix(): Matrix;
  130248. /**
  130249. * @hidden
  130250. */
  130251. get rightHMatrix(): Matrix;
  130252. /**
  130253. * @hidden
  130254. */
  130255. get leftPreViewMatrix(): Matrix;
  130256. /**
  130257. * @hidden
  130258. */
  130259. get rightPreViewMatrix(): Matrix;
  130260. /**
  130261. * Get the default VRMetrics based on the most generic setup.
  130262. * @returns the default vr metrics
  130263. */
  130264. static GetDefault(): VRCameraMetrics;
  130265. }
  130266. }
  130267. declare module BABYLON {
  130268. /** @hidden */
  130269. export var vrDistortionCorrectionPixelShader: {
  130270. name: string;
  130271. shader: string;
  130272. };
  130273. }
  130274. declare module BABYLON {
  130275. /**
  130276. * VRDistortionCorrectionPostProcess used for mobile VR
  130277. */
  130278. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130279. private _isRightEye;
  130280. private _distortionFactors;
  130281. private _postProcessScaleFactor;
  130282. private _lensCenterOffset;
  130283. private _scaleIn;
  130284. private _scaleFactor;
  130285. private _lensCenter;
  130286. /**
  130287. * Gets a string identifying the name of the class
  130288. * @returns "VRDistortionCorrectionPostProcess" string
  130289. */
  130290. getClassName(): string;
  130291. /**
  130292. * Initializes the VRDistortionCorrectionPostProcess
  130293. * @param name The name of the effect.
  130294. * @param camera The camera to apply the render pass to.
  130295. * @param isRightEye If this is for the right eye distortion
  130296. * @param vrMetrics All the required metrics for the VR camera
  130297. */
  130298. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130299. }
  130300. }
  130301. declare module BABYLON {
  130302. /**
  130303. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130304. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130305. */
  130306. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130307. /**
  130308. * Creates a new VRDeviceOrientationArcRotateCamera
  130309. * @param name defines camera name
  130310. * @param alpha defines the camera rotation along the logitudinal axis
  130311. * @param beta defines the camera rotation along the latitudinal axis
  130312. * @param radius defines the camera distance from its target
  130313. * @param target defines the camera target
  130314. * @param scene defines the scene the camera belongs to
  130315. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130316. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130317. */
  130318. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130319. /**
  130320. * Gets camera class name
  130321. * @returns VRDeviceOrientationArcRotateCamera
  130322. */
  130323. getClassName(): string;
  130324. }
  130325. }
  130326. declare module BABYLON {
  130327. /**
  130328. * Camera used to simulate VR rendering (based on FreeCamera)
  130329. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130330. */
  130331. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130332. /**
  130333. * Creates a new VRDeviceOrientationFreeCamera
  130334. * @param name defines camera name
  130335. * @param position defines the start position of the camera
  130336. * @param scene defines the scene the camera belongs to
  130337. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130338. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130339. */
  130340. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130341. /**
  130342. * Gets camera class name
  130343. * @returns VRDeviceOrientationFreeCamera
  130344. */
  130345. getClassName(): string;
  130346. }
  130347. }
  130348. declare module BABYLON {
  130349. /**
  130350. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130351. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130352. */
  130353. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130354. /**
  130355. * Creates a new VRDeviceOrientationGamepadCamera
  130356. * @param name defines camera name
  130357. * @param position defines the start position of the camera
  130358. * @param scene defines the scene the camera belongs to
  130359. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130360. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130361. */
  130362. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130363. /**
  130364. * Gets camera class name
  130365. * @returns VRDeviceOrientationGamepadCamera
  130366. */
  130367. getClassName(): string;
  130368. }
  130369. }
  130370. declare module BABYLON {
  130371. /**
  130372. * A class extending Texture allowing drawing on a texture
  130373. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130374. */
  130375. export class DynamicTexture extends Texture {
  130376. private _generateMipMaps;
  130377. private _canvas;
  130378. private _context;
  130379. /**
  130380. * Creates a DynamicTexture
  130381. * @param name defines the name of the texture
  130382. * @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
  130383. * @param scene defines the scene where you want the texture
  130384. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130385. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130386. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130387. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130388. */
  130389. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130390. /**
  130391. * Get the current class name of the texture useful for serialization or dynamic coding.
  130392. * @returns "DynamicTexture"
  130393. */
  130394. getClassName(): string;
  130395. /**
  130396. * Gets the current state of canRescale
  130397. */
  130398. get canRescale(): boolean;
  130399. private _recreate;
  130400. /**
  130401. * Scales the texture
  130402. * @param ratio the scale factor to apply to both width and height
  130403. */
  130404. scale(ratio: number): void;
  130405. /**
  130406. * Resizes the texture
  130407. * @param width the new width
  130408. * @param height the new height
  130409. */
  130410. scaleTo(width: number, height: number): void;
  130411. /**
  130412. * Gets the context of the canvas used by the texture
  130413. * @returns the canvas context of the dynamic texture
  130414. */
  130415. getContext(): CanvasRenderingContext2D;
  130416. /**
  130417. * Clears the texture
  130418. */
  130419. clear(): void;
  130420. /**
  130421. * Updates the texture
  130422. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130423. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130424. */
  130425. update(invertY?: boolean, premulAlpha?: boolean): void;
  130426. /**
  130427. * Draws text onto the texture
  130428. * @param text defines the text to be drawn
  130429. * @param x defines the placement of the text from the left
  130430. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130431. * @param font defines the font to be used with font-style, font-size, font-name
  130432. * @param color defines the color used for the text
  130433. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130434. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130435. * @param update defines whether texture is immediately update (default is true)
  130436. */
  130437. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130438. /**
  130439. * Clones the texture
  130440. * @returns the clone of the texture.
  130441. */
  130442. clone(): DynamicTexture;
  130443. /**
  130444. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130445. * @returns a serialized dynamic texture object
  130446. */
  130447. serialize(): any;
  130448. private _IsCanvasElement;
  130449. /** @hidden */
  130450. _rebuild(): void;
  130451. }
  130452. }
  130453. declare module BABYLON {
  130454. /**
  130455. * Class containing static functions to help procedurally build meshes
  130456. */
  130457. export class GroundBuilder {
  130458. /**
  130459. * Creates a ground mesh
  130460. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130461. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130463. * @param name defines the name of the mesh
  130464. * @param options defines the options used to create the mesh
  130465. * @param scene defines the hosting scene
  130466. * @returns the ground mesh
  130467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130468. */
  130469. static CreateGround(name: string, options: {
  130470. width?: number;
  130471. height?: number;
  130472. subdivisions?: number;
  130473. subdivisionsX?: number;
  130474. subdivisionsY?: number;
  130475. updatable?: boolean;
  130476. }, scene: any): Mesh;
  130477. /**
  130478. * Creates a tiled ground mesh
  130479. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130480. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130481. * * 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
  130482. * * 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
  130483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130484. * @param name defines the name of the mesh
  130485. * @param options defines the options used to create the mesh
  130486. * @param scene defines the hosting scene
  130487. * @returns the tiled ground mesh
  130488. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130489. */
  130490. static CreateTiledGround(name: string, options: {
  130491. xmin: number;
  130492. zmin: number;
  130493. xmax: number;
  130494. zmax: number;
  130495. subdivisions?: {
  130496. w: number;
  130497. h: number;
  130498. };
  130499. precision?: {
  130500. w: number;
  130501. h: number;
  130502. };
  130503. updatable?: boolean;
  130504. }, scene?: Nullable<Scene>): Mesh;
  130505. /**
  130506. * Creates a ground mesh from a height map
  130507. * * The parameter `url` sets the URL of the height map image resource.
  130508. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130509. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130510. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130511. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130512. * * 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.
  130513. * * 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).
  130514. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130516. * @param name defines the name of the mesh
  130517. * @param url defines the url to the height map
  130518. * @param options defines the options used to create the mesh
  130519. * @param scene defines the hosting scene
  130520. * @returns the ground mesh
  130521. * @see https://doc.babylonjs.com/babylon101/height_map
  130522. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130523. */
  130524. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130525. width?: number;
  130526. height?: number;
  130527. subdivisions?: number;
  130528. minHeight?: number;
  130529. maxHeight?: number;
  130530. colorFilter?: Color3;
  130531. alphaFilter?: number;
  130532. updatable?: boolean;
  130533. onReady?: (mesh: GroundMesh) => void;
  130534. }, scene?: Nullable<Scene>): GroundMesh;
  130535. }
  130536. }
  130537. declare module BABYLON {
  130538. /**
  130539. * Class containing static functions to help procedurally build meshes
  130540. */
  130541. export class TorusBuilder {
  130542. /**
  130543. * Creates a torus mesh
  130544. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130545. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130546. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130550. * @param name defines the name of the mesh
  130551. * @param options defines the options used to create the mesh
  130552. * @param scene defines the hosting scene
  130553. * @returns the torus mesh
  130554. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130555. */
  130556. static CreateTorus(name: string, options: {
  130557. diameter?: number;
  130558. thickness?: number;
  130559. tessellation?: number;
  130560. updatable?: boolean;
  130561. sideOrientation?: number;
  130562. frontUVs?: Vector4;
  130563. backUVs?: Vector4;
  130564. }, scene: any): Mesh;
  130565. }
  130566. }
  130567. declare module BABYLON {
  130568. /**
  130569. * Class containing static functions to help procedurally build meshes
  130570. */
  130571. export class CylinderBuilder {
  130572. /**
  130573. * Creates a cylinder or a cone mesh
  130574. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130575. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130576. * * 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.
  130577. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130578. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130579. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130580. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130581. * * 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).
  130582. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130583. * * 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).
  130584. * * 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
  130585. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130586. * * 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
  130587. * * 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.
  130588. * * If `enclose` is false, a ring surface is one element.
  130589. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130590. * * 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
  130591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130594. * @param name defines the name of the mesh
  130595. * @param options defines the options used to create the mesh
  130596. * @param scene defines the hosting scene
  130597. * @returns the cylinder mesh
  130598. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130599. */
  130600. static CreateCylinder(name: string, options: {
  130601. height?: number;
  130602. diameterTop?: number;
  130603. diameterBottom?: number;
  130604. diameter?: number;
  130605. tessellation?: number;
  130606. subdivisions?: number;
  130607. arc?: number;
  130608. faceColors?: Color4[];
  130609. faceUV?: Vector4[];
  130610. updatable?: boolean;
  130611. hasRings?: boolean;
  130612. enclose?: boolean;
  130613. cap?: number;
  130614. sideOrientation?: number;
  130615. frontUVs?: Vector4;
  130616. backUVs?: Vector4;
  130617. }, scene: any): Mesh;
  130618. }
  130619. }
  130620. declare module BABYLON {
  130621. /**
  130622. * States of the webXR experience
  130623. */
  130624. export enum WebXRState {
  130625. /**
  130626. * Transitioning to being in XR mode
  130627. */
  130628. ENTERING_XR = 0,
  130629. /**
  130630. * Transitioning to non XR mode
  130631. */
  130632. EXITING_XR = 1,
  130633. /**
  130634. * In XR mode and presenting
  130635. */
  130636. IN_XR = 2,
  130637. /**
  130638. * Not entered XR mode
  130639. */
  130640. NOT_IN_XR = 3
  130641. }
  130642. /**
  130643. * The state of the XR camera's tracking
  130644. */
  130645. export enum WebXRTrackingState {
  130646. /**
  130647. * No transformation received, device is not being tracked
  130648. */
  130649. NOT_TRACKING = 0,
  130650. /**
  130651. * Tracking lost - using emulated position
  130652. */
  130653. TRACKING_LOST = 1,
  130654. /**
  130655. * Transformation tracking works normally
  130656. */
  130657. TRACKING = 2
  130658. }
  130659. /**
  130660. * Abstraction of the XR render target
  130661. */
  130662. export interface WebXRRenderTarget extends IDisposable {
  130663. /**
  130664. * xrpresent context of the canvas which can be used to display/mirror xr content
  130665. */
  130666. canvasContext: WebGLRenderingContext;
  130667. /**
  130668. * xr layer for the canvas
  130669. */
  130670. xrLayer: Nullable<XRWebGLLayer>;
  130671. /**
  130672. * Initializes the xr layer for the session
  130673. * @param xrSession xr session
  130674. * @returns a promise that will resolve once the XR Layer has been created
  130675. */
  130676. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130677. }
  130678. }
  130679. declare module BABYLON {
  130680. /**
  130681. * COnfiguration object for WebXR output canvas
  130682. */
  130683. export class WebXRManagedOutputCanvasOptions {
  130684. /**
  130685. * An optional canvas in case you wish to create it yourself and provide it here.
  130686. * If not provided, a new canvas will be created
  130687. */
  130688. canvasElement?: HTMLCanvasElement;
  130689. /**
  130690. * Options for this XR Layer output
  130691. */
  130692. canvasOptions?: XRWebGLLayerOptions;
  130693. /**
  130694. * CSS styling for a newly created canvas (if not provided)
  130695. */
  130696. newCanvasCssStyle?: string;
  130697. /**
  130698. * Get the default values of the configuration object
  130699. * @param engine defines the engine to use (can be null)
  130700. * @returns default values of this configuration object
  130701. */
  130702. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130703. }
  130704. /**
  130705. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130706. */
  130707. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130708. private _options;
  130709. private _canvas;
  130710. private _engine;
  130711. private _originalCanvasSize;
  130712. /**
  130713. * Rendering context of the canvas which can be used to display/mirror xr content
  130714. */
  130715. canvasContext: WebGLRenderingContext;
  130716. /**
  130717. * xr layer for the canvas
  130718. */
  130719. xrLayer: Nullable<XRWebGLLayer>;
  130720. /**
  130721. * Obseervers registered here will be triggered when the xr layer was initialized
  130722. */
  130723. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130724. /**
  130725. * Initializes the canvas to be added/removed upon entering/exiting xr
  130726. * @param _xrSessionManager The XR Session manager
  130727. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130728. */
  130729. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130730. /**
  130731. * Disposes of the object
  130732. */
  130733. dispose(): void;
  130734. /**
  130735. * Initializes the xr layer for the session
  130736. * @param xrSession xr session
  130737. * @returns a promise that will resolve once the XR Layer has been created
  130738. */
  130739. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130740. private _addCanvas;
  130741. private _removeCanvas;
  130742. private _setCanvasSize;
  130743. private _setManagedOutputCanvas;
  130744. }
  130745. }
  130746. declare module BABYLON {
  130747. /**
  130748. * Manages an XRSession to work with Babylon's engine
  130749. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130750. */
  130751. export class WebXRSessionManager implements IDisposable {
  130752. /** The scene which the session should be created for */
  130753. scene: Scene;
  130754. private _referenceSpace;
  130755. private _rttProvider;
  130756. private _sessionEnded;
  130757. private _xrNavigator;
  130758. private baseLayer;
  130759. /**
  130760. * The base reference space from which the session started. good if you want to reset your
  130761. * reference space
  130762. */
  130763. baseReferenceSpace: XRReferenceSpace;
  130764. /**
  130765. * Current XR frame
  130766. */
  130767. currentFrame: Nullable<XRFrame>;
  130768. /** WebXR timestamp updated every frame */
  130769. currentTimestamp: number;
  130770. /**
  130771. * Used just in case of a failure to initialize an immersive session.
  130772. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130773. */
  130774. defaultHeightCompensation: number;
  130775. /**
  130776. * Fires every time a new xrFrame arrives which can be used to update the camera
  130777. */
  130778. onXRFrameObservable: Observable<XRFrame>;
  130779. /**
  130780. * Fires when the reference space changed
  130781. */
  130782. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130783. /**
  130784. * Fires when the xr session is ended either by the device or manually done
  130785. */
  130786. onXRSessionEnded: Observable<any>;
  130787. /**
  130788. * Fires when the xr session is ended either by the device or manually done
  130789. */
  130790. onXRSessionInit: Observable<XRSession>;
  130791. /**
  130792. * Underlying xr session
  130793. */
  130794. session: XRSession;
  130795. /**
  130796. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130797. * or get the offset the player is currently at.
  130798. */
  130799. viewerReferenceSpace: XRReferenceSpace;
  130800. /**
  130801. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130802. * @param scene The scene which the session should be created for
  130803. */
  130804. constructor(
  130805. /** The scene which the session should be created for */
  130806. scene: Scene);
  130807. /**
  130808. * The current reference space used in this session. This reference space can constantly change!
  130809. * It is mainly used to offset the camera's position.
  130810. */
  130811. get referenceSpace(): XRReferenceSpace;
  130812. /**
  130813. * Set a new reference space and triggers the observable
  130814. */
  130815. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130816. /**
  130817. * Disposes of the session manager
  130818. */
  130819. dispose(): void;
  130820. /**
  130821. * Stops the xrSession and restores the render loop
  130822. * @returns Promise which resolves after it exits XR
  130823. */
  130824. exitXRAsync(): Promise<void>;
  130825. /**
  130826. * Gets the correct render target texture to be rendered this frame for this eye
  130827. * @param eye the eye for which to get the render target
  130828. * @returns the render target for the specified eye
  130829. */
  130830. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130831. /**
  130832. * Creates a WebXRRenderTarget object for the XR session
  130833. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130834. * @param options optional options to provide when creating a new render target
  130835. * @returns a WebXR render target to which the session can render
  130836. */
  130837. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130838. /**
  130839. * Initializes the manager
  130840. * After initialization enterXR can be called to start an XR session
  130841. * @returns Promise which resolves after it is initialized
  130842. */
  130843. initializeAsync(): Promise<void>;
  130844. /**
  130845. * Initializes an xr session
  130846. * @param xrSessionMode mode to initialize
  130847. * @param xrSessionInit defines optional and required values to pass to the session builder
  130848. * @returns a promise which will resolve once the session has been initialized
  130849. */
  130850. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130851. /**
  130852. * Checks if a session would be supported for the creation options specified
  130853. * @param sessionMode session mode to check if supported eg. immersive-vr
  130854. * @returns A Promise that resolves to true if supported and false if not
  130855. */
  130856. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130857. /**
  130858. * Resets the reference space to the one started the session
  130859. */
  130860. resetReferenceSpace(): void;
  130861. /**
  130862. * Starts rendering to the xr layer
  130863. */
  130864. runXRRenderLoop(): void;
  130865. /**
  130866. * Sets the reference space on the xr session
  130867. * @param referenceSpaceType space to set
  130868. * @returns a promise that will resolve once the reference space has been set
  130869. */
  130870. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130871. /**
  130872. * Updates the render state of the session
  130873. * @param state state to set
  130874. * @returns a promise that resolves once the render state has been updated
  130875. */
  130876. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130877. /**
  130878. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130879. * @param sessionMode defines the session to test
  130880. * @returns a promise with boolean as final value
  130881. */
  130882. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130883. private _createRenderTargetTexture;
  130884. }
  130885. }
  130886. declare module BABYLON {
  130887. /**
  130888. * WebXR Camera which holds the views for the xrSession
  130889. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130890. */
  130891. export class WebXRCamera extends FreeCamera {
  130892. private _xrSessionManager;
  130893. private _firstFrame;
  130894. private _referenceQuaternion;
  130895. private _referencedPosition;
  130896. private _xrInvPositionCache;
  130897. private _xrInvQuaternionCache;
  130898. private _trackingState;
  130899. /**
  130900. * Observable raised before camera teleportation
  130901. */
  130902. onBeforeCameraTeleport: Observable<Vector3>;
  130903. /**
  130904. * Observable raised after camera teleportation
  130905. */
  130906. onAfterCameraTeleport: Observable<Vector3>;
  130907. /**
  130908. * Notifies when the camera's tracking state has changed.
  130909. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  130910. */
  130911. onTrackingStateChanged: Observable<WebXRTrackingState>;
  130912. /**
  130913. * Should position compensation execute on first frame.
  130914. * This is used when copying the position from a native (non XR) camera
  130915. */
  130916. compensateOnFirstFrame: boolean;
  130917. /**
  130918. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130919. * @param name the name of the camera
  130920. * @param scene the scene to add the camera to
  130921. * @param _xrSessionManager a constructed xr session manager
  130922. */
  130923. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130924. /**
  130925. * Get the current XR tracking state of the camera
  130926. */
  130927. get trackingState(): WebXRTrackingState;
  130928. private _setTrackingState;
  130929. /**
  130930. * Return the user's height, unrelated to the current ground.
  130931. * This will be the y position of this camera, when ground level is 0.
  130932. */
  130933. get realWorldHeight(): number;
  130934. /** @hidden */
  130935. _updateForDualEyeDebugging(): void;
  130936. /**
  130937. * Sets this camera's transformation based on a non-vr camera
  130938. * @param otherCamera the non-vr camera to copy the transformation from
  130939. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130940. */
  130941. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130942. /**
  130943. * Gets the current instance class name ("WebXRCamera").
  130944. * @returns the class name
  130945. */
  130946. getClassName(): string;
  130947. private _rotate180;
  130948. private _updateFromXRSession;
  130949. private _updateNumberOfRigCameras;
  130950. private _updateReferenceSpace;
  130951. private _updateReferenceSpaceOffset;
  130952. }
  130953. }
  130954. declare module BABYLON {
  130955. /**
  130956. * Defining the interface required for a (webxr) feature
  130957. */
  130958. export interface IWebXRFeature extends IDisposable {
  130959. /**
  130960. * Is this feature attached
  130961. */
  130962. attached: boolean;
  130963. /**
  130964. * Should auto-attach be disabled?
  130965. */
  130966. disableAutoAttach: boolean;
  130967. /**
  130968. * Attach the feature to the session
  130969. * Will usually be called by the features manager
  130970. *
  130971. * @param force should attachment be forced (even when already attached)
  130972. * @returns true if successful.
  130973. */
  130974. attach(force?: boolean): boolean;
  130975. /**
  130976. * Detach the feature from the session
  130977. * Will usually be called by the features manager
  130978. *
  130979. * @returns true if successful.
  130980. */
  130981. detach(): boolean;
  130982. /**
  130983. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  130984. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  130985. *
  130986. * @returns whether or not the feature is compatible in this environment
  130987. */
  130988. isCompatible(): boolean;
  130989. /**
  130990. * Was this feature disposed;
  130991. */
  130992. isDisposed: boolean;
  130993. /**
  130994. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  130995. */
  130996. xrNativeFeatureName?: string;
  130997. /**
  130998. * A list of (Babylon WebXR) features this feature depends on
  130999. */
  131000. dependsOn?: string[];
  131001. }
  131002. /**
  131003. * A list of the currently available features without referencing them
  131004. */
  131005. export class WebXRFeatureName {
  131006. /**
  131007. * The name of the anchor system feature
  131008. */
  131009. static readonly ANCHOR_SYSTEM: string;
  131010. /**
  131011. * The name of the background remover feature
  131012. */
  131013. static readonly BACKGROUND_REMOVER: string;
  131014. /**
  131015. * The name of the hit test feature
  131016. */
  131017. static readonly HIT_TEST: string;
  131018. /**
  131019. * physics impostors for xr controllers feature
  131020. */
  131021. static readonly PHYSICS_CONTROLLERS: string;
  131022. /**
  131023. * The name of the plane detection feature
  131024. */
  131025. static readonly PLANE_DETECTION: string;
  131026. /**
  131027. * The name of the pointer selection feature
  131028. */
  131029. static readonly POINTER_SELECTION: string;
  131030. /**
  131031. * The name of the teleportation feature
  131032. */
  131033. static readonly TELEPORTATION: string;
  131034. /**
  131035. * The name of the feature points feature.
  131036. */
  131037. static readonly FEATURE_POINTS: string;
  131038. /**
  131039. * The name of the hand tracking feature.
  131040. */
  131041. static readonly HAND_TRACKING: string;
  131042. }
  131043. /**
  131044. * Defining the constructor of a feature. Used to register the modules.
  131045. */
  131046. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131047. /**
  131048. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131049. * It is mainly used in AR sessions.
  131050. *
  131051. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131052. */
  131053. export class WebXRFeaturesManager implements IDisposable {
  131054. private _xrSessionManager;
  131055. private static readonly _AvailableFeatures;
  131056. private _features;
  131057. /**
  131058. * constructs a new features manages.
  131059. *
  131060. * @param _xrSessionManager an instance of WebXRSessionManager
  131061. */
  131062. constructor(_xrSessionManager: WebXRSessionManager);
  131063. /**
  131064. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131065. * Mainly used internally.
  131066. *
  131067. * @param featureName the name of the feature to register
  131068. * @param constructorFunction the function used to construct the module
  131069. * @param version the (babylon) version of the module
  131070. * @param stable is that a stable version of this module
  131071. */
  131072. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131073. /**
  131074. * Returns a constructor of a specific feature.
  131075. *
  131076. * @param featureName the name of the feature to construct
  131077. * @param version the version of the feature to load
  131078. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131079. * @param options optional options provided to the module.
  131080. * @returns a function that, when called, will return a new instance of this feature
  131081. */
  131082. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131083. /**
  131084. * Can be used to return the list of features currently registered
  131085. *
  131086. * @returns an Array of available features
  131087. */
  131088. static GetAvailableFeatures(): string[];
  131089. /**
  131090. * Gets the versions available for a specific feature
  131091. * @param featureName the name of the feature
  131092. * @returns an array with the available versions
  131093. */
  131094. static GetAvailableVersions(featureName: string): string[];
  131095. /**
  131096. * Return the latest unstable version of this feature
  131097. * @param featureName the name of the feature to search
  131098. * @returns the version number. if not found will return -1
  131099. */
  131100. static GetLatestVersionOfFeature(featureName: string): number;
  131101. /**
  131102. * Return the latest stable version of this feature
  131103. * @param featureName the name of the feature to search
  131104. * @returns the version number. if not found will return -1
  131105. */
  131106. static GetStableVersionOfFeature(featureName: string): number;
  131107. /**
  131108. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131109. * Can be used during a session to start a feature
  131110. * @param featureName the name of feature to attach
  131111. */
  131112. attachFeature(featureName: string): void;
  131113. /**
  131114. * Can be used inside a session or when the session ends to detach a specific feature
  131115. * @param featureName the name of the feature to detach
  131116. */
  131117. detachFeature(featureName: string): void;
  131118. /**
  131119. * Used to disable an already-enabled feature
  131120. * The feature will be disposed and will be recreated once enabled.
  131121. * @param featureName the feature to disable
  131122. * @returns true if disable was successful
  131123. */
  131124. disableFeature(featureName: string | {
  131125. Name: string;
  131126. }): boolean;
  131127. /**
  131128. * dispose this features manager
  131129. */
  131130. dispose(): void;
  131131. /**
  131132. * 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.
  131133. * 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.
  131134. *
  131135. * @param featureName the name of the feature to load or the class of the feature
  131136. * @param version optional version to load. if not provided the latest version will be enabled
  131137. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131138. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131139. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131140. * @returns a new constructed feature or throws an error if feature not found.
  131141. */
  131142. enableFeature(featureName: string | {
  131143. Name: string;
  131144. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131145. /**
  131146. * get the implementation of an enabled feature.
  131147. * @param featureName the name of the feature to load
  131148. * @returns the feature class, if found
  131149. */
  131150. getEnabledFeature(featureName: string): IWebXRFeature;
  131151. /**
  131152. * Get the list of enabled features
  131153. * @returns an array of enabled features
  131154. */
  131155. getEnabledFeatures(): string[];
  131156. /**
  131157. * This function will exten the session creation configuration object with enabled features.
  131158. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131159. * according to the defined "required" variable, provided during enableFeature call
  131160. * @param xrSessionInit the xr Session init object to extend
  131161. *
  131162. * @returns an extended XRSessionInit object
  131163. */
  131164. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131165. }
  131166. }
  131167. declare module BABYLON {
  131168. /**
  131169. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131170. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131171. */
  131172. export class WebXRExperienceHelper implements IDisposable {
  131173. private scene;
  131174. private _nonVRCamera;
  131175. private _originalSceneAutoClear;
  131176. private _supported;
  131177. /**
  131178. * Camera used to render xr content
  131179. */
  131180. camera: WebXRCamera;
  131181. /** A features manager for this xr session */
  131182. featuresManager: WebXRFeaturesManager;
  131183. /**
  131184. * Observers registered here will be triggered after the camera's initial transformation is set
  131185. * This can be used to set a different ground level or an extra rotation.
  131186. *
  131187. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131188. * to the position set after this observable is done executing.
  131189. */
  131190. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131191. /**
  131192. * Fires when the state of the experience helper has changed
  131193. */
  131194. onStateChangedObservable: Observable<WebXRState>;
  131195. /** Session manager used to keep track of xr session */
  131196. sessionManager: WebXRSessionManager;
  131197. /**
  131198. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131199. */
  131200. state: WebXRState;
  131201. /**
  131202. * Creates a WebXRExperienceHelper
  131203. * @param scene The scene the helper should be created in
  131204. */
  131205. private constructor();
  131206. /**
  131207. * Creates the experience helper
  131208. * @param scene the scene to attach the experience helper to
  131209. * @returns a promise for the experience helper
  131210. */
  131211. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131212. /**
  131213. * Disposes of the experience helper
  131214. */
  131215. dispose(): void;
  131216. /**
  131217. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131218. * @param sessionMode options for the XR session
  131219. * @param referenceSpaceType frame of reference of the XR session
  131220. * @param renderTarget the output canvas that will be used to enter XR mode
  131221. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131222. * @returns promise that resolves after xr mode has entered
  131223. */
  131224. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131225. /**
  131226. * Exits XR mode and returns the scene to its original state
  131227. * @returns promise that resolves after xr mode has exited
  131228. */
  131229. exitXRAsync(): Promise<void>;
  131230. private _nonXRToXRCamera;
  131231. private _setState;
  131232. }
  131233. }
  131234. declare module BABYLON {
  131235. /**
  131236. * X-Y values for axes in WebXR
  131237. */
  131238. export interface IWebXRMotionControllerAxesValue {
  131239. /**
  131240. * The value of the x axis
  131241. */
  131242. x: number;
  131243. /**
  131244. * The value of the y-axis
  131245. */
  131246. y: number;
  131247. }
  131248. /**
  131249. * changed / previous values for the values of this component
  131250. */
  131251. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131252. /**
  131253. * current (this frame) value
  131254. */
  131255. current: T;
  131256. /**
  131257. * previous (last change) value
  131258. */
  131259. previous: T;
  131260. }
  131261. /**
  131262. * Represents changes in the component between current frame and last values recorded
  131263. */
  131264. export interface IWebXRMotionControllerComponentChanges {
  131265. /**
  131266. * will be populated with previous and current values if axes changed
  131267. */
  131268. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131269. /**
  131270. * will be populated with previous and current values if pressed changed
  131271. */
  131272. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131273. /**
  131274. * will be populated with previous and current values if touched changed
  131275. */
  131276. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131277. /**
  131278. * will be populated with previous and current values if value changed
  131279. */
  131280. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131281. }
  131282. /**
  131283. * This class represents a single component (for example button or thumbstick) of a motion controller
  131284. */
  131285. export class WebXRControllerComponent implements IDisposable {
  131286. /**
  131287. * the id of this component
  131288. */
  131289. id: string;
  131290. /**
  131291. * the type of the component
  131292. */
  131293. type: MotionControllerComponentType;
  131294. private _buttonIndex;
  131295. private _axesIndices;
  131296. private _axes;
  131297. private _changes;
  131298. private _currentValue;
  131299. private _hasChanges;
  131300. private _pressed;
  131301. private _touched;
  131302. /**
  131303. * button component type
  131304. */
  131305. static BUTTON_TYPE: MotionControllerComponentType;
  131306. /**
  131307. * squeeze component type
  131308. */
  131309. static SQUEEZE_TYPE: MotionControllerComponentType;
  131310. /**
  131311. * Thumbstick component type
  131312. */
  131313. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131314. /**
  131315. * Touchpad component type
  131316. */
  131317. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131318. /**
  131319. * trigger component type
  131320. */
  131321. static TRIGGER_TYPE: MotionControllerComponentType;
  131322. /**
  131323. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131324. * the axes data changes
  131325. */
  131326. onAxisValueChangedObservable: Observable<{
  131327. x: number;
  131328. y: number;
  131329. }>;
  131330. /**
  131331. * Observers registered here will be triggered when the state of a button changes
  131332. * State change is either pressed / touched / value
  131333. */
  131334. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131335. /**
  131336. * Creates a new component for a motion controller.
  131337. * It is created by the motion controller itself
  131338. *
  131339. * @param id the id of this component
  131340. * @param type the type of the component
  131341. * @param _buttonIndex index in the buttons array of the gamepad
  131342. * @param _axesIndices indices of the values in the axes array of the gamepad
  131343. */
  131344. constructor(
  131345. /**
  131346. * the id of this component
  131347. */
  131348. id: string,
  131349. /**
  131350. * the type of the component
  131351. */
  131352. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131353. /**
  131354. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131355. */
  131356. get axes(): IWebXRMotionControllerAxesValue;
  131357. /**
  131358. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131359. */
  131360. get changes(): IWebXRMotionControllerComponentChanges;
  131361. /**
  131362. * Return whether or not the component changed the last frame
  131363. */
  131364. get hasChanges(): boolean;
  131365. /**
  131366. * is the button currently pressed
  131367. */
  131368. get pressed(): boolean;
  131369. /**
  131370. * is the button currently touched
  131371. */
  131372. get touched(): boolean;
  131373. /**
  131374. * Get the current value of this component
  131375. */
  131376. get value(): number;
  131377. /**
  131378. * Dispose this component
  131379. */
  131380. dispose(): void;
  131381. /**
  131382. * Are there axes correlating to this component
  131383. * @return true is axes data is available
  131384. */
  131385. isAxes(): boolean;
  131386. /**
  131387. * Is this component a button (hence - pressable)
  131388. * @returns true if can be pressed
  131389. */
  131390. isButton(): boolean;
  131391. /**
  131392. * update this component using the gamepad object it is in. Called on every frame
  131393. * @param nativeController the native gamepad controller object
  131394. */
  131395. update(nativeController: IMinimalMotionControllerObject): void;
  131396. }
  131397. }
  131398. declare module BABYLON {
  131399. /**
  131400. * Interface used to represent data loading progression
  131401. */
  131402. export interface ISceneLoaderProgressEvent {
  131403. /**
  131404. * Defines if data length to load can be evaluated
  131405. */
  131406. readonly lengthComputable: boolean;
  131407. /**
  131408. * Defines the loaded data length
  131409. */
  131410. readonly loaded: number;
  131411. /**
  131412. * Defines the data length to load
  131413. */
  131414. readonly total: number;
  131415. }
  131416. /**
  131417. * Interface used by SceneLoader plugins to define supported file extensions
  131418. */
  131419. export interface ISceneLoaderPluginExtensions {
  131420. /**
  131421. * Defines the list of supported extensions
  131422. */
  131423. [extension: string]: {
  131424. isBinary: boolean;
  131425. };
  131426. }
  131427. /**
  131428. * Interface used by SceneLoader plugin factory
  131429. */
  131430. export interface ISceneLoaderPluginFactory {
  131431. /**
  131432. * Defines the name of the factory
  131433. */
  131434. name: string;
  131435. /**
  131436. * Function called to create a new plugin
  131437. * @return the new plugin
  131438. */
  131439. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131440. /**
  131441. * The callback that returns true if the data can be directly loaded.
  131442. * @param data string containing the file data
  131443. * @returns if the data can be loaded directly
  131444. */
  131445. canDirectLoad?(data: string): boolean;
  131446. }
  131447. /**
  131448. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131449. */
  131450. export interface ISceneLoaderPluginBase {
  131451. /**
  131452. * The friendly name of this plugin.
  131453. */
  131454. name: string;
  131455. /**
  131456. * The file extensions supported by this plugin.
  131457. */
  131458. extensions: string | ISceneLoaderPluginExtensions;
  131459. /**
  131460. * The callback called when loading from a url.
  131461. * @param scene scene loading this url
  131462. * @param url url to load
  131463. * @param onSuccess callback called when the file successfully loads
  131464. * @param onProgress callback called while file is loading (if the server supports this mode)
  131465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131466. * @param onError callback called when the file fails to load
  131467. * @returns a file request object
  131468. */
  131469. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131470. /**
  131471. * The callback called when loading from a file object.
  131472. * @param scene scene loading this file
  131473. * @param file defines the file to load
  131474. * @param onSuccess defines the callback to call when data is loaded
  131475. * @param onProgress defines the callback to call during loading process
  131476. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131477. * @param onError defines the callback to call when an error occurs
  131478. * @returns a file request object
  131479. */
  131480. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131481. /**
  131482. * The callback that returns true if the data can be directly loaded.
  131483. * @param data string containing the file data
  131484. * @returns if the data can be loaded directly
  131485. */
  131486. canDirectLoad?(data: string): boolean;
  131487. /**
  131488. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131489. * @param scene scene loading this data
  131490. * @param data string containing the data
  131491. * @returns data to pass to the plugin
  131492. */
  131493. directLoad?(scene: Scene, data: string): any;
  131494. /**
  131495. * The callback that allows custom handling of the root url based on the response url.
  131496. * @param rootUrl the original root url
  131497. * @param responseURL the response url if available
  131498. * @returns the new root url
  131499. */
  131500. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131501. }
  131502. /**
  131503. * Interface used to define a SceneLoader plugin
  131504. */
  131505. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131506. /**
  131507. * Import meshes into a scene.
  131508. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131509. * @param scene The scene to import into
  131510. * @param data The data to import
  131511. * @param rootUrl The root url for scene and resources
  131512. * @param meshes The meshes array to import into
  131513. * @param particleSystems The particle systems array to import into
  131514. * @param skeletons The skeletons array to import into
  131515. * @param onError The callback when import fails
  131516. * @returns True if successful or false otherwise
  131517. */
  131518. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131519. /**
  131520. * Load into a scene.
  131521. * @param scene The scene to load into
  131522. * @param data The data to import
  131523. * @param rootUrl The root url for scene and resources
  131524. * @param onError The callback when import fails
  131525. * @returns True if successful or false otherwise
  131526. */
  131527. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131528. /**
  131529. * Load into an asset container.
  131530. * @param scene The scene to load into
  131531. * @param data The data to import
  131532. * @param rootUrl The root url for scene and resources
  131533. * @param onError The callback when import fails
  131534. * @returns The loaded asset container
  131535. */
  131536. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131537. }
  131538. /**
  131539. * Interface used to define an async SceneLoader plugin
  131540. */
  131541. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131542. /**
  131543. * Import meshes into a scene.
  131544. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131545. * @param scene The scene to import into
  131546. * @param data The data to import
  131547. * @param rootUrl The root url for scene and resources
  131548. * @param onProgress The callback when the load progresses
  131549. * @param fileName Defines the name of the file to load
  131550. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131551. */
  131552. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131553. meshes: AbstractMesh[];
  131554. particleSystems: IParticleSystem[];
  131555. skeletons: Skeleton[];
  131556. animationGroups: AnimationGroup[];
  131557. }>;
  131558. /**
  131559. * Load into a scene.
  131560. * @param scene The scene to load into
  131561. * @param data The data to import
  131562. * @param rootUrl The root url for scene and resources
  131563. * @param onProgress The callback when the load progresses
  131564. * @param fileName Defines the name of the file to load
  131565. * @returns Nothing
  131566. */
  131567. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131568. /**
  131569. * Load into an asset container.
  131570. * @param scene The scene to load into
  131571. * @param data The data to import
  131572. * @param rootUrl The root url for scene and resources
  131573. * @param onProgress The callback when the load progresses
  131574. * @param fileName Defines the name of the file to load
  131575. * @returns The loaded asset container
  131576. */
  131577. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131578. }
  131579. /**
  131580. * Mode that determines how to handle old animation groups before loading new ones.
  131581. */
  131582. export enum SceneLoaderAnimationGroupLoadingMode {
  131583. /**
  131584. * Reset all old animations to initial state then dispose them.
  131585. */
  131586. Clean = 0,
  131587. /**
  131588. * Stop all old animations.
  131589. */
  131590. Stop = 1,
  131591. /**
  131592. * Restart old animations from first frame.
  131593. */
  131594. Sync = 2,
  131595. /**
  131596. * Old animations remains untouched.
  131597. */
  131598. NoSync = 3
  131599. }
  131600. /**
  131601. * Defines a plugin registered by the SceneLoader
  131602. */
  131603. interface IRegisteredPlugin {
  131604. /**
  131605. * Defines the plugin to use
  131606. */
  131607. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131608. /**
  131609. * Defines if the plugin supports binary data
  131610. */
  131611. isBinary: boolean;
  131612. }
  131613. /**
  131614. * Class used to load scene from various file formats using registered plugins
  131615. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131616. */
  131617. export class SceneLoader {
  131618. /**
  131619. * No logging while loading
  131620. */
  131621. static readonly NO_LOGGING: number;
  131622. /**
  131623. * Minimal logging while loading
  131624. */
  131625. static readonly MINIMAL_LOGGING: number;
  131626. /**
  131627. * Summary logging while loading
  131628. */
  131629. static readonly SUMMARY_LOGGING: number;
  131630. /**
  131631. * Detailled logging while loading
  131632. */
  131633. static readonly DETAILED_LOGGING: number;
  131634. /**
  131635. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131636. */
  131637. static get ForceFullSceneLoadingForIncremental(): boolean;
  131638. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131639. /**
  131640. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131641. */
  131642. static get ShowLoadingScreen(): boolean;
  131643. static set ShowLoadingScreen(value: boolean);
  131644. /**
  131645. * Defines the current logging level (while loading the scene)
  131646. * @ignorenaming
  131647. */
  131648. static get loggingLevel(): number;
  131649. static set loggingLevel(value: number);
  131650. /**
  131651. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131652. */
  131653. static get CleanBoneMatrixWeights(): boolean;
  131654. static set CleanBoneMatrixWeights(value: boolean);
  131655. /**
  131656. * Event raised when a plugin is used to load a scene
  131657. */
  131658. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131659. private static _registeredPlugins;
  131660. private static _showingLoadingScreen;
  131661. /**
  131662. * Gets the default plugin (used to load Babylon files)
  131663. * @returns the .babylon plugin
  131664. */
  131665. static GetDefaultPlugin(): IRegisteredPlugin;
  131666. private static _GetPluginForExtension;
  131667. private static _GetPluginForDirectLoad;
  131668. private static _GetPluginForFilename;
  131669. private static _GetDirectLoad;
  131670. private static _LoadData;
  131671. private static _GetFileInfo;
  131672. /**
  131673. * Gets a plugin that can load the given extension
  131674. * @param extension defines the extension to load
  131675. * @returns a plugin or null if none works
  131676. */
  131677. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131678. /**
  131679. * Gets a boolean indicating that the given extension can be loaded
  131680. * @param extension defines the extension to load
  131681. * @returns true if the extension is supported
  131682. */
  131683. static IsPluginForExtensionAvailable(extension: string): boolean;
  131684. /**
  131685. * Adds a new plugin to the list of registered plugins
  131686. * @param plugin defines the plugin to add
  131687. */
  131688. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131689. /**
  131690. * Import meshes into a scene
  131691. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131692. * @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)
  131693. * @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)
  131694. * @param scene the instance of BABYLON.Scene to append to
  131695. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131696. * @param onProgress a callback with a progress event for each file being loaded
  131697. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131698. * @param pluginExtension the extension used to determine the plugin
  131699. * @returns The loaded plugin
  131700. */
  131701. 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>;
  131702. /**
  131703. * Import meshes into a scene
  131704. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131705. * @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)
  131706. * @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)
  131707. * @param scene the instance of BABYLON.Scene to append to
  131708. * @param onProgress a callback with a progress event for each file being loaded
  131709. * @param pluginExtension the extension used to determine the plugin
  131710. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131711. */
  131712. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131713. meshes: AbstractMesh[];
  131714. particleSystems: IParticleSystem[];
  131715. skeletons: Skeleton[];
  131716. animationGroups: AnimationGroup[];
  131717. }>;
  131718. /**
  131719. * Load a scene
  131720. * @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)
  131721. * @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)
  131722. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131723. * @param onSuccess a callback with the scene when import succeeds
  131724. * @param onProgress a callback with a progress event for each file being loaded
  131725. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131726. * @param pluginExtension the extension used to determine the plugin
  131727. * @returns The loaded plugin
  131728. */
  131729. 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>;
  131730. /**
  131731. * Load a scene
  131732. * @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)
  131733. * @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)
  131734. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131735. * @param onProgress a callback with a progress event for each file being loaded
  131736. * @param pluginExtension the extension used to determine the plugin
  131737. * @returns The loaded scene
  131738. */
  131739. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131740. /**
  131741. * Append a scene
  131742. * @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)
  131743. * @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)
  131744. * @param scene is the instance of BABYLON.Scene to append to
  131745. * @param onSuccess a callback with the scene when import succeeds
  131746. * @param onProgress a callback with a progress event for each file being loaded
  131747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131748. * @param pluginExtension the extension used to determine the plugin
  131749. * @returns The loaded plugin
  131750. */
  131751. 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>;
  131752. /**
  131753. * Append a scene
  131754. * @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)
  131755. * @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)
  131756. * @param scene is the instance of BABYLON.Scene to append to
  131757. * @param onProgress a callback with a progress event for each file being loaded
  131758. * @param pluginExtension the extension used to determine the plugin
  131759. * @returns The given scene
  131760. */
  131761. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131762. /**
  131763. * Load a scene into an asset container
  131764. * @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)
  131765. * @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)
  131766. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131767. * @param onSuccess a callback with the scene when import succeeds
  131768. * @param onProgress a callback with a progress event for each file being loaded
  131769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131770. * @param pluginExtension the extension used to determine the plugin
  131771. * @returns The loaded plugin
  131772. */
  131773. 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>;
  131774. /**
  131775. * Load a scene into an asset container
  131776. * @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)
  131777. * @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)
  131778. * @param scene is the instance of Scene to append to
  131779. * @param onProgress a callback with a progress event for each file being loaded
  131780. * @param pluginExtension the extension used to determine the plugin
  131781. * @returns The loaded asset container
  131782. */
  131783. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131784. /**
  131785. * Import animations from a file into a scene
  131786. * @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)
  131787. * @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)
  131788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131789. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131790. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131791. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131792. * @param onSuccess a callback with the scene when import succeeds
  131793. * @param onProgress a callback with a progress event for each file being loaded
  131794. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131795. * @param pluginExtension the extension used to determine the plugin
  131796. */
  131797. 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;
  131798. /**
  131799. * Import animations from a file into a scene
  131800. * @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)
  131801. * @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)
  131802. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131803. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131804. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131805. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131806. * @param onSuccess a callback with the scene when import succeeds
  131807. * @param onProgress a callback with a progress event for each file being loaded
  131808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131809. * @param pluginExtension the extension used to determine the plugin
  131810. * @returns the updated scene with imported animations
  131811. */
  131812. 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>;
  131813. }
  131814. }
  131815. declare module BABYLON {
  131816. /**
  131817. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131818. */
  131819. export type MotionControllerHandedness = "none" | "left" | "right";
  131820. /**
  131821. * The type of components available in motion controllers.
  131822. * This is not the name of the component.
  131823. */
  131824. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131825. /**
  131826. * The state of a controller component
  131827. */
  131828. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131829. /**
  131830. * The schema of motion controller layout.
  131831. * No object will be initialized using this interface
  131832. * This is used just to define the profile.
  131833. */
  131834. export interface IMotionControllerLayout {
  131835. /**
  131836. * Path to load the assets. Usually relative to the base path
  131837. */
  131838. assetPath: string;
  131839. /**
  131840. * Available components (unsorted)
  131841. */
  131842. components: {
  131843. /**
  131844. * A map of component Ids
  131845. */
  131846. [componentId: string]: {
  131847. /**
  131848. * The type of input the component outputs
  131849. */
  131850. type: MotionControllerComponentType;
  131851. /**
  131852. * The indices of this component in the gamepad object
  131853. */
  131854. gamepadIndices: {
  131855. /**
  131856. * Index of button
  131857. */
  131858. button?: number;
  131859. /**
  131860. * If available, index of x-axis
  131861. */
  131862. xAxis?: number;
  131863. /**
  131864. * If available, index of y-axis
  131865. */
  131866. yAxis?: number;
  131867. };
  131868. /**
  131869. * The mesh's root node name
  131870. */
  131871. rootNodeName: string;
  131872. /**
  131873. * Animation definitions for this model
  131874. */
  131875. visualResponses: {
  131876. [stateKey: string]: {
  131877. /**
  131878. * What property will be animated
  131879. */
  131880. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131881. /**
  131882. * What states influence this visual response
  131883. */
  131884. states: MotionControllerComponentStateType[];
  131885. /**
  131886. * Type of animation - movement or visibility
  131887. */
  131888. valueNodeProperty: "transform" | "visibility";
  131889. /**
  131890. * Base node name to move. Its position will be calculated according to the min and max nodes
  131891. */
  131892. valueNodeName?: string;
  131893. /**
  131894. * Minimum movement node
  131895. */
  131896. minNodeName?: string;
  131897. /**
  131898. * Max movement node
  131899. */
  131900. maxNodeName?: string;
  131901. };
  131902. };
  131903. /**
  131904. * If touch enabled, what is the name of node to display user feedback
  131905. */
  131906. touchPointNodeName?: string;
  131907. };
  131908. };
  131909. /**
  131910. * Is it xr standard mapping or not
  131911. */
  131912. gamepadMapping: "" | "xr-standard";
  131913. /**
  131914. * Base root node of this entire model
  131915. */
  131916. rootNodeName: string;
  131917. /**
  131918. * Defines the main button component id
  131919. */
  131920. selectComponentId: string;
  131921. }
  131922. /**
  131923. * A definition for the layout map in the input profile
  131924. */
  131925. export interface IMotionControllerLayoutMap {
  131926. /**
  131927. * Layouts with handedness type as a key
  131928. */
  131929. [handedness: string]: IMotionControllerLayout;
  131930. }
  131931. /**
  131932. * The XR Input profile schema
  131933. * Profiles can be found here:
  131934. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131935. */
  131936. export interface IMotionControllerProfile {
  131937. /**
  131938. * fallback profiles for this profileId
  131939. */
  131940. fallbackProfileIds: string[];
  131941. /**
  131942. * The layout map, with handedness as key
  131943. */
  131944. layouts: IMotionControllerLayoutMap;
  131945. /**
  131946. * The id of this profile
  131947. * correlates to the profile(s) in the xrInput.profiles array
  131948. */
  131949. profileId: string;
  131950. }
  131951. /**
  131952. * A helper-interface for the 3 meshes needed for controller button animation
  131953. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131954. */
  131955. export interface IMotionControllerButtonMeshMap {
  131956. /**
  131957. * the mesh that defines the pressed value mesh position.
  131958. * This is used to find the max-position of this button
  131959. */
  131960. pressedMesh: AbstractMesh;
  131961. /**
  131962. * the mesh that defines the unpressed value mesh position.
  131963. * This is used to find the min (or initial) position of this button
  131964. */
  131965. unpressedMesh: AbstractMesh;
  131966. /**
  131967. * The mesh that will be changed when value changes
  131968. */
  131969. valueMesh: AbstractMesh;
  131970. }
  131971. /**
  131972. * A helper-interface for the 3 meshes needed for controller axis animation.
  131973. * This will be expanded when touchpad animations are fully supported
  131974. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131975. */
  131976. export interface IMotionControllerMeshMap {
  131977. /**
  131978. * the mesh that defines the maximum value mesh position.
  131979. */
  131980. maxMesh?: AbstractMesh;
  131981. /**
  131982. * the mesh that defines the minimum value mesh position.
  131983. */
  131984. minMesh?: AbstractMesh;
  131985. /**
  131986. * The mesh that will be changed when axis value changes
  131987. */
  131988. valueMesh?: AbstractMesh;
  131989. }
  131990. /**
  131991. * The elements needed for change-detection of the gamepad objects in motion controllers
  131992. */
  131993. export interface IMinimalMotionControllerObject {
  131994. /**
  131995. * Available axes of this controller
  131996. */
  131997. axes: number[];
  131998. /**
  131999. * An array of available buttons
  132000. */
  132001. buttons: Array<{
  132002. /**
  132003. * Value of the button/trigger
  132004. */
  132005. value: number;
  132006. /**
  132007. * If the button/trigger is currently touched
  132008. */
  132009. touched: boolean;
  132010. /**
  132011. * If the button/trigger is currently pressed
  132012. */
  132013. pressed: boolean;
  132014. }>;
  132015. /**
  132016. * EXPERIMENTAL haptic support.
  132017. */
  132018. hapticActuators?: Array<{
  132019. pulse: (value: number, duration: number) => Promise<boolean>;
  132020. }>;
  132021. }
  132022. /**
  132023. * An Abstract Motion controller
  132024. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132025. * Each component has an observable to check for changes in value and state
  132026. */
  132027. export abstract class WebXRAbstractMotionController implements IDisposable {
  132028. protected scene: Scene;
  132029. protected layout: IMotionControllerLayout;
  132030. /**
  132031. * The gamepad object correlating to this controller
  132032. */
  132033. gamepadObject: IMinimalMotionControllerObject;
  132034. /**
  132035. * handedness (left/right/none) of this controller
  132036. */
  132037. handedness: MotionControllerHandedness;
  132038. private _initComponent;
  132039. private _modelReady;
  132040. /**
  132041. * A map of components (WebXRControllerComponent) in this motion controller
  132042. * Components have a ComponentType and can also have both button and axis definitions
  132043. */
  132044. readonly components: {
  132045. [id: string]: WebXRControllerComponent;
  132046. };
  132047. /**
  132048. * Disable the model's animation. Can be set at any time.
  132049. */
  132050. disableAnimation: boolean;
  132051. /**
  132052. * Observers registered here will be triggered when the model of this controller is done loading
  132053. */
  132054. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132055. /**
  132056. * The profile id of this motion controller
  132057. */
  132058. abstract profileId: string;
  132059. /**
  132060. * The root mesh of the model. It is null if the model was not yet initialized
  132061. */
  132062. rootMesh: Nullable<AbstractMesh>;
  132063. /**
  132064. * constructs a new abstract motion controller
  132065. * @param scene the scene to which the model of the controller will be added
  132066. * @param layout The profile layout to load
  132067. * @param gamepadObject The gamepad object correlating to this controller
  132068. * @param handedness handedness (left/right/none) of this controller
  132069. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132070. */
  132071. constructor(scene: Scene, layout: IMotionControllerLayout,
  132072. /**
  132073. * The gamepad object correlating to this controller
  132074. */
  132075. gamepadObject: IMinimalMotionControllerObject,
  132076. /**
  132077. * handedness (left/right/none) of this controller
  132078. */
  132079. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132080. /**
  132081. * Dispose this controller, the model mesh and all its components
  132082. */
  132083. dispose(): void;
  132084. /**
  132085. * Returns all components of specific type
  132086. * @param type the type to search for
  132087. * @return an array of components with this type
  132088. */
  132089. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132090. /**
  132091. * get a component based an its component id as defined in layout.components
  132092. * @param id the id of the component
  132093. * @returns the component correlates to the id or undefined if not found
  132094. */
  132095. getComponent(id: string): WebXRControllerComponent;
  132096. /**
  132097. * Get the list of components available in this motion controller
  132098. * @returns an array of strings correlating to available components
  132099. */
  132100. getComponentIds(): string[];
  132101. /**
  132102. * Get the first component of specific type
  132103. * @param type type of component to find
  132104. * @return a controller component or null if not found
  132105. */
  132106. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132107. /**
  132108. * Get the main (Select) component of this controller as defined in the layout
  132109. * @returns the main component of this controller
  132110. */
  132111. getMainComponent(): WebXRControllerComponent;
  132112. /**
  132113. * Loads the model correlating to this controller
  132114. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132115. * @returns A promise fulfilled with the result of the model loading
  132116. */
  132117. loadModel(): Promise<boolean>;
  132118. /**
  132119. * Update this model using the current XRFrame
  132120. * @param xrFrame the current xr frame to use and update the model
  132121. */
  132122. updateFromXRFrame(xrFrame: XRFrame): void;
  132123. /**
  132124. * Backwards compatibility due to a deeply-integrated typo
  132125. */
  132126. get handness(): XREye;
  132127. /**
  132128. * Pulse (vibrate) this controller
  132129. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132130. * Consecutive calls to this function will cancel the last pulse call
  132131. *
  132132. * @param value the strength of the pulse in 0.0...1.0 range
  132133. * @param duration Duration of the pulse in milliseconds
  132134. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132135. * @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
  132136. */
  132137. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132138. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132139. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132140. /**
  132141. * Moves the axis on the controller mesh based on its current state
  132142. * @param axis the index of the axis
  132143. * @param axisValue the value of the axis which determines the meshes new position
  132144. * @hidden
  132145. */
  132146. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132147. /**
  132148. * Update the model itself with the current frame data
  132149. * @param xrFrame the frame to use for updating the model mesh
  132150. */
  132151. protected updateModel(xrFrame: XRFrame): void;
  132152. /**
  132153. * Get the filename and path for this controller's model
  132154. * @returns a map of filename and path
  132155. */
  132156. protected abstract _getFilenameAndPath(): {
  132157. filename: string;
  132158. path: string;
  132159. };
  132160. /**
  132161. * This function is called before the mesh is loaded. It checks for loading constraints.
  132162. * For example, this function can check if the GLB loader is available
  132163. * If this function returns false, the generic controller will be loaded instead
  132164. * @returns Is the client ready to load the mesh
  132165. */
  132166. protected abstract _getModelLoadingConstraints(): boolean;
  132167. /**
  132168. * This function will be called after the model was successfully loaded and can be used
  132169. * for mesh transformations before it is available for the user
  132170. * @param meshes the loaded meshes
  132171. */
  132172. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132173. /**
  132174. * Set the root mesh for this controller. Important for the WebXR controller class
  132175. * @param meshes the loaded meshes
  132176. */
  132177. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132178. /**
  132179. * A function executed each frame that updates the mesh (if needed)
  132180. * @param xrFrame the current xrFrame
  132181. */
  132182. protected abstract _updateModel(xrFrame: XRFrame): void;
  132183. private _getGenericFilenameAndPath;
  132184. private _getGenericParentMesh;
  132185. }
  132186. }
  132187. declare module BABYLON {
  132188. /**
  132189. * A generic trigger-only motion controller for WebXR
  132190. */
  132191. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132192. /**
  132193. * Static version of the profile id of this controller
  132194. */
  132195. static ProfileId: string;
  132196. profileId: string;
  132197. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132198. protected _getFilenameAndPath(): {
  132199. filename: string;
  132200. path: string;
  132201. };
  132202. protected _getModelLoadingConstraints(): boolean;
  132203. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132204. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132205. protected _updateModel(): void;
  132206. }
  132207. }
  132208. declare module BABYLON {
  132209. /**
  132210. * Class containing static functions to help procedurally build meshes
  132211. */
  132212. export class SphereBuilder {
  132213. /**
  132214. * Creates a sphere mesh
  132215. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132216. * * 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`)
  132217. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132218. * * 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
  132219. * * 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)
  132220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132223. * @param name defines the name of the mesh
  132224. * @param options defines the options used to create the mesh
  132225. * @param scene defines the hosting scene
  132226. * @returns the sphere mesh
  132227. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132228. */
  132229. static CreateSphere(name: string, options: {
  132230. segments?: number;
  132231. diameter?: number;
  132232. diameterX?: number;
  132233. diameterY?: number;
  132234. diameterZ?: number;
  132235. arc?: number;
  132236. slice?: number;
  132237. sideOrientation?: number;
  132238. frontUVs?: Vector4;
  132239. backUVs?: Vector4;
  132240. updatable?: boolean;
  132241. }, scene?: Nullable<Scene>): Mesh;
  132242. }
  132243. }
  132244. declare module BABYLON {
  132245. /**
  132246. * A profiled motion controller has its profile loaded from an online repository.
  132247. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132248. */
  132249. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132250. private _repositoryUrl;
  132251. private _buttonMeshMapping;
  132252. private _touchDots;
  132253. /**
  132254. * The profile ID of this controller. Will be populated when the controller initializes.
  132255. */
  132256. profileId: string;
  132257. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132258. dispose(): void;
  132259. protected _getFilenameAndPath(): {
  132260. filename: string;
  132261. path: string;
  132262. };
  132263. protected _getModelLoadingConstraints(): boolean;
  132264. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132265. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132266. protected _updateModel(_xrFrame: XRFrame): void;
  132267. }
  132268. }
  132269. declare module BABYLON {
  132270. /**
  132271. * A construction function type to create a new controller based on an xrInput object
  132272. */
  132273. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132274. /**
  132275. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132276. *
  132277. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132278. * it should be replaced with auto-loaded controllers.
  132279. *
  132280. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132281. */
  132282. export class WebXRMotionControllerManager {
  132283. private static _AvailableControllers;
  132284. private static _Fallbacks;
  132285. private static _ProfileLoadingPromises;
  132286. private static _ProfilesList;
  132287. /**
  132288. * The base URL of the online controller repository. Can be changed at any time.
  132289. */
  132290. static BaseRepositoryUrl: string;
  132291. /**
  132292. * Which repository gets priority - local or online
  132293. */
  132294. static PrioritizeOnlineRepository: boolean;
  132295. /**
  132296. * Use the online repository, or use only locally-defined controllers
  132297. */
  132298. static UseOnlineRepository: boolean;
  132299. /**
  132300. * Clear the cache used for profile loading and reload when requested again
  132301. */
  132302. static ClearProfilesCache(): void;
  132303. /**
  132304. * Register the default fallbacks.
  132305. * This function is called automatically when this file is imported.
  132306. */
  132307. static DefaultFallbacks(): void;
  132308. /**
  132309. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132310. * @param profileId the profile to which a fallback needs to be found
  132311. * @return an array with corresponding fallback profiles
  132312. */
  132313. static FindFallbackWithProfileId(profileId: string): string[];
  132314. /**
  132315. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132316. * The order of search:
  132317. *
  132318. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132319. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132320. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132321. * 4) return the generic trigger controller if none were found
  132322. *
  132323. * @param xrInput the xrInput to which a new controller is initialized
  132324. * @param scene the scene to which the model will be added
  132325. * @param forceProfile force a certain profile for this controller
  132326. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132327. */
  132328. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132329. /**
  132330. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132331. *
  132332. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132333. *
  132334. * @param type the profile type to register
  132335. * @param constructFunction the function to be called when loading this profile
  132336. */
  132337. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132338. /**
  132339. * Register a fallback to a specific profile.
  132340. * @param profileId the profileId that will receive the fallbacks
  132341. * @param fallbacks A list of fallback profiles
  132342. */
  132343. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132344. /**
  132345. * Will update the list of profiles available in the repository
  132346. * @return a promise that resolves to a map of profiles available online
  132347. */
  132348. static UpdateProfilesList(): Promise<{
  132349. [profile: string]: string;
  132350. }>;
  132351. private static _LoadProfileFromRepository;
  132352. private static _LoadProfilesFromAvailableControllers;
  132353. }
  132354. }
  132355. declare module BABYLON {
  132356. /**
  132357. * Configuration options for the WebXR controller creation
  132358. */
  132359. export interface IWebXRControllerOptions {
  132360. /**
  132361. * Should the controller mesh be animated when a user interacts with it
  132362. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132363. */
  132364. disableMotionControllerAnimation?: boolean;
  132365. /**
  132366. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132367. */
  132368. doNotLoadControllerMesh?: boolean;
  132369. /**
  132370. * Force a specific controller type for this controller.
  132371. * This can be used when creating your own profile or when testing different controllers
  132372. */
  132373. forceControllerProfile?: string;
  132374. /**
  132375. * Defines a rendering group ID for meshes that will be loaded.
  132376. * This is for the default controllers only.
  132377. */
  132378. renderingGroupId?: number;
  132379. }
  132380. /**
  132381. * Represents an XR controller
  132382. */
  132383. export class WebXRInputSource {
  132384. private _scene;
  132385. /** The underlying input source for the controller */
  132386. inputSource: XRInputSource;
  132387. private _options;
  132388. private _tmpVector;
  132389. private _uniqueId;
  132390. private _disposed;
  132391. /**
  132392. * 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
  132393. */
  132394. grip?: AbstractMesh;
  132395. /**
  132396. * If available, this is the gamepad object related to this controller.
  132397. * Using this object it is possible to get click events and trackpad changes of the
  132398. * webxr controller that is currently being used.
  132399. */
  132400. motionController?: WebXRAbstractMotionController;
  132401. /**
  132402. * Event that fires when the controller is removed/disposed.
  132403. * The object provided as event data is this controller, after associated assets were disposed.
  132404. * uniqueId is still available.
  132405. */
  132406. onDisposeObservable: Observable<WebXRInputSource>;
  132407. /**
  132408. * Will be triggered when the mesh associated with the motion controller is done loading.
  132409. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132410. * A shortened version of controller -> motion controller -> on mesh loaded.
  132411. */
  132412. onMeshLoadedObservable: Observable<AbstractMesh>;
  132413. /**
  132414. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132415. */
  132416. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132417. /**
  132418. * Pointer which can be used to select objects or attach a visible laser to
  132419. */
  132420. pointer: AbstractMesh;
  132421. /**
  132422. * Creates the input source object
  132423. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132424. * @param _scene the scene which the controller should be associated to
  132425. * @param inputSource the underlying input source for the controller
  132426. * @param _options options for this controller creation
  132427. */
  132428. constructor(_scene: Scene,
  132429. /** The underlying input source for the controller */
  132430. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132431. /**
  132432. * Get this controllers unique id
  132433. */
  132434. get uniqueId(): string;
  132435. /**
  132436. * Disposes of the object
  132437. */
  132438. dispose(): void;
  132439. /**
  132440. * Gets a world space ray coming from the pointer or grip
  132441. * @param result the resulting ray
  132442. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132443. */
  132444. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132445. /**
  132446. * Updates the controller pose based on the given XRFrame
  132447. * @param xrFrame xr frame to update the pose with
  132448. * @param referenceSpace reference space to use
  132449. */
  132450. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132451. }
  132452. }
  132453. declare module BABYLON {
  132454. /**
  132455. * The schema for initialization options of the XR Input class
  132456. */
  132457. export interface IWebXRInputOptions {
  132458. /**
  132459. * If set to true no model will be automatically loaded
  132460. */
  132461. doNotLoadControllerMeshes?: boolean;
  132462. /**
  132463. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132464. * If not found, the xr input profile data will be used.
  132465. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132466. */
  132467. forceInputProfile?: string;
  132468. /**
  132469. * Do not send a request to the controller repository to load the profile.
  132470. *
  132471. * Instead, use the controllers available in babylon itself.
  132472. */
  132473. disableOnlineControllerRepository?: boolean;
  132474. /**
  132475. * A custom URL for the controllers repository
  132476. */
  132477. customControllersRepositoryURL?: string;
  132478. /**
  132479. * Should the controller model's components not move according to the user input
  132480. */
  132481. disableControllerAnimation?: boolean;
  132482. /**
  132483. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132484. */
  132485. controllerOptions?: IWebXRControllerOptions;
  132486. }
  132487. /**
  132488. * XR input used to track XR inputs such as controllers/rays
  132489. */
  132490. export class WebXRInput implements IDisposable {
  132491. /**
  132492. * the xr session manager for this session
  132493. */
  132494. xrSessionManager: WebXRSessionManager;
  132495. /**
  132496. * the WebXR camera for this session. Mainly used for teleportation
  132497. */
  132498. xrCamera: WebXRCamera;
  132499. private readonly options;
  132500. /**
  132501. * XR controllers being tracked
  132502. */
  132503. controllers: Array<WebXRInputSource>;
  132504. private _frameObserver;
  132505. private _sessionEndedObserver;
  132506. private _sessionInitObserver;
  132507. /**
  132508. * Event when a controller has been connected/added
  132509. */
  132510. onControllerAddedObservable: Observable<WebXRInputSource>;
  132511. /**
  132512. * Event when a controller has been removed/disconnected
  132513. */
  132514. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132515. /**
  132516. * Initializes the WebXRInput
  132517. * @param xrSessionManager the xr session manager for this session
  132518. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132519. * @param options = initialization options for this xr input
  132520. */
  132521. constructor(
  132522. /**
  132523. * the xr session manager for this session
  132524. */
  132525. xrSessionManager: WebXRSessionManager,
  132526. /**
  132527. * the WebXR camera for this session. Mainly used for teleportation
  132528. */
  132529. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132530. private _onInputSourcesChange;
  132531. private _addAndRemoveControllers;
  132532. /**
  132533. * Disposes of the object
  132534. */
  132535. dispose(): void;
  132536. }
  132537. }
  132538. declare module BABYLON {
  132539. /**
  132540. * This is the base class for all WebXR features.
  132541. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132542. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132543. */
  132544. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132545. protected _xrSessionManager: WebXRSessionManager;
  132546. private _attached;
  132547. private _removeOnDetach;
  132548. /**
  132549. * Is this feature disposed?
  132550. */
  132551. isDisposed: boolean;
  132552. /**
  132553. * Should auto-attach be disabled?
  132554. */
  132555. disableAutoAttach: boolean;
  132556. /**
  132557. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132558. */
  132559. xrNativeFeatureName: string;
  132560. /**
  132561. * Construct a new (abstract) WebXR feature
  132562. * @param _xrSessionManager the xr session manager for this feature
  132563. */
  132564. constructor(_xrSessionManager: WebXRSessionManager);
  132565. /**
  132566. * Is this feature attached
  132567. */
  132568. get attached(): boolean;
  132569. /**
  132570. * attach this feature
  132571. *
  132572. * @param force should attachment be forced (even when already attached)
  132573. * @returns true if successful, false is failed or already attached
  132574. */
  132575. attach(force?: boolean): boolean;
  132576. /**
  132577. * detach this feature.
  132578. *
  132579. * @returns true if successful, false if failed or already detached
  132580. */
  132581. detach(): boolean;
  132582. /**
  132583. * Dispose this feature and all of the resources attached
  132584. */
  132585. dispose(): void;
  132586. /**
  132587. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132588. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132589. *
  132590. * @returns whether or not the feature is compatible in this environment
  132591. */
  132592. isCompatible(): boolean;
  132593. /**
  132594. * This is used to register callbacks that will automatically be removed when detach is called.
  132595. * @param observable the observable to which the observer will be attached
  132596. * @param callback the callback to register
  132597. */
  132598. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132599. /**
  132600. * Code in this function will be executed on each xrFrame received from the browser.
  132601. * This function will not execute after the feature is detached.
  132602. * @param _xrFrame the current frame
  132603. */
  132604. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132605. }
  132606. }
  132607. declare module BABYLON {
  132608. /**
  132609. * Renders a layer on top of an existing scene
  132610. */
  132611. export class UtilityLayerRenderer implements IDisposable {
  132612. /** the original scene that will be rendered on top of */
  132613. originalScene: Scene;
  132614. private _pointerCaptures;
  132615. private _lastPointerEvents;
  132616. private static _DefaultUtilityLayer;
  132617. private static _DefaultKeepDepthUtilityLayer;
  132618. private _sharedGizmoLight;
  132619. private _renderCamera;
  132620. /**
  132621. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132622. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132623. * @returns the camera that is used when rendering the utility layer
  132624. */
  132625. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132626. /**
  132627. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132628. * @param cam the camera that should be used when rendering the utility layer
  132629. */
  132630. setRenderCamera(cam: Nullable<Camera>): void;
  132631. /**
  132632. * @hidden
  132633. * Light which used by gizmos to get light shading
  132634. */
  132635. _getSharedGizmoLight(): HemisphericLight;
  132636. /**
  132637. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132638. */
  132639. pickUtilitySceneFirst: boolean;
  132640. /**
  132641. * 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)
  132642. */
  132643. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132644. /**
  132645. * 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)
  132646. */
  132647. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132648. /**
  132649. * The scene that is rendered on top of the original scene
  132650. */
  132651. utilityLayerScene: Scene;
  132652. /**
  132653. * If the utility layer should automatically be rendered on top of existing scene
  132654. */
  132655. shouldRender: boolean;
  132656. /**
  132657. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132658. */
  132659. onlyCheckPointerDownEvents: boolean;
  132660. /**
  132661. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132662. */
  132663. processAllEvents: boolean;
  132664. /**
  132665. * Observable raised when the pointer move from the utility layer scene to the main scene
  132666. */
  132667. onPointerOutObservable: Observable<number>;
  132668. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132669. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132670. private _afterRenderObserver;
  132671. private _sceneDisposeObserver;
  132672. private _originalPointerObserver;
  132673. /**
  132674. * Instantiates a UtilityLayerRenderer
  132675. * @param originalScene the original scene that will be rendered on top of
  132676. * @param handleEvents boolean indicating if the utility layer should handle events
  132677. */
  132678. constructor(
  132679. /** the original scene that will be rendered on top of */
  132680. originalScene: Scene, handleEvents?: boolean);
  132681. private _notifyObservers;
  132682. /**
  132683. * Renders the utility layers scene on top of the original scene
  132684. */
  132685. render(): void;
  132686. /**
  132687. * Disposes of the renderer
  132688. */
  132689. dispose(): void;
  132690. private _updateCamera;
  132691. }
  132692. }
  132693. declare module BABYLON {
  132694. /**
  132695. * Options interface for the pointer selection module
  132696. */
  132697. export interface IWebXRControllerPointerSelectionOptions {
  132698. /**
  132699. * if provided, this scene will be used to render meshes.
  132700. */
  132701. customUtilityLayerScene?: Scene;
  132702. /**
  132703. * 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)
  132704. * If not disabled, the last picked point will be used to execute a pointer up event
  132705. * If disabled, pointer up event will be triggered right after the pointer down event.
  132706. * Used in screen and gaze target ray mode only
  132707. */
  132708. disablePointerUpOnTouchOut: boolean;
  132709. /**
  132710. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132711. */
  132712. forceGazeMode: boolean;
  132713. /**
  132714. * 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
  132715. * to start a new countdown to the pointer down event.
  132716. * Defaults to 1.
  132717. */
  132718. gazeModePointerMovedFactor?: number;
  132719. /**
  132720. * Different button type to use instead of the main component
  132721. */
  132722. overrideButtonId?: string;
  132723. /**
  132724. * use this rendering group id for the meshes (optional)
  132725. */
  132726. renderingGroupId?: number;
  132727. /**
  132728. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132729. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132730. * 3000 means 3 seconds between pointing at something and selecting it
  132731. */
  132732. timeToSelect?: number;
  132733. /**
  132734. * Should meshes created here be added to a utility layer or the main scene
  132735. */
  132736. useUtilityLayer?: boolean;
  132737. /**
  132738. * Optional WebXR camera to be used for gaze selection
  132739. */
  132740. gazeCamera?: WebXRCamera;
  132741. /**
  132742. * the xr input to use with this pointer selection
  132743. */
  132744. xrInput: WebXRInput;
  132745. /**
  132746. * Should the scene pointerX and pointerY update be disabled
  132747. * This is required for fullscreen AR GUI, but might slow down other experiences.
  132748. * Disable in VR, if not needed.
  132749. * The first rig camera (left eye) will be used to calculate the projection
  132750. */
  132751. disableScenePointerVectorUpdate: boolean;
  132752. }
  132753. /**
  132754. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132755. */
  132756. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132757. private readonly _options;
  132758. private static _idCounter;
  132759. private _attachController;
  132760. private _controllers;
  132761. private _scene;
  132762. private _tmpVectorForPickCompare;
  132763. /**
  132764. * The module's name
  132765. */
  132766. static readonly Name: string;
  132767. /**
  132768. * The (Babylon) version of this module.
  132769. * This is an integer representing the implementation version.
  132770. * This number does not correspond to the WebXR specs version
  132771. */
  132772. static readonly Version: number;
  132773. /**
  132774. * Disable lighting on the laser pointer (so it will always be visible)
  132775. */
  132776. disablePointerLighting: boolean;
  132777. /**
  132778. * Disable lighting on the selection mesh (so it will always be visible)
  132779. */
  132780. disableSelectionMeshLighting: boolean;
  132781. /**
  132782. * Should the laser pointer be displayed
  132783. */
  132784. displayLaserPointer: boolean;
  132785. /**
  132786. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132787. */
  132788. displaySelectionMesh: boolean;
  132789. /**
  132790. * This color will be set to the laser pointer when selection is triggered
  132791. */
  132792. laserPointerPickedColor: Color3;
  132793. /**
  132794. * Default color of the laser pointer
  132795. */
  132796. laserPointerDefaultColor: Color3;
  132797. /**
  132798. * default color of the selection ring
  132799. */
  132800. selectionMeshDefaultColor: Color3;
  132801. /**
  132802. * This color will be applied to the selection ring when selection is triggered
  132803. */
  132804. selectionMeshPickedColor: Color3;
  132805. /**
  132806. * Optional filter to be used for ray selection. This predicate shares behavior with
  132807. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132808. */
  132809. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132810. /**
  132811. * constructs a new background remover module
  132812. * @param _xrSessionManager the session manager for this module
  132813. * @param _options read-only options to be used in this module
  132814. */
  132815. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132816. /**
  132817. * attach this feature
  132818. * Will usually be called by the features manager
  132819. *
  132820. * @returns true if successful.
  132821. */
  132822. attach(): boolean;
  132823. /**
  132824. * detach this feature.
  132825. * Will usually be called by the features manager
  132826. *
  132827. * @returns true if successful.
  132828. */
  132829. detach(): boolean;
  132830. /**
  132831. * Will get the mesh under a specific pointer.
  132832. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132833. * @param controllerId the controllerId to check
  132834. * @returns The mesh under pointer or null if no mesh is under the pointer
  132835. */
  132836. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132837. /**
  132838. * Get the xr controller that correlates to the pointer id in the pointer event
  132839. *
  132840. * @param id the pointer id to search for
  132841. * @returns the controller that correlates to this id or null if not found
  132842. */
  132843. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132844. private _identityMatrix;
  132845. private _screenCoordinatesRef;
  132846. private _viewportRef;
  132847. protected _onXRFrame(_xrFrame: XRFrame): void;
  132848. private _attachGazeMode;
  132849. private _attachScreenRayMode;
  132850. private _attachTrackedPointerRayMode;
  132851. private _convertNormalToDirectionOfRay;
  132852. private _detachController;
  132853. private _generateNewMeshPair;
  132854. private _pickingMoved;
  132855. private _updatePointerDistance;
  132856. /** @hidden */
  132857. get lasterPointerDefaultColor(): Color3;
  132858. }
  132859. }
  132860. declare module BABYLON {
  132861. /**
  132862. * Button which can be used to enter a different mode of XR
  132863. */
  132864. export class WebXREnterExitUIButton {
  132865. /** button element */
  132866. element: HTMLElement;
  132867. /** XR initialization options for the button */
  132868. sessionMode: XRSessionMode;
  132869. /** Reference space type */
  132870. referenceSpaceType: XRReferenceSpaceType;
  132871. /**
  132872. * Creates a WebXREnterExitUIButton
  132873. * @param element button element
  132874. * @param sessionMode XR initialization session mode
  132875. * @param referenceSpaceType the type of reference space to be used
  132876. */
  132877. constructor(
  132878. /** button element */
  132879. element: HTMLElement,
  132880. /** XR initialization options for the button */
  132881. sessionMode: XRSessionMode,
  132882. /** Reference space type */
  132883. referenceSpaceType: XRReferenceSpaceType);
  132884. /**
  132885. * Extendable function which can be used to update the button's visuals when the state changes
  132886. * @param activeButton the current active button in the UI
  132887. */
  132888. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132889. }
  132890. /**
  132891. * Options to create the webXR UI
  132892. */
  132893. export class WebXREnterExitUIOptions {
  132894. /**
  132895. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132896. */
  132897. customButtons?: Array<WebXREnterExitUIButton>;
  132898. /**
  132899. * A reference space type to use when creating the default button.
  132900. * Default is local-floor
  132901. */
  132902. referenceSpaceType?: XRReferenceSpaceType;
  132903. /**
  132904. * Context to enter xr with
  132905. */
  132906. renderTarget?: Nullable<WebXRRenderTarget>;
  132907. /**
  132908. * A session mode to use when creating the default button.
  132909. * Default is immersive-vr
  132910. */
  132911. sessionMode?: XRSessionMode;
  132912. /**
  132913. * A list of optional features to init the session with
  132914. */
  132915. optionalFeatures?: string[];
  132916. /**
  132917. * A list of optional features to init the session with
  132918. */
  132919. requiredFeatures?: string[];
  132920. }
  132921. /**
  132922. * UI to allow the user to enter/exit XR mode
  132923. */
  132924. export class WebXREnterExitUI implements IDisposable {
  132925. private scene;
  132926. /** version of the options passed to this UI */
  132927. options: WebXREnterExitUIOptions;
  132928. private _activeButton;
  132929. private _buttons;
  132930. /**
  132931. * The HTML Div Element to which buttons are added.
  132932. */
  132933. readonly overlay: HTMLDivElement;
  132934. /**
  132935. * Fired every time the active button is changed.
  132936. *
  132937. * When xr is entered via a button that launches xr that button will be the callback parameter
  132938. *
  132939. * When exiting xr the callback parameter will be null)
  132940. */
  132941. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132942. /**
  132943. *
  132944. * @param scene babylon scene object to use
  132945. * @param options (read-only) version of the options passed to this UI
  132946. */
  132947. private constructor();
  132948. /**
  132949. * Creates UI to allow the user to enter/exit XR mode
  132950. * @param scene the scene to add the ui to
  132951. * @param helper the xr experience helper to enter/exit xr with
  132952. * @param options options to configure the UI
  132953. * @returns the created ui
  132954. */
  132955. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132956. /**
  132957. * Disposes of the XR UI component
  132958. */
  132959. dispose(): void;
  132960. private _updateButtons;
  132961. }
  132962. }
  132963. declare module BABYLON {
  132964. /**
  132965. * Class containing static functions to help procedurally build meshes
  132966. */
  132967. export class LinesBuilder {
  132968. /**
  132969. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132970. * * 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
  132971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132972. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132973. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132974. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132975. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132976. * * 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
  132977. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  132978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  132980. * @param name defines the name of the new line system
  132981. * @param options defines the options used to create the line system
  132982. * @param scene defines the hosting scene
  132983. * @returns a new line system mesh
  132984. */
  132985. static CreateLineSystem(name: string, options: {
  132986. lines: Vector3[][];
  132987. updatable?: boolean;
  132988. instance?: Nullable<LinesMesh>;
  132989. colors?: Nullable<Color4[][]>;
  132990. useVertexAlpha?: boolean;
  132991. }, scene: Nullable<Scene>): LinesMesh;
  132992. /**
  132993. * Creates a line mesh
  132994. * 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
  132995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132996. * * The parameter `points` is an array successive Vector3
  132997. * * 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
  132998. * * The optional parameter `colors` is an array of successive Color4, one per line point
  132999. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133000. * * When updating an instance, remember that only point positions can change, not the number of points
  133001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133003. * @param name defines the name of the new line system
  133004. * @param options defines the options used to create the line system
  133005. * @param scene defines the hosting scene
  133006. * @returns a new line mesh
  133007. */
  133008. static CreateLines(name: string, options: {
  133009. points: Vector3[];
  133010. updatable?: boolean;
  133011. instance?: Nullable<LinesMesh>;
  133012. colors?: Color4[];
  133013. useVertexAlpha?: boolean;
  133014. }, scene?: Nullable<Scene>): LinesMesh;
  133015. /**
  133016. * Creates a dashed line mesh
  133017. * * 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
  133018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133019. * * The parameter `points` is an array successive Vector3
  133020. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133021. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133022. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133023. * * 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
  133024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133025. * * When updating an instance, remember that only point positions can change, not the number of points
  133026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133027. * @param name defines the name of the mesh
  133028. * @param options defines the options used to create the mesh
  133029. * @param scene defines the hosting scene
  133030. * @returns the dashed line mesh
  133031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133032. */
  133033. static CreateDashedLines(name: string, options: {
  133034. points: Vector3[];
  133035. dashSize?: number;
  133036. gapSize?: number;
  133037. dashNb?: number;
  133038. updatable?: boolean;
  133039. instance?: LinesMesh;
  133040. useVertexAlpha?: boolean;
  133041. }, scene?: Nullable<Scene>): LinesMesh;
  133042. }
  133043. }
  133044. declare module BABYLON {
  133045. /**
  133046. * Construction options for a timer
  133047. */
  133048. export interface ITimerOptions<T> {
  133049. /**
  133050. * Time-to-end
  133051. */
  133052. timeout: number;
  133053. /**
  133054. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133055. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133056. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133057. */
  133058. contextObservable: Observable<T>;
  133059. /**
  133060. * Optional parameters when adding an observer to the observable
  133061. */
  133062. observableParameters?: {
  133063. mask?: number;
  133064. insertFirst?: boolean;
  133065. scope?: any;
  133066. };
  133067. /**
  133068. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133069. */
  133070. breakCondition?: (data?: ITimerData<T>) => boolean;
  133071. /**
  133072. * Will be triggered when the time condition has met
  133073. */
  133074. onEnded?: (data: ITimerData<any>) => void;
  133075. /**
  133076. * Will be triggered when the break condition has met (prematurely ended)
  133077. */
  133078. onAborted?: (data: ITimerData<any>) => void;
  133079. /**
  133080. * Optional function to execute on each tick (or count)
  133081. */
  133082. onTick?: (data: ITimerData<any>) => void;
  133083. }
  133084. /**
  133085. * An interface defining the data sent by the timer
  133086. */
  133087. export interface ITimerData<T> {
  133088. /**
  133089. * When did it start
  133090. */
  133091. startTime: number;
  133092. /**
  133093. * Time now
  133094. */
  133095. currentTime: number;
  133096. /**
  133097. * Time passed since started
  133098. */
  133099. deltaTime: number;
  133100. /**
  133101. * How much is completed, in [0.0...1.0].
  133102. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133103. */
  133104. completeRate: number;
  133105. /**
  133106. * What the registered observable sent in the last count
  133107. */
  133108. payload: T;
  133109. }
  133110. /**
  133111. * The current state of the timer
  133112. */
  133113. export enum TimerState {
  133114. /**
  133115. * Timer initialized, not yet started
  133116. */
  133117. INIT = 0,
  133118. /**
  133119. * Timer started and counting
  133120. */
  133121. STARTED = 1,
  133122. /**
  133123. * Timer ended (whether aborted or time reached)
  133124. */
  133125. ENDED = 2
  133126. }
  133127. /**
  133128. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133129. *
  133130. * @param options options with which to initialize this timer
  133131. */
  133132. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133133. /**
  133134. * An advanced implementation of a timer class
  133135. */
  133136. export class AdvancedTimer<T = any> implements IDisposable {
  133137. /**
  133138. * Will notify each time the timer calculates the remaining time
  133139. */
  133140. onEachCountObservable: Observable<ITimerData<T>>;
  133141. /**
  133142. * Will trigger when the timer was aborted due to the break condition
  133143. */
  133144. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133145. /**
  133146. * Will trigger when the timer ended successfully
  133147. */
  133148. onTimerEndedObservable: Observable<ITimerData<T>>;
  133149. /**
  133150. * Will trigger when the timer state has changed
  133151. */
  133152. onStateChangedObservable: Observable<TimerState>;
  133153. private _observer;
  133154. private _contextObservable;
  133155. private _observableParameters;
  133156. private _startTime;
  133157. private _timer;
  133158. private _state;
  133159. private _breakCondition;
  133160. private _timeToEnd;
  133161. private _breakOnNextTick;
  133162. /**
  133163. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133164. * @param options construction options for this advanced timer
  133165. */
  133166. constructor(options: ITimerOptions<T>);
  133167. /**
  133168. * set a breaking condition for this timer. Default is to never break during count
  133169. * @param predicate the new break condition. Returns true to break, false otherwise
  133170. */
  133171. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133172. /**
  133173. * Reset ALL associated observables in this advanced timer
  133174. */
  133175. clearObservables(): void;
  133176. /**
  133177. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133178. *
  133179. * @param timeToEnd how much time to measure until timer ended
  133180. */
  133181. start(timeToEnd?: number): void;
  133182. /**
  133183. * Will force a stop on the next tick.
  133184. */
  133185. stop(): void;
  133186. /**
  133187. * Dispose this timer, clearing all resources
  133188. */
  133189. dispose(): void;
  133190. private _setState;
  133191. private _tick;
  133192. private _stop;
  133193. }
  133194. }
  133195. declare module BABYLON {
  133196. /**
  133197. * The options container for the teleportation module
  133198. */
  133199. export interface IWebXRTeleportationOptions {
  133200. /**
  133201. * if provided, this scene will be used to render meshes.
  133202. */
  133203. customUtilityLayerScene?: Scene;
  133204. /**
  133205. * Values to configure the default target mesh
  133206. */
  133207. defaultTargetMeshOptions?: {
  133208. /**
  133209. * Fill color of the teleportation area
  133210. */
  133211. teleportationFillColor?: string;
  133212. /**
  133213. * Border color for the teleportation area
  133214. */
  133215. teleportationBorderColor?: string;
  133216. /**
  133217. * Disable the mesh's animation sequence
  133218. */
  133219. disableAnimation?: boolean;
  133220. /**
  133221. * Disable lighting on the material or the ring and arrow
  133222. */
  133223. disableLighting?: boolean;
  133224. /**
  133225. * Override the default material of the torus and arrow
  133226. */
  133227. torusArrowMaterial?: Material;
  133228. };
  133229. /**
  133230. * A list of meshes to use as floor meshes.
  133231. * Meshes can be added and removed after initializing the feature using the
  133232. * addFloorMesh and removeFloorMesh functions
  133233. * If empty, rotation will still work
  133234. */
  133235. floorMeshes?: AbstractMesh[];
  133236. /**
  133237. * use this rendering group id for the meshes (optional)
  133238. */
  133239. renderingGroupId?: number;
  133240. /**
  133241. * Should teleportation move only to snap points
  133242. */
  133243. snapPointsOnly?: boolean;
  133244. /**
  133245. * An array of points to which the teleportation will snap to.
  133246. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133247. */
  133248. snapPositions?: Vector3[];
  133249. /**
  133250. * How close should the teleportation ray be in order to snap to position.
  133251. * Default to 0.8 units (meters)
  133252. */
  133253. snapToPositionRadius?: number;
  133254. /**
  133255. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133256. * If you want to support rotation, make sure your mesh has a direction indicator.
  133257. *
  133258. * When left untouched, the default mesh will be initialized.
  133259. */
  133260. teleportationTargetMesh?: AbstractMesh;
  133261. /**
  133262. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133263. */
  133264. timeToTeleport?: number;
  133265. /**
  133266. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133267. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133268. */
  133269. useMainComponentOnly?: boolean;
  133270. /**
  133271. * Should meshes created here be added to a utility layer or the main scene
  133272. */
  133273. useUtilityLayer?: boolean;
  133274. /**
  133275. * Babylon XR Input class for controller
  133276. */
  133277. xrInput: WebXRInput;
  133278. /**
  133279. * Meshes that the teleportation ray cannot go through
  133280. */
  133281. pickBlockerMeshes?: AbstractMesh[];
  133282. }
  133283. /**
  133284. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133285. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133286. * the input of the attached controllers.
  133287. */
  133288. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133289. private _options;
  133290. private _controllers;
  133291. private _currentTeleportationControllerId;
  133292. private _floorMeshes;
  133293. private _quadraticBezierCurve;
  133294. private _selectionFeature;
  133295. private _snapToPositions;
  133296. private _snappedToPoint;
  133297. private _teleportationRingMaterial?;
  133298. private _tmpRay;
  133299. private _tmpVector;
  133300. private _tmpQuaternion;
  133301. /**
  133302. * The module's name
  133303. */
  133304. static readonly Name: string;
  133305. /**
  133306. * The (Babylon) version of this module.
  133307. * This is an integer representing the implementation version.
  133308. * This number does not correspond to the webxr specs version
  133309. */
  133310. static readonly Version: number;
  133311. /**
  133312. * Is movement backwards enabled
  133313. */
  133314. backwardsMovementEnabled: boolean;
  133315. /**
  133316. * Distance to travel when moving backwards
  133317. */
  133318. backwardsTeleportationDistance: number;
  133319. /**
  133320. * The distance from the user to the inspection point in the direction of the controller
  133321. * A higher number will allow the user to move further
  133322. * defaults to 5 (meters, in xr units)
  133323. */
  133324. parabolicCheckRadius: number;
  133325. /**
  133326. * Should the module support parabolic ray on top of direct ray
  133327. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133328. * Very helpful when moving between floors / different heights
  133329. */
  133330. parabolicRayEnabled: boolean;
  133331. /**
  133332. * How much rotation should be applied when rotating right and left
  133333. */
  133334. rotationAngle: number;
  133335. /**
  133336. * Is rotation enabled when moving forward?
  133337. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133338. */
  133339. rotationEnabled: boolean;
  133340. /**
  133341. * constructs a new anchor system
  133342. * @param _xrSessionManager an instance of WebXRSessionManager
  133343. * @param _options configuration object for this feature
  133344. */
  133345. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133346. /**
  133347. * Get the snapPointsOnly flag
  133348. */
  133349. get snapPointsOnly(): boolean;
  133350. /**
  133351. * Sets the snapPointsOnly flag
  133352. * @param snapToPoints should teleportation be exclusively to snap points
  133353. */
  133354. set snapPointsOnly(snapToPoints: boolean);
  133355. /**
  133356. * Add a new mesh to the floor meshes array
  133357. * @param mesh the mesh to use as floor mesh
  133358. */
  133359. addFloorMesh(mesh: AbstractMesh): void;
  133360. /**
  133361. * Add a new snap-to point to fix teleportation to this position
  133362. * @param newSnapPoint The new Snap-To point
  133363. */
  133364. addSnapPoint(newSnapPoint: Vector3): void;
  133365. attach(): boolean;
  133366. detach(): boolean;
  133367. dispose(): void;
  133368. /**
  133369. * Remove a mesh from the floor meshes array
  133370. * @param mesh the mesh to remove
  133371. */
  133372. removeFloorMesh(mesh: AbstractMesh): void;
  133373. /**
  133374. * Remove a mesh from the floor meshes array using its name
  133375. * @param name the mesh name to remove
  133376. */
  133377. removeFloorMeshByName(name: string): void;
  133378. /**
  133379. * 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
  133380. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133381. * @returns was the point found and removed or not
  133382. */
  133383. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133384. /**
  133385. * This function sets a selection feature that will be disabled when
  133386. * the forward ray is shown and will be reattached when hidden.
  133387. * This is used to remove the selection rays when moving.
  133388. * @param selectionFeature the feature to disable when forward movement is enabled
  133389. */
  133390. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133391. protected _onXRFrame(_xrFrame: XRFrame): void;
  133392. private _attachController;
  133393. private _createDefaultTargetMesh;
  133394. private _detachController;
  133395. private _findClosestSnapPointWithRadius;
  133396. private _setTargetMeshPosition;
  133397. private _setTargetMeshVisibility;
  133398. private _showParabolicPath;
  133399. private _teleportForward;
  133400. }
  133401. }
  133402. declare module BABYLON {
  133403. /**
  133404. * Options for the default xr helper
  133405. */
  133406. export class WebXRDefaultExperienceOptions {
  133407. /**
  133408. * Enable or disable default UI to enter XR
  133409. */
  133410. disableDefaultUI?: boolean;
  133411. /**
  133412. * Should teleportation not initialize. defaults to false.
  133413. */
  133414. disableTeleportation?: boolean;
  133415. /**
  133416. * Floor meshes that will be used for teleport
  133417. */
  133418. floorMeshes?: Array<AbstractMesh>;
  133419. /**
  133420. * If set to true, the first frame will not be used to reset position
  133421. * The first frame is mainly used when copying transformation from the old camera
  133422. * Mainly used in AR
  133423. */
  133424. ignoreNativeCameraTransformation?: boolean;
  133425. /**
  133426. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133427. */
  133428. inputOptions?: IWebXRInputOptions;
  133429. /**
  133430. * optional configuration for the output canvas
  133431. */
  133432. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133433. /**
  133434. * optional UI options. This can be used among other to change session mode and reference space type
  133435. */
  133436. uiOptions?: WebXREnterExitUIOptions;
  133437. /**
  133438. * When loading teleportation and pointer select, use stable versions instead of latest.
  133439. */
  133440. useStablePlugins?: boolean;
  133441. /**
  133442. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133443. */
  133444. renderingGroupId?: number;
  133445. /**
  133446. * A list of optional features to init the session with
  133447. * If set to true, all features we support will be added
  133448. */
  133449. optionalFeatures?: boolean | string[];
  133450. }
  133451. /**
  133452. * Default experience which provides a similar setup to the previous webVRExperience
  133453. */
  133454. export class WebXRDefaultExperience {
  133455. /**
  133456. * Base experience
  133457. */
  133458. baseExperience: WebXRExperienceHelper;
  133459. /**
  133460. * Enables ui for entering/exiting xr
  133461. */
  133462. enterExitUI: WebXREnterExitUI;
  133463. /**
  133464. * Input experience extension
  133465. */
  133466. input: WebXRInput;
  133467. /**
  133468. * Enables laser pointer and selection
  133469. */
  133470. pointerSelection: WebXRControllerPointerSelection;
  133471. /**
  133472. * Default target xr should render to
  133473. */
  133474. renderTarget: WebXRRenderTarget;
  133475. /**
  133476. * Enables teleportation
  133477. */
  133478. teleportation: WebXRMotionControllerTeleportation;
  133479. private constructor();
  133480. /**
  133481. * Creates the default xr experience
  133482. * @param scene scene
  133483. * @param options options for basic configuration
  133484. * @returns resulting WebXRDefaultExperience
  133485. */
  133486. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133487. /**
  133488. * DIsposes of the experience helper
  133489. */
  133490. dispose(): void;
  133491. }
  133492. }
  133493. declare module BABYLON {
  133494. /**
  133495. * Options to modify the vr teleportation behavior.
  133496. */
  133497. export interface VRTeleportationOptions {
  133498. /**
  133499. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133500. */
  133501. floorMeshName?: string;
  133502. /**
  133503. * A list of meshes to be used as the teleportation floor. (default: empty)
  133504. */
  133505. floorMeshes?: Mesh[];
  133506. /**
  133507. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133508. */
  133509. teleportationMode?: number;
  133510. /**
  133511. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133512. */
  133513. teleportationTime?: number;
  133514. /**
  133515. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133516. */
  133517. teleportationSpeed?: number;
  133518. /**
  133519. * The easing function used in the animation or null for Linear. (default CircleEase)
  133520. */
  133521. easingFunction?: EasingFunction;
  133522. }
  133523. /**
  133524. * Options to modify the vr experience helper's behavior.
  133525. */
  133526. export interface VRExperienceHelperOptions extends WebVROptions {
  133527. /**
  133528. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133529. */
  133530. createDeviceOrientationCamera?: boolean;
  133531. /**
  133532. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133533. */
  133534. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133535. /**
  133536. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133537. */
  133538. laserToggle?: boolean;
  133539. /**
  133540. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133541. */
  133542. floorMeshes?: Mesh[];
  133543. /**
  133544. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133545. */
  133546. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133547. /**
  133548. * Defines if WebXR should be used instead of WebVR (if available)
  133549. */
  133550. useXR?: boolean;
  133551. }
  133552. /**
  133553. * Event containing information after VR has been entered
  133554. */
  133555. export class OnAfterEnteringVRObservableEvent {
  133556. /**
  133557. * If entering vr was successful
  133558. */
  133559. success: boolean;
  133560. }
  133561. /**
  133562. * Helps to quickly add VR support to an existing scene.
  133563. * See https://doc.babylonjs.com/how_to/webvr_helper
  133564. */
  133565. export class VRExperienceHelper {
  133566. /** Options to modify the vr experience helper's behavior. */
  133567. webVROptions: VRExperienceHelperOptions;
  133568. private _scene;
  133569. private _position;
  133570. private _btnVR;
  133571. private _btnVRDisplayed;
  133572. private _webVRsupported;
  133573. private _webVRready;
  133574. private _webVRrequesting;
  133575. private _webVRpresenting;
  133576. private _hasEnteredVR;
  133577. private _fullscreenVRpresenting;
  133578. private _inputElement;
  133579. private _webVRCamera;
  133580. private _vrDeviceOrientationCamera;
  133581. private _deviceOrientationCamera;
  133582. private _existingCamera;
  133583. private _onKeyDown;
  133584. private _onVrDisplayPresentChange;
  133585. private _onVRDisplayChanged;
  133586. private _onVRRequestPresentStart;
  133587. private _onVRRequestPresentComplete;
  133588. /**
  133589. * 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)
  133590. */
  133591. enableGazeEvenWhenNoPointerLock: boolean;
  133592. /**
  133593. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133594. */
  133595. exitVROnDoubleTap: boolean;
  133596. /**
  133597. * Observable raised right before entering VR.
  133598. */
  133599. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133600. /**
  133601. * Observable raised when entering VR has completed.
  133602. */
  133603. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133604. /**
  133605. * Observable raised when exiting VR.
  133606. */
  133607. onExitingVRObservable: Observable<VRExperienceHelper>;
  133608. /**
  133609. * Observable raised when controller mesh is loaded.
  133610. */
  133611. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133612. /** Return this.onEnteringVRObservable
  133613. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133614. */
  133615. get onEnteringVR(): Observable<VRExperienceHelper>;
  133616. /** Return this.onExitingVRObservable
  133617. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133618. */
  133619. get onExitingVR(): Observable<VRExperienceHelper>;
  133620. /** Return this.onControllerMeshLoadedObservable
  133621. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133622. */
  133623. get onControllerMeshLoaded(): Observable<WebVRController>;
  133624. private _rayLength;
  133625. private _useCustomVRButton;
  133626. private _teleportationRequested;
  133627. private _teleportActive;
  133628. private _floorMeshName;
  133629. private _floorMeshesCollection;
  133630. private _teleportationMode;
  133631. private _teleportationTime;
  133632. private _teleportationSpeed;
  133633. private _teleportationEasing;
  133634. private _rotationAllowed;
  133635. private _teleportBackwardsVector;
  133636. private _teleportationTarget;
  133637. private _isDefaultTeleportationTarget;
  133638. private _postProcessMove;
  133639. private _teleportationFillColor;
  133640. private _teleportationBorderColor;
  133641. private _rotationAngle;
  133642. private _haloCenter;
  133643. private _cameraGazer;
  133644. private _padSensibilityUp;
  133645. private _padSensibilityDown;
  133646. private _leftController;
  133647. private _rightController;
  133648. private _gazeColor;
  133649. private _laserColor;
  133650. private _pickedLaserColor;
  133651. private _pickedGazeColor;
  133652. /**
  133653. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133654. */
  133655. onNewMeshSelected: Observable<AbstractMesh>;
  133656. /**
  133657. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133658. * This observable will provide the mesh and the controller used to select the mesh
  133659. */
  133660. onMeshSelectedWithController: Observable<{
  133661. mesh: AbstractMesh;
  133662. controller: WebVRController;
  133663. }>;
  133664. /**
  133665. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133666. */
  133667. onNewMeshPicked: Observable<PickingInfo>;
  133668. private _circleEase;
  133669. /**
  133670. * Observable raised before camera teleportation
  133671. */
  133672. onBeforeCameraTeleport: Observable<Vector3>;
  133673. /**
  133674. * Observable raised after camera teleportation
  133675. */
  133676. onAfterCameraTeleport: Observable<Vector3>;
  133677. /**
  133678. * Observable raised when current selected mesh gets unselected
  133679. */
  133680. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133681. private _raySelectionPredicate;
  133682. /**
  133683. * To be optionaly changed by user to define custom ray selection
  133684. */
  133685. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133686. /**
  133687. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133688. */
  133689. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133690. /**
  133691. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133692. */
  133693. teleportationEnabled: boolean;
  133694. private _defaultHeight;
  133695. private _teleportationInitialized;
  133696. private _interactionsEnabled;
  133697. private _interactionsRequested;
  133698. private _displayGaze;
  133699. private _displayLaserPointer;
  133700. /**
  133701. * The mesh used to display where the user is going to teleport.
  133702. */
  133703. get teleportationTarget(): Mesh;
  133704. /**
  133705. * Sets the mesh to be used to display where the user is going to teleport.
  133706. */
  133707. set teleportationTarget(value: Mesh);
  133708. /**
  133709. * 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
  133710. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133711. * See https://doc.babylonjs.com/resources/baking_transformations
  133712. */
  133713. get gazeTrackerMesh(): Mesh;
  133714. set gazeTrackerMesh(value: Mesh);
  133715. /**
  133716. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133717. */
  133718. updateGazeTrackerScale: boolean;
  133719. /**
  133720. * If the gaze trackers color should be updated when selecting meshes
  133721. */
  133722. updateGazeTrackerColor: boolean;
  133723. /**
  133724. * If the controller laser color should be updated when selecting meshes
  133725. */
  133726. updateControllerLaserColor: boolean;
  133727. /**
  133728. * The gaze tracking mesh corresponding to the left controller
  133729. */
  133730. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133731. /**
  133732. * The gaze tracking mesh corresponding to the right controller
  133733. */
  133734. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133735. /**
  133736. * If the ray of the gaze should be displayed.
  133737. */
  133738. get displayGaze(): boolean;
  133739. /**
  133740. * Sets if the ray of the gaze should be displayed.
  133741. */
  133742. set displayGaze(value: boolean);
  133743. /**
  133744. * If the ray of the LaserPointer should be displayed.
  133745. */
  133746. get displayLaserPointer(): boolean;
  133747. /**
  133748. * Sets if the ray of the LaserPointer should be displayed.
  133749. */
  133750. set displayLaserPointer(value: boolean);
  133751. /**
  133752. * The deviceOrientationCamera used as the camera when not in VR.
  133753. */
  133754. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133755. /**
  133756. * Based on the current WebVR support, returns the current VR camera used.
  133757. */
  133758. get currentVRCamera(): Nullable<Camera>;
  133759. /**
  133760. * The webVRCamera which is used when in VR.
  133761. */
  133762. get webVRCamera(): WebVRFreeCamera;
  133763. /**
  133764. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133765. */
  133766. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133767. /**
  133768. * The html button that is used to trigger entering into VR.
  133769. */
  133770. get vrButton(): Nullable<HTMLButtonElement>;
  133771. private get _teleportationRequestInitiated();
  133772. /**
  133773. * Defines whether or not Pointer lock should be requested when switching to
  133774. * full screen.
  133775. */
  133776. requestPointerLockOnFullScreen: boolean;
  133777. /**
  133778. * If asking to force XR, this will be populated with the default xr experience
  133779. */
  133780. xr: WebXRDefaultExperience;
  133781. /**
  133782. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133783. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133784. */
  133785. xrTestDone: boolean;
  133786. /**
  133787. * Instantiates a VRExperienceHelper.
  133788. * Helps to quickly add VR support to an existing scene.
  133789. * @param scene The scene the VRExperienceHelper belongs to.
  133790. * @param webVROptions Options to modify the vr experience helper's behavior.
  133791. */
  133792. constructor(scene: Scene,
  133793. /** Options to modify the vr experience helper's behavior. */
  133794. webVROptions?: VRExperienceHelperOptions);
  133795. private completeVRInit;
  133796. private _onDefaultMeshLoaded;
  133797. private _onResize;
  133798. private _onFullscreenChange;
  133799. /**
  133800. * Gets a value indicating if we are currently in VR mode.
  133801. */
  133802. get isInVRMode(): boolean;
  133803. private onVrDisplayPresentChange;
  133804. private onVRDisplayChanged;
  133805. private moveButtonToBottomRight;
  133806. private displayVRButton;
  133807. private updateButtonVisibility;
  133808. private _cachedAngularSensibility;
  133809. /**
  133810. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133811. * Otherwise, will use the fullscreen API.
  133812. */
  133813. enterVR(): void;
  133814. /**
  133815. * Attempt to exit VR, or fullscreen.
  133816. */
  133817. exitVR(): void;
  133818. /**
  133819. * The position of the vr experience helper.
  133820. */
  133821. get position(): Vector3;
  133822. /**
  133823. * Sets the position of the vr experience helper.
  133824. */
  133825. set position(value: Vector3);
  133826. /**
  133827. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133828. */
  133829. enableInteractions(): void;
  133830. private get _noControllerIsActive();
  133831. private beforeRender;
  133832. private _isTeleportationFloor;
  133833. /**
  133834. * Adds a floor mesh to be used for teleportation.
  133835. * @param floorMesh the mesh to be used for teleportation.
  133836. */
  133837. addFloorMesh(floorMesh: Mesh): void;
  133838. /**
  133839. * Removes a floor mesh from being used for teleportation.
  133840. * @param floorMesh the mesh to be removed.
  133841. */
  133842. removeFloorMesh(floorMesh: Mesh): void;
  133843. /**
  133844. * Enables interactions and teleportation using the VR controllers and gaze.
  133845. * @param vrTeleportationOptions options to modify teleportation behavior.
  133846. */
  133847. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133848. private _onNewGamepadConnected;
  133849. private _tryEnableInteractionOnController;
  133850. private _onNewGamepadDisconnected;
  133851. private _enableInteractionOnController;
  133852. private _checkTeleportWithRay;
  133853. private _checkRotate;
  133854. private _checkTeleportBackwards;
  133855. private _enableTeleportationOnController;
  133856. private _createTeleportationCircles;
  133857. private _displayTeleportationTarget;
  133858. private _hideTeleportationTarget;
  133859. private _rotateCamera;
  133860. private _moveTeleportationSelectorTo;
  133861. private _workingVector;
  133862. private _workingQuaternion;
  133863. private _workingMatrix;
  133864. /**
  133865. * Time Constant Teleportation Mode
  133866. */
  133867. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133868. /**
  133869. * Speed Constant Teleportation Mode
  133870. */
  133871. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133872. /**
  133873. * Teleports the users feet to the desired location
  133874. * @param location The location where the user's feet should be placed
  133875. */
  133876. teleportCamera(location: Vector3): void;
  133877. private _convertNormalToDirectionOfRay;
  133878. private _castRayAndSelectObject;
  133879. private _notifySelectedMeshUnselected;
  133880. /**
  133881. * Permanently set new colors for the laser pointer
  133882. * @param color the new laser color
  133883. * @param pickedColor the new laser color when picked mesh detected
  133884. */
  133885. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133886. /**
  133887. * Set lighting enabled / disabled on the laser pointer of both controllers
  133888. * @param enabled should the lighting be enabled on the laser pointer
  133889. */
  133890. setLaserLightingState(enabled?: boolean): void;
  133891. /**
  133892. * Permanently set new colors for the gaze pointer
  133893. * @param color the new gaze color
  133894. * @param pickedColor the new gaze color when picked mesh detected
  133895. */
  133896. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133897. /**
  133898. * Sets the color of the laser ray from the vr controllers.
  133899. * @param color new color for the ray.
  133900. */
  133901. changeLaserColor(color: Color3): void;
  133902. /**
  133903. * Sets the color of the ray from the vr headsets gaze.
  133904. * @param color new color for the ray.
  133905. */
  133906. changeGazeColor(color: Color3): void;
  133907. /**
  133908. * Exits VR and disposes of the vr experience helper
  133909. */
  133910. dispose(): void;
  133911. /**
  133912. * Gets the name of the VRExperienceHelper class
  133913. * @returns "VRExperienceHelper"
  133914. */
  133915. getClassName(): string;
  133916. }
  133917. }
  133918. declare module BABYLON {
  133919. /**
  133920. * Contains an array of blocks representing the octree
  133921. */
  133922. export interface IOctreeContainer<T> {
  133923. /**
  133924. * Blocks within the octree
  133925. */
  133926. blocks: Array<OctreeBlock<T>>;
  133927. }
  133928. /**
  133929. * Class used to store a cell in an octree
  133930. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133931. */
  133932. export class OctreeBlock<T> {
  133933. /**
  133934. * Gets the content of the current block
  133935. */
  133936. entries: T[];
  133937. /**
  133938. * Gets the list of block children
  133939. */
  133940. blocks: Array<OctreeBlock<T>>;
  133941. private _depth;
  133942. private _maxDepth;
  133943. private _capacity;
  133944. private _minPoint;
  133945. private _maxPoint;
  133946. private _boundingVectors;
  133947. private _creationFunc;
  133948. /**
  133949. * Creates a new block
  133950. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133951. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133952. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133953. * @param depth defines the current depth of this block in the octree
  133954. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133955. * @param creationFunc defines a callback to call when an element is added to the block
  133956. */
  133957. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133958. /**
  133959. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133960. */
  133961. get capacity(): number;
  133962. /**
  133963. * Gets the minimum vector (in world space) of the block's bounding box
  133964. */
  133965. get minPoint(): Vector3;
  133966. /**
  133967. * Gets the maximum vector (in world space) of the block's bounding box
  133968. */
  133969. get maxPoint(): Vector3;
  133970. /**
  133971. * Add a new element to this block
  133972. * @param entry defines the element to add
  133973. */
  133974. addEntry(entry: T): void;
  133975. /**
  133976. * Remove an element from this block
  133977. * @param entry defines the element to remove
  133978. */
  133979. removeEntry(entry: T): void;
  133980. /**
  133981. * Add an array of elements to this block
  133982. * @param entries defines the array of elements to add
  133983. */
  133984. addEntries(entries: T[]): void;
  133985. /**
  133986. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  133987. * @param frustumPlanes defines the frustum planes to test
  133988. * @param selection defines the array to store current content if selection is positive
  133989. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133990. */
  133991. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133992. /**
  133993. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  133994. * @param sphereCenter defines the bounding sphere center
  133995. * @param sphereRadius defines the bounding sphere radius
  133996. * @param selection defines the array to store current content if selection is positive
  133997. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133998. */
  133999. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134000. /**
  134001. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134002. * @param ray defines the ray to test with
  134003. * @param selection defines the array to store current content if selection is positive
  134004. */
  134005. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134006. /**
  134007. * Subdivide the content into child blocks (this block will then be empty)
  134008. */
  134009. createInnerBlocks(): void;
  134010. /**
  134011. * @hidden
  134012. */
  134013. 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;
  134014. }
  134015. }
  134016. declare module BABYLON {
  134017. /**
  134018. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134020. */
  134021. export class Octree<T> {
  134022. /** 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.) */
  134023. maxDepth: number;
  134024. /**
  134025. * Blocks within the octree containing objects
  134026. */
  134027. blocks: Array<OctreeBlock<T>>;
  134028. /**
  134029. * Content stored in the octree
  134030. */
  134031. dynamicContent: T[];
  134032. private _maxBlockCapacity;
  134033. private _selectionContent;
  134034. private _creationFunc;
  134035. /**
  134036. * Creates a octree
  134037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134038. * @param creationFunc function to be used to instatiate the octree
  134039. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134040. * @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.)
  134041. */
  134042. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134043. /** 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.) */
  134044. maxDepth?: number);
  134045. /**
  134046. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134047. * @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);
  134048. * @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);
  134049. * @param entries meshes to be added to the octree blocks
  134050. */
  134051. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134052. /**
  134053. * Adds a mesh to the octree
  134054. * @param entry Mesh to add to the octree
  134055. */
  134056. addMesh(entry: T): void;
  134057. /**
  134058. * Remove an element from the octree
  134059. * @param entry defines the element to remove
  134060. */
  134061. removeMesh(entry: T): void;
  134062. /**
  134063. * Selects an array of meshes within the frustum
  134064. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134065. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134066. * @returns array of meshes within the frustum
  134067. */
  134068. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134069. /**
  134070. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134071. * @param sphereCenter defines the bounding sphere center
  134072. * @param sphereRadius defines the bounding sphere radius
  134073. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134074. * @returns an array of objects that intersect the sphere
  134075. */
  134076. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134077. /**
  134078. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134079. * @param ray defines the ray to test with
  134080. * @returns array of intersected objects
  134081. */
  134082. intersectsRay(ray: Ray): SmartArray<T>;
  134083. /**
  134084. * Adds a mesh into the octree block if it intersects the block
  134085. */
  134086. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134087. /**
  134088. * Adds a submesh into the octree block if it intersects the block
  134089. */
  134090. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134091. }
  134092. }
  134093. declare module BABYLON {
  134094. interface Scene {
  134095. /**
  134096. * @hidden
  134097. * Backing Filed
  134098. */
  134099. _selectionOctree: Octree<AbstractMesh>;
  134100. /**
  134101. * Gets the octree used to boost mesh selection (picking)
  134102. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134103. */
  134104. selectionOctree: Octree<AbstractMesh>;
  134105. /**
  134106. * Creates or updates the octree used to boost selection (picking)
  134107. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134108. * @param maxCapacity defines the maximum capacity per leaf
  134109. * @param maxDepth defines the maximum depth of the octree
  134110. * @returns an octree of AbstractMesh
  134111. */
  134112. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134113. }
  134114. interface AbstractMesh {
  134115. /**
  134116. * @hidden
  134117. * Backing Field
  134118. */
  134119. _submeshesOctree: Octree<SubMesh>;
  134120. /**
  134121. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134122. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134123. * @param maxCapacity defines the maximum size of each block (64 by default)
  134124. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134125. * @returns the new octree
  134126. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134128. */
  134129. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134130. }
  134131. /**
  134132. * Defines the octree scene component responsible to manage any octrees
  134133. * in a given scene.
  134134. */
  134135. export class OctreeSceneComponent {
  134136. /**
  134137. * The component name help to identify the component in the list of scene components.
  134138. */
  134139. readonly name: string;
  134140. /**
  134141. * The scene the component belongs to.
  134142. */
  134143. scene: Scene;
  134144. /**
  134145. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134146. */
  134147. readonly checksIsEnabled: boolean;
  134148. /**
  134149. * Creates a new instance of the component for the given scene
  134150. * @param scene Defines the scene to register the component in
  134151. */
  134152. constructor(scene: Scene);
  134153. /**
  134154. * Registers the component in a given scene
  134155. */
  134156. register(): void;
  134157. /**
  134158. * Return the list of active meshes
  134159. * @returns the list of active meshes
  134160. */
  134161. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134162. /**
  134163. * Return the list of active sub meshes
  134164. * @param mesh The mesh to get the candidates sub meshes from
  134165. * @returns the list of active sub meshes
  134166. */
  134167. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134168. private _tempRay;
  134169. /**
  134170. * Return the list of sub meshes intersecting with a given local ray
  134171. * @param mesh defines the mesh to find the submesh for
  134172. * @param localRay defines the ray in local space
  134173. * @returns the list of intersecting sub meshes
  134174. */
  134175. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134176. /**
  134177. * Return the list of sub meshes colliding with a collider
  134178. * @param mesh defines the mesh to find the submesh for
  134179. * @param collider defines the collider to evaluate the collision against
  134180. * @returns the list of colliding sub meshes
  134181. */
  134182. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134183. /**
  134184. * Rebuilds the elements related to this component in case of
  134185. * context lost for instance.
  134186. */
  134187. rebuild(): void;
  134188. /**
  134189. * Disposes the component and the associated ressources.
  134190. */
  134191. dispose(): void;
  134192. }
  134193. }
  134194. declare module BABYLON {
  134195. /**
  134196. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134197. */
  134198. export class Gizmo implements IDisposable {
  134199. /** The utility layer the gizmo will be added to */
  134200. gizmoLayer: UtilityLayerRenderer;
  134201. /**
  134202. * The root mesh of the gizmo
  134203. */
  134204. _rootMesh: Mesh;
  134205. private _attachedMesh;
  134206. private _attachedNode;
  134207. /**
  134208. * Ratio for the scale of the gizmo (Default: 1)
  134209. */
  134210. protected _scaleRatio: number;
  134211. /**
  134212. * boolean updated by pointermove when a gizmo mesh is hovered
  134213. */
  134214. protected _isHovered: boolean;
  134215. /**
  134216. * Ratio for the scale of the gizmo (Default: 1)
  134217. */
  134218. set scaleRatio(value: number);
  134219. get scaleRatio(): number;
  134220. /**
  134221. * True when the mouse pointer is hovered a gizmo mesh
  134222. */
  134223. get isHovered(): boolean;
  134224. /**
  134225. * If a custom mesh has been set (Default: false)
  134226. */
  134227. protected _customMeshSet: boolean;
  134228. /**
  134229. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134230. * * When set, interactions will be enabled
  134231. */
  134232. get attachedMesh(): Nullable<AbstractMesh>;
  134233. set attachedMesh(value: Nullable<AbstractMesh>);
  134234. /**
  134235. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134236. * * When set, interactions will be enabled
  134237. */
  134238. get attachedNode(): Nullable<Node>;
  134239. set attachedNode(value: Nullable<Node>);
  134240. /**
  134241. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134242. * @param mesh The mesh to replace the default mesh of the gizmo
  134243. */
  134244. setCustomMesh(mesh: Mesh): void;
  134245. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134246. /**
  134247. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134248. */
  134249. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134250. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134251. /**
  134252. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134253. */
  134254. updateGizmoPositionToMatchAttachedMesh: boolean;
  134255. /**
  134256. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134257. */
  134258. updateScale: boolean;
  134259. protected _interactionsEnabled: boolean;
  134260. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134261. private _beforeRenderObserver;
  134262. private _tempQuaternion;
  134263. private _tempVector;
  134264. private _tempVector2;
  134265. private _tempMatrix1;
  134266. private _tempMatrix2;
  134267. private _rightHandtoLeftHandMatrix;
  134268. /**
  134269. * Creates a gizmo
  134270. * @param gizmoLayer The utility layer the gizmo will be added to
  134271. */
  134272. constructor(
  134273. /** The utility layer the gizmo will be added to */
  134274. gizmoLayer?: UtilityLayerRenderer);
  134275. /**
  134276. * Updates the gizmo to match the attached mesh's position/rotation
  134277. */
  134278. protected _update(): void;
  134279. /**
  134280. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134281. * @param value Node, TransformNode or mesh
  134282. */
  134283. protected _matrixChanged(): void;
  134284. /**
  134285. * Disposes of the gizmo
  134286. */
  134287. dispose(): void;
  134288. }
  134289. }
  134290. declare module BABYLON {
  134291. /**
  134292. * Single plane drag gizmo
  134293. */
  134294. export class PlaneDragGizmo extends Gizmo {
  134295. /**
  134296. * Drag behavior responsible for the gizmos dragging interactions
  134297. */
  134298. dragBehavior: PointerDragBehavior;
  134299. private _pointerObserver;
  134300. /**
  134301. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134302. */
  134303. snapDistance: number;
  134304. /**
  134305. * Event that fires each time the gizmo snaps to a new location.
  134306. * * snapDistance is the the change in distance
  134307. */
  134308. onSnapObservable: Observable<{
  134309. snapDistance: number;
  134310. }>;
  134311. private _plane;
  134312. private _coloredMaterial;
  134313. private _hoverMaterial;
  134314. private _isEnabled;
  134315. private _parent;
  134316. /** @hidden */
  134317. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134318. /** @hidden */
  134319. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134320. /**
  134321. * Creates a PlaneDragGizmo
  134322. * @param gizmoLayer The utility layer the gizmo will be added to
  134323. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134324. * @param color The color of the gizmo
  134325. */
  134326. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134327. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134328. /**
  134329. * If the gizmo is enabled
  134330. */
  134331. set isEnabled(value: boolean);
  134332. get isEnabled(): boolean;
  134333. /**
  134334. * Disposes of the gizmo
  134335. */
  134336. dispose(): void;
  134337. }
  134338. }
  134339. declare module BABYLON {
  134340. /**
  134341. * Gizmo that enables dragging a mesh along 3 axis
  134342. */
  134343. export class PositionGizmo extends Gizmo {
  134344. /**
  134345. * Internal gizmo used for interactions on the x axis
  134346. */
  134347. xGizmo: AxisDragGizmo;
  134348. /**
  134349. * Internal gizmo used for interactions on the y axis
  134350. */
  134351. yGizmo: AxisDragGizmo;
  134352. /**
  134353. * Internal gizmo used for interactions on the z axis
  134354. */
  134355. zGizmo: AxisDragGizmo;
  134356. /**
  134357. * Internal gizmo used for interactions on the yz plane
  134358. */
  134359. xPlaneGizmo: PlaneDragGizmo;
  134360. /**
  134361. * Internal gizmo used for interactions on the xz plane
  134362. */
  134363. yPlaneGizmo: PlaneDragGizmo;
  134364. /**
  134365. * Internal gizmo used for interactions on the xy plane
  134366. */
  134367. zPlaneGizmo: PlaneDragGizmo;
  134368. /**
  134369. * private variables
  134370. */
  134371. private _meshAttached;
  134372. private _nodeAttached;
  134373. private _snapDistance;
  134374. /** Fires an event when any of it's sub gizmos are dragged */
  134375. onDragStartObservable: Observable<unknown>;
  134376. /** Fires an event when any of it's sub gizmos are released from dragging */
  134377. onDragEndObservable: Observable<unknown>;
  134378. /**
  134379. * If set to true, planar drag is enabled
  134380. */
  134381. private _planarGizmoEnabled;
  134382. get attachedMesh(): Nullable<AbstractMesh>;
  134383. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134384. get attachedNode(): Nullable<Node>;
  134385. set attachedNode(node: Nullable<Node>);
  134386. /**
  134387. * True when the mouse pointer is hovering a gizmo mesh
  134388. */
  134389. get isHovered(): boolean;
  134390. /**
  134391. * Creates a PositionGizmo
  134392. * @param gizmoLayer The utility layer the gizmo will be added to
  134393. @param thickness display gizmo axis thickness
  134394. */
  134395. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134396. /**
  134397. * If the planar drag gizmo is enabled
  134398. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134399. */
  134400. set planarGizmoEnabled(value: boolean);
  134401. get planarGizmoEnabled(): boolean;
  134402. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134403. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134404. /**
  134405. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134406. */
  134407. set snapDistance(value: number);
  134408. get snapDistance(): number;
  134409. /**
  134410. * Ratio for the scale of the gizmo (Default: 1)
  134411. */
  134412. set scaleRatio(value: number);
  134413. get scaleRatio(): number;
  134414. /**
  134415. * Disposes of the gizmo
  134416. */
  134417. dispose(): void;
  134418. /**
  134419. * CustomMeshes are not supported by this gizmo
  134420. * @param mesh The mesh to replace the default mesh of the gizmo
  134421. */
  134422. setCustomMesh(mesh: Mesh): void;
  134423. }
  134424. }
  134425. declare module BABYLON {
  134426. /**
  134427. * Single axis drag gizmo
  134428. */
  134429. export class AxisDragGizmo extends Gizmo {
  134430. /**
  134431. * Drag behavior responsible for the gizmos dragging interactions
  134432. */
  134433. dragBehavior: PointerDragBehavior;
  134434. private _pointerObserver;
  134435. /**
  134436. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134437. */
  134438. snapDistance: number;
  134439. /**
  134440. * Event that fires each time the gizmo snaps to a new location.
  134441. * * snapDistance is the the change in distance
  134442. */
  134443. onSnapObservable: Observable<{
  134444. snapDistance: number;
  134445. }>;
  134446. private _isEnabled;
  134447. private _parent;
  134448. private _arrow;
  134449. private _coloredMaterial;
  134450. private _hoverMaterial;
  134451. /** @hidden */
  134452. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134453. /** @hidden */
  134454. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134455. /**
  134456. * Creates an AxisDragGizmo
  134457. * @param gizmoLayer The utility layer the gizmo will be added to
  134458. * @param dragAxis The axis which the gizmo will be able to drag on
  134459. * @param color The color of the gizmo
  134460. * @param thickness display gizmo axis thickness
  134461. */
  134462. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134463. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134464. /**
  134465. * If the gizmo is enabled
  134466. */
  134467. set isEnabled(value: boolean);
  134468. get isEnabled(): boolean;
  134469. /**
  134470. * Disposes of the gizmo
  134471. */
  134472. dispose(): void;
  134473. }
  134474. }
  134475. declare module BABYLON.Debug {
  134476. /**
  134477. * The Axes viewer will show 3 axes in a specific point in space
  134478. */
  134479. export class AxesViewer {
  134480. private _xAxis;
  134481. private _yAxis;
  134482. private _zAxis;
  134483. private _scaleLinesFactor;
  134484. private _instanced;
  134485. /**
  134486. * Gets the hosting scene
  134487. */
  134488. scene: Nullable<Scene>;
  134489. /**
  134490. * Gets or sets a number used to scale line length
  134491. */
  134492. scaleLines: number;
  134493. /** Gets the node hierarchy used to render x-axis */
  134494. get xAxis(): TransformNode;
  134495. /** Gets the node hierarchy used to render y-axis */
  134496. get yAxis(): TransformNode;
  134497. /** Gets the node hierarchy used to render z-axis */
  134498. get zAxis(): TransformNode;
  134499. /**
  134500. * Creates a new AxesViewer
  134501. * @param scene defines the hosting scene
  134502. * @param scaleLines defines a number used to scale line length (1 by default)
  134503. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134504. * @param xAxis defines the node hierarchy used to render the x-axis
  134505. * @param yAxis defines the node hierarchy used to render the y-axis
  134506. * @param zAxis defines the node hierarchy used to render the z-axis
  134507. */
  134508. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134509. /**
  134510. * Force the viewer to update
  134511. * @param position defines the position of the viewer
  134512. * @param xaxis defines the x axis of the viewer
  134513. * @param yaxis defines the y axis of the viewer
  134514. * @param zaxis defines the z axis of the viewer
  134515. */
  134516. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134517. /**
  134518. * Creates an instance of this axes viewer.
  134519. * @returns a new axes viewer with instanced meshes
  134520. */
  134521. createInstance(): AxesViewer;
  134522. /** Releases resources */
  134523. dispose(): void;
  134524. private static _SetRenderingGroupId;
  134525. }
  134526. }
  134527. declare module BABYLON.Debug {
  134528. /**
  134529. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134530. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134531. */
  134532. export class BoneAxesViewer extends AxesViewer {
  134533. /**
  134534. * Gets or sets the target mesh where to display the axes viewer
  134535. */
  134536. mesh: Nullable<Mesh>;
  134537. /**
  134538. * Gets or sets the target bone where to display the axes viewer
  134539. */
  134540. bone: Nullable<Bone>;
  134541. /** Gets current position */
  134542. pos: Vector3;
  134543. /** Gets direction of X axis */
  134544. xaxis: Vector3;
  134545. /** Gets direction of Y axis */
  134546. yaxis: Vector3;
  134547. /** Gets direction of Z axis */
  134548. zaxis: Vector3;
  134549. /**
  134550. * Creates a new BoneAxesViewer
  134551. * @param scene defines the hosting scene
  134552. * @param bone defines the target bone
  134553. * @param mesh defines the target mesh
  134554. * @param scaleLines defines a scaling factor for line length (1 by default)
  134555. */
  134556. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134557. /**
  134558. * Force the viewer to update
  134559. */
  134560. update(): void;
  134561. /** Releases resources */
  134562. dispose(): void;
  134563. }
  134564. }
  134565. declare module BABYLON {
  134566. /**
  134567. * Interface used to define scene explorer extensibility option
  134568. */
  134569. export interface IExplorerExtensibilityOption {
  134570. /**
  134571. * Define the option label
  134572. */
  134573. label: string;
  134574. /**
  134575. * Defines the action to execute on click
  134576. */
  134577. action: (entity: any) => void;
  134578. }
  134579. /**
  134580. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134581. */
  134582. export interface IExplorerExtensibilityGroup {
  134583. /**
  134584. * Defines a predicate to test if a given type mut be extended
  134585. */
  134586. predicate: (entity: any) => boolean;
  134587. /**
  134588. * Gets the list of options added to a type
  134589. */
  134590. entries: IExplorerExtensibilityOption[];
  134591. }
  134592. /**
  134593. * Interface used to define the options to use to create the Inspector
  134594. */
  134595. export interface IInspectorOptions {
  134596. /**
  134597. * Display in overlay mode (default: false)
  134598. */
  134599. overlay?: boolean;
  134600. /**
  134601. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134602. */
  134603. globalRoot?: HTMLElement;
  134604. /**
  134605. * Display the Scene explorer
  134606. */
  134607. showExplorer?: boolean;
  134608. /**
  134609. * Display the property inspector
  134610. */
  134611. showInspector?: boolean;
  134612. /**
  134613. * Display in embed mode (both panes on the right)
  134614. */
  134615. embedMode?: boolean;
  134616. /**
  134617. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134618. */
  134619. handleResize?: boolean;
  134620. /**
  134621. * Allow the panes to popup (default: true)
  134622. */
  134623. enablePopup?: boolean;
  134624. /**
  134625. * Allow the panes to be closed by users (default: true)
  134626. */
  134627. enableClose?: boolean;
  134628. /**
  134629. * Optional list of extensibility entries
  134630. */
  134631. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134632. /**
  134633. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134634. */
  134635. inspectorURL?: string;
  134636. /**
  134637. * Optional initial tab (default to DebugLayerTab.Properties)
  134638. */
  134639. initialTab?: DebugLayerTab;
  134640. }
  134641. interface Scene {
  134642. /**
  134643. * @hidden
  134644. * Backing field
  134645. */
  134646. _debugLayer: DebugLayer;
  134647. /**
  134648. * Gets the debug layer (aka Inspector) associated with the scene
  134649. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134650. */
  134651. debugLayer: DebugLayer;
  134652. }
  134653. /**
  134654. * Enum of inspector action tab
  134655. */
  134656. export enum DebugLayerTab {
  134657. /**
  134658. * Properties tag (default)
  134659. */
  134660. Properties = 0,
  134661. /**
  134662. * Debug tab
  134663. */
  134664. Debug = 1,
  134665. /**
  134666. * Statistics tab
  134667. */
  134668. Statistics = 2,
  134669. /**
  134670. * Tools tab
  134671. */
  134672. Tools = 3,
  134673. /**
  134674. * Settings tab
  134675. */
  134676. Settings = 4
  134677. }
  134678. /**
  134679. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134680. * what is happening in your scene
  134681. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134682. */
  134683. export class DebugLayer {
  134684. /**
  134685. * Define the url to get the inspector script from.
  134686. * By default it uses the babylonjs CDN.
  134687. * @ignoreNaming
  134688. */
  134689. static InspectorURL: string;
  134690. private _scene;
  134691. private BJSINSPECTOR;
  134692. private _onPropertyChangedObservable?;
  134693. /**
  134694. * Observable triggered when a property is changed through the inspector.
  134695. */
  134696. get onPropertyChangedObservable(): any;
  134697. /**
  134698. * Instantiates a new debug layer.
  134699. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134700. * what is happening in your scene
  134701. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134702. * @param scene Defines the scene to inspect
  134703. */
  134704. constructor(scene: Scene);
  134705. /** Creates the inspector window. */
  134706. private _createInspector;
  134707. /**
  134708. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134709. * @param entity defines the entity to select
  134710. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134711. */
  134712. select(entity: any, lineContainerTitles?: string | string[]): void;
  134713. /** Get the inspector from bundle or global */
  134714. private _getGlobalInspector;
  134715. /**
  134716. * Get if the inspector is visible or not.
  134717. * @returns true if visible otherwise, false
  134718. */
  134719. isVisible(): boolean;
  134720. /**
  134721. * Hide the inspector and close its window.
  134722. */
  134723. hide(): void;
  134724. /**
  134725. * Update the scene in the inspector
  134726. */
  134727. setAsActiveScene(): void;
  134728. /**
  134729. * Launch the debugLayer.
  134730. * @param config Define the configuration of the inspector
  134731. * @return a promise fulfilled when the debug layer is visible
  134732. */
  134733. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134734. }
  134735. }
  134736. declare module BABYLON {
  134737. /**
  134738. * Class containing static functions to help procedurally build meshes
  134739. */
  134740. export class BoxBuilder {
  134741. /**
  134742. * Creates a box mesh
  134743. * * The parameter `size` sets the size (float) of each box side (default 1)
  134744. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134745. * * 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)
  134746. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134750. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134751. * @param name defines the name of the mesh
  134752. * @param options defines the options used to create the mesh
  134753. * @param scene defines the hosting scene
  134754. * @returns the box mesh
  134755. */
  134756. static CreateBox(name: string, options: {
  134757. size?: number;
  134758. width?: number;
  134759. height?: number;
  134760. depth?: number;
  134761. faceUV?: Vector4[];
  134762. faceColors?: Color4[];
  134763. sideOrientation?: number;
  134764. frontUVs?: Vector4;
  134765. backUVs?: Vector4;
  134766. wrap?: boolean;
  134767. topBaseAt?: number;
  134768. bottomBaseAt?: number;
  134769. updatable?: boolean;
  134770. }, scene?: Nullable<Scene>): Mesh;
  134771. }
  134772. }
  134773. declare module BABYLON.Debug {
  134774. /**
  134775. * Used to show the physics impostor around the specific mesh
  134776. */
  134777. export class PhysicsViewer {
  134778. /** @hidden */
  134779. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134780. /** @hidden */
  134781. protected _meshes: Array<Nullable<AbstractMesh>>;
  134782. /** @hidden */
  134783. protected _scene: Nullable<Scene>;
  134784. /** @hidden */
  134785. protected _numMeshes: number;
  134786. /** @hidden */
  134787. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134788. private _renderFunction;
  134789. private _utilityLayer;
  134790. private _debugBoxMesh;
  134791. private _debugSphereMesh;
  134792. private _debugCylinderMesh;
  134793. private _debugMaterial;
  134794. private _debugMeshMeshes;
  134795. /**
  134796. * Creates a new PhysicsViewer
  134797. * @param scene defines the hosting scene
  134798. */
  134799. constructor(scene: Scene);
  134800. /** @hidden */
  134801. protected _updateDebugMeshes(): void;
  134802. /**
  134803. * Renders a specified physic impostor
  134804. * @param impostor defines the impostor to render
  134805. * @param targetMesh defines the mesh represented by the impostor
  134806. * @returns the new debug mesh used to render the impostor
  134807. */
  134808. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134809. /**
  134810. * Hides a specified physic impostor
  134811. * @param impostor defines the impostor to hide
  134812. */
  134813. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134814. private _getDebugMaterial;
  134815. private _getDebugBoxMesh;
  134816. private _getDebugSphereMesh;
  134817. private _getDebugCylinderMesh;
  134818. private _getDebugMeshMesh;
  134819. private _getDebugMesh;
  134820. /** Releases all resources */
  134821. dispose(): void;
  134822. }
  134823. }
  134824. declare module BABYLON {
  134825. /**
  134826. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134827. * in order to better appreciate the issue one might have.
  134828. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134829. */
  134830. export class RayHelper {
  134831. /**
  134832. * Defines the ray we are currently tryin to visualize.
  134833. */
  134834. ray: Nullable<Ray>;
  134835. private _renderPoints;
  134836. private _renderLine;
  134837. private _renderFunction;
  134838. private _scene;
  134839. private _onAfterRenderObserver;
  134840. private _onAfterStepObserver;
  134841. private _attachedToMesh;
  134842. private _meshSpaceDirection;
  134843. private _meshSpaceOrigin;
  134844. /**
  134845. * Helper function to create a colored helper in a scene in one line.
  134846. * @param ray Defines the ray we are currently tryin to visualize
  134847. * @param scene Defines the scene the ray is used in
  134848. * @param color Defines the color we want to see the ray in
  134849. * @returns The newly created ray helper.
  134850. */
  134851. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134852. /**
  134853. * Instantiate a new ray helper.
  134854. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134855. * in order to better appreciate the issue one might have.
  134856. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134857. * @param ray Defines the ray we are currently tryin to visualize
  134858. */
  134859. constructor(ray: Ray);
  134860. /**
  134861. * Shows the ray we are willing to debug.
  134862. * @param scene Defines the scene the ray needs to be rendered in
  134863. * @param color Defines the color the ray needs to be rendered in
  134864. */
  134865. show(scene: Scene, color?: Color3): void;
  134866. /**
  134867. * Hides the ray we are debugging.
  134868. */
  134869. hide(): void;
  134870. private _render;
  134871. /**
  134872. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134873. * @param mesh Defines the mesh we want the helper attached to
  134874. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134875. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134876. * @param length Defines the length of the ray
  134877. */
  134878. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134879. /**
  134880. * Detach the ray helper from the mesh it has previously been attached to.
  134881. */
  134882. detachFromMesh(): void;
  134883. private _updateToMesh;
  134884. /**
  134885. * Dispose the helper and release its associated resources.
  134886. */
  134887. dispose(): void;
  134888. }
  134889. }
  134890. declare module BABYLON {
  134891. /**
  134892. * Defines the options associated with the creation of a SkeletonViewer.
  134893. */
  134894. export interface ISkeletonViewerOptions {
  134895. /** Should the system pause animations before building the Viewer? */
  134896. pauseAnimations: boolean;
  134897. /** Should the system return the skeleton to rest before building? */
  134898. returnToRest: boolean;
  134899. /** public Display Mode of the Viewer */
  134900. displayMode: number;
  134901. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134902. displayOptions: ISkeletonViewerDisplayOptions;
  134903. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134904. computeBonesUsingShaders: boolean;
  134905. /** Flag ignore non weighted bones */
  134906. useAllBones: boolean;
  134907. }
  134908. /**
  134909. * Defines how to display the various bone meshes for the viewer.
  134910. */
  134911. export interface ISkeletonViewerDisplayOptions {
  134912. /** How far down to start tapering the bone spurs */
  134913. midStep?: number;
  134914. /** How big is the midStep? */
  134915. midStepFactor?: number;
  134916. /** Base for the Sphere Size */
  134917. sphereBaseSize?: number;
  134918. /** The ratio of the sphere to the longest bone in units */
  134919. sphereScaleUnit?: number;
  134920. /** Ratio for the Sphere Size */
  134921. sphereFactor?: number;
  134922. /** Whether a spur should attach its far end to the child bone position */
  134923. spurFollowsChild?: boolean;
  134924. /** Whether to show local axes or not */
  134925. showLocalAxes?: boolean;
  134926. /** Length of each local axis */
  134927. localAxesSize?: number;
  134928. }
  134929. /**
  134930. * Defines the constructor options for the BoneWeight Shader.
  134931. */
  134932. export interface IBoneWeightShaderOptions {
  134933. /** Skeleton to Map */
  134934. skeleton: Skeleton;
  134935. /** Colors for Uninfluenced bones */
  134936. colorBase?: Color3;
  134937. /** Colors for 0.0-0.25 Weight bones */
  134938. colorZero?: Color3;
  134939. /** Color for 0.25-0.5 Weight Influence */
  134940. colorQuarter?: Color3;
  134941. /** Color for 0.5-0.75 Weight Influence */
  134942. colorHalf?: Color3;
  134943. /** Color for 0.75-1 Weight Influence */
  134944. colorFull?: Color3;
  134945. /** Color for Zero Weight Influence */
  134946. targetBoneIndex?: number;
  134947. }
  134948. /**
  134949. * Simple structure of the gradient steps for the Color Map.
  134950. */
  134951. export interface ISkeletonMapShaderColorMapKnot {
  134952. /** Color of the Knot */
  134953. color: Color3;
  134954. /** Location of the Knot */
  134955. location: number;
  134956. }
  134957. /**
  134958. * Defines the constructor options for the SkeletonMap Shader.
  134959. */
  134960. export interface ISkeletonMapShaderOptions {
  134961. /** Skeleton to Map */
  134962. skeleton: Skeleton;
  134963. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134964. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134965. }
  134966. }
  134967. declare module BABYLON {
  134968. /**
  134969. * Class containing static functions to help procedurally build meshes
  134970. */
  134971. export class RibbonBuilder {
  134972. /**
  134973. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134974. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134975. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134976. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134977. * * 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
  134978. * * 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
  134979. * * 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
  134980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134983. * * 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
  134984. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134985. * * 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
  134986. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134988. * @param name defines the name of the mesh
  134989. * @param options defines the options used to create the mesh
  134990. * @param scene defines the hosting scene
  134991. * @returns the ribbon mesh
  134992. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134994. */
  134995. static CreateRibbon(name: string, options: {
  134996. pathArray: Vector3[][];
  134997. closeArray?: boolean;
  134998. closePath?: boolean;
  134999. offset?: number;
  135000. updatable?: boolean;
  135001. sideOrientation?: number;
  135002. frontUVs?: Vector4;
  135003. backUVs?: Vector4;
  135004. instance?: Mesh;
  135005. invertUV?: boolean;
  135006. uvs?: Vector2[];
  135007. colors?: Color4[];
  135008. }, scene?: Nullable<Scene>): Mesh;
  135009. }
  135010. }
  135011. declare module BABYLON {
  135012. /**
  135013. * Class containing static functions to help procedurally build meshes
  135014. */
  135015. export class ShapeBuilder {
  135016. /**
  135017. * 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.
  135018. * * 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.
  135019. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135020. * * 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.
  135021. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135022. * * 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
  135023. * * 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
  135024. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135029. * @param name defines the name of the mesh
  135030. * @param options defines the options used to create the mesh
  135031. * @param scene defines the hosting scene
  135032. * @returns the extruded shape mesh
  135033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135035. */
  135036. static ExtrudeShape(name: string, options: {
  135037. shape: Vector3[];
  135038. path: Vector3[];
  135039. scale?: number;
  135040. rotation?: number;
  135041. cap?: number;
  135042. updatable?: boolean;
  135043. sideOrientation?: number;
  135044. frontUVs?: Vector4;
  135045. backUVs?: Vector4;
  135046. instance?: Mesh;
  135047. invertUV?: boolean;
  135048. }, scene?: Nullable<Scene>): Mesh;
  135049. /**
  135050. * Creates an custom extruded shape mesh.
  135051. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135052. * * 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.
  135053. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135054. * * 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
  135055. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135056. * * 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
  135057. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135058. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135059. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135060. * * 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
  135061. * * 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
  135062. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135067. * @param name defines the name of the mesh
  135068. * @param options defines the options used to create the mesh
  135069. * @param scene defines the hosting scene
  135070. * @returns the custom extruded shape mesh
  135071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135072. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135074. */
  135075. static ExtrudeShapeCustom(name: string, options: {
  135076. shape: Vector3[];
  135077. path: Vector3[];
  135078. scaleFunction?: any;
  135079. rotationFunction?: any;
  135080. ribbonCloseArray?: boolean;
  135081. ribbonClosePath?: boolean;
  135082. cap?: number;
  135083. updatable?: boolean;
  135084. sideOrientation?: number;
  135085. frontUVs?: Vector4;
  135086. backUVs?: Vector4;
  135087. instance?: Mesh;
  135088. invertUV?: boolean;
  135089. }, scene?: Nullable<Scene>): Mesh;
  135090. private static _ExtrudeShapeGeneric;
  135091. }
  135092. }
  135093. declare module BABYLON.Debug {
  135094. /**
  135095. * Class used to render a debug view of a given skeleton
  135096. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135097. */
  135098. export class SkeletonViewer {
  135099. /** defines the skeleton to render */
  135100. skeleton: Skeleton;
  135101. /** defines the mesh attached to the skeleton */
  135102. mesh: AbstractMesh;
  135103. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135104. autoUpdateBonesMatrices: boolean;
  135105. /** defines the rendering group id to use with the viewer */
  135106. renderingGroupId: number;
  135107. /** is the options for the viewer */
  135108. options: Partial<ISkeletonViewerOptions>;
  135109. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135110. static readonly DISPLAY_LINES: number;
  135111. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135112. static readonly DISPLAY_SPHERES: number;
  135113. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135114. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135115. /** public static method to create a BoneWeight Shader
  135116. * @param options The constructor options
  135117. * @param scene The scene that the shader is scoped to
  135118. * @returns The created ShaderMaterial
  135119. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135120. */
  135121. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135122. /** public static method to create a BoneWeight Shader
  135123. * @param options The constructor options
  135124. * @param scene The scene that the shader is scoped to
  135125. * @returns The created ShaderMaterial
  135126. */
  135127. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135128. /** private static method to create a BoneWeight Shader
  135129. * @param size The size of the buffer to create (usually the bone count)
  135130. * @param colorMap The gradient data to generate
  135131. * @param scene The scene that the shader is scoped to
  135132. * @returns an Array of floats from the color gradient values
  135133. */
  135134. private static _CreateBoneMapColorBuffer;
  135135. /** If SkeletonViewer scene scope. */
  135136. private _scene;
  135137. /** Gets or sets the color used to render the skeleton */
  135138. color: Color3;
  135139. /** Array of the points of the skeleton fo the line view. */
  135140. private _debugLines;
  135141. /** The SkeletonViewers Mesh. */
  135142. private _debugMesh;
  135143. /** The local axes Meshes. */
  135144. private _localAxes;
  135145. /** If SkeletonViewer is enabled. */
  135146. private _isEnabled;
  135147. /** If SkeletonViewer is ready. */
  135148. private _ready;
  135149. /** SkeletonViewer render observable. */
  135150. private _obs;
  135151. /** The Utility Layer to render the gizmos in. */
  135152. private _utilityLayer;
  135153. private _boneIndices;
  135154. /** Gets the Scene. */
  135155. get scene(): Scene;
  135156. /** Gets the utilityLayer. */
  135157. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135158. /** Checks Ready Status. */
  135159. get isReady(): Boolean;
  135160. /** Sets Ready Status. */
  135161. set ready(value: boolean);
  135162. /** Gets the debugMesh */
  135163. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135164. /** Sets the debugMesh */
  135165. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135166. /** Gets the displayMode */
  135167. get displayMode(): number;
  135168. /** Sets the displayMode */
  135169. set displayMode(value: number);
  135170. /**
  135171. * Creates a new SkeletonViewer
  135172. * @param skeleton defines the skeleton to render
  135173. * @param mesh defines the mesh attached to the skeleton
  135174. * @param scene defines the hosting scene
  135175. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135176. * @param renderingGroupId defines the rendering group id to use with the viewer
  135177. * @param options All of the extra constructor options for the SkeletonViewer
  135178. */
  135179. constructor(
  135180. /** defines the skeleton to render */
  135181. skeleton: Skeleton,
  135182. /** defines the mesh attached to the skeleton */
  135183. mesh: AbstractMesh,
  135184. /** The Scene scope*/
  135185. scene: Scene,
  135186. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135187. autoUpdateBonesMatrices?: boolean,
  135188. /** defines the rendering group id to use with the viewer */
  135189. renderingGroupId?: number,
  135190. /** is the options for the viewer */
  135191. options?: Partial<ISkeletonViewerOptions>);
  135192. /** The Dynamic bindings for the update functions */
  135193. private _bindObs;
  135194. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135195. update(): void;
  135196. /** Gets or sets a boolean indicating if the viewer is enabled */
  135197. set isEnabled(value: boolean);
  135198. get isEnabled(): boolean;
  135199. private _getBonePosition;
  135200. private _getLinesForBonesWithLength;
  135201. private _getLinesForBonesNoLength;
  135202. /** function to revert the mesh and scene back to the initial state. */
  135203. private _revert;
  135204. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135205. private _getAbsoluteBindPoseToRef;
  135206. /** function to build and bind sphere joint points and spur bone representations. */
  135207. private _buildSpheresAndSpurs;
  135208. private _buildLocalAxes;
  135209. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135210. private _displayLinesUpdate;
  135211. /** Changes the displayMode of the skeleton viewer
  135212. * @param mode The displayMode numerical value
  135213. */
  135214. changeDisplayMode(mode: number): void;
  135215. /** Sets a display option of the skeleton viewer
  135216. *
  135217. * | Option | Type | Default | Description |
  135218. * | ---------------- | ------- | ------- | ----------- |
  135219. * | 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`. |
  135220. * | 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`. |
  135221. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135222. * | 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`. |
  135223. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135224. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135225. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135226. *
  135227. * @param option String of the option name
  135228. * @param value The numerical option value
  135229. */
  135230. changeDisplayOptions(option: string, value: number): void;
  135231. /** Release associated resources */
  135232. dispose(): void;
  135233. }
  135234. }
  135235. declare module BABYLON {
  135236. /**
  135237. * Enum for Device Types
  135238. */
  135239. export enum DeviceType {
  135240. /** Generic */
  135241. Generic = 0,
  135242. /** Keyboard */
  135243. Keyboard = 1,
  135244. /** Mouse */
  135245. Mouse = 2,
  135246. /** Touch Pointers */
  135247. Touch = 3,
  135248. /** PS4 Dual Shock */
  135249. DualShock = 4,
  135250. /** Xbox */
  135251. Xbox = 5,
  135252. /** Switch Controller */
  135253. Switch = 6
  135254. }
  135255. /**
  135256. * Enum for All Pointers (Touch/Mouse)
  135257. */
  135258. export enum PointerInput {
  135259. /** Horizontal Axis */
  135260. Horizontal = 0,
  135261. /** Vertical Axis */
  135262. Vertical = 1,
  135263. /** Left Click or Touch */
  135264. LeftClick = 2,
  135265. /** Middle Click */
  135266. MiddleClick = 3,
  135267. /** Right Click */
  135268. RightClick = 4,
  135269. /** Browser Back */
  135270. BrowserBack = 5,
  135271. /** Browser Forward */
  135272. BrowserForward = 6
  135273. }
  135274. /**
  135275. * Enum for Dual Shock Gamepad
  135276. */
  135277. export enum DualShockInput {
  135278. /** Cross */
  135279. Cross = 0,
  135280. /** Circle */
  135281. Circle = 1,
  135282. /** Square */
  135283. Square = 2,
  135284. /** Triangle */
  135285. Triangle = 3,
  135286. /** L1 */
  135287. L1 = 4,
  135288. /** R1 */
  135289. R1 = 5,
  135290. /** L2 */
  135291. L2 = 6,
  135292. /** R2 */
  135293. R2 = 7,
  135294. /** Share */
  135295. Share = 8,
  135296. /** Options */
  135297. Options = 9,
  135298. /** L3 */
  135299. L3 = 10,
  135300. /** R3 */
  135301. R3 = 11,
  135302. /** DPadUp */
  135303. DPadUp = 12,
  135304. /** DPadDown */
  135305. DPadDown = 13,
  135306. /** DPadLeft */
  135307. DPadLeft = 14,
  135308. /** DRight */
  135309. DPadRight = 15,
  135310. /** Home */
  135311. Home = 16,
  135312. /** TouchPad */
  135313. TouchPad = 17,
  135314. /** LStickXAxis */
  135315. LStickXAxis = 18,
  135316. /** LStickYAxis */
  135317. LStickYAxis = 19,
  135318. /** RStickXAxis */
  135319. RStickXAxis = 20,
  135320. /** RStickYAxis */
  135321. RStickYAxis = 21
  135322. }
  135323. /**
  135324. * Enum for Xbox Gamepad
  135325. */
  135326. export enum XboxInput {
  135327. /** A */
  135328. A = 0,
  135329. /** B */
  135330. B = 1,
  135331. /** X */
  135332. X = 2,
  135333. /** Y */
  135334. Y = 3,
  135335. /** LB */
  135336. LB = 4,
  135337. /** RB */
  135338. RB = 5,
  135339. /** LT */
  135340. LT = 6,
  135341. /** RT */
  135342. RT = 7,
  135343. /** Back */
  135344. Back = 8,
  135345. /** Start */
  135346. Start = 9,
  135347. /** LS */
  135348. LS = 10,
  135349. /** RS */
  135350. RS = 11,
  135351. /** DPadUp */
  135352. DPadUp = 12,
  135353. /** DPadDown */
  135354. DPadDown = 13,
  135355. /** DPadLeft */
  135356. DPadLeft = 14,
  135357. /** DRight */
  135358. DPadRight = 15,
  135359. /** Home */
  135360. Home = 16,
  135361. /** LStickXAxis */
  135362. LStickXAxis = 17,
  135363. /** LStickYAxis */
  135364. LStickYAxis = 18,
  135365. /** RStickXAxis */
  135366. RStickXAxis = 19,
  135367. /** RStickYAxis */
  135368. RStickYAxis = 20
  135369. }
  135370. /**
  135371. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135372. */
  135373. export enum SwitchInput {
  135374. /** B */
  135375. B = 0,
  135376. /** A */
  135377. A = 1,
  135378. /** Y */
  135379. Y = 2,
  135380. /** X */
  135381. X = 3,
  135382. /** L */
  135383. L = 4,
  135384. /** R */
  135385. R = 5,
  135386. /** ZL */
  135387. ZL = 6,
  135388. /** ZR */
  135389. ZR = 7,
  135390. /** Minus */
  135391. Minus = 8,
  135392. /** Plus */
  135393. Plus = 9,
  135394. /** LS */
  135395. LS = 10,
  135396. /** RS */
  135397. RS = 11,
  135398. /** DPadUp */
  135399. DPadUp = 12,
  135400. /** DPadDown */
  135401. DPadDown = 13,
  135402. /** DPadLeft */
  135403. DPadLeft = 14,
  135404. /** DRight */
  135405. DPadRight = 15,
  135406. /** Home */
  135407. Home = 16,
  135408. /** Capture */
  135409. Capture = 17,
  135410. /** LStickXAxis */
  135411. LStickXAxis = 18,
  135412. /** LStickYAxis */
  135413. LStickYAxis = 19,
  135414. /** RStickXAxis */
  135415. RStickXAxis = 20,
  135416. /** RStickYAxis */
  135417. RStickYAxis = 21
  135418. }
  135419. }
  135420. declare module BABYLON {
  135421. /**
  135422. * This class will take all inputs from Keyboard, Pointer, and
  135423. * any Gamepads and provide a polling system that all devices
  135424. * will use. This class assumes that there will only be one
  135425. * pointer device and one keyboard.
  135426. */
  135427. export class DeviceInputSystem implements IDisposable {
  135428. /**
  135429. * Callback to be triggered when a device is connected
  135430. */
  135431. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135432. /**
  135433. * Callback to be triggered when a device is disconnected
  135434. */
  135435. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135436. /**
  135437. * Callback to be triggered when event driven input is updated
  135438. */
  135439. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135440. private _inputs;
  135441. private _gamepads;
  135442. private _keyboardActive;
  135443. private _pointerActive;
  135444. private _elementToAttachTo;
  135445. private _keyboardDownEvent;
  135446. private _keyboardUpEvent;
  135447. private _pointerMoveEvent;
  135448. private _pointerDownEvent;
  135449. private _pointerUpEvent;
  135450. private _gamepadConnectedEvent;
  135451. private _gamepadDisconnectedEvent;
  135452. private static _MAX_KEYCODES;
  135453. private static _MAX_POINTER_INPUTS;
  135454. private constructor();
  135455. /**
  135456. * Creates a new DeviceInputSystem instance
  135457. * @param engine Engine to pull input element from
  135458. * @returns The new instance
  135459. */
  135460. static Create(engine: Engine): DeviceInputSystem;
  135461. /**
  135462. * Checks for current device input value, given an id and input index
  135463. * @param deviceName Id of connected device
  135464. * @param inputIndex Index of device input
  135465. * @returns Current value of input
  135466. */
  135467. /**
  135468. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135469. * @param deviceType Enum specifiying device type
  135470. * @param deviceSlot "Slot" or index that device is referenced in
  135471. * @param inputIndex Id of input to be checked
  135472. * @returns Current value of input
  135473. */
  135474. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135475. /**
  135476. * Dispose of all the eventlisteners
  135477. */
  135478. dispose(): void;
  135479. /**
  135480. * Add device and inputs to device array
  135481. * @param deviceType Enum specifiying device type
  135482. * @param deviceSlot "Slot" or index that device is referenced in
  135483. * @param numberOfInputs Number of input entries to create for given device
  135484. */
  135485. private _registerDevice;
  135486. /**
  135487. * Given a specific device name, remove that device from the device map
  135488. * @param deviceType Enum specifiying device type
  135489. * @param deviceSlot "Slot" or index that device is referenced in
  135490. */
  135491. private _unregisterDevice;
  135492. /**
  135493. * Handle all actions that come from keyboard interaction
  135494. */
  135495. private _handleKeyActions;
  135496. /**
  135497. * Handle all actions that come from pointer interaction
  135498. */
  135499. private _handlePointerActions;
  135500. /**
  135501. * Handle all actions that come from gamepad interaction
  135502. */
  135503. private _handleGamepadActions;
  135504. /**
  135505. * Update all non-event based devices with each frame
  135506. * @param deviceType Enum specifiying device type
  135507. * @param deviceSlot "Slot" or index that device is referenced in
  135508. * @param inputIndex Id of input to be checked
  135509. */
  135510. private _updateDevice;
  135511. /**
  135512. * Gets DeviceType from the device name
  135513. * @param deviceName Name of Device from DeviceInputSystem
  135514. * @returns DeviceType enum value
  135515. */
  135516. private _getGamepadDeviceType;
  135517. }
  135518. }
  135519. declare module BABYLON {
  135520. /**
  135521. * Type to handle enforcement of inputs
  135522. */
  135523. 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;
  135524. }
  135525. declare module BABYLON {
  135526. /**
  135527. * Class that handles all input for a specific device
  135528. */
  135529. export class DeviceSource<T extends DeviceType> {
  135530. /** Type of device */
  135531. readonly deviceType: DeviceType;
  135532. /** "Slot" or index that device is referenced in */
  135533. readonly deviceSlot: number;
  135534. /**
  135535. * Observable to handle device input changes per device
  135536. */
  135537. readonly onInputChangedObservable: Observable<{
  135538. inputIndex: DeviceInput<T>;
  135539. previousState: Nullable<number>;
  135540. currentState: Nullable<number>;
  135541. }>;
  135542. private readonly _deviceInputSystem;
  135543. /**
  135544. * Default Constructor
  135545. * @param deviceInputSystem Reference to DeviceInputSystem
  135546. * @param deviceType Type of device
  135547. * @param deviceSlot "Slot" or index that device is referenced in
  135548. */
  135549. constructor(deviceInputSystem: DeviceInputSystem,
  135550. /** Type of device */
  135551. deviceType: DeviceType,
  135552. /** "Slot" or index that device is referenced in */
  135553. deviceSlot?: number);
  135554. /**
  135555. * Get input for specific input
  135556. * @param inputIndex index of specific input on device
  135557. * @returns Input value from DeviceInputSystem
  135558. */
  135559. getInput(inputIndex: DeviceInput<T>): number;
  135560. }
  135561. /**
  135562. * Class to keep track of devices
  135563. */
  135564. export class DeviceSourceManager implements IDisposable {
  135565. /**
  135566. * Observable to be triggered when before a device is connected
  135567. */
  135568. readonly onBeforeDeviceConnectedObservable: Observable<{
  135569. deviceType: DeviceType;
  135570. deviceSlot: number;
  135571. }>;
  135572. /**
  135573. * Observable to be triggered when before a device is disconnected
  135574. */
  135575. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135576. deviceType: DeviceType;
  135577. deviceSlot: number;
  135578. }>;
  135579. /**
  135580. * Observable to be triggered when after a device is connected
  135581. */
  135582. readonly onAfterDeviceConnectedObservable: Observable<{
  135583. deviceType: DeviceType;
  135584. deviceSlot: number;
  135585. }>;
  135586. /**
  135587. * Observable to be triggered when after a device is disconnected
  135588. */
  135589. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135590. deviceType: DeviceType;
  135591. deviceSlot: number;
  135592. }>;
  135593. private readonly _devices;
  135594. private readonly _firstDevice;
  135595. private readonly _deviceInputSystem;
  135596. /**
  135597. * Default Constructor
  135598. * @param engine engine to pull input element from
  135599. */
  135600. constructor(engine: Engine);
  135601. /**
  135602. * Gets a DeviceSource, given a type and slot
  135603. * @param deviceType Enum specifying device type
  135604. * @param deviceSlot "Slot" or index that device is referenced in
  135605. * @returns DeviceSource object
  135606. */
  135607. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135608. /**
  135609. * Gets an array of DeviceSource objects for a given device type
  135610. * @param deviceType Enum specifying device type
  135611. * @returns Array of DeviceSource objects
  135612. */
  135613. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135614. /**
  135615. * Dispose of DeviceInputSystem and other parts
  135616. */
  135617. dispose(): void;
  135618. /**
  135619. * Function to add device name to device list
  135620. * @param deviceType Enum specifying device type
  135621. * @param deviceSlot "Slot" or index that device is referenced in
  135622. */
  135623. private _addDevice;
  135624. /**
  135625. * Function to remove device name to device list
  135626. * @param deviceType Enum specifying device type
  135627. * @param deviceSlot "Slot" or index that device is referenced in
  135628. */
  135629. private _removeDevice;
  135630. /**
  135631. * Updates array storing first connected device of each type
  135632. * @param type Type of Device
  135633. */
  135634. private _updateFirstDevices;
  135635. }
  135636. }
  135637. declare module BABYLON {
  135638. /**
  135639. * Options to create the null engine
  135640. */
  135641. export class NullEngineOptions {
  135642. /**
  135643. * Render width (Default: 512)
  135644. */
  135645. renderWidth: number;
  135646. /**
  135647. * Render height (Default: 256)
  135648. */
  135649. renderHeight: number;
  135650. /**
  135651. * Texture size (Default: 512)
  135652. */
  135653. textureSize: number;
  135654. /**
  135655. * If delta time between frames should be constant
  135656. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135657. */
  135658. deterministicLockstep: boolean;
  135659. /**
  135660. * Maximum about of steps between frames (Default: 4)
  135661. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135662. */
  135663. lockstepMaxSteps: number;
  135664. /**
  135665. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135666. */
  135667. useHighPrecisionMatrix?: boolean;
  135668. }
  135669. /**
  135670. * The null engine class provides support for headless version of babylon.js.
  135671. * This can be used in server side scenario or for testing purposes
  135672. */
  135673. export class NullEngine extends Engine {
  135674. private _options;
  135675. /**
  135676. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135677. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135678. * @returns true if engine is in deterministic lock step mode
  135679. */
  135680. isDeterministicLockStep(): boolean;
  135681. /**
  135682. * Gets the max steps when engine is running in deterministic lock step
  135683. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135684. * @returns the max steps
  135685. */
  135686. getLockstepMaxSteps(): number;
  135687. /**
  135688. * Gets the current hardware scaling level.
  135689. * By default the hardware scaling level is computed from the window device ratio.
  135690. * 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.
  135691. * @returns a number indicating the current hardware scaling level
  135692. */
  135693. getHardwareScalingLevel(): number;
  135694. constructor(options?: NullEngineOptions);
  135695. /**
  135696. * Creates a vertex buffer
  135697. * @param vertices the data for the vertex buffer
  135698. * @returns the new WebGL static buffer
  135699. */
  135700. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135701. /**
  135702. * Creates a new index buffer
  135703. * @param indices defines the content of the index buffer
  135704. * @param updatable defines if the index buffer must be updatable
  135705. * @returns a new webGL buffer
  135706. */
  135707. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135708. /**
  135709. * Clear the current render buffer or the current render target (if any is set up)
  135710. * @param color defines the color to use
  135711. * @param backBuffer defines if the back buffer must be cleared
  135712. * @param depth defines if the depth buffer must be cleared
  135713. * @param stencil defines if the stencil buffer must be cleared
  135714. */
  135715. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135716. /**
  135717. * Gets the current render width
  135718. * @param useScreen defines if screen size must be used (or the current render target if any)
  135719. * @returns a number defining the current render width
  135720. */
  135721. getRenderWidth(useScreen?: boolean): number;
  135722. /**
  135723. * Gets the current render height
  135724. * @param useScreen defines if screen size must be used (or the current render target if any)
  135725. * @returns a number defining the current render height
  135726. */
  135727. getRenderHeight(useScreen?: boolean): number;
  135728. /**
  135729. * Set the WebGL's viewport
  135730. * @param viewport defines the viewport element to be used
  135731. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135732. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135733. */
  135734. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135735. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135736. /**
  135737. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135738. * @param pipelineContext defines the pipeline context to use
  135739. * @param uniformsNames defines the list of uniform names
  135740. * @returns an array of webGL uniform locations
  135741. */
  135742. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135743. /**
  135744. * Gets the lsit of active attributes for a given webGL program
  135745. * @param pipelineContext defines the pipeline context to use
  135746. * @param attributesNames defines the list of attribute names to get
  135747. * @returns an array of indices indicating the offset of each attribute
  135748. */
  135749. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135750. /**
  135751. * Binds an effect to the webGL context
  135752. * @param effect defines the effect to bind
  135753. */
  135754. bindSamplers(effect: Effect): void;
  135755. /**
  135756. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135757. * @param effect defines the effect to activate
  135758. */
  135759. enableEffect(effect: Effect): void;
  135760. /**
  135761. * Set various states to the webGL context
  135762. * @param culling defines backface culling state
  135763. * @param zOffset defines the value to apply to zOffset (0 by default)
  135764. * @param force defines if states must be applied even if cache is up to date
  135765. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135766. */
  135767. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135768. /**
  135769. * Set the value of an uniform to an array of int32
  135770. * @param uniform defines the webGL uniform location where to store the value
  135771. * @param array defines the array of int32 to store
  135772. * @returns true if value was set
  135773. */
  135774. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135775. /**
  135776. * Set the value of an uniform to an array of int32 (stored as vec2)
  135777. * @param uniform defines the webGL uniform location where to store the value
  135778. * @param array defines the array of int32 to store
  135779. * @returns true if value was set
  135780. */
  135781. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135782. /**
  135783. * Set the value of an uniform to an array of int32 (stored as vec3)
  135784. * @param uniform defines the webGL uniform location where to store the value
  135785. * @param array defines the array of int32 to store
  135786. * @returns true if value was set
  135787. */
  135788. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135789. /**
  135790. * Set the value of an uniform to an array of int32 (stored as vec4)
  135791. * @param uniform defines the webGL uniform location where to store the value
  135792. * @param array defines the array of int32 to store
  135793. * @returns true if value was set
  135794. */
  135795. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135796. /**
  135797. * Set the value of an uniform to an array of float32
  135798. * @param uniform defines the webGL uniform location where to store the value
  135799. * @param array defines the array of float32 to store
  135800. * @returns true if value was set
  135801. */
  135802. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135803. /**
  135804. * Set the value of an uniform to an array of float32 (stored as vec2)
  135805. * @param uniform defines the webGL uniform location where to store the value
  135806. * @param array defines the array of float32 to store
  135807. * @returns true if value was set
  135808. */
  135809. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135810. /**
  135811. * Set the value of an uniform to an array of float32 (stored as vec3)
  135812. * @param uniform defines the webGL uniform location where to store the value
  135813. * @param array defines the array of float32 to store
  135814. * @returns true if value was set
  135815. */
  135816. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135817. /**
  135818. * Set the value of an uniform to an array of float32 (stored as vec4)
  135819. * @param uniform defines the webGL uniform location where to store the value
  135820. * @param array defines the array of float32 to store
  135821. * @returns true if value was set
  135822. */
  135823. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135824. /**
  135825. * Set the value of an uniform to an array of number
  135826. * @param uniform defines the webGL uniform location where to store the value
  135827. * @param array defines the array of number to store
  135828. * @returns true if value was set
  135829. */
  135830. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135831. /**
  135832. * Set the value of an uniform to an array of number (stored as vec2)
  135833. * @param uniform defines the webGL uniform location where to store the value
  135834. * @param array defines the array of number to store
  135835. * @returns true if value was set
  135836. */
  135837. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135838. /**
  135839. * Set the value of an uniform to an array of number (stored as vec3)
  135840. * @param uniform defines the webGL uniform location where to store the value
  135841. * @param array defines the array of number to store
  135842. * @returns true if value was set
  135843. */
  135844. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135845. /**
  135846. * Set the value of an uniform to an array of number (stored as vec4)
  135847. * @param uniform defines the webGL uniform location where to store the value
  135848. * @param array defines the array of number to store
  135849. * @returns true if value was set
  135850. */
  135851. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135852. /**
  135853. * Set the value of an uniform to an array of float32 (stored as matrices)
  135854. * @param uniform defines the webGL uniform location where to store the value
  135855. * @param matrices defines the array of float32 to store
  135856. * @returns true if value was set
  135857. */
  135858. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135859. /**
  135860. * Set the value of an uniform to a matrix (3x3)
  135861. * @param uniform defines the webGL uniform location where to store the value
  135862. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135863. * @returns true if value was set
  135864. */
  135865. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135866. /**
  135867. * Set the value of an uniform to a matrix (2x2)
  135868. * @param uniform defines the webGL uniform location where to store the value
  135869. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135870. * @returns true if value was set
  135871. */
  135872. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135873. /**
  135874. * Set the value of an uniform to a number (float)
  135875. * @param uniform defines the webGL uniform location where to store the value
  135876. * @param value defines the float number to store
  135877. * @returns true if value was set
  135878. */
  135879. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135880. /**
  135881. * Set the value of an uniform to a vec2
  135882. * @param uniform defines the webGL uniform location where to store the value
  135883. * @param x defines the 1st component of the value
  135884. * @param y defines the 2nd component of the value
  135885. * @returns true if value was set
  135886. */
  135887. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135888. /**
  135889. * Set the value of an uniform to a vec3
  135890. * @param uniform defines the webGL uniform location where to store the value
  135891. * @param x defines the 1st component of the value
  135892. * @param y defines the 2nd component of the value
  135893. * @param z defines the 3rd component of the value
  135894. * @returns true if value was set
  135895. */
  135896. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135897. /**
  135898. * Set the value of an uniform to a boolean
  135899. * @param uniform defines the webGL uniform location where to store the value
  135900. * @param bool defines the boolean to store
  135901. * @returns true if value was set
  135902. */
  135903. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135904. /**
  135905. * Set the value of an uniform to a vec4
  135906. * @param uniform defines the webGL uniform location where to store the value
  135907. * @param x defines the 1st component of the value
  135908. * @param y defines the 2nd component of the value
  135909. * @param z defines the 3rd component of the value
  135910. * @param w defines the 4th component of the value
  135911. * @returns true if value was set
  135912. */
  135913. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135914. /**
  135915. * Sets the current alpha mode
  135916. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135917. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135918. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135919. */
  135920. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135921. /**
  135922. * Bind webGl buffers directly to the webGL context
  135923. * @param vertexBuffers defines the vertex buffer to bind
  135924. * @param indexBuffer defines the index buffer to bind
  135925. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135926. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135927. * @param effect defines the effect associated with the vertex buffer
  135928. */
  135929. bindBuffers(vertexBuffers: {
  135930. [key: string]: VertexBuffer;
  135931. }, indexBuffer: DataBuffer, effect: Effect): void;
  135932. /**
  135933. * Force the entire cache to be cleared
  135934. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135935. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135936. */
  135937. wipeCaches(bruteForce?: boolean): void;
  135938. /**
  135939. * Send a draw order
  135940. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135941. * @param indexStart defines the starting index
  135942. * @param indexCount defines the number of index to draw
  135943. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135944. */
  135945. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135946. /**
  135947. * Draw a list of indexed primitives
  135948. * @param fillMode defines the primitive to use
  135949. * @param indexStart defines the starting index
  135950. * @param indexCount defines the number of index to draw
  135951. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135952. */
  135953. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135954. /**
  135955. * Draw a list of unindexed primitives
  135956. * @param fillMode defines the primitive to use
  135957. * @param verticesStart defines the index of first vertex to draw
  135958. * @param verticesCount defines the count of vertices to draw
  135959. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135960. */
  135961. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135962. /** @hidden */
  135963. _createTexture(): WebGLTexture;
  135964. /** @hidden */
  135965. _releaseTexture(texture: InternalTexture): void;
  135966. /**
  135967. * Usually called from Texture.ts.
  135968. * Passed information to create a WebGLTexture
  135969. * @param urlArg defines a value which contains one of the following:
  135970. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135971. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135972. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135973. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135974. * @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)
  135975. * @param scene needed for loading to the correct scene
  135976. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  135977. * @param onLoad optional callback to be called upon successful completion
  135978. * @param onError optional callback to be called upon failure
  135979. * @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
  135980. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  135981. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  135982. * @param forcedExtension defines the extension to use to pick the right loader
  135983. * @param mimeType defines an optional mime type
  135984. * @returns a InternalTexture for assignment back into BABYLON.Texture
  135985. */
  135986. 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;
  135987. /**
  135988. * Creates a new render target texture
  135989. * @param size defines the size of the texture
  135990. * @param options defines the options used to create the texture
  135991. * @returns a new render target texture stored in an InternalTexture
  135992. */
  135993. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  135994. /**
  135995. * Update the sampling mode of a given texture
  135996. * @param samplingMode defines the required sampling mode
  135997. * @param texture defines the texture to update
  135998. */
  135999. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136000. /**
  136001. * Binds the frame buffer to the specified texture.
  136002. * @param texture The texture to render to or null for the default canvas
  136003. * @param faceIndex The face of the texture to render to in case of cube texture
  136004. * @param requiredWidth The width of the target to render to
  136005. * @param requiredHeight The height of the target to render to
  136006. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136007. * @param lodLevel defines le lod level to bind to the frame buffer
  136008. */
  136009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136010. /**
  136011. * Unbind the current render target texture from the webGL context
  136012. * @param texture defines the render target texture to unbind
  136013. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136014. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136015. */
  136016. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136017. /**
  136018. * Creates a dynamic vertex buffer
  136019. * @param vertices the data for the dynamic vertex buffer
  136020. * @returns the new WebGL dynamic buffer
  136021. */
  136022. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136023. /**
  136024. * Update the content of a dynamic texture
  136025. * @param texture defines the texture to update
  136026. * @param canvas defines the canvas containing the source
  136027. * @param invertY defines if data must be stored with Y axis inverted
  136028. * @param premulAlpha defines if alpha is stored as premultiplied
  136029. * @param format defines the format of the data
  136030. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136031. */
  136032. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136033. /**
  136034. * Gets a boolean indicating if all created effects are ready
  136035. * @returns true if all effects are ready
  136036. */
  136037. areAllEffectsReady(): boolean;
  136038. /**
  136039. * @hidden
  136040. * Get the current error code of the webGL context
  136041. * @returns the error code
  136042. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136043. */
  136044. getError(): number;
  136045. /** @hidden */
  136046. _getUnpackAlignement(): number;
  136047. /** @hidden */
  136048. _unpackFlipY(value: boolean): void;
  136049. /**
  136050. * Update a dynamic index buffer
  136051. * @param indexBuffer defines the target index buffer
  136052. * @param indices defines the data to update
  136053. * @param offset defines the offset in the target index buffer where update should start
  136054. */
  136055. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136056. /**
  136057. * Updates a dynamic vertex buffer.
  136058. * @param vertexBuffer the vertex buffer to update
  136059. * @param vertices the data used to update the vertex buffer
  136060. * @param byteOffset the byte offset of the data (optional)
  136061. * @param byteLength the byte length of the data (optional)
  136062. */
  136063. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136064. /** @hidden */
  136065. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136066. /** @hidden */
  136067. _bindTexture(channel: number, texture: InternalTexture): void;
  136068. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136069. /**
  136070. * 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
  136071. */
  136072. releaseEffects(): void;
  136073. displayLoadingUI(): void;
  136074. hideLoadingUI(): void;
  136075. /** @hidden */
  136076. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136077. /** @hidden */
  136078. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136079. /** @hidden */
  136080. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136081. /** @hidden */
  136082. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136083. }
  136084. }
  136085. declare module BABYLON {
  136086. /**
  136087. * @hidden
  136088. **/
  136089. export class _TimeToken {
  136090. _startTimeQuery: Nullable<WebGLQuery>;
  136091. _endTimeQuery: Nullable<WebGLQuery>;
  136092. _timeElapsedQuery: Nullable<WebGLQuery>;
  136093. _timeElapsedQueryEnded: boolean;
  136094. }
  136095. }
  136096. declare module BABYLON {
  136097. /** @hidden */
  136098. export class _OcclusionDataStorage {
  136099. /** @hidden */
  136100. occlusionInternalRetryCounter: number;
  136101. /** @hidden */
  136102. isOcclusionQueryInProgress: boolean;
  136103. /** @hidden */
  136104. isOccluded: boolean;
  136105. /** @hidden */
  136106. occlusionRetryCount: number;
  136107. /** @hidden */
  136108. occlusionType: number;
  136109. /** @hidden */
  136110. occlusionQueryAlgorithmType: number;
  136111. }
  136112. interface Engine {
  136113. /**
  136114. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136115. * @return the new query
  136116. */
  136117. createQuery(): WebGLQuery;
  136118. /**
  136119. * Delete and release a webGL query
  136120. * @param query defines the query to delete
  136121. * @return the current engine
  136122. */
  136123. deleteQuery(query: WebGLQuery): Engine;
  136124. /**
  136125. * Check if a given query has resolved and got its value
  136126. * @param query defines the query to check
  136127. * @returns true if the query got its value
  136128. */
  136129. isQueryResultAvailable(query: WebGLQuery): boolean;
  136130. /**
  136131. * Gets the value of a given query
  136132. * @param query defines the query to check
  136133. * @returns the value of the query
  136134. */
  136135. getQueryResult(query: WebGLQuery): number;
  136136. /**
  136137. * Initiates an occlusion query
  136138. * @param algorithmType defines the algorithm to use
  136139. * @param query defines the query to use
  136140. * @returns the current engine
  136141. * @see https://doc.babylonjs.com/features/occlusionquery
  136142. */
  136143. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136144. /**
  136145. * Ends an occlusion query
  136146. * @see https://doc.babylonjs.com/features/occlusionquery
  136147. * @param algorithmType defines the algorithm to use
  136148. * @returns the current engine
  136149. */
  136150. endOcclusionQuery(algorithmType: number): Engine;
  136151. /**
  136152. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136153. * Please note that only one query can be issued at a time
  136154. * @returns a time token used to track the time span
  136155. */
  136156. startTimeQuery(): Nullable<_TimeToken>;
  136157. /**
  136158. * Ends a time query
  136159. * @param token defines the token used to measure the time span
  136160. * @returns the time spent (in ns)
  136161. */
  136162. endTimeQuery(token: _TimeToken): int;
  136163. /** @hidden */
  136164. _currentNonTimestampToken: Nullable<_TimeToken>;
  136165. /** @hidden */
  136166. _createTimeQuery(): WebGLQuery;
  136167. /** @hidden */
  136168. _deleteTimeQuery(query: WebGLQuery): void;
  136169. /** @hidden */
  136170. _getGlAlgorithmType(algorithmType: number): number;
  136171. /** @hidden */
  136172. _getTimeQueryResult(query: WebGLQuery): any;
  136173. /** @hidden */
  136174. _getTimeQueryAvailability(query: WebGLQuery): any;
  136175. }
  136176. interface AbstractMesh {
  136177. /**
  136178. * Backing filed
  136179. * @hidden
  136180. */
  136181. __occlusionDataStorage: _OcclusionDataStorage;
  136182. /**
  136183. * Access property
  136184. * @hidden
  136185. */
  136186. _occlusionDataStorage: _OcclusionDataStorage;
  136187. /**
  136188. * 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.
  136189. * The default value is -1 which means don't break the query and wait till the result
  136190. * @see https://doc.babylonjs.com/features/occlusionquery
  136191. */
  136192. occlusionRetryCount: number;
  136193. /**
  136194. * 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:
  136195. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136196. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136197. * * 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.
  136198. * @see https://doc.babylonjs.com/features/occlusionquery
  136199. */
  136200. occlusionType: number;
  136201. /**
  136202. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136203. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136204. * * 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.
  136205. * @see https://doc.babylonjs.com/features/occlusionquery
  136206. */
  136207. occlusionQueryAlgorithmType: number;
  136208. /**
  136209. * 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
  136210. * @see https://doc.babylonjs.com/features/occlusionquery
  136211. */
  136212. isOccluded: boolean;
  136213. /**
  136214. * Flag to check the progress status of the query
  136215. * @see https://doc.babylonjs.com/features/occlusionquery
  136216. */
  136217. isOcclusionQueryInProgress: boolean;
  136218. }
  136219. }
  136220. declare module BABYLON {
  136221. /** @hidden */
  136222. export var _forceTransformFeedbackToBundle: boolean;
  136223. interface Engine {
  136224. /**
  136225. * Creates a webGL transform feedback object
  136226. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136227. * @returns the webGL transform feedback object
  136228. */
  136229. createTransformFeedback(): WebGLTransformFeedback;
  136230. /**
  136231. * Delete a webGL transform feedback object
  136232. * @param value defines the webGL transform feedback object to delete
  136233. */
  136234. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136235. /**
  136236. * Bind a webGL transform feedback object to the webgl context
  136237. * @param value defines the webGL transform feedback object to bind
  136238. */
  136239. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136240. /**
  136241. * Begins a transform feedback operation
  136242. * @param usePoints defines if points or triangles must be used
  136243. */
  136244. beginTransformFeedback(usePoints: boolean): void;
  136245. /**
  136246. * Ends a transform feedback operation
  136247. */
  136248. endTransformFeedback(): void;
  136249. /**
  136250. * Specify the varyings to use with transform feedback
  136251. * @param program defines the associated webGL program
  136252. * @param value defines the list of strings representing the varying names
  136253. */
  136254. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136255. /**
  136256. * Bind a webGL buffer for a transform feedback operation
  136257. * @param value defines the webGL buffer to bind
  136258. */
  136259. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136260. }
  136261. }
  136262. declare module BABYLON {
  136263. /**
  136264. * Class used to define an additional view for the engine
  136265. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136266. */
  136267. export class EngineView {
  136268. /** Defines the canvas where to render the view */
  136269. target: HTMLCanvasElement;
  136270. /** Defines an optional camera used to render the view (will use active camera else) */
  136271. camera?: Camera;
  136272. }
  136273. interface Engine {
  136274. /**
  136275. * Gets or sets the HTML element to use for attaching events
  136276. */
  136277. inputElement: Nullable<HTMLElement>;
  136278. /**
  136279. * Gets the current engine view
  136280. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136281. */
  136282. activeView: Nullable<EngineView>;
  136283. /** Gets or sets the list of views */
  136284. views: EngineView[];
  136285. /**
  136286. * Register a new child canvas
  136287. * @param canvas defines the canvas to register
  136288. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136289. * @returns the associated view
  136290. */
  136291. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136292. /**
  136293. * Remove a registered child canvas
  136294. * @param canvas defines the canvas to remove
  136295. * @returns the current engine
  136296. */
  136297. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136298. }
  136299. }
  136300. declare module BABYLON {
  136301. interface Engine {
  136302. /** @hidden */
  136303. _excludedCompressedTextures: string[];
  136304. /** @hidden */
  136305. _textureFormatInUse: string;
  136306. /**
  136307. * Gets the list of texture formats supported
  136308. */
  136309. readonly texturesSupported: Array<string>;
  136310. /**
  136311. * Gets the texture format in use
  136312. */
  136313. readonly textureFormatInUse: Nullable<string>;
  136314. /**
  136315. * Set the compressed texture extensions or file names to skip.
  136316. *
  136317. * @param skippedFiles defines the list of those texture files you want to skip
  136318. * Example: [".dds", ".env", "myfile.png"]
  136319. */
  136320. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136321. /**
  136322. * Set the compressed texture format to use, based on the formats you have, and the formats
  136323. * supported by the hardware / browser.
  136324. *
  136325. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136326. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136327. * to API arguments needed to compressed textures. This puts the burden on the container
  136328. * generator to house the arcane code for determining these for current & future formats.
  136329. *
  136330. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136331. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136332. *
  136333. * Note: The result of this call is not taken into account when a texture is base64.
  136334. *
  136335. * @param formatsAvailable defines the list of those format families you have created
  136336. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136337. *
  136338. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136339. * @returns The extension selected.
  136340. */
  136341. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136342. }
  136343. }
  136344. declare module BABYLON {
  136345. /** @hidden */
  136346. export var rgbdEncodePixelShader: {
  136347. name: string;
  136348. shader: string;
  136349. };
  136350. }
  136351. declare module BABYLON {
  136352. /**
  136353. * Raw texture data and descriptor sufficient for WebGL texture upload
  136354. */
  136355. export interface EnvironmentTextureInfo {
  136356. /**
  136357. * Version of the environment map
  136358. */
  136359. version: number;
  136360. /**
  136361. * Width of image
  136362. */
  136363. width: number;
  136364. /**
  136365. * Irradiance information stored in the file.
  136366. */
  136367. irradiance: any;
  136368. /**
  136369. * Specular information stored in the file.
  136370. */
  136371. specular: any;
  136372. }
  136373. /**
  136374. * Defines One Image in the file. It requires only the position in the file
  136375. * as well as the length.
  136376. */
  136377. interface BufferImageData {
  136378. /**
  136379. * Length of the image data.
  136380. */
  136381. length: number;
  136382. /**
  136383. * Position of the data from the null terminator delimiting the end of the JSON.
  136384. */
  136385. position: number;
  136386. }
  136387. /**
  136388. * Defines the specular data enclosed in the file.
  136389. * This corresponds to the version 1 of the data.
  136390. */
  136391. export interface EnvironmentTextureSpecularInfoV1 {
  136392. /**
  136393. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136394. */
  136395. specularDataPosition?: number;
  136396. /**
  136397. * This contains all the images data needed to reconstruct the cubemap.
  136398. */
  136399. mipmaps: Array<BufferImageData>;
  136400. /**
  136401. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136402. */
  136403. lodGenerationScale: number;
  136404. }
  136405. /**
  136406. * Sets of helpers addressing the serialization and deserialization of environment texture
  136407. * stored in a BabylonJS env file.
  136408. * Those files are usually stored as .env files.
  136409. */
  136410. export class EnvironmentTextureTools {
  136411. /**
  136412. * Magic number identifying the env file.
  136413. */
  136414. private static _MagicBytes;
  136415. /**
  136416. * Gets the environment info from an env file.
  136417. * @param data The array buffer containing the .env bytes.
  136418. * @returns the environment file info (the json header) if successfully parsed.
  136419. */
  136420. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136421. /**
  136422. * Creates an environment texture from a loaded cube texture.
  136423. * @param texture defines the cube texture to convert in env file
  136424. * @return a promise containing the environment data if succesfull.
  136425. */
  136426. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136427. /**
  136428. * Creates a JSON representation of the spherical data.
  136429. * @param texture defines the texture containing the polynomials
  136430. * @return the JSON representation of the spherical info
  136431. */
  136432. private static _CreateEnvTextureIrradiance;
  136433. /**
  136434. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136435. * @param data the image data
  136436. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136437. * @return the views described by info providing access to the underlying buffer
  136438. */
  136439. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136440. /**
  136441. * Uploads the texture info contained in the env file to the GPU.
  136442. * @param texture defines the internal texture to upload to
  136443. * @param data defines the data to load
  136444. * @param info defines the texture info retrieved through the GetEnvInfo method
  136445. * @returns a promise
  136446. */
  136447. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136448. private static _OnImageReadyAsync;
  136449. /**
  136450. * Uploads the levels of image data to the GPU.
  136451. * @param texture defines the internal texture to upload to
  136452. * @param imageData defines the array buffer views of image data [mipmap][face]
  136453. * @returns a promise
  136454. */
  136455. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136456. /**
  136457. * Uploads spherical polynomials information to the texture.
  136458. * @param texture defines the texture we are trying to upload the information to
  136459. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136460. */
  136461. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136462. /** @hidden */
  136463. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136464. }
  136465. }
  136466. declare module BABYLON {
  136467. /**
  136468. * Class used to inline functions in shader code
  136469. */
  136470. export class ShaderCodeInliner {
  136471. private static readonly _RegexpFindFunctionNameAndType;
  136472. private _sourceCode;
  136473. private _functionDescr;
  136474. private _numMaxIterations;
  136475. /** Gets or sets the token used to mark the functions to inline */
  136476. inlineToken: string;
  136477. /** Gets or sets the debug mode */
  136478. debug: boolean;
  136479. /** Gets the code after the inlining process */
  136480. get code(): string;
  136481. /**
  136482. * Initializes the inliner
  136483. * @param sourceCode shader code source to inline
  136484. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136485. */
  136486. constructor(sourceCode: string, numMaxIterations?: number);
  136487. /**
  136488. * Start the processing of the shader code
  136489. */
  136490. processCode(): void;
  136491. private _collectFunctions;
  136492. private _processInlining;
  136493. private _extractBetweenMarkers;
  136494. private _skipWhitespaces;
  136495. private _removeComments;
  136496. private _replaceFunctionCallsByCode;
  136497. private _findBackward;
  136498. private _escapeRegExp;
  136499. private _replaceNames;
  136500. }
  136501. }
  136502. declare module BABYLON {
  136503. /**
  136504. * Container for accessors for natively-stored mesh data buffers.
  136505. */
  136506. class NativeDataBuffer extends DataBuffer {
  136507. /**
  136508. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136509. */
  136510. nativeIndexBuffer?: any;
  136511. /**
  136512. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136513. */
  136514. nativeVertexBuffer?: any;
  136515. }
  136516. /** @hidden */
  136517. class NativeTexture extends InternalTexture {
  136518. getInternalTexture(): InternalTexture;
  136519. getViewCount(): number;
  136520. }
  136521. /** @hidden */
  136522. export class NativeEngine extends Engine {
  136523. private readonly _native;
  136524. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136525. private readonly INVALID_HANDLE;
  136526. private _boundBuffersVertexArray;
  136527. private _currentDepthTest;
  136528. getHardwareScalingLevel(): number;
  136529. constructor();
  136530. dispose(): void;
  136531. /**
  136532. * Can be used to override the current requestAnimationFrame requester.
  136533. * @hidden
  136534. */
  136535. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136536. /**
  136537. * Override default engine behavior.
  136538. * @param color
  136539. * @param backBuffer
  136540. * @param depth
  136541. * @param stencil
  136542. */
  136543. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136544. /**
  136545. * Gets host document
  136546. * @returns the host document object
  136547. */
  136548. getHostDocument(): Nullable<Document>;
  136549. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136550. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136551. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136552. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136553. [key: string]: VertexBuffer;
  136554. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136555. bindBuffers(vertexBuffers: {
  136556. [key: string]: VertexBuffer;
  136557. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136558. recordVertexArrayObject(vertexBuffers: {
  136559. [key: string]: VertexBuffer;
  136560. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136561. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136562. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136563. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136564. /**
  136565. * Draw a list of indexed primitives
  136566. * @param fillMode defines the primitive to use
  136567. * @param indexStart defines the starting index
  136568. * @param indexCount defines the number of index to draw
  136569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136570. */
  136571. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136572. /**
  136573. * Draw a list of unindexed primitives
  136574. * @param fillMode defines the primitive to use
  136575. * @param verticesStart defines the index of first vertex to draw
  136576. * @param verticesCount defines the count of vertices to draw
  136577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136578. */
  136579. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136580. createPipelineContext(): IPipelineContext;
  136581. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136582. /** @hidden */
  136583. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136584. /** @hidden */
  136585. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136586. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136587. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136588. protected _setProgram(program: WebGLProgram): void;
  136589. _releaseEffect(effect: Effect): void;
  136590. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136591. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136592. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136593. bindSamplers(effect: Effect): void;
  136594. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136595. getRenderWidth(useScreen?: boolean): number;
  136596. getRenderHeight(useScreen?: boolean): number;
  136597. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136598. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136599. /**
  136600. * Set the z offset to apply to current rendering
  136601. * @param value defines the offset to apply
  136602. */
  136603. setZOffset(value: number): void;
  136604. /**
  136605. * Gets the current value of the zOffset
  136606. * @returns the current zOffset state
  136607. */
  136608. getZOffset(): number;
  136609. /**
  136610. * Enable or disable depth buffering
  136611. * @param enable defines the state to set
  136612. */
  136613. setDepthBuffer(enable: boolean): void;
  136614. /**
  136615. * Gets a boolean indicating if depth writing is enabled
  136616. * @returns the current depth writing state
  136617. */
  136618. getDepthWrite(): boolean;
  136619. setDepthFunctionToGreater(): void;
  136620. setDepthFunctionToGreaterOrEqual(): void;
  136621. setDepthFunctionToLess(): void;
  136622. setDepthFunctionToLessOrEqual(): void;
  136623. /**
  136624. * Enable or disable depth writing
  136625. * @param enable defines the state to set
  136626. */
  136627. setDepthWrite(enable: boolean): void;
  136628. /**
  136629. * Enable or disable color writing
  136630. * @param enable defines the state to set
  136631. */
  136632. setColorWrite(enable: boolean): void;
  136633. /**
  136634. * Gets a boolean indicating if color writing is enabled
  136635. * @returns the current color writing state
  136636. */
  136637. getColorWrite(): boolean;
  136638. /**
  136639. * Sets alpha constants used by some alpha blending modes
  136640. * @param r defines the red component
  136641. * @param g defines the green component
  136642. * @param b defines the blue component
  136643. * @param a defines the alpha component
  136644. */
  136645. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136646. /**
  136647. * Sets the current alpha mode
  136648. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136649. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136650. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136651. */
  136652. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136653. /**
  136654. * Gets the current alpha mode
  136655. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136656. * @returns the current alpha mode
  136657. */
  136658. getAlphaMode(): number;
  136659. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136660. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136661. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136662. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136663. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136664. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136665. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136666. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136667. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136668. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136669. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136670. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136671. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136672. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136673. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136674. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136675. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136676. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136677. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136678. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136679. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136680. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136681. wipeCaches(bruteForce?: boolean): void;
  136682. _createTexture(): WebGLTexture;
  136683. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136684. /**
  136685. * Update the content of a dynamic texture
  136686. * @param texture defines the texture to update
  136687. * @param canvas defines the canvas containing the source
  136688. * @param invertY defines if data must be stored with Y axis inverted
  136689. * @param premulAlpha defines if alpha is stored as premultiplied
  136690. * @param format defines the format of the data
  136691. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136692. */
  136693. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136694. /**
  136695. * Usually called from Texture.ts.
  136696. * Passed information to create a WebGLTexture
  136697. * @param url defines a value which contains one of the following:
  136698. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136699. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136700. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136702. * @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)
  136703. * @param scene needed for loading to the correct scene
  136704. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136705. * @param onLoad optional callback to be called upon successful completion
  136706. * @param onError optional callback to be called upon failure
  136707. * @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
  136708. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136709. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136710. * @param forcedExtension defines the extension to use to pick the right loader
  136711. * @param mimeType defines an optional mime type
  136712. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136713. */
  136714. 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;
  136715. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136716. _releaseFramebufferObjects(texture: InternalTexture): void;
  136717. /**
  136718. * Creates a cube texture
  136719. * @param rootUrl defines the url where the files to load is located
  136720. * @param scene defines the current scene
  136721. * @param files defines the list of files to load (1 per face)
  136722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136723. * @param onLoad defines an optional callback raised when the texture is loaded
  136724. * @param onError defines an optional callback raised if there is an issue to load the texture
  136725. * @param format defines the format of the data
  136726. * @param forcedExtension defines the extension to use to pick the right loader
  136727. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136728. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136729. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136730. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136731. * @returns the cube texture as an InternalTexture
  136732. */
  136733. 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;
  136734. createRenderTargetTexture(size: number | {
  136735. width: number;
  136736. height: number;
  136737. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136738. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136739. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136741. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136742. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136743. /**
  136744. * Updates a dynamic vertex buffer.
  136745. * @param vertexBuffer the vertex buffer to update
  136746. * @param data the data used to update the vertex buffer
  136747. * @param byteOffset the byte offset of the data (optional)
  136748. * @param byteLength the byte length of the data (optional)
  136749. */
  136750. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136751. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136752. private _updateAnisotropicLevel;
  136753. private _getAddressMode;
  136754. /** @hidden */
  136755. _bindTexture(channel: number, texture: InternalTexture): void;
  136756. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136757. releaseEffects(): void;
  136758. /** @hidden */
  136759. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136760. /** @hidden */
  136761. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136762. /** @hidden */
  136763. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136764. /** @hidden */
  136765. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136766. private _getNativeSamplingMode;
  136767. private _getNativeTextureFormat;
  136768. private _getNativeAlphaMode;
  136769. private _getNativeAttribType;
  136770. }
  136771. }
  136772. declare module BABYLON {
  136773. /**
  136774. * Gather the list of clipboard event types as constants.
  136775. */
  136776. export class ClipboardEventTypes {
  136777. /**
  136778. * The clipboard event is fired when a copy command is active (pressed).
  136779. */
  136780. static readonly COPY: number;
  136781. /**
  136782. * The clipboard event is fired when a cut command is active (pressed).
  136783. */
  136784. static readonly CUT: number;
  136785. /**
  136786. * The clipboard event is fired when a paste command is active (pressed).
  136787. */
  136788. static readonly PASTE: number;
  136789. }
  136790. /**
  136791. * This class is used to store clipboard related info for the onClipboardObservable event.
  136792. */
  136793. export class ClipboardInfo {
  136794. /**
  136795. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136796. */
  136797. type: number;
  136798. /**
  136799. * Defines the related dom event
  136800. */
  136801. event: ClipboardEvent;
  136802. /**
  136803. *Creates an instance of ClipboardInfo.
  136804. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136805. * @param event Defines the related dom event
  136806. */
  136807. constructor(
  136808. /**
  136809. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136810. */
  136811. type: number,
  136812. /**
  136813. * Defines the related dom event
  136814. */
  136815. event: ClipboardEvent);
  136816. /**
  136817. * Get the clipboard event's type from the keycode.
  136818. * @param keyCode Defines the keyCode for the current keyboard event.
  136819. * @return {number}
  136820. */
  136821. static GetTypeFromCharacter(keyCode: number): number;
  136822. }
  136823. }
  136824. declare module BABYLON {
  136825. /**
  136826. * Google Daydream controller
  136827. */
  136828. export class DaydreamController extends WebVRController {
  136829. /**
  136830. * Base Url for the controller model.
  136831. */
  136832. static MODEL_BASE_URL: string;
  136833. /**
  136834. * File name for the controller model.
  136835. */
  136836. static MODEL_FILENAME: string;
  136837. /**
  136838. * Gamepad Id prefix used to identify Daydream Controller.
  136839. */
  136840. static readonly GAMEPAD_ID_PREFIX: string;
  136841. /**
  136842. * Creates a new DaydreamController from a gamepad
  136843. * @param vrGamepad the gamepad that the controller should be created from
  136844. */
  136845. constructor(vrGamepad: any);
  136846. /**
  136847. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136848. * @param scene scene in which to add meshes
  136849. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136850. */
  136851. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136852. /**
  136853. * Called once for each button that changed state since the last frame
  136854. * @param buttonIdx Which button index changed
  136855. * @param state New state of the button
  136856. * @param changes Which properties on the state changed since last frame
  136857. */
  136858. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136859. }
  136860. }
  136861. declare module BABYLON {
  136862. /**
  136863. * Gear VR Controller
  136864. */
  136865. export class GearVRController extends WebVRController {
  136866. /**
  136867. * Base Url for the controller model.
  136868. */
  136869. static MODEL_BASE_URL: string;
  136870. /**
  136871. * File name for the controller model.
  136872. */
  136873. static MODEL_FILENAME: string;
  136874. /**
  136875. * Gamepad Id prefix used to identify this controller.
  136876. */
  136877. static readonly GAMEPAD_ID_PREFIX: string;
  136878. private readonly _buttonIndexToObservableNameMap;
  136879. /**
  136880. * Creates a new GearVRController from a gamepad
  136881. * @param vrGamepad the gamepad that the controller should be created from
  136882. */
  136883. constructor(vrGamepad: any);
  136884. /**
  136885. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136886. * @param scene scene in which to add meshes
  136887. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136888. */
  136889. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136890. /**
  136891. * Called once for each button that changed state since the last frame
  136892. * @param buttonIdx Which button index changed
  136893. * @param state New state of the button
  136894. * @param changes Which properties on the state changed since last frame
  136895. */
  136896. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136897. }
  136898. }
  136899. declare module BABYLON {
  136900. /**
  136901. * Generic Controller
  136902. */
  136903. export class GenericController extends WebVRController {
  136904. /**
  136905. * Base Url for the controller model.
  136906. */
  136907. static readonly MODEL_BASE_URL: string;
  136908. /**
  136909. * File name for the controller model.
  136910. */
  136911. static readonly MODEL_FILENAME: string;
  136912. /**
  136913. * Creates a new GenericController from a gamepad
  136914. * @param vrGamepad the gamepad that the controller should be created from
  136915. */
  136916. constructor(vrGamepad: any);
  136917. /**
  136918. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136919. * @param scene scene in which to add meshes
  136920. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136921. */
  136922. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136923. /**
  136924. * Called once for each button that changed state since the last frame
  136925. * @param buttonIdx Which button index changed
  136926. * @param state New state of the button
  136927. * @param changes Which properties on the state changed since last frame
  136928. */
  136929. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136930. }
  136931. }
  136932. declare module BABYLON {
  136933. /**
  136934. * Oculus Touch Controller
  136935. */
  136936. export class OculusTouchController extends WebVRController {
  136937. /**
  136938. * Base Url for the controller model.
  136939. */
  136940. static MODEL_BASE_URL: string;
  136941. /**
  136942. * File name for the left controller model.
  136943. */
  136944. static MODEL_LEFT_FILENAME: string;
  136945. /**
  136946. * File name for the right controller model.
  136947. */
  136948. static MODEL_RIGHT_FILENAME: string;
  136949. /**
  136950. * Base Url for the Quest controller model.
  136951. */
  136952. static QUEST_MODEL_BASE_URL: string;
  136953. /**
  136954. * @hidden
  136955. * If the controllers are running on a device that needs the updated Quest controller models
  136956. */
  136957. static _IsQuest: boolean;
  136958. /**
  136959. * Fired when the secondary trigger on this controller is modified
  136960. */
  136961. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136962. /**
  136963. * Fired when the thumb rest on this controller is modified
  136964. */
  136965. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136966. /**
  136967. * Creates a new OculusTouchController from a gamepad
  136968. * @param vrGamepad the gamepad that the controller should be created from
  136969. */
  136970. constructor(vrGamepad: any);
  136971. /**
  136972. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136973. * @param scene scene in which to add meshes
  136974. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136975. */
  136976. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136977. /**
  136978. * Fired when the A button on this controller is modified
  136979. */
  136980. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136981. /**
  136982. * Fired when the B button on this controller is modified
  136983. */
  136984. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136985. /**
  136986. * Fired when the X button on this controller is modified
  136987. */
  136988. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136989. /**
  136990. * Fired when the Y button on this controller is modified
  136991. */
  136992. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136993. /**
  136994. * Called once for each button that changed state since the last frame
  136995. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  136996. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  136997. * 2) secondary trigger (same)
  136998. * 3) A (right) X (left), touch, pressed = value
  136999. * 4) B / Y
  137000. * 5) thumb rest
  137001. * @param buttonIdx Which button index changed
  137002. * @param state New state of the button
  137003. * @param changes Which properties on the state changed since last frame
  137004. */
  137005. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137006. }
  137007. }
  137008. declare module BABYLON {
  137009. /**
  137010. * Vive Controller
  137011. */
  137012. export class ViveController extends WebVRController {
  137013. /**
  137014. * Base Url for the controller model.
  137015. */
  137016. static MODEL_BASE_URL: string;
  137017. /**
  137018. * File name for the controller model.
  137019. */
  137020. static MODEL_FILENAME: string;
  137021. /**
  137022. * Creates a new ViveController from a gamepad
  137023. * @param vrGamepad the gamepad that the controller should be created from
  137024. */
  137025. constructor(vrGamepad: any);
  137026. /**
  137027. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137028. * @param scene scene in which to add meshes
  137029. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137030. */
  137031. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137032. /**
  137033. * Fired when the left button on this controller is modified
  137034. */
  137035. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137036. /**
  137037. * Fired when the right button on this controller is modified
  137038. */
  137039. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137040. /**
  137041. * Fired when the menu button on this controller is modified
  137042. */
  137043. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137044. /**
  137045. * Called once for each button that changed state since the last frame
  137046. * Vive mapping:
  137047. * 0: touchpad
  137048. * 1: trigger
  137049. * 2: left AND right buttons
  137050. * 3: menu button
  137051. * @param buttonIdx Which button index changed
  137052. * @param state New state of the button
  137053. * @param changes Which properties on the state changed since last frame
  137054. */
  137055. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137056. }
  137057. }
  137058. declare module BABYLON {
  137059. /**
  137060. * Defines the WindowsMotionController object that the state of the windows motion controller
  137061. */
  137062. export class WindowsMotionController extends WebVRController {
  137063. /**
  137064. * The base url used to load the left and right controller models
  137065. */
  137066. static MODEL_BASE_URL: string;
  137067. /**
  137068. * The name of the left controller model file
  137069. */
  137070. static MODEL_LEFT_FILENAME: string;
  137071. /**
  137072. * The name of the right controller model file
  137073. */
  137074. static MODEL_RIGHT_FILENAME: string;
  137075. /**
  137076. * The controller name prefix for this controller type
  137077. */
  137078. static readonly GAMEPAD_ID_PREFIX: string;
  137079. /**
  137080. * The controller id pattern for this controller type
  137081. */
  137082. private static readonly GAMEPAD_ID_PATTERN;
  137083. private _loadedMeshInfo;
  137084. protected readonly _mapping: {
  137085. buttons: string[];
  137086. buttonMeshNames: {
  137087. trigger: string;
  137088. menu: string;
  137089. grip: string;
  137090. thumbstick: string;
  137091. trackpad: string;
  137092. };
  137093. buttonObservableNames: {
  137094. trigger: string;
  137095. menu: string;
  137096. grip: string;
  137097. thumbstick: string;
  137098. trackpad: string;
  137099. };
  137100. axisMeshNames: string[];
  137101. pointingPoseMeshName: string;
  137102. };
  137103. /**
  137104. * Fired when the trackpad on this controller is clicked
  137105. */
  137106. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137107. /**
  137108. * Fired when the trackpad on this controller is modified
  137109. */
  137110. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137111. /**
  137112. * The current x and y values of this controller's trackpad
  137113. */
  137114. trackpad: StickValues;
  137115. /**
  137116. * Creates a new WindowsMotionController from a gamepad
  137117. * @param vrGamepad the gamepad that the controller should be created from
  137118. */
  137119. constructor(vrGamepad: any);
  137120. /**
  137121. * Fired when the trigger on this controller is modified
  137122. */
  137123. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137124. /**
  137125. * Fired when the menu button on this controller is modified
  137126. */
  137127. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137128. /**
  137129. * Fired when the grip button on this controller is modified
  137130. */
  137131. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137132. /**
  137133. * Fired when the thumbstick button on this controller is modified
  137134. */
  137135. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137136. /**
  137137. * Fired when the touchpad button on this controller is modified
  137138. */
  137139. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137140. /**
  137141. * Fired when the touchpad values on this controller are modified
  137142. */
  137143. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137144. protected _updateTrackpad(): void;
  137145. /**
  137146. * Called once per frame by the engine.
  137147. */
  137148. update(): void;
  137149. /**
  137150. * Called once for each button that changed state since the last frame
  137151. * @param buttonIdx Which button index changed
  137152. * @param state New state of the button
  137153. * @param changes Which properties on the state changed since last frame
  137154. */
  137155. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137156. /**
  137157. * Moves the buttons on the controller mesh based on their current state
  137158. * @param buttonName the name of the button to move
  137159. * @param buttonValue the value of the button which determines the buttons new position
  137160. */
  137161. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137162. /**
  137163. * Moves the axis on the controller mesh based on its current state
  137164. * @param axis the index of the axis
  137165. * @param axisValue the value of the axis which determines the meshes new position
  137166. * @hidden
  137167. */
  137168. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137169. /**
  137170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137171. * @param scene scene in which to add meshes
  137172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137173. */
  137174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137175. /**
  137176. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137177. * can be transformed by button presses and axes values, based on this._mapping.
  137178. *
  137179. * @param scene scene in which the meshes exist
  137180. * @param meshes list of meshes that make up the controller model to process
  137181. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137182. */
  137183. private processModel;
  137184. private createMeshInfo;
  137185. /**
  137186. * Gets the ray of the controller in the direction the controller is pointing
  137187. * @param length the length the resulting ray should be
  137188. * @returns a ray in the direction the controller is pointing
  137189. */
  137190. getForwardRay(length?: number): Ray;
  137191. /**
  137192. * Disposes of the controller
  137193. */
  137194. dispose(): void;
  137195. }
  137196. /**
  137197. * This class represents a new windows motion controller in XR.
  137198. */
  137199. export class XRWindowsMotionController extends WindowsMotionController {
  137200. /**
  137201. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137202. */
  137203. protected readonly _mapping: {
  137204. buttons: string[];
  137205. buttonMeshNames: {
  137206. trigger: string;
  137207. menu: string;
  137208. grip: string;
  137209. thumbstick: string;
  137210. trackpad: string;
  137211. };
  137212. buttonObservableNames: {
  137213. trigger: string;
  137214. menu: string;
  137215. grip: string;
  137216. thumbstick: string;
  137217. trackpad: string;
  137218. };
  137219. axisMeshNames: string[];
  137220. pointingPoseMeshName: string;
  137221. };
  137222. /**
  137223. * Construct a new XR-Based windows motion controller
  137224. *
  137225. * @param gamepadInfo the gamepad object from the browser
  137226. */
  137227. constructor(gamepadInfo: any);
  137228. /**
  137229. * holds the thumbstick values (X,Y)
  137230. */
  137231. thumbstickValues: StickValues;
  137232. /**
  137233. * Fired when the thumbstick on this controller is clicked
  137234. */
  137235. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137236. /**
  137237. * Fired when the thumbstick on this controller is modified
  137238. */
  137239. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137240. /**
  137241. * Fired when the touchpad button on this controller is modified
  137242. */
  137243. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137244. /**
  137245. * Fired when the touchpad values on this controller are modified
  137246. */
  137247. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137248. /**
  137249. * Fired when the thumbstick button on this controller is modified
  137250. * here to prevent breaking changes
  137251. */
  137252. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137253. /**
  137254. * updating the thumbstick(!) and not the trackpad.
  137255. * This is named this way due to the difference between WebVR and XR and to avoid
  137256. * changing the parent class.
  137257. */
  137258. protected _updateTrackpad(): void;
  137259. /**
  137260. * Disposes the class with joy
  137261. */
  137262. dispose(): void;
  137263. }
  137264. }
  137265. declare module BABYLON {
  137266. /**
  137267. * Class containing static functions to help procedurally build meshes
  137268. */
  137269. export class PolyhedronBuilder {
  137270. /**
  137271. * Creates a polyhedron mesh
  137272. * * 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
  137273. * * The parameter `size` (positive float, default 1) sets the polygon size
  137274. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137275. * * 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`
  137276. * * 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
  137277. * * 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)`)
  137278. * * 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
  137279. * * 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
  137280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137283. * @param name defines the name of the mesh
  137284. * @param options defines the options used to create the mesh
  137285. * @param scene defines the hosting scene
  137286. * @returns the polyhedron mesh
  137287. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137288. */
  137289. static CreatePolyhedron(name: string, options: {
  137290. type?: number;
  137291. size?: number;
  137292. sizeX?: number;
  137293. sizeY?: number;
  137294. sizeZ?: number;
  137295. custom?: any;
  137296. faceUV?: Vector4[];
  137297. faceColors?: Color4[];
  137298. flat?: boolean;
  137299. updatable?: boolean;
  137300. sideOrientation?: number;
  137301. frontUVs?: Vector4;
  137302. backUVs?: Vector4;
  137303. }, scene?: Nullable<Scene>): Mesh;
  137304. }
  137305. }
  137306. declare module BABYLON {
  137307. /**
  137308. * Gizmo that enables scaling a mesh along 3 axis
  137309. */
  137310. export class ScaleGizmo extends Gizmo {
  137311. /**
  137312. * Internal gizmo used for interactions on the x axis
  137313. */
  137314. xGizmo: AxisScaleGizmo;
  137315. /**
  137316. * Internal gizmo used for interactions on the y axis
  137317. */
  137318. yGizmo: AxisScaleGizmo;
  137319. /**
  137320. * Internal gizmo used for interactions on the z axis
  137321. */
  137322. zGizmo: AxisScaleGizmo;
  137323. /**
  137324. * Internal gizmo used to scale all axis equally
  137325. */
  137326. uniformScaleGizmo: AxisScaleGizmo;
  137327. private _meshAttached;
  137328. private _nodeAttached;
  137329. private _snapDistance;
  137330. private _uniformScalingMesh;
  137331. private _octahedron;
  137332. private _sensitivity;
  137333. /** Fires an event when any of it's sub gizmos are dragged */
  137334. onDragStartObservable: Observable<unknown>;
  137335. /** Fires an event when any of it's sub gizmos are released from dragging */
  137336. onDragEndObservable: Observable<unknown>;
  137337. get attachedMesh(): Nullable<AbstractMesh>;
  137338. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137339. get attachedNode(): Nullable<Node>;
  137340. set attachedNode(node: Nullable<Node>);
  137341. /**
  137342. * True when the mouse pointer is hovering a gizmo mesh
  137343. */
  137344. get isHovered(): boolean;
  137345. /**
  137346. * Creates a ScaleGizmo
  137347. * @param gizmoLayer The utility layer the gizmo will be added to
  137348. * @param thickness display gizmo axis thickness
  137349. */
  137350. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137351. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137352. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137353. /**
  137354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137355. */
  137356. set snapDistance(value: number);
  137357. get snapDistance(): number;
  137358. /**
  137359. * Ratio for the scale of the gizmo (Default: 1)
  137360. */
  137361. set scaleRatio(value: number);
  137362. get scaleRatio(): number;
  137363. /**
  137364. * Sensitivity factor for dragging (Default: 1)
  137365. */
  137366. set sensitivity(value: number);
  137367. get sensitivity(): number;
  137368. /**
  137369. * Disposes of the gizmo
  137370. */
  137371. dispose(): void;
  137372. }
  137373. }
  137374. declare module BABYLON {
  137375. /**
  137376. * Single axis scale gizmo
  137377. */
  137378. export class AxisScaleGizmo extends Gizmo {
  137379. /**
  137380. * Drag behavior responsible for the gizmos dragging interactions
  137381. */
  137382. dragBehavior: PointerDragBehavior;
  137383. private _pointerObserver;
  137384. /**
  137385. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137386. */
  137387. snapDistance: number;
  137388. /**
  137389. * Event that fires each time the gizmo snaps to a new location.
  137390. * * snapDistance is the the change in distance
  137391. */
  137392. onSnapObservable: Observable<{
  137393. snapDistance: number;
  137394. }>;
  137395. /**
  137396. * If the scaling operation should be done on all axis (default: false)
  137397. */
  137398. uniformScaling: boolean;
  137399. /**
  137400. * Custom sensitivity value for the drag strength
  137401. */
  137402. sensitivity: number;
  137403. private _isEnabled;
  137404. private _parent;
  137405. private _arrow;
  137406. private _coloredMaterial;
  137407. private _hoverMaterial;
  137408. /**
  137409. * Creates an AxisScaleGizmo
  137410. * @param gizmoLayer The utility layer the gizmo will be added to
  137411. * @param dragAxis The axis which the gizmo will be able to scale on
  137412. * @param color The color of the gizmo
  137413. * @param thickness display gizmo axis thickness
  137414. */
  137415. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137416. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137417. /**
  137418. * If the gizmo is enabled
  137419. */
  137420. set isEnabled(value: boolean);
  137421. get isEnabled(): boolean;
  137422. /**
  137423. * Disposes of the gizmo
  137424. */
  137425. dispose(): void;
  137426. /**
  137427. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137428. * @param mesh The mesh to replace the default mesh of the gizmo
  137429. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137430. */
  137431. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137432. }
  137433. }
  137434. declare module BABYLON {
  137435. /**
  137436. * Bounding box gizmo
  137437. */
  137438. export class BoundingBoxGizmo extends Gizmo {
  137439. private _lineBoundingBox;
  137440. private _rotateSpheresParent;
  137441. private _scaleBoxesParent;
  137442. private _boundingDimensions;
  137443. private _renderObserver;
  137444. private _pointerObserver;
  137445. private _scaleDragSpeed;
  137446. private _tmpQuaternion;
  137447. private _tmpVector;
  137448. private _tmpRotationMatrix;
  137449. /**
  137450. * 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)
  137451. */
  137452. ignoreChildren: boolean;
  137453. /**
  137454. * 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)
  137455. */
  137456. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137457. /**
  137458. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137459. */
  137460. rotationSphereSize: number;
  137461. /**
  137462. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137463. */
  137464. scaleBoxSize: number;
  137465. /**
  137466. * 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)
  137467. */
  137468. fixedDragMeshScreenSize: boolean;
  137469. /**
  137470. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137471. */
  137472. fixedDragMeshScreenSizeDistanceFactor: number;
  137473. /**
  137474. * Fired when a rotation sphere or scale box is dragged
  137475. */
  137476. onDragStartObservable: Observable<{}>;
  137477. /**
  137478. * Fired when a scale box is dragged
  137479. */
  137480. onScaleBoxDragObservable: Observable<{}>;
  137481. /**
  137482. * Fired when a scale box drag is ended
  137483. */
  137484. onScaleBoxDragEndObservable: Observable<{}>;
  137485. /**
  137486. * Fired when a rotation sphere is dragged
  137487. */
  137488. onRotationSphereDragObservable: Observable<{}>;
  137489. /**
  137490. * Fired when a rotation sphere drag is ended
  137491. */
  137492. onRotationSphereDragEndObservable: Observable<{}>;
  137493. /**
  137494. * 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)
  137495. */
  137496. scalePivot: Nullable<Vector3>;
  137497. /**
  137498. * Mesh used as a pivot to rotate the attached node
  137499. */
  137500. private _anchorMesh;
  137501. private _existingMeshScale;
  137502. private _dragMesh;
  137503. private pointerDragBehavior;
  137504. private coloredMaterial;
  137505. private hoverColoredMaterial;
  137506. /**
  137507. * Sets the color of the bounding box gizmo
  137508. * @param color the color to set
  137509. */
  137510. setColor(color: Color3): void;
  137511. /**
  137512. * Creates an BoundingBoxGizmo
  137513. * @param gizmoLayer The utility layer the gizmo will be added to
  137514. * @param color The color of the gizmo
  137515. */
  137516. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137517. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137518. private _selectNode;
  137519. /**
  137520. * Updates the bounding box information for the Gizmo
  137521. */
  137522. updateBoundingBox(): void;
  137523. private _updateRotationSpheres;
  137524. private _updateScaleBoxes;
  137525. /**
  137526. * Enables rotation on the specified axis and disables rotation on the others
  137527. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137528. */
  137529. setEnabledRotationAxis(axis: string): void;
  137530. /**
  137531. * Enables/disables scaling
  137532. * @param enable if scaling should be enabled
  137533. * @param homogeneousScaling defines if scaling should only be homogeneous
  137534. */
  137535. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137536. private _updateDummy;
  137537. /**
  137538. * Enables a pointer drag behavior on the bounding box of the gizmo
  137539. */
  137540. enableDragBehavior(): void;
  137541. /**
  137542. * Disposes of the gizmo
  137543. */
  137544. dispose(): void;
  137545. /**
  137546. * 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)
  137547. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137548. * @returns the bounding box mesh with the passed in mesh as a child
  137549. */
  137550. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137551. /**
  137552. * CustomMeshes are not supported by this gizmo
  137553. * @param mesh The mesh to replace the default mesh of the gizmo
  137554. */
  137555. setCustomMesh(mesh: Mesh): void;
  137556. }
  137557. }
  137558. declare module BABYLON {
  137559. /**
  137560. * Single plane rotation gizmo
  137561. */
  137562. export class PlaneRotationGizmo extends Gizmo {
  137563. /**
  137564. * Drag behavior responsible for the gizmos dragging interactions
  137565. */
  137566. dragBehavior: PointerDragBehavior;
  137567. private _pointerObserver;
  137568. /**
  137569. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137570. */
  137571. snapDistance: number;
  137572. /**
  137573. * Event that fires each time the gizmo snaps to a new location.
  137574. * * snapDistance is the the change in distance
  137575. */
  137576. onSnapObservable: Observable<{
  137577. snapDistance: number;
  137578. }>;
  137579. private _isEnabled;
  137580. private _parent;
  137581. /**
  137582. * Creates a PlaneRotationGizmo
  137583. * @param gizmoLayer The utility layer the gizmo will be added to
  137584. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137585. * @param color The color of the gizmo
  137586. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137587. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137588. * @param thickness display gizmo axis thickness
  137589. */
  137590. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137591. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137592. /**
  137593. * If the gizmo is enabled
  137594. */
  137595. set isEnabled(value: boolean);
  137596. get isEnabled(): boolean;
  137597. /**
  137598. * Disposes of the gizmo
  137599. */
  137600. dispose(): void;
  137601. }
  137602. }
  137603. declare module BABYLON {
  137604. /**
  137605. * Gizmo that enables rotating a mesh along 3 axis
  137606. */
  137607. export class RotationGizmo extends Gizmo {
  137608. /**
  137609. * Internal gizmo used for interactions on the x axis
  137610. */
  137611. xGizmo: PlaneRotationGizmo;
  137612. /**
  137613. * Internal gizmo used for interactions on the y axis
  137614. */
  137615. yGizmo: PlaneRotationGizmo;
  137616. /**
  137617. * Internal gizmo used for interactions on the z axis
  137618. */
  137619. zGizmo: PlaneRotationGizmo;
  137620. /** Fires an event when any of it's sub gizmos are dragged */
  137621. onDragStartObservable: Observable<unknown>;
  137622. /** Fires an event when any of it's sub gizmos are released from dragging */
  137623. onDragEndObservable: Observable<unknown>;
  137624. private _meshAttached;
  137625. private _nodeAttached;
  137626. get attachedMesh(): Nullable<AbstractMesh>;
  137627. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137628. get attachedNode(): Nullable<Node>;
  137629. set attachedNode(node: Nullable<Node>);
  137630. protected _checkBillboardTransform(): void;
  137631. /**
  137632. * True when the mouse pointer is hovering a gizmo mesh
  137633. */
  137634. get isHovered(): boolean;
  137635. /**
  137636. * Creates a RotationGizmo
  137637. * @param gizmoLayer The utility layer the gizmo will be added to
  137638. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137639. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137640. * @param thickness display gizmo axis thickness
  137641. */
  137642. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137643. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137644. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137645. /**
  137646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137647. */
  137648. set snapDistance(value: number);
  137649. get snapDistance(): number;
  137650. /**
  137651. * Ratio for the scale of the gizmo (Default: 1)
  137652. */
  137653. set scaleRatio(value: number);
  137654. get scaleRatio(): number;
  137655. /**
  137656. * Disposes of the gizmo
  137657. */
  137658. dispose(): void;
  137659. /**
  137660. * CustomMeshes are not supported by this gizmo
  137661. * @param mesh The mesh to replace the default mesh of the gizmo
  137662. */
  137663. setCustomMesh(mesh: Mesh): void;
  137664. }
  137665. }
  137666. declare module BABYLON {
  137667. /**
  137668. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137669. */
  137670. export class GizmoManager implements IDisposable {
  137671. private scene;
  137672. /**
  137673. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137674. */
  137675. gizmos: {
  137676. positionGizmo: Nullable<PositionGizmo>;
  137677. rotationGizmo: Nullable<RotationGizmo>;
  137678. scaleGizmo: Nullable<ScaleGizmo>;
  137679. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137680. };
  137681. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137682. clearGizmoOnEmptyPointerEvent: boolean;
  137683. /** Fires an event when the manager is attached to a mesh */
  137684. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137685. /** Fires an event when the manager is attached to a node */
  137686. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137687. private _gizmosEnabled;
  137688. private _pointerObserver;
  137689. private _attachedMesh;
  137690. private _attachedNode;
  137691. private _boundingBoxColor;
  137692. private _defaultUtilityLayer;
  137693. private _defaultKeepDepthUtilityLayer;
  137694. private _thickness;
  137695. /**
  137696. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137697. */
  137698. boundingBoxDragBehavior: SixDofDragBehavior;
  137699. /**
  137700. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137701. */
  137702. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137703. /**
  137704. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137705. */
  137706. attachableNodes: Nullable<Array<Node>>;
  137707. /**
  137708. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137709. */
  137710. usePointerToAttachGizmos: boolean;
  137711. /**
  137712. * Utility layer that the bounding box gizmo belongs to
  137713. */
  137714. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137715. /**
  137716. * Utility layer that all gizmos besides bounding box belong to
  137717. */
  137718. get utilityLayer(): UtilityLayerRenderer;
  137719. /**
  137720. * True when the mouse pointer is hovering a gizmo mesh
  137721. */
  137722. get isHovered(): boolean;
  137723. /**
  137724. * Instatiates a gizmo manager
  137725. * @param scene the scene to overlay the gizmos on top of
  137726. * @param thickness display gizmo axis thickness
  137727. */
  137728. constructor(scene: Scene, thickness?: number);
  137729. /**
  137730. * Attaches a set of gizmos to the specified mesh
  137731. * @param mesh The mesh the gizmo's should be attached to
  137732. */
  137733. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137734. /**
  137735. * Attaches a set of gizmos to the specified node
  137736. * @param node The node the gizmo's should be attached to
  137737. */
  137738. attachToNode(node: Nullable<Node>): void;
  137739. /**
  137740. * If the position gizmo is enabled
  137741. */
  137742. set positionGizmoEnabled(value: boolean);
  137743. get positionGizmoEnabled(): boolean;
  137744. /**
  137745. * If the rotation gizmo is enabled
  137746. */
  137747. set rotationGizmoEnabled(value: boolean);
  137748. get rotationGizmoEnabled(): boolean;
  137749. /**
  137750. * If the scale gizmo is enabled
  137751. */
  137752. set scaleGizmoEnabled(value: boolean);
  137753. get scaleGizmoEnabled(): boolean;
  137754. /**
  137755. * If the boundingBox gizmo is enabled
  137756. */
  137757. set boundingBoxGizmoEnabled(value: boolean);
  137758. get boundingBoxGizmoEnabled(): boolean;
  137759. /**
  137760. * Disposes of the gizmo manager
  137761. */
  137762. dispose(): void;
  137763. }
  137764. }
  137765. declare module BABYLON {
  137766. /**
  137767. * A directional light is defined by a direction (what a surprise!).
  137768. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137769. * 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.
  137770. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137771. */
  137772. export class DirectionalLight extends ShadowLight {
  137773. private _shadowFrustumSize;
  137774. /**
  137775. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137776. */
  137777. get shadowFrustumSize(): number;
  137778. /**
  137779. * Specifies a fix frustum size for the shadow generation.
  137780. */
  137781. set shadowFrustumSize(value: number);
  137782. private _shadowOrthoScale;
  137783. /**
  137784. * Gets the shadow projection scale against the optimal computed one.
  137785. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137786. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137787. */
  137788. get shadowOrthoScale(): number;
  137789. /**
  137790. * Sets the shadow projection scale against the optimal computed one.
  137791. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137792. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137793. */
  137794. set shadowOrthoScale(value: number);
  137795. /**
  137796. * Automatically compute the projection matrix to best fit (including all the casters)
  137797. * on each frame.
  137798. */
  137799. autoUpdateExtends: boolean;
  137800. /**
  137801. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137802. * on each frame. autoUpdateExtends must be set to true for this to work
  137803. */
  137804. autoCalcShadowZBounds: boolean;
  137805. private _orthoLeft;
  137806. private _orthoRight;
  137807. private _orthoTop;
  137808. private _orthoBottom;
  137809. /**
  137810. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137811. * The directional light is emitted from everywhere in the given direction.
  137812. * It can cast shadows.
  137813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137814. * @param name The friendly name of the light
  137815. * @param direction The direction of the light
  137816. * @param scene The scene the light belongs to
  137817. */
  137818. constructor(name: string, direction: Vector3, scene: Scene);
  137819. /**
  137820. * Returns the string "DirectionalLight".
  137821. * @return The class name
  137822. */
  137823. getClassName(): string;
  137824. /**
  137825. * Returns the integer 1.
  137826. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137827. */
  137828. getTypeID(): number;
  137829. /**
  137830. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137831. * Returns the DirectionalLight Shadow projection matrix.
  137832. */
  137833. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137834. /**
  137835. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137836. * Returns the DirectionalLight Shadow projection matrix.
  137837. */
  137838. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137839. /**
  137840. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137841. * Returns the DirectionalLight Shadow projection matrix.
  137842. */
  137843. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137844. protected _buildUniformLayout(): void;
  137845. /**
  137846. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137847. * @param effect The effect to update
  137848. * @param lightIndex The index of the light in the effect to update
  137849. * @returns The directional light
  137850. */
  137851. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137852. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137853. /**
  137854. * Gets the minZ used for shadow according to both the scene and the light.
  137855. *
  137856. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137857. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137858. * @param activeCamera The camera we are returning the min for
  137859. * @returns the depth min z
  137860. */
  137861. getDepthMinZ(activeCamera: Camera): number;
  137862. /**
  137863. * Gets the maxZ used for shadow according to both the scene and the light.
  137864. *
  137865. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137866. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137867. * @param activeCamera The camera we are returning the max for
  137868. * @returns the depth max z
  137869. */
  137870. getDepthMaxZ(activeCamera: Camera): number;
  137871. /**
  137872. * Prepares the list of defines specific to the light type.
  137873. * @param defines the list of defines
  137874. * @param lightIndex defines the index of the light for the effect
  137875. */
  137876. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137877. }
  137878. }
  137879. declare module BABYLON {
  137880. /**
  137881. * Class containing static functions to help procedurally build meshes
  137882. */
  137883. export class HemisphereBuilder {
  137884. /**
  137885. * Creates a hemisphere mesh
  137886. * @param name defines the name of the mesh
  137887. * @param options defines the options used to create the mesh
  137888. * @param scene defines the hosting scene
  137889. * @returns the hemisphere mesh
  137890. */
  137891. static CreateHemisphere(name: string, options: {
  137892. segments?: number;
  137893. diameter?: number;
  137894. sideOrientation?: number;
  137895. }, scene: any): Mesh;
  137896. }
  137897. }
  137898. declare module BABYLON {
  137899. /**
  137900. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137901. * These values define a cone of light starting from the position, emitting toward the direction.
  137902. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137903. * and the exponent defines the speed of the decay of the light with distance (reach).
  137904. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137905. */
  137906. export class SpotLight extends ShadowLight {
  137907. private _angle;
  137908. private _innerAngle;
  137909. private _cosHalfAngle;
  137910. private _lightAngleScale;
  137911. private _lightAngleOffset;
  137912. /**
  137913. * Gets the cone angle of the spot light in Radians.
  137914. */
  137915. get angle(): number;
  137916. /**
  137917. * Sets the cone angle of the spot light in Radians.
  137918. */
  137919. set angle(value: number);
  137920. /**
  137921. * Only used in gltf falloff mode, this defines the angle where
  137922. * the directional falloff will start before cutting at angle which could be seen
  137923. * as outer angle.
  137924. */
  137925. get innerAngle(): number;
  137926. /**
  137927. * Only used in gltf falloff mode, this defines the angle where
  137928. * the directional falloff will start before cutting at angle which could be seen
  137929. * as outer angle.
  137930. */
  137931. set innerAngle(value: number);
  137932. private _shadowAngleScale;
  137933. /**
  137934. * Allows scaling the angle of the light for shadow generation only.
  137935. */
  137936. get shadowAngleScale(): number;
  137937. /**
  137938. * Allows scaling the angle of the light for shadow generation only.
  137939. */
  137940. set shadowAngleScale(value: number);
  137941. /**
  137942. * The light decay speed with the distance from the emission spot.
  137943. */
  137944. exponent: number;
  137945. private _projectionTextureMatrix;
  137946. /**
  137947. * Allows reading the projecton texture
  137948. */
  137949. get projectionTextureMatrix(): Matrix;
  137950. protected _projectionTextureLightNear: number;
  137951. /**
  137952. * Gets the near clip of the Spotlight for texture projection.
  137953. */
  137954. get projectionTextureLightNear(): number;
  137955. /**
  137956. * Sets the near clip of the Spotlight for texture projection.
  137957. */
  137958. set projectionTextureLightNear(value: number);
  137959. protected _projectionTextureLightFar: number;
  137960. /**
  137961. * Gets the far clip of the Spotlight for texture projection.
  137962. */
  137963. get projectionTextureLightFar(): number;
  137964. /**
  137965. * Sets the far clip of the Spotlight for texture projection.
  137966. */
  137967. set projectionTextureLightFar(value: number);
  137968. protected _projectionTextureUpDirection: Vector3;
  137969. /**
  137970. * Gets the Up vector of the Spotlight for texture projection.
  137971. */
  137972. get projectionTextureUpDirection(): Vector3;
  137973. /**
  137974. * Sets the Up vector of the Spotlight for texture projection.
  137975. */
  137976. set projectionTextureUpDirection(value: Vector3);
  137977. private _projectionTexture;
  137978. /**
  137979. * Gets the projection texture of the light.
  137980. */
  137981. get projectionTexture(): Nullable<BaseTexture>;
  137982. /**
  137983. * Sets the projection texture of the light.
  137984. */
  137985. set projectionTexture(value: Nullable<BaseTexture>);
  137986. private _projectionTextureViewLightDirty;
  137987. private _projectionTextureProjectionLightDirty;
  137988. private _projectionTextureDirty;
  137989. private _projectionTextureViewTargetVector;
  137990. private _projectionTextureViewLightMatrix;
  137991. private _projectionTextureProjectionLightMatrix;
  137992. private _projectionTextureScalingMatrix;
  137993. /**
  137994. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  137995. * It can cast shadows.
  137996. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137997. * @param name The light friendly name
  137998. * @param position The position of the spot light in the scene
  137999. * @param direction The direction of the light in the scene
  138000. * @param angle The cone angle of the light in Radians
  138001. * @param exponent The light decay speed with the distance from the emission spot
  138002. * @param scene The scene the lights belongs to
  138003. */
  138004. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138005. /**
  138006. * Returns the string "SpotLight".
  138007. * @returns the class name
  138008. */
  138009. getClassName(): string;
  138010. /**
  138011. * Returns the integer 2.
  138012. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138013. */
  138014. getTypeID(): number;
  138015. /**
  138016. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138017. */
  138018. protected _setDirection(value: Vector3): void;
  138019. /**
  138020. * Overrides the position setter to recompute the projection texture view light Matrix.
  138021. */
  138022. protected _setPosition(value: Vector3): void;
  138023. /**
  138024. * 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.
  138025. * Returns the SpotLight.
  138026. */
  138027. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138028. protected _computeProjectionTextureViewLightMatrix(): void;
  138029. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138030. /**
  138031. * Main function for light texture projection matrix computing.
  138032. */
  138033. protected _computeProjectionTextureMatrix(): void;
  138034. protected _buildUniformLayout(): void;
  138035. private _computeAngleValues;
  138036. /**
  138037. * Sets the passed Effect "effect" with the Light textures.
  138038. * @param effect The effect to update
  138039. * @param lightIndex The index of the light in the effect to update
  138040. * @returns The light
  138041. */
  138042. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138043. /**
  138044. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138045. * @param effect The effect to update
  138046. * @param lightIndex The index of the light in the effect to update
  138047. * @returns The spot light
  138048. */
  138049. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138050. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138051. /**
  138052. * Disposes the light and the associated resources.
  138053. */
  138054. dispose(): void;
  138055. /**
  138056. * Prepares the list of defines specific to the light type.
  138057. * @param defines the list of defines
  138058. * @param lightIndex defines the index of the light for the effect
  138059. */
  138060. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138061. }
  138062. }
  138063. declare module BABYLON {
  138064. /**
  138065. * Gizmo that enables viewing a light
  138066. */
  138067. export class LightGizmo extends Gizmo {
  138068. private _lightMesh;
  138069. private _material;
  138070. private _cachedPosition;
  138071. private _cachedForward;
  138072. private _attachedMeshParent;
  138073. private _pointerObserver;
  138074. /**
  138075. * Event that fires each time the gizmo is clicked
  138076. */
  138077. onClickedObservable: Observable<Light>;
  138078. /**
  138079. * Creates a LightGizmo
  138080. * @param gizmoLayer The utility layer the gizmo will be added to
  138081. */
  138082. constructor(gizmoLayer?: UtilityLayerRenderer);
  138083. private _light;
  138084. /**
  138085. * The light that the gizmo is attached to
  138086. */
  138087. set light(light: Nullable<Light>);
  138088. get light(): Nullable<Light>;
  138089. /**
  138090. * Gets the material used to render the light gizmo
  138091. */
  138092. get material(): StandardMaterial;
  138093. /**
  138094. * @hidden
  138095. * Updates the gizmo to match the attached mesh's position/rotation
  138096. */
  138097. protected _update(): void;
  138098. private static _Scale;
  138099. /**
  138100. * Creates the lines for a light mesh
  138101. */
  138102. private static _CreateLightLines;
  138103. /**
  138104. * Disposes of the light gizmo
  138105. */
  138106. dispose(): void;
  138107. private static _CreateHemisphericLightMesh;
  138108. private static _CreatePointLightMesh;
  138109. private static _CreateSpotLightMesh;
  138110. private static _CreateDirectionalLightMesh;
  138111. }
  138112. }
  138113. declare module BABYLON {
  138114. /**
  138115. * Gizmo that enables viewing a camera
  138116. */
  138117. export class CameraGizmo extends Gizmo {
  138118. private _cameraMesh;
  138119. private _cameraLinesMesh;
  138120. private _material;
  138121. private _pointerObserver;
  138122. /**
  138123. * Event that fires each time the gizmo is clicked
  138124. */
  138125. onClickedObservable: Observable<Camera>;
  138126. /**
  138127. * Creates a CameraGizmo
  138128. * @param gizmoLayer The utility layer the gizmo will be added to
  138129. */
  138130. constructor(gizmoLayer?: UtilityLayerRenderer);
  138131. private _camera;
  138132. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138133. get displayFrustum(): boolean;
  138134. set displayFrustum(value: boolean);
  138135. /**
  138136. * The camera that the gizmo is attached to
  138137. */
  138138. set camera(camera: Nullable<Camera>);
  138139. get camera(): Nullable<Camera>;
  138140. /**
  138141. * Gets the material used to render the camera gizmo
  138142. */
  138143. get material(): StandardMaterial;
  138144. /**
  138145. * @hidden
  138146. * Updates the gizmo to match the attached mesh's position/rotation
  138147. */
  138148. protected _update(): void;
  138149. private static _Scale;
  138150. private _invProjection;
  138151. /**
  138152. * Disposes of the camera gizmo
  138153. */
  138154. dispose(): void;
  138155. private static _CreateCameraMesh;
  138156. private static _CreateCameraFrustum;
  138157. }
  138158. }
  138159. declare module BABYLON {
  138160. /** @hidden */
  138161. export var backgroundFragmentDeclaration: {
  138162. name: string;
  138163. shader: string;
  138164. };
  138165. }
  138166. declare module BABYLON {
  138167. /** @hidden */
  138168. export var backgroundUboDeclaration: {
  138169. name: string;
  138170. shader: string;
  138171. };
  138172. }
  138173. declare module BABYLON {
  138174. /** @hidden */
  138175. export var backgroundPixelShader: {
  138176. name: string;
  138177. shader: string;
  138178. };
  138179. }
  138180. declare module BABYLON {
  138181. /** @hidden */
  138182. export var backgroundVertexDeclaration: {
  138183. name: string;
  138184. shader: string;
  138185. };
  138186. }
  138187. declare module BABYLON {
  138188. /** @hidden */
  138189. export var backgroundVertexShader: {
  138190. name: string;
  138191. shader: string;
  138192. };
  138193. }
  138194. declare module BABYLON {
  138195. /**
  138196. * Background material used to create an efficient environement around your scene.
  138197. */
  138198. export class BackgroundMaterial extends PushMaterial {
  138199. /**
  138200. * Standard reflectance value at parallel view angle.
  138201. */
  138202. static StandardReflectance0: number;
  138203. /**
  138204. * Standard reflectance value at grazing angle.
  138205. */
  138206. static StandardReflectance90: number;
  138207. protected _primaryColor: Color3;
  138208. /**
  138209. * Key light Color (multiply against the environement texture)
  138210. */
  138211. primaryColor: Color3;
  138212. protected __perceptualColor: Nullable<Color3>;
  138213. /**
  138214. * Experimental Internal Use Only.
  138215. *
  138216. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138217. * This acts as a helper to set the primary color to a more "human friendly" value.
  138218. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138219. * output color as close as possible from the chosen value.
  138220. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138221. * part of lighting setup.)
  138222. */
  138223. get _perceptualColor(): Nullable<Color3>;
  138224. set _perceptualColor(value: Nullable<Color3>);
  138225. protected _primaryColorShadowLevel: float;
  138226. /**
  138227. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138228. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138229. */
  138230. get primaryColorShadowLevel(): float;
  138231. set primaryColorShadowLevel(value: float);
  138232. protected _primaryColorHighlightLevel: float;
  138233. /**
  138234. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138235. * The primary color is used at the level chosen to define what the white area would look.
  138236. */
  138237. get primaryColorHighlightLevel(): float;
  138238. set primaryColorHighlightLevel(value: float);
  138239. protected _reflectionTexture: Nullable<BaseTexture>;
  138240. /**
  138241. * Reflection Texture used in the material.
  138242. * Should be author in a specific way for the best result (refer to the documentation).
  138243. */
  138244. reflectionTexture: Nullable<BaseTexture>;
  138245. protected _reflectionBlur: float;
  138246. /**
  138247. * Reflection Texture level of blur.
  138248. *
  138249. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138250. * texture twice.
  138251. */
  138252. reflectionBlur: float;
  138253. protected _diffuseTexture: Nullable<BaseTexture>;
  138254. /**
  138255. * Diffuse Texture used in the material.
  138256. * Should be author in a specific way for the best result (refer to the documentation).
  138257. */
  138258. diffuseTexture: Nullable<BaseTexture>;
  138259. protected _shadowLights: Nullable<IShadowLight[]>;
  138260. /**
  138261. * Specify the list of lights casting shadow on the material.
  138262. * All scene shadow lights will be included if null.
  138263. */
  138264. shadowLights: Nullable<IShadowLight[]>;
  138265. protected _shadowLevel: float;
  138266. /**
  138267. * Helps adjusting the shadow to a softer level if required.
  138268. * 0 means black shadows and 1 means no shadows.
  138269. */
  138270. shadowLevel: float;
  138271. protected _sceneCenter: Vector3;
  138272. /**
  138273. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138274. * It is usually zero but might be interesting to modify according to your setup.
  138275. */
  138276. sceneCenter: Vector3;
  138277. protected _opacityFresnel: boolean;
  138278. /**
  138279. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138280. * This helps ensuring a nice transition when the camera goes under the ground.
  138281. */
  138282. opacityFresnel: boolean;
  138283. protected _reflectionFresnel: boolean;
  138284. /**
  138285. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138286. * This helps adding a mirror texture on the ground.
  138287. */
  138288. reflectionFresnel: boolean;
  138289. protected _reflectionFalloffDistance: number;
  138290. /**
  138291. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138292. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138293. */
  138294. reflectionFalloffDistance: number;
  138295. protected _reflectionAmount: number;
  138296. /**
  138297. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138298. */
  138299. reflectionAmount: number;
  138300. protected _reflectionReflectance0: number;
  138301. /**
  138302. * This specifies the weight of the reflection at grazing angle.
  138303. */
  138304. reflectionReflectance0: number;
  138305. protected _reflectionReflectance90: number;
  138306. /**
  138307. * This specifies the weight of the reflection at a perpendicular point of view.
  138308. */
  138309. reflectionReflectance90: number;
  138310. /**
  138311. * Sets the reflection reflectance fresnel values according to the default standard
  138312. * empirically know to work well :-)
  138313. */
  138314. set reflectionStandardFresnelWeight(value: number);
  138315. protected _useRGBColor: boolean;
  138316. /**
  138317. * Helps to directly use the maps channels instead of their level.
  138318. */
  138319. useRGBColor: boolean;
  138320. protected _enableNoise: boolean;
  138321. /**
  138322. * This helps reducing the banding effect that could occur on the background.
  138323. */
  138324. enableNoise: boolean;
  138325. /**
  138326. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138327. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138328. * Recommended to be keep at 1.0 except for special cases.
  138329. */
  138330. get fovMultiplier(): number;
  138331. set fovMultiplier(value: number);
  138332. private _fovMultiplier;
  138333. /**
  138334. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138335. */
  138336. useEquirectangularFOV: boolean;
  138337. private _maxSimultaneousLights;
  138338. /**
  138339. * Number of Simultaneous lights allowed on the material.
  138340. */
  138341. maxSimultaneousLights: int;
  138342. private _shadowOnly;
  138343. /**
  138344. * Make the material only render shadows
  138345. */
  138346. shadowOnly: boolean;
  138347. /**
  138348. * Default configuration related to image processing available in the Background Material.
  138349. */
  138350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138351. /**
  138352. * Keep track of the image processing observer to allow dispose and replace.
  138353. */
  138354. private _imageProcessingObserver;
  138355. /**
  138356. * Attaches a new image processing configuration to the PBR Material.
  138357. * @param configuration (if null the scene configuration will be use)
  138358. */
  138359. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138360. /**
  138361. * Gets the image processing configuration used either in this material.
  138362. */
  138363. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138364. /**
  138365. * Sets the Default image processing configuration used either in the this material.
  138366. *
  138367. * If sets to null, the scene one is in use.
  138368. */
  138369. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138370. /**
  138371. * Gets wether the color curves effect is enabled.
  138372. */
  138373. get cameraColorCurvesEnabled(): boolean;
  138374. /**
  138375. * Sets wether the color curves effect is enabled.
  138376. */
  138377. set cameraColorCurvesEnabled(value: boolean);
  138378. /**
  138379. * Gets wether the color grading effect is enabled.
  138380. */
  138381. get cameraColorGradingEnabled(): boolean;
  138382. /**
  138383. * Gets wether the color grading effect is enabled.
  138384. */
  138385. set cameraColorGradingEnabled(value: boolean);
  138386. /**
  138387. * Gets wether tonemapping is enabled or not.
  138388. */
  138389. get cameraToneMappingEnabled(): boolean;
  138390. /**
  138391. * Sets wether tonemapping is enabled or not
  138392. */
  138393. set cameraToneMappingEnabled(value: boolean);
  138394. /**
  138395. * The camera exposure used on this material.
  138396. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138397. * This corresponds to a photographic exposure.
  138398. */
  138399. get cameraExposure(): float;
  138400. /**
  138401. * The camera exposure used on this material.
  138402. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138403. * This corresponds to a photographic exposure.
  138404. */
  138405. set cameraExposure(value: float);
  138406. /**
  138407. * Gets The camera contrast used on this material.
  138408. */
  138409. get cameraContrast(): float;
  138410. /**
  138411. * Sets The camera contrast used on this material.
  138412. */
  138413. set cameraContrast(value: float);
  138414. /**
  138415. * Gets the Color Grading 2D Lookup Texture.
  138416. */
  138417. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138418. /**
  138419. * Sets the Color Grading 2D Lookup Texture.
  138420. */
  138421. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138422. /**
  138423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138425. * 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;
  138426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138427. */
  138428. get cameraColorCurves(): Nullable<ColorCurves>;
  138429. /**
  138430. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138431. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138432. * 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;
  138433. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138434. */
  138435. set cameraColorCurves(value: Nullable<ColorCurves>);
  138436. /**
  138437. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138438. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138439. */
  138440. switchToBGR: boolean;
  138441. private _renderTargets;
  138442. private _reflectionControls;
  138443. private _white;
  138444. private _primaryShadowColor;
  138445. private _primaryHighlightColor;
  138446. /**
  138447. * Instantiates a Background Material in the given scene
  138448. * @param name The friendly name of the material
  138449. * @param scene The scene to add the material to
  138450. */
  138451. constructor(name: string, scene: Scene);
  138452. /**
  138453. * Gets a boolean indicating that current material needs to register RTT
  138454. */
  138455. get hasRenderTargetTextures(): boolean;
  138456. /**
  138457. * The entire material has been created in order to prevent overdraw.
  138458. * @returns false
  138459. */
  138460. needAlphaTesting(): boolean;
  138461. /**
  138462. * The entire material has been created in order to prevent overdraw.
  138463. * @returns true if blending is enable
  138464. */
  138465. needAlphaBlending(): boolean;
  138466. /**
  138467. * Checks wether the material is ready to be rendered for a given mesh.
  138468. * @param mesh The mesh to render
  138469. * @param subMesh The submesh to check against
  138470. * @param useInstances Specify wether or not the material is used with instances
  138471. * @returns true if all the dependencies are ready (Textures, Effects...)
  138472. */
  138473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138474. /**
  138475. * Compute the primary color according to the chosen perceptual color.
  138476. */
  138477. private _computePrimaryColorFromPerceptualColor;
  138478. /**
  138479. * Compute the highlights and shadow colors according to their chosen levels.
  138480. */
  138481. private _computePrimaryColors;
  138482. /**
  138483. * Build the uniform buffer used in the material.
  138484. */
  138485. buildUniformLayout(): void;
  138486. /**
  138487. * Unbind the material.
  138488. */
  138489. unbind(): void;
  138490. /**
  138491. * Bind only the world matrix to the material.
  138492. * @param world The world matrix to bind.
  138493. */
  138494. bindOnlyWorldMatrix(world: Matrix): void;
  138495. /**
  138496. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138497. * @param world The world matrix to bind.
  138498. * @param subMesh The submesh to bind for.
  138499. */
  138500. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138501. /**
  138502. * Checks to see if a texture is used in the material.
  138503. * @param texture - Base texture to use.
  138504. * @returns - Boolean specifying if a texture is used in the material.
  138505. */
  138506. hasTexture(texture: BaseTexture): boolean;
  138507. /**
  138508. * Dispose the material.
  138509. * @param forceDisposeEffect Force disposal of the associated effect.
  138510. * @param forceDisposeTextures Force disposal of the associated textures.
  138511. */
  138512. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138513. /**
  138514. * Clones the material.
  138515. * @param name The cloned name.
  138516. * @returns The cloned material.
  138517. */
  138518. clone(name: string): BackgroundMaterial;
  138519. /**
  138520. * Serializes the current material to its JSON representation.
  138521. * @returns The JSON representation.
  138522. */
  138523. serialize(): any;
  138524. /**
  138525. * Gets the class name of the material
  138526. * @returns "BackgroundMaterial"
  138527. */
  138528. getClassName(): string;
  138529. /**
  138530. * Parse a JSON input to create back a background material.
  138531. * @param source The JSON data to parse
  138532. * @param scene The scene to create the parsed material in
  138533. * @param rootUrl The root url of the assets the material depends upon
  138534. * @returns the instantiated BackgroundMaterial.
  138535. */
  138536. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138537. }
  138538. }
  138539. declare module BABYLON {
  138540. /**
  138541. * Represents the different options available during the creation of
  138542. * a Environment helper.
  138543. *
  138544. * This can control the default ground, skybox and image processing setup of your scene.
  138545. */
  138546. export interface IEnvironmentHelperOptions {
  138547. /**
  138548. * Specifies whether or not to create a ground.
  138549. * True by default.
  138550. */
  138551. createGround: boolean;
  138552. /**
  138553. * Specifies the ground size.
  138554. * 15 by default.
  138555. */
  138556. groundSize: number;
  138557. /**
  138558. * The texture used on the ground for the main color.
  138559. * Comes from the BabylonJS CDN by default.
  138560. *
  138561. * Remarks: Can be either a texture or a url.
  138562. */
  138563. groundTexture: string | BaseTexture;
  138564. /**
  138565. * The color mixed in the ground texture by default.
  138566. * BabylonJS clearColor by default.
  138567. */
  138568. groundColor: Color3;
  138569. /**
  138570. * Specifies the ground opacity.
  138571. * 1 by default.
  138572. */
  138573. groundOpacity: number;
  138574. /**
  138575. * Enables the ground to receive shadows.
  138576. * True by default.
  138577. */
  138578. enableGroundShadow: boolean;
  138579. /**
  138580. * Helps preventing the shadow to be fully black on the ground.
  138581. * 0.5 by default.
  138582. */
  138583. groundShadowLevel: number;
  138584. /**
  138585. * Creates a mirror texture attach to the ground.
  138586. * false by default.
  138587. */
  138588. enableGroundMirror: boolean;
  138589. /**
  138590. * Specifies the ground mirror size ratio.
  138591. * 0.3 by default as the default kernel is 64.
  138592. */
  138593. groundMirrorSizeRatio: number;
  138594. /**
  138595. * Specifies the ground mirror blur kernel size.
  138596. * 64 by default.
  138597. */
  138598. groundMirrorBlurKernel: number;
  138599. /**
  138600. * Specifies the ground mirror visibility amount.
  138601. * 1 by default
  138602. */
  138603. groundMirrorAmount: number;
  138604. /**
  138605. * Specifies the ground mirror reflectance weight.
  138606. * This uses the standard weight of the background material to setup the fresnel effect
  138607. * of the mirror.
  138608. * 1 by default.
  138609. */
  138610. groundMirrorFresnelWeight: number;
  138611. /**
  138612. * Specifies the ground mirror Falloff distance.
  138613. * This can helps reducing the size of the reflection.
  138614. * 0 by Default.
  138615. */
  138616. groundMirrorFallOffDistance: number;
  138617. /**
  138618. * Specifies the ground mirror texture type.
  138619. * Unsigned Int by Default.
  138620. */
  138621. groundMirrorTextureType: number;
  138622. /**
  138623. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138624. * the shown objects.
  138625. */
  138626. groundYBias: number;
  138627. /**
  138628. * Specifies whether or not to create a skybox.
  138629. * True by default.
  138630. */
  138631. createSkybox: boolean;
  138632. /**
  138633. * Specifies the skybox size.
  138634. * 20 by default.
  138635. */
  138636. skyboxSize: number;
  138637. /**
  138638. * The texture used on the skybox for the main color.
  138639. * Comes from the BabylonJS CDN by default.
  138640. *
  138641. * Remarks: Can be either a texture or a url.
  138642. */
  138643. skyboxTexture: string | BaseTexture;
  138644. /**
  138645. * The color mixed in the skybox texture by default.
  138646. * BabylonJS clearColor by default.
  138647. */
  138648. skyboxColor: Color3;
  138649. /**
  138650. * The background rotation around the Y axis of the scene.
  138651. * This helps aligning the key lights of your scene with the background.
  138652. * 0 by default.
  138653. */
  138654. backgroundYRotation: number;
  138655. /**
  138656. * Compute automatically the size of the elements to best fit with the scene.
  138657. */
  138658. sizeAuto: boolean;
  138659. /**
  138660. * Default position of the rootMesh if autoSize is not true.
  138661. */
  138662. rootPosition: Vector3;
  138663. /**
  138664. * Sets up the image processing in the scene.
  138665. * true by default.
  138666. */
  138667. setupImageProcessing: boolean;
  138668. /**
  138669. * The texture used as your environment texture in the scene.
  138670. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138671. *
  138672. * Remarks: Can be either a texture or a url.
  138673. */
  138674. environmentTexture: string | BaseTexture;
  138675. /**
  138676. * The value of the exposure to apply to the scene.
  138677. * 0.6 by default if setupImageProcessing is true.
  138678. */
  138679. cameraExposure: number;
  138680. /**
  138681. * The value of the contrast to apply to the scene.
  138682. * 1.6 by default if setupImageProcessing is true.
  138683. */
  138684. cameraContrast: number;
  138685. /**
  138686. * Specifies whether or not tonemapping should be enabled in the scene.
  138687. * true by default if setupImageProcessing is true.
  138688. */
  138689. toneMappingEnabled: boolean;
  138690. }
  138691. /**
  138692. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138693. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138694. * It also helps with the default setup of your imageProcessing configuration.
  138695. */
  138696. export class EnvironmentHelper {
  138697. /**
  138698. * Default ground texture URL.
  138699. */
  138700. private static _groundTextureCDNUrl;
  138701. /**
  138702. * Default skybox texture URL.
  138703. */
  138704. private static _skyboxTextureCDNUrl;
  138705. /**
  138706. * Default environment texture URL.
  138707. */
  138708. private static _environmentTextureCDNUrl;
  138709. /**
  138710. * Creates the default options for the helper.
  138711. */
  138712. private static _getDefaultOptions;
  138713. private _rootMesh;
  138714. /**
  138715. * Gets the root mesh created by the helper.
  138716. */
  138717. get rootMesh(): Mesh;
  138718. private _skybox;
  138719. /**
  138720. * Gets the skybox created by the helper.
  138721. */
  138722. get skybox(): Nullable<Mesh>;
  138723. private _skyboxTexture;
  138724. /**
  138725. * Gets the skybox texture created by the helper.
  138726. */
  138727. get skyboxTexture(): Nullable<BaseTexture>;
  138728. private _skyboxMaterial;
  138729. /**
  138730. * Gets the skybox material created by the helper.
  138731. */
  138732. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138733. private _ground;
  138734. /**
  138735. * Gets the ground mesh created by the helper.
  138736. */
  138737. get ground(): Nullable<Mesh>;
  138738. private _groundTexture;
  138739. /**
  138740. * Gets the ground texture created by the helper.
  138741. */
  138742. get groundTexture(): Nullable<BaseTexture>;
  138743. private _groundMirror;
  138744. /**
  138745. * Gets the ground mirror created by the helper.
  138746. */
  138747. get groundMirror(): Nullable<MirrorTexture>;
  138748. /**
  138749. * Gets the ground mirror render list to helps pushing the meshes
  138750. * you wish in the ground reflection.
  138751. */
  138752. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138753. private _groundMaterial;
  138754. /**
  138755. * Gets the ground material created by the helper.
  138756. */
  138757. get groundMaterial(): Nullable<BackgroundMaterial>;
  138758. /**
  138759. * Stores the creation options.
  138760. */
  138761. private readonly _scene;
  138762. private _options;
  138763. /**
  138764. * This observable will be notified with any error during the creation of the environment,
  138765. * mainly texture creation errors.
  138766. */
  138767. onErrorObservable: Observable<{
  138768. message?: string;
  138769. exception?: any;
  138770. }>;
  138771. /**
  138772. * constructor
  138773. * @param options Defines the options we want to customize the helper
  138774. * @param scene The scene to add the material to
  138775. */
  138776. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138777. /**
  138778. * Updates the background according to the new options
  138779. * @param options
  138780. */
  138781. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138782. /**
  138783. * Sets the primary color of all the available elements.
  138784. * @param color the main color to affect to the ground and the background
  138785. */
  138786. setMainColor(color: Color3): void;
  138787. /**
  138788. * Setup the image processing according to the specified options.
  138789. */
  138790. private _setupImageProcessing;
  138791. /**
  138792. * Setup the environment texture according to the specified options.
  138793. */
  138794. private _setupEnvironmentTexture;
  138795. /**
  138796. * Setup the background according to the specified options.
  138797. */
  138798. private _setupBackground;
  138799. /**
  138800. * Get the scene sizes according to the setup.
  138801. */
  138802. private _getSceneSize;
  138803. /**
  138804. * Setup the ground according to the specified options.
  138805. */
  138806. private _setupGround;
  138807. /**
  138808. * Setup the ground material according to the specified options.
  138809. */
  138810. private _setupGroundMaterial;
  138811. /**
  138812. * Setup the ground diffuse texture according to the specified options.
  138813. */
  138814. private _setupGroundDiffuseTexture;
  138815. /**
  138816. * Setup the ground mirror texture according to the specified options.
  138817. */
  138818. private _setupGroundMirrorTexture;
  138819. /**
  138820. * Setup the ground to receive the mirror texture.
  138821. */
  138822. private _setupMirrorInGroundMaterial;
  138823. /**
  138824. * Setup the skybox according to the specified options.
  138825. */
  138826. private _setupSkybox;
  138827. /**
  138828. * Setup the skybox material according to the specified options.
  138829. */
  138830. private _setupSkyboxMaterial;
  138831. /**
  138832. * Setup the skybox reflection texture according to the specified options.
  138833. */
  138834. private _setupSkyboxReflectionTexture;
  138835. private _errorHandler;
  138836. /**
  138837. * Dispose all the elements created by the Helper.
  138838. */
  138839. dispose(): void;
  138840. }
  138841. }
  138842. declare module BABYLON {
  138843. /**
  138844. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138845. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138846. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138847. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138848. */
  138849. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138850. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138851. /**
  138852. * Define the source as a Monoscopic panoramic 360/180.
  138853. */
  138854. static readonly MODE_MONOSCOPIC: number;
  138855. /**
  138856. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138857. */
  138858. static readonly MODE_TOPBOTTOM: number;
  138859. /**
  138860. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138861. */
  138862. static readonly MODE_SIDEBYSIDE: number;
  138863. private _halfDome;
  138864. private _crossEye;
  138865. protected _useDirectMapping: boolean;
  138866. /**
  138867. * The texture being displayed on the sphere
  138868. */
  138869. protected _texture: T;
  138870. /**
  138871. * Gets the texture being displayed on the sphere
  138872. */
  138873. get texture(): T;
  138874. /**
  138875. * Sets the texture being displayed on the sphere
  138876. */
  138877. set texture(newTexture: T);
  138878. /**
  138879. * The skybox material
  138880. */
  138881. protected _material: BackgroundMaterial;
  138882. /**
  138883. * The surface used for the dome
  138884. */
  138885. protected _mesh: Mesh;
  138886. /**
  138887. * Gets the mesh used for the dome.
  138888. */
  138889. get mesh(): Mesh;
  138890. /**
  138891. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138892. */
  138893. private _halfDomeMask;
  138894. /**
  138895. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138896. * Also see the options.resolution property.
  138897. */
  138898. get fovMultiplier(): number;
  138899. set fovMultiplier(value: number);
  138900. protected _textureMode: number;
  138901. /**
  138902. * Gets or set the current texture mode for the texture. It can be:
  138903. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138904. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138905. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138906. */
  138907. get textureMode(): number;
  138908. /**
  138909. * Sets the current texture mode for the texture. It can be:
  138910. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138911. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138912. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138913. */
  138914. set textureMode(value: number);
  138915. /**
  138916. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138917. */
  138918. get halfDome(): boolean;
  138919. /**
  138920. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138921. */
  138922. set halfDome(enabled: boolean);
  138923. /**
  138924. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  138925. */
  138926. set crossEye(enabled: boolean);
  138927. /**
  138928. * Is it a cross-eye texture?
  138929. */
  138930. get crossEye(): boolean;
  138931. /**
  138932. * The background material of this dome.
  138933. */
  138934. get material(): BackgroundMaterial;
  138935. /**
  138936. * Oberserver used in Stereoscopic VR Mode.
  138937. */
  138938. private _onBeforeCameraRenderObserver;
  138939. /**
  138940. * Observable raised when an error occured while loading the 360 image
  138941. */
  138942. onLoadErrorObservable: Observable<string>;
  138943. /**
  138944. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138945. * @param name Element's name, child elements will append suffixes for their own names.
  138946. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138947. * @param options An object containing optional or exposed sub element properties
  138948. */
  138949. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138950. resolution?: number;
  138951. clickToPlay?: boolean;
  138952. autoPlay?: boolean;
  138953. loop?: boolean;
  138954. size?: number;
  138955. poster?: string;
  138956. faceForward?: boolean;
  138957. useDirectMapping?: boolean;
  138958. halfDomeMode?: boolean;
  138959. crossEyeMode?: boolean;
  138960. generateMipMaps?: boolean;
  138961. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138962. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138963. protected _changeTextureMode(value: number): void;
  138964. /**
  138965. * Releases resources associated with this node.
  138966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138968. */
  138969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138970. }
  138971. }
  138972. declare module BABYLON {
  138973. /**
  138974. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138975. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  138976. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138977. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138978. */
  138979. export class PhotoDome extends TextureDome<Texture> {
  138980. /**
  138981. * Define the image as a Monoscopic panoramic 360 image.
  138982. */
  138983. static readonly MODE_MONOSCOPIC: number;
  138984. /**
  138985. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  138986. */
  138987. static readonly MODE_TOPBOTTOM: number;
  138988. /**
  138989. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  138990. */
  138991. static readonly MODE_SIDEBYSIDE: number;
  138992. /**
  138993. * Gets or sets the texture being displayed on the sphere
  138994. */
  138995. get photoTexture(): Texture;
  138996. /**
  138997. * sets the texture being displayed on the sphere
  138998. */
  138999. set photoTexture(value: Texture);
  139000. /**
  139001. * Gets the current video mode for the video. It can be:
  139002. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139003. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139004. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139005. */
  139006. get imageMode(): number;
  139007. /**
  139008. * Sets the current video mode for the video. It can be:
  139009. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139010. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139011. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139012. */
  139013. set imageMode(value: number);
  139014. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139015. }
  139016. }
  139017. declare module BABYLON {
  139018. /**
  139019. * Direct draw surface info
  139020. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139021. */
  139022. export interface DDSInfo {
  139023. /**
  139024. * Width of the texture
  139025. */
  139026. width: number;
  139027. /**
  139028. * Width of the texture
  139029. */
  139030. height: number;
  139031. /**
  139032. * Number of Mipmaps for the texture
  139033. * @see https://en.wikipedia.org/wiki/Mipmap
  139034. */
  139035. mipmapCount: number;
  139036. /**
  139037. * If the textures format is a known fourCC format
  139038. * @see https://www.fourcc.org/
  139039. */
  139040. isFourCC: boolean;
  139041. /**
  139042. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139043. */
  139044. isRGB: boolean;
  139045. /**
  139046. * If the texture is a lumincance format
  139047. */
  139048. isLuminance: boolean;
  139049. /**
  139050. * If this is a cube texture
  139051. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139052. */
  139053. isCube: boolean;
  139054. /**
  139055. * If the texture is a compressed format eg. FOURCC_DXT1
  139056. */
  139057. isCompressed: boolean;
  139058. /**
  139059. * The dxgiFormat of the texture
  139060. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139061. */
  139062. dxgiFormat: number;
  139063. /**
  139064. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139065. */
  139066. textureType: number;
  139067. /**
  139068. * Sphericle polynomial created for the dds texture
  139069. */
  139070. sphericalPolynomial?: SphericalPolynomial;
  139071. }
  139072. /**
  139073. * Class used to provide DDS decompression tools
  139074. */
  139075. export class DDSTools {
  139076. /**
  139077. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139078. */
  139079. static StoreLODInAlphaChannel: boolean;
  139080. /**
  139081. * Gets DDS information from an array buffer
  139082. * @param data defines the array buffer view to read data from
  139083. * @returns the DDS information
  139084. */
  139085. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139086. private static _FloatView;
  139087. private static _Int32View;
  139088. private static _ToHalfFloat;
  139089. private static _FromHalfFloat;
  139090. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139091. private static _GetHalfFloatRGBAArrayBuffer;
  139092. private static _GetFloatRGBAArrayBuffer;
  139093. private static _GetFloatAsUIntRGBAArrayBuffer;
  139094. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139095. private static _GetRGBAArrayBuffer;
  139096. private static _ExtractLongWordOrder;
  139097. private static _GetRGBArrayBuffer;
  139098. private static _GetLuminanceArrayBuffer;
  139099. /**
  139100. * Uploads DDS Levels to a Babylon Texture
  139101. * @hidden
  139102. */
  139103. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139104. }
  139105. interface ThinEngine {
  139106. /**
  139107. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139108. * @param rootUrl defines the url where the file to load is located
  139109. * @param scene defines the current scene
  139110. * @param lodScale defines scale to apply to the mip map selection
  139111. * @param lodOffset defines offset to apply to the mip map selection
  139112. * @param onLoad defines an optional callback raised when the texture is loaded
  139113. * @param onError defines an optional callback raised if there is an issue to load the texture
  139114. * @param format defines the format of the data
  139115. * @param forcedExtension defines the extension to use to pick the right loader
  139116. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139117. * @returns the cube texture as an InternalTexture
  139118. */
  139119. 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;
  139120. }
  139121. }
  139122. declare module BABYLON {
  139123. /**
  139124. * Implementation of the DDS Texture Loader.
  139125. * @hidden
  139126. */
  139127. export class _DDSTextureLoader implements IInternalTextureLoader {
  139128. /**
  139129. * Defines wether the loader supports cascade loading the different faces.
  139130. */
  139131. readonly supportCascades: boolean;
  139132. /**
  139133. * This returns if the loader support the current file information.
  139134. * @param extension defines the file extension of the file being loaded
  139135. * @returns true if the loader can load the specified file
  139136. */
  139137. canLoad(extension: string): boolean;
  139138. /**
  139139. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139140. * @param data contains the texture data
  139141. * @param texture defines the BabylonJS internal texture
  139142. * @param createPolynomials will be true if polynomials have been requested
  139143. * @param onLoad defines the callback to trigger once the texture is ready
  139144. * @param onError defines the callback to trigger in case of error
  139145. */
  139146. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139147. /**
  139148. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139149. * @param data contains the texture data
  139150. * @param texture defines the BabylonJS internal texture
  139151. * @param callback defines the method to call once ready to upload
  139152. */
  139153. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139154. }
  139155. }
  139156. declare module BABYLON {
  139157. /**
  139158. * Implementation of the ENV Texture Loader.
  139159. * @hidden
  139160. */
  139161. export class _ENVTextureLoader implements IInternalTextureLoader {
  139162. /**
  139163. * Defines wether the loader supports cascade loading the different faces.
  139164. */
  139165. readonly supportCascades: boolean;
  139166. /**
  139167. * This returns if the loader support the current file information.
  139168. * @param extension defines the file extension of the file being loaded
  139169. * @returns true if the loader can load the specified file
  139170. */
  139171. canLoad(extension: string): boolean;
  139172. /**
  139173. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139174. * @param data contains the texture data
  139175. * @param texture defines the BabylonJS internal texture
  139176. * @param createPolynomials will be true if polynomials have been requested
  139177. * @param onLoad defines the callback to trigger once the texture is ready
  139178. * @param onError defines the callback to trigger in case of error
  139179. */
  139180. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139181. /**
  139182. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139183. * @param data contains the texture data
  139184. * @param texture defines the BabylonJS internal texture
  139185. * @param callback defines the method to call once ready to upload
  139186. */
  139187. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139188. }
  139189. }
  139190. declare module BABYLON {
  139191. /**
  139192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139194. */
  139195. export class KhronosTextureContainer {
  139196. /** contents of the KTX container file */
  139197. data: ArrayBufferView;
  139198. private static HEADER_LEN;
  139199. private static COMPRESSED_2D;
  139200. private static COMPRESSED_3D;
  139201. private static TEX_2D;
  139202. private static TEX_3D;
  139203. /**
  139204. * Gets the openGL type
  139205. */
  139206. glType: number;
  139207. /**
  139208. * Gets the openGL type size
  139209. */
  139210. glTypeSize: number;
  139211. /**
  139212. * Gets the openGL format
  139213. */
  139214. glFormat: number;
  139215. /**
  139216. * Gets the openGL internal format
  139217. */
  139218. glInternalFormat: number;
  139219. /**
  139220. * Gets the base internal format
  139221. */
  139222. glBaseInternalFormat: number;
  139223. /**
  139224. * Gets image width in pixel
  139225. */
  139226. pixelWidth: number;
  139227. /**
  139228. * Gets image height in pixel
  139229. */
  139230. pixelHeight: number;
  139231. /**
  139232. * Gets image depth in pixels
  139233. */
  139234. pixelDepth: number;
  139235. /**
  139236. * Gets the number of array elements
  139237. */
  139238. numberOfArrayElements: number;
  139239. /**
  139240. * Gets the number of faces
  139241. */
  139242. numberOfFaces: number;
  139243. /**
  139244. * Gets the number of mipmap levels
  139245. */
  139246. numberOfMipmapLevels: number;
  139247. /**
  139248. * Gets the bytes of key value data
  139249. */
  139250. bytesOfKeyValueData: number;
  139251. /**
  139252. * Gets the load type
  139253. */
  139254. loadType: number;
  139255. /**
  139256. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139257. */
  139258. isInvalid: boolean;
  139259. /**
  139260. * Creates a new KhronosTextureContainer
  139261. * @param data contents of the KTX container file
  139262. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139263. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139264. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139265. */
  139266. constructor(
  139267. /** contents of the KTX container file */
  139268. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139269. /**
  139270. * Uploads KTX content to a Babylon Texture.
  139271. * It is assumed that the texture has already been created & is currently bound
  139272. * @hidden
  139273. */
  139274. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139275. private _upload2DCompressedLevels;
  139276. /**
  139277. * Checks if the given data starts with a KTX file identifier.
  139278. * @param data the data to check
  139279. * @returns true if the data is a KTX file or false otherwise
  139280. */
  139281. static IsValid(data: ArrayBufferView): boolean;
  139282. }
  139283. }
  139284. declare module BABYLON {
  139285. /**
  139286. * Helper class to push actions to a pool of workers.
  139287. */
  139288. export class WorkerPool implements IDisposable {
  139289. private _workerInfos;
  139290. private _pendingActions;
  139291. /**
  139292. * Constructor
  139293. * @param workers Array of workers to use for actions
  139294. */
  139295. constructor(workers: Array<Worker>);
  139296. /**
  139297. * Terminates all workers and clears any pending actions.
  139298. */
  139299. dispose(): void;
  139300. /**
  139301. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139302. * pended until a worker has completed its action.
  139303. * @param action The action to perform. Call onComplete when the action is complete.
  139304. */
  139305. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139306. private _execute;
  139307. }
  139308. }
  139309. declare module BABYLON {
  139310. /**
  139311. * Class for loading KTX2 files
  139312. */
  139313. export class KhronosTextureContainer2 {
  139314. private static _WorkerPoolPromise?;
  139315. private static _Initialized;
  139316. private static _Ktx2Decoder;
  139317. /**
  139318. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139319. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139320. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139321. * Urls you can change:
  139322. * URLConfig.jsDecoderModule
  139323. * URLConfig.wasmUASTCToASTC
  139324. * URLConfig.wasmUASTCToBC7
  139325. * URLConfig.jsMSCTranscoder
  139326. * URLConfig.wasmMSCTranscoder
  139327. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139328. */
  139329. static URLConfig: {
  139330. jsDecoderModule: string;
  139331. wasmUASTCToASTC: null;
  139332. wasmUASTCToBC7: null;
  139333. jsMSCTranscoder: null;
  139334. wasmMSCTranscoder: null;
  139335. };
  139336. /**
  139337. * Default number of workers used to handle data decoding
  139338. */
  139339. static DefaultNumWorkers: number;
  139340. private static GetDefaultNumWorkers;
  139341. private _engine;
  139342. private static _CreateWorkerPool;
  139343. /**
  139344. * Constructor
  139345. * @param engine The engine to use
  139346. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139347. */
  139348. constructor(engine: ThinEngine, numWorkers?: number);
  139349. /** @hidden */
  139350. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  139351. /**
  139352. * Stop all async operations and release resources.
  139353. */
  139354. dispose(): void;
  139355. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139356. /**
  139357. * Checks if the given data starts with a KTX2 file identifier.
  139358. * @param data the data to check
  139359. * @returns true if the data is a KTX2 file or false otherwise
  139360. */
  139361. static IsValid(data: ArrayBufferView): boolean;
  139362. }
  139363. }
  139364. declare module BABYLON {
  139365. /**
  139366. * Implementation of the KTX Texture Loader.
  139367. * @hidden
  139368. */
  139369. export class _KTXTextureLoader implements IInternalTextureLoader {
  139370. /**
  139371. * Defines wether the loader supports cascade loading the different faces.
  139372. */
  139373. readonly supportCascades: boolean;
  139374. /**
  139375. * This returns if the loader support the current file information.
  139376. * @param extension defines the file extension of the file being loaded
  139377. * @param mimeType defines the optional mime type of the file being loaded
  139378. * @returns true if the loader can load the specified file
  139379. */
  139380. canLoad(extension: string, mimeType?: string): boolean;
  139381. /**
  139382. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139383. * @param data contains the texture data
  139384. * @param texture defines the BabylonJS internal texture
  139385. * @param createPolynomials will be true if polynomials have been requested
  139386. * @param onLoad defines the callback to trigger once the texture is ready
  139387. * @param onError defines the callback to trigger in case of error
  139388. */
  139389. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139390. /**
  139391. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139392. * @param data contains the texture data
  139393. * @param texture defines the BabylonJS internal texture
  139394. * @param callback defines the method to call once ready to upload
  139395. */
  139396. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  139397. }
  139398. }
  139399. declare module BABYLON {
  139400. /** @hidden */
  139401. export var _forceSceneHelpersToBundle: boolean;
  139402. interface Scene {
  139403. /**
  139404. * Creates a default light for the scene.
  139405. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139406. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139407. */
  139408. createDefaultLight(replace?: boolean): void;
  139409. /**
  139410. * Creates a default camera for the scene.
  139411. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139412. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139413. * @param replace has default false, when true replaces the active camera in the scene
  139414. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139415. */
  139416. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139417. /**
  139418. * Creates a default camera and a default light.
  139419. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139420. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139421. * @param replace has the default false, when true replaces the active camera/light in the scene
  139422. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139423. */
  139424. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139425. /**
  139426. * Creates a new sky box
  139427. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139428. * @param environmentTexture defines the texture to use as environment texture
  139429. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139430. * @param scale defines the overall scale of the skybox
  139431. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139432. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139433. * @returns a new mesh holding the sky box
  139434. */
  139435. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139436. /**
  139437. * Creates a new environment
  139438. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139439. * @param options defines the options you can use to configure the environment
  139440. * @returns the new EnvironmentHelper
  139441. */
  139442. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139443. /**
  139444. * Creates a new VREXperienceHelper
  139445. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139446. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139447. * @returns a new VREXperienceHelper
  139448. */
  139449. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139450. /**
  139451. * Creates a new WebXRDefaultExperience
  139452. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139453. * @param options experience options
  139454. * @returns a promise for a new WebXRDefaultExperience
  139455. */
  139456. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139457. }
  139458. }
  139459. declare module BABYLON {
  139460. /**
  139461. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139462. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139463. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139464. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139465. */
  139466. export class VideoDome extends TextureDome<VideoTexture> {
  139467. /**
  139468. * Define the video source as a Monoscopic panoramic 360 video.
  139469. */
  139470. static readonly MODE_MONOSCOPIC: number;
  139471. /**
  139472. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139473. */
  139474. static readonly MODE_TOPBOTTOM: number;
  139475. /**
  139476. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139477. */
  139478. static readonly MODE_SIDEBYSIDE: number;
  139479. /**
  139480. * Get the video texture associated with this video dome
  139481. */
  139482. get videoTexture(): VideoTexture;
  139483. /**
  139484. * Get the video mode of this dome
  139485. */
  139486. get videoMode(): number;
  139487. /**
  139488. * Set the video mode of this dome.
  139489. * @see textureMode
  139490. */
  139491. set videoMode(value: number);
  139492. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139493. }
  139494. }
  139495. declare module BABYLON {
  139496. /**
  139497. * This class can be used to get instrumentation data from a Babylon engine
  139498. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139499. */
  139500. export class EngineInstrumentation implements IDisposable {
  139501. /**
  139502. * Define the instrumented engine.
  139503. */
  139504. engine: Engine;
  139505. private _captureGPUFrameTime;
  139506. private _gpuFrameTimeToken;
  139507. private _gpuFrameTime;
  139508. private _captureShaderCompilationTime;
  139509. private _shaderCompilationTime;
  139510. private _onBeginFrameObserver;
  139511. private _onEndFrameObserver;
  139512. private _onBeforeShaderCompilationObserver;
  139513. private _onAfterShaderCompilationObserver;
  139514. /**
  139515. * Gets the perf counter used for GPU frame time
  139516. */
  139517. get gpuFrameTimeCounter(): PerfCounter;
  139518. /**
  139519. * Gets the GPU frame time capture status
  139520. */
  139521. get captureGPUFrameTime(): boolean;
  139522. /**
  139523. * Enable or disable the GPU frame time capture
  139524. */
  139525. set captureGPUFrameTime(value: boolean);
  139526. /**
  139527. * Gets the perf counter used for shader compilation time
  139528. */
  139529. get shaderCompilationTimeCounter(): PerfCounter;
  139530. /**
  139531. * Gets the shader compilation time capture status
  139532. */
  139533. get captureShaderCompilationTime(): boolean;
  139534. /**
  139535. * Enable or disable the shader compilation time capture
  139536. */
  139537. set captureShaderCompilationTime(value: boolean);
  139538. /**
  139539. * Instantiates a new engine instrumentation.
  139540. * This class can be used to get instrumentation data from a Babylon engine
  139541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139542. * @param engine Defines the engine to instrument
  139543. */
  139544. constructor(
  139545. /**
  139546. * Define the instrumented engine.
  139547. */
  139548. engine: Engine);
  139549. /**
  139550. * Dispose and release associated resources.
  139551. */
  139552. dispose(): void;
  139553. }
  139554. }
  139555. declare module BABYLON {
  139556. /**
  139557. * This class can be used to get instrumentation data from a Babylon engine
  139558. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139559. */
  139560. export class SceneInstrumentation implements IDisposable {
  139561. /**
  139562. * Defines the scene to instrument
  139563. */
  139564. scene: Scene;
  139565. private _captureActiveMeshesEvaluationTime;
  139566. private _activeMeshesEvaluationTime;
  139567. private _captureRenderTargetsRenderTime;
  139568. private _renderTargetsRenderTime;
  139569. private _captureFrameTime;
  139570. private _frameTime;
  139571. private _captureRenderTime;
  139572. private _renderTime;
  139573. private _captureInterFrameTime;
  139574. private _interFrameTime;
  139575. private _captureParticlesRenderTime;
  139576. private _particlesRenderTime;
  139577. private _captureSpritesRenderTime;
  139578. private _spritesRenderTime;
  139579. private _capturePhysicsTime;
  139580. private _physicsTime;
  139581. private _captureAnimationsTime;
  139582. private _animationsTime;
  139583. private _captureCameraRenderTime;
  139584. private _cameraRenderTime;
  139585. private _onBeforeActiveMeshesEvaluationObserver;
  139586. private _onAfterActiveMeshesEvaluationObserver;
  139587. private _onBeforeRenderTargetsRenderObserver;
  139588. private _onAfterRenderTargetsRenderObserver;
  139589. private _onAfterRenderObserver;
  139590. private _onBeforeDrawPhaseObserver;
  139591. private _onAfterDrawPhaseObserver;
  139592. private _onBeforeAnimationsObserver;
  139593. private _onBeforeParticlesRenderingObserver;
  139594. private _onAfterParticlesRenderingObserver;
  139595. private _onBeforeSpritesRenderingObserver;
  139596. private _onAfterSpritesRenderingObserver;
  139597. private _onBeforePhysicsObserver;
  139598. private _onAfterPhysicsObserver;
  139599. private _onAfterAnimationsObserver;
  139600. private _onBeforeCameraRenderObserver;
  139601. private _onAfterCameraRenderObserver;
  139602. /**
  139603. * Gets the perf counter used for active meshes evaluation time
  139604. */
  139605. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139606. /**
  139607. * Gets the active meshes evaluation time capture status
  139608. */
  139609. get captureActiveMeshesEvaluationTime(): boolean;
  139610. /**
  139611. * Enable or disable the active meshes evaluation time capture
  139612. */
  139613. set captureActiveMeshesEvaluationTime(value: boolean);
  139614. /**
  139615. * Gets the perf counter used for render targets render time
  139616. */
  139617. get renderTargetsRenderTimeCounter(): PerfCounter;
  139618. /**
  139619. * Gets the render targets render time capture status
  139620. */
  139621. get captureRenderTargetsRenderTime(): boolean;
  139622. /**
  139623. * Enable or disable the render targets render time capture
  139624. */
  139625. set captureRenderTargetsRenderTime(value: boolean);
  139626. /**
  139627. * Gets the perf counter used for particles render time
  139628. */
  139629. get particlesRenderTimeCounter(): PerfCounter;
  139630. /**
  139631. * Gets the particles render time capture status
  139632. */
  139633. get captureParticlesRenderTime(): boolean;
  139634. /**
  139635. * Enable or disable the particles render time capture
  139636. */
  139637. set captureParticlesRenderTime(value: boolean);
  139638. /**
  139639. * Gets the perf counter used for sprites render time
  139640. */
  139641. get spritesRenderTimeCounter(): PerfCounter;
  139642. /**
  139643. * Gets the sprites render time capture status
  139644. */
  139645. get captureSpritesRenderTime(): boolean;
  139646. /**
  139647. * Enable or disable the sprites render time capture
  139648. */
  139649. set captureSpritesRenderTime(value: boolean);
  139650. /**
  139651. * Gets the perf counter used for physics time
  139652. */
  139653. get physicsTimeCounter(): PerfCounter;
  139654. /**
  139655. * Gets the physics time capture status
  139656. */
  139657. get capturePhysicsTime(): boolean;
  139658. /**
  139659. * Enable or disable the physics time capture
  139660. */
  139661. set capturePhysicsTime(value: boolean);
  139662. /**
  139663. * Gets the perf counter used for animations time
  139664. */
  139665. get animationsTimeCounter(): PerfCounter;
  139666. /**
  139667. * Gets the animations time capture status
  139668. */
  139669. get captureAnimationsTime(): boolean;
  139670. /**
  139671. * Enable or disable the animations time capture
  139672. */
  139673. set captureAnimationsTime(value: boolean);
  139674. /**
  139675. * Gets the perf counter used for frame time capture
  139676. */
  139677. get frameTimeCounter(): PerfCounter;
  139678. /**
  139679. * Gets the frame time capture status
  139680. */
  139681. get captureFrameTime(): boolean;
  139682. /**
  139683. * Enable or disable the frame time capture
  139684. */
  139685. set captureFrameTime(value: boolean);
  139686. /**
  139687. * Gets the perf counter used for inter-frames time capture
  139688. */
  139689. get interFrameTimeCounter(): PerfCounter;
  139690. /**
  139691. * Gets the inter-frames time capture status
  139692. */
  139693. get captureInterFrameTime(): boolean;
  139694. /**
  139695. * Enable or disable the inter-frames time capture
  139696. */
  139697. set captureInterFrameTime(value: boolean);
  139698. /**
  139699. * Gets the perf counter used for render time capture
  139700. */
  139701. get renderTimeCounter(): PerfCounter;
  139702. /**
  139703. * Gets the render time capture status
  139704. */
  139705. get captureRenderTime(): boolean;
  139706. /**
  139707. * Enable or disable the render time capture
  139708. */
  139709. set captureRenderTime(value: boolean);
  139710. /**
  139711. * Gets the perf counter used for camera render time capture
  139712. */
  139713. get cameraRenderTimeCounter(): PerfCounter;
  139714. /**
  139715. * Gets the camera render time capture status
  139716. */
  139717. get captureCameraRenderTime(): boolean;
  139718. /**
  139719. * Enable or disable the camera render time capture
  139720. */
  139721. set captureCameraRenderTime(value: boolean);
  139722. /**
  139723. * Gets the perf counter used for draw calls
  139724. */
  139725. get drawCallsCounter(): PerfCounter;
  139726. /**
  139727. * Instantiates a new scene instrumentation.
  139728. * This class can be used to get instrumentation data from a Babylon engine
  139729. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139730. * @param scene Defines the scene to instrument
  139731. */
  139732. constructor(
  139733. /**
  139734. * Defines the scene to instrument
  139735. */
  139736. scene: Scene);
  139737. /**
  139738. * Dispose and release associated resources.
  139739. */
  139740. dispose(): void;
  139741. }
  139742. }
  139743. declare module BABYLON {
  139744. /** @hidden */
  139745. export var glowMapGenerationPixelShader: {
  139746. name: string;
  139747. shader: string;
  139748. };
  139749. }
  139750. declare module BABYLON {
  139751. /** @hidden */
  139752. export var glowMapGenerationVertexShader: {
  139753. name: string;
  139754. shader: string;
  139755. };
  139756. }
  139757. declare module BABYLON {
  139758. /**
  139759. * Effect layer options. This helps customizing the behaviour
  139760. * of the effect layer.
  139761. */
  139762. export interface IEffectLayerOptions {
  139763. /**
  139764. * Multiplication factor apply to the canvas size to compute the render target size
  139765. * used to generated the objects (the smaller the faster).
  139766. */
  139767. mainTextureRatio: number;
  139768. /**
  139769. * Enforces a fixed size texture to ensure effect stability across devices.
  139770. */
  139771. mainTextureFixedSize?: number;
  139772. /**
  139773. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139774. */
  139775. alphaBlendingMode: number;
  139776. /**
  139777. * The camera attached to the layer.
  139778. */
  139779. camera: Nullable<Camera>;
  139780. /**
  139781. * The rendering group to draw the layer in.
  139782. */
  139783. renderingGroupId: number;
  139784. }
  139785. /**
  139786. * The effect layer Helps adding post process effect blended with the main pass.
  139787. *
  139788. * This can be for instance use to generate glow or higlight effects on the scene.
  139789. *
  139790. * The effect layer class can not be used directly and is intented to inherited from to be
  139791. * customized per effects.
  139792. */
  139793. export abstract class EffectLayer {
  139794. private _vertexBuffers;
  139795. private _indexBuffer;
  139796. private _cachedDefines;
  139797. private _effectLayerMapGenerationEffect;
  139798. private _effectLayerOptions;
  139799. private _mergeEffect;
  139800. protected _scene: Scene;
  139801. protected _engine: Engine;
  139802. protected _maxSize: number;
  139803. protected _mainTextureDesiredSize: ISize;
  139804. protected _mainTexture: RenderTargetTexture;
  139805. protected _shouldRender: boolean;
  139806. protected _postProcesses: PostProcess[];
  139807. protected _textures: BaseTexture[];
  139808. protected _emissiveTextureAndColor: {
  139809. texture: Nullable<BaseTexture>;
  139810. color: Color4;
  139811. };
  139812. /**
  139813. * The name of the layer
  139814. */
  139815. name: string;
  139816. /**
  139817. * The clear color of the texture used to generate the glow map.
  139818. */
  139819. neutralColor: Color4;
  139820. /**
  139821. * Specifies whether the highlight layer is enabled or not.
  139822. */
  139823. isEnabled: boolean;
  139824. /**
  139825. * Gets the camera attached to the layer.
  139826. */
  139827. get camera(): Nullable<Camera>;
  139828. /**
  139829. * Gets the rendering group id the layer should render in.
  139830. */
  139831. get renderingGroupId(): number;
  139832. set renderingGroupId(renderingGroupId: number);
  139833. /**
  139834. * An event triggered when the effect layer has been disposed.
  139835. */
  139836. onDisposeObservable: Observable<EffectLayer>;
  139837. /**
  139838. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139839. */
  139840. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139841. /**
  139842. * An event triggered when the generated texture is being merged in the scene.
  139843. */
  139844. onBeforeComposeObservable: Observable<EffectLayer>;
  139845. /**
  139846. * An event triggered when the mesh is rendered into the effect render target.
  139847. */
  139848. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139849. /**
  139850. * An event triggered after the mesh has been rendered into the effect render target.
  139851. */
  139852. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139853. /**
  139854. * An event triggered when the generated texture has been merged in the scene.
  139855. */
  139856. onAfterComposeObservable: Observable<EffectLayer>;
  139857. /**
  139858. * An event triggered when the efffect layer changes its size.
  139859. */
  139860. onSizeChangedObservable: Observable<EffectLayer>;
  139861. /** @hidden */
  139862. static _SceneComponentInitialization: (scene: Scene) => void;
  139863. /**
  139864. * Instantiates a new effect Layer and references it in the scene.
  139865. * @param name The name of the layer
  139866. * @param scene The scene to use the layer in
  139867. */
  139868. constructor(
  139869. /** The Friendly of the effect in the scene */
  139870. name: string, scene: Scene);
  139871. /**
  139872. * Get the effect name of the layer.
  139873. * @return The effect name
  139874. */
  139875. abstract getEffectName(): string;
  139876. /**
  139877. * Checks for the readiness of the element composing the layer.
  139878. * @param subMesh the mesh to check for
  139879. * @param useInstances specify whether or not to use instances to render the mesh
  139880. * @return true if ready otherwise, false
  139881. */
  139882. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139883. /**
  139884. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139885. * @returns true if the effect requires stencil during the main canvas render pass.
  139886. */
  139887. abstract needStencil(): boolean;
  139888. /**
  139889. * Create the merge effect. This is the shader use to blit the information back
  139890. * to the main canvas at the end of the scene rendering.
  139891. * @returns The effect containing the shader used to merge the effect on the main canvas
  139892. */
  139893. protected abstract _createMergeEffect(): Effect;
  139894. /**
  139895. * Creates the render target textures and post processes used in the effect layer.
  139896. */
  139897. protected abstract _createTextureAndPostProcesses(): void;
  139898. /**
  139899. * Implementation specific of rendering the generating effect on the main canvas.
  139900. * @param effect The effect used to render through
  139901. */
  139902. protected abstract _internalRender(effect: Effect): void;
  139903. /**
  139904. * Sets the required values for both the emissive texture and and the main color.
  139905. */
  139906. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139907. /**
  139908. * Free any resources and references associated to a mesh.
  139909. * Internal use
  139910. * @param mesh The mesh to free.
  139911. */
  139912. abstract _disposeMesh(mesh: Mesh): void;
  139913. /**
  139914. * Serializes this layer (Glow or Highlight for example)
  139915. * @returns a serialized layer object
  139916. */
  139917. abstract serialize?(): any;
  139918. /**
  139919. * Initializes the effect layer with the required options.
  139920. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139921. */
  139922. protected _init(options: Partial<IEffectLayerOptions>): void;
  139923. /**
  139924. * Generates the index buffer of the full screen quad blending to the main canvas.
  139925. */
  139926. private _generateIndexBuffer;
  139927. /**
  139928. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139929. */
  139930. private _generateVertexBuffer;
  139931. /**
  139932. * Sets the main texture desired size which is the closest power of two
  139933. * of the engine canvas size.
  139934. */
  139935. private _setMainTextureSize;
  139936. /**
  139937. * Creates the main texture for the effect layer.
  139938. */
  139939. protected _createMainTexture(): void;
  139940. /**
  139941. * Adds specific effects defines.
  139942. * @param defines The defines to add specifics to.
  139943. */
  139944. protected _addCustomEffectDefines(defines: string[]): void;
  139945. /**
  139946. * Checks for the readiness of the element composing the layer.
  139947. * @param subMesh the mesh to check for
  139948. * @param useInstances specify whether or not to use instances to render the mesh
  139949. * @param emissiveTexture the associated emissive texture used to generate the glow
  139950. * @return true if ready otherwise, false
  139951. */
  139952. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139953. /**
  139954. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139955. */
  139956. render(): void;
  139957. /**
  139958. * Determine if a given mesh will be used in the current effect.
  139959. * @param mesh mesh to test
  139960. * @returns true if the mesh will be used
  139961. */
  139962. hasMesh(mesh: AbstractMesh): boolean;
  139963. /**
  139964. * Returns true if the layer contains information to display, otherwise false.
  139965. * @returns true if the glow layer should be rendered
  139966. */
  139967. shouldRender(): boolean;
  139968. /**
  139969. * Returns true if the mesh should render, otherwise false.
  139970. * @param mesh The mesh to render
  139971. * @returns true if it should render otherwise false
  139972. */
  139973. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139974. /**
  139975. * Returns true if the mesh can be rendered, otherwise false.
  139976. * @param mesh The mesh to render
  139977. * @param material The material used on the mesh
  139978. * @returns true if it can be rendered otherwise false
  139979. */
  139980. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139981. /**
  139982. * Returns true if the mesh should render, otherwise false.
  139983. * @param mesh The mesh to render
  139984. * @returns true if it should render otherwise false
  139985. */
  139986. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139987. /**
  139988. * Renders the submesh passed in parameter to the generation map.
  139989. */
  139990. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139991. /**
  139992. * Defines whether the current material of the mesh should be use to render the effect.
  139993. * @param mesh defines the current mesh to render
  139994. */
  139995. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139996. /**
  139997. * Rebuild the required buffers.
  139998. * @hidden Internal use only.
  139999. */
  140000. _rebuild(): void;
  140001. /**
  140002. * Dispose only the render target textures and post process.
  140003. */
  140004. private _disposeTextureAndPostProcesses;
  140005. /**
  140006. * Dispose the highlight layer and free resources.
  140007. */
  140008. dispose(): void;
  140009. /**
  140010. * Gets the class name of the effect layer
  140011. * @returns the string with the class name of the effect layer
  140012. */
  140013. getClassName(): string;
  140014. /**
  140015. * Creates an effect layer from parsed effect layer data
  140016. * @param parsedEffectLayer defines effect layer data
  140017. * @param scene defines the current scene
  140018. * @param rootUrl defines the root URL containing the effect layer information
  140019. * @returns a parsed effect Layer
  140020. */
  140021. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140022. }
  140023. }
  140024. declare module BABYLON {
  140025. interface AbstractScene {
  140026. /**
  140027. * The list of effect layers (highlights/glow) added to the scene
  140028. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140029. * @see https://doc.babylonjs.com/how_to/glow_layer
  140030. */
  140031. effectLayers: Array<EffectLayer>;
  140032. /**
  140033. * Removes the given effect layer from this scene.
  140034. * @param toRemove defines the effect layer to remove
  140035. * @returns the index of the removed effect layer
  140036. */
  140037. removeEffectLayer(toRemove: EffectLayer): number;
  140038. /**
  140039. * Adds the given effect layer to this scene
  140040. * @param newEffectLayer defines the effect layer to add
  140041. */
  140042. addEffectLayer(newEffectLayer: EffectLayer): void;
  140043. }
  140044. /**
  140045. * Defines the layer scene component responsible to manage any effect layers
  140046. * in a given scene.
  140047. */
  140048. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140049. /**
  140050. * The component name helpfull to identify the component in the list of scene components.
  140051. */
  140052. readonly name: string;
  140053. /**
  140054. * The scene the component belongs to.
  140055. */
  140056. scene: Scene;
  140057. private _engine;
  140058. private _renderEffects;
  140059. private _needStencil;
  140060. private _previousStencilState;
  140061. /**
  140062. * Creates a new instance of the component for the given scene
  140063. * @param scene Defines the scene to register the component in
  140064. */
  140065. constructor(scene: Scene);
  140066. /**
  140067. * Registers the component in a given scene
  140068. */
  140069. register(): void;
  140070. /**
  140071. * Rebuilds the elements related to this component in case of
  140072. * context lost for instance.
  140073. */
  140074. rebuild(): void;
  140075. /**
  140076. * Serializes the component data to the specified json object
  140077. * @param serializationObject The object to serialize to
  140078. */
  140079. serialize(serializationObject: any): void;
  140080. /**
  140081. * Adds all the elements from the container to the scene
  140082. * @param container the container holding the elements
  140083. */
  140084. addFromContainer(container: AbstractScene): void;
  140085. /**
  140086. * Removes all the elements in the container from the scene
  140087. * @param container contains the elements to remove
  140088. * @param dispose if the removed element should be disposed (default: false)
  140089. */
  140090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140091. /**
  140092. * Disposes the component and the associated ressources.
  140093. */
  140094. dispose(): void;
  140095. private _isReadyForMesh;
  140096. private _renderMainTexture;
  140097. private _setStencil;
  140098. private _setStencilBack;
  140099. private _draw;
  140100. private _drawCamera;
  140101. private _drawRenderingGroup;
  140102. }
  140103. }
  140104. declare module BABYLON {
  140105. /** @hidden */
  140106. export var glowMapMergePixelShader: {
  140107. name: string;
  140108. shader: string;
  140109. };
  140110. }
  140111. declare module BABYLON {
  140112. /** @hidden */
  140113. export var glowMapMergeVertexShader: {
  140114. name: string;
  140115. shader: string;
  140116. };
  140117. }
  140118. declare module BABYLON {
  140119. interface AbstractScene {
  140120. /**
  140121. * Return a the first highlight layer of the scene with a given name.
  140122. * @param name The name of the highlight layer to look for.
  140123. * @return The highlight layer if found otherwise null.
  140124. */
  140125. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140126. }
  140127. /**
  140128. * Glow layer options. This helps customizing the behaviour
  140129. * of the glow layer.
  140130. */
  140131. export interface IGlowLayerOptions {
  140132. /**
  140133. * Multiplication factor apply to the canvas size to compute the render target size
  140134. * used to generated the glowing objects (the smaller the faster).
  140135. */
  140136. mainTextureRatio: number;
  140137. /**
  140138. * Enforces a fixed size texture to ensure resize independant blur.
  140139. */
  140140. mainTextureFixedSize?: number;
  140141. /**
  140142. * How big is the kernel of the blur texture.
  140143. */
  140144. blurKernelSize: number;
  140145. /**
  140146. * The camera attached to the layer.
  140147. */
  140148. camera: Nullable<Camera>;
  140149. /**
  140150. * Enable MSAA by chosing the number of samples.
  140151. */
  140152. mainTextureSamples?: number;
  140153. /**
  140154. * The rendering group to draw the layer in.
  140155. */
  140156. renderingGroupId: number;
  140157. }
  140158. /**
  140159. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140160. *
  140161. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140162. *
  140163. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140164. */
  140165. export class GlowLayer extends EffectLayer {
  140166. /**
  140167. * Effect Name of the layer.
  140168. */
  140169. static readonly EffectName: string;
  140170. /**
  140171. * The default blur kernel size used for the glow.
  140172. */
  140173. static DefaultBlurKernelSize: number;
  140174. /**
  140175. * The default texture size ratio used for the glow.
  140176. */
  140177. static DefaultTextureRatio: number;
  140178. /**
  140179. * Sets the kernel size of the blur.
  140180. */
  140181. set blurKernelSize(value: number);
  140182. /**
  140183. * Gets the kernel size of the blur.
  140184. */
  140185. get blurKernelSize(): number;
  140186. /**
  140187. * Sets the glow intensity.
  140188. */
  140189. set intensity(value: number);
  140190. /**
  140191. * Gets the glow intensity.
  140192. */
  140193. get intensity(): number;
  140194. private _options;
  140195. private _intensity;
  140196. private _horizontalBlurPostprocess1;
  140197. private _verticalBlurPostprocess1;
  140198. private _horizontalBlurPostprocess2;
  140199. private _verticalBlurPostprocess2;
  140200. private _blurTexture1;
  140201. private _blurTexture2;
  140202. private _postProcesses1;
  140203. private _postProcesses2;
  140204. private _includedOnlyMeshes;
  140205. private _excludedMeshes;
  140206. private _meshesUsingTheirOwnMaterials;
  140207. /**
  140208. * Callback used to let the user override the color selection on a per mesh basis
  140209. */
  140210. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140211. /**
  140212. * Callback used to let the user override the texture selection on a per mesh basis
  140213. */
  140214. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140215. /**
  140216. * Instantiates a new glow Layer and references it to the scene.
  140217. * @param name The name of the layer
  140218. * @param scene The scene to use the layer in
  140219. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140220. */
  140221. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140222. /**
  140223. * Get the effect name of the layer.
  140224. * @return The effect name
  140225. */
  140226. getEffectName(): string;
  140227. /**
  140228. * Create the merge effect. This is the shader use to blit the information back
  140229. * to the main canvas at the end of the scene rendering.
  140230. */
  140231. protected _createMergeEffect(): Effect;
  140232. /**
  140233. * Creates the render target textures and post processes used in the glow layer.
  140234. */
  140235. protected _createTextureAndPostProcesses(): void;
  140236. /**
  140237. * Checks for the readiness of the element composing the layer.
  140238. * @param subMesh the mesh to check for
  140239. * @param useInstances specify wether or not to use instances to render the mesh
  140240. * @param emissiveTexture the associated emissive texture used to generate the glow
  140241. * @return true if ready otherwise, false
  140242. */
  140243. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140244. /**
  140245. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140246. */
  140247. needStencil(): boolean;
  140248. /**
  140249. * Returns true if the mesh can be rendered, otherwise false.
  140250. * @param mesh The mesh to render
  140251. * @param material The material used on the mesh
  140252. * @returns true if it can be rendered otherwise false
  140253. */
  140254. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140255. /**
  140256. * Implementation specific of rendering the generating effect on the main canvas.
  140257. * @param effect The effect used to render through
  140258. */
  140259. protected _internalRender(effect: Effect): void;
  140260. /**
  140261. * Sets the required values for both the emissive texture and and the main color.
  140262. */
  140263. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140264. /**
  140265. * Returns true if the mesh should render, otherwise false.
  140266. * @param mesh The mesh to render
  140267. * @returns true if it should render otherwise false
  140268. */
  140269. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140270. /**
  140271. * Adds specific effects defines.
  140272. * @param defines The defines to add specifics to.
  140273. */
  140274. protected _addCustomEffectDefines(defines: string[]): void;
  140275. /**
  140276. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140277. * @param mesh The mesh to exclude from the glow layer
  140278. */
  140279. addExcludedMesh(mesh: Mesh): void;
  140280. /**
  140281. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140282. * @param mesh The mesh to remove
  140283. */
  140284. removeExcludedMesh(mesh: Mesh): void;
  140285. /**
  140286. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140287. * @param mesh The mesh to include in the glow layer
  140288. */
  140289. addIncludedOnlyMesh(mesh: Mesh): void;
  140290. /**
  140291. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140292. * @param mesh The mesh to remove
  140293. */
  140294. removeIncludedOnlyMesh(mesh: Mesh): void;
  140295. /**
  140296. * Determine if a given mesh will be used in the glow layer
  140297. * @param mesh The mesh to test
  140298. * @returns true if the mesh will be highlighted by the current glow layer
  140299. */
  140300. hasMesh(mesh: AbstractMesh): boolean;
  140301. /**
  140302. * Defines whether the current material of the mesh should be use to render the effect.
  140303. * @param mesh defines the current mesh to render
  140304. */
  140305. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140306. /**
  140307. * Add a mesh to be rendered through its own material and not with emissive only.
  140308. * @param mesh The mesh for which we need to use its material
  140309. */
  140310. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140311. /**
  140312. * Remove a mesh from being rendered through its own material and not with emissive only.
  140313. * @param mesh The mesh for which we need to not use its material
  140314. */
  140315. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140316. /**
  140317. * Free any resources and references associated to a mesh.
  140318. * Internal use
  140319. * @param mesh The mesh to free.
  140320. * @hidden
  140321. */
  140322. _disposeMesh(mesh: Mesh): void;
  140323. /**
  140324. * Gets the class name of the effect layer
  140325. * @returns the string with the class name of the effect layer
  140326. */
  140327. getClassName(): string;
  140328. /**
  140329. * Serializes this glow layer
  140330. * @returns a serialized glow layer object
  140331. */
  140332. serialize(): any;
  140333. /**
  140334. * Creates a Glow Layer from parsed glow layer data
  140335. * @param parsedGlowLayer defines glow layer data
  140336. * @param scene defines the current scene
  140337. * @param rootUrl defines the root URL containing the glow layer information
  140338. * @returns a parsed Glow Layer
  140339. */
  140340. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140341. }
  140342. }
  140343. declare module BABYLON {
  140344. /** @hidden */
  140345. export var glowBlurPostProcessPixelShader: {
  140346. name: string;
  140347. shader: string;
  140348. };
  140349. }
  140350. declare module BABYLON {
  140351. interface AbstractScene {
  140352. /**
  140353. * Return a the first highlight layer of the scene with a given name.
  140354. * @param name The name of the highlight layer to look for.
  140355. * @return The highlight layer if found otherwise null.
  140356. */
  140357. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140358. }
  140359. /**
  140360. * Highlight layer options. This helps customizing the behaviour
  140361. * of the highlight layer.
  140362. */
  140363. export interface IHighlightLayerOptions {
  140364. /**
  140365. * Multiplication factor apply to the canvas size to compute the render target size
  140366. * used to generated the glowing objects (the smaller the faster).
  140367. */
  140368. mainTextureRatio: number;
  140369. /**
  140370. * Enforces a fixed size texture to ensure resize independant blur.
  140371. */
  140372. mainTextureFixedSize?: number;
  140373. /**
  140374. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140375. * of the picture to blur (the smaller the faster).
  140376. */
  140377. blurTextureSizeRatio: number;
  140378. /**
  140379. * How big in texel of the blur texture is the vertical blur.
  140380. */
  140381. blurVerticalSize: number;
  140382. /**
  140383. * How big in texel of the blur texture is the horizontal blur.
  140384. */
  140385. blurHorizontalSize: number;
  140386. /**
  140387. * Alpha blending mode used to apply the blur. Default is combine.
  140388. */
  140389. alphaBlendingMode: number;
  140390. /**
  140391. * The camera attached to the layer.
  140392. */
  140393. camera: Nullable<Camera>;
  140394. /**
  140395. * Should we display highlight as a solid stroke?
  140396. */
  140397. isStroke?: boolean;
  140398. /**
  140399. * The rendering group to draw the layer in.
  140400. */
  140401. renderingGroupId: number;
  140402. }
  140403. /**
  140404. * The highlight layer Helps adding a glow effect around a mesh.
  140405. *
  140406. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140407. * glowy meshes to your scene.
  140408. *
  140409. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140410. */
  140411. export class HighlightLayer extends EffectLayer {
  140412. name: string;
  140413. /**
  140414. * Effect Name of the highlight layer.
  140415. */
  140416. static readonly EffectName: string;
  140417. /**
  140418. * The neutral color used during the preparation of the glow effect.
  140419. * This is black by default as the blend operation is a blend operation.
  140420. */
  140421. static NeutralColor: Color4;
  140422. /**
  140423. * Stencil value used for glowing meshes.
  140424. */
  140425. static GlowingMeshStencilReference: number;
  140426. /**
  140427. * Stencil value used for the other meshes in the scene.
  140428. */
  140429. static NormalMeshStencilReference: number;
  140430. /**
  140431. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140432. */
  140433. innerGlow: boolean;
  140434. /**
  140435. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140436. */
  140437. outerGlow: boolean;
  140438. /**
  140439. * Specifies the horizontal size of the blur.
  140440. */
  140441. set blurHorizontalSize(value: number);
  140442. /**
  140443. * Specifies the vertical size of the blur.
  140444. */
  140445. set blurVerticalSize(value: number);
  140446. /**
  140447. * Gets the horizontal size of the blur.
  140448. */
  140449. get blurHorizontalSize(): number;
  140450. /**
  140451. * Gets the vertical size of the blur.
  140452. */
  140453. get blurVerticalSize(): number;
  140454. /**
  140455. * An event triggered when the highlight layer is being blurred.
  140456. */
  140457. onBeforeBlurObservable: Observable<HighlightLayer>;
  140458. /**
  140459. * An event triggered when the highlight layer has been blurred.
  140460. */
  140461. onAfterBlurObservable: Observable<HighlightLayer>;
  140462. private _instanceGlowingMeshStencilReference;
  140463. private _options;
  140464. private _downSamplePostprocess;
  140465. private _horizontalBlurPostprocess;
  140466. private _verticalBlurPostprocess;
  140467. private _blurTexture;
  140468. private _meshes;
  140469. private _excludedMeshes;
  140470. /**
  140471. * Instantiates a new highlight Layer and references it to the scene..
  140472. * @param name The name of the layer
  140473. * @param scene The scene to use the layer in
  140474. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140475. */
  140476. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140477. /**
  140478. * Get the effect name of the layer.
  140479. * @return The effect name
  140480. */
  140481. getEffectName(): string;
  140482. /**
  140483. * Create the merge effect. This is the shader use to blit the information back
  140484. * to the main canvas at the end of the scene rendering.
  140485. */
  140486. protected _createMergeEffect(): Effect;
  140487. /**
  140488. * Creates the render target textures and post processes used in the highlight layer.
  140489. */
  140490. protected _createTextureAndPostProcesses(): void;
  140491. /**
  140492. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140493. */
  140494. needStencil(): boolean;
  140495. /**
  140496. * Checks for the readiness of the element composing the layer.
  140497. * @param subMesh the mesh to check for
  140498. * @param useInstances specify wether or not to use instances to render the mesh
  140499. * @param emissiveTexture the associated emissive texture used to generate the glow
  140500. * @return true if ready otherwise, false
  140501. */
  140502. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140503. /**
  140504. * Implementation specific of rendering the generating effect on the main canvas.
  140505. * @param effect The effect used to render through
  140506. */
  140507. protected _internalRender(effect: Effect): void;
  140508. /**
  140509. * Returns true if the layer contains information to display, otherwise false.
  140510. */
  140511. shouldRender(): boolean;
  140512. /**
  140513. * Returns true if the mesh should render, otherwise false.
  140514. * @param mesh The mesh to render
  140515. * @returns true if it should render otherwise false
  140516. */
  140517. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140518. /**
  140519. * Returns true if the mesh can be rendered, otherwise false.
  140520. * @param mesh The mesh to render
  140521. * @param material The material used on the mesh
  140522. * @returns true if it can be rendered otherwise false
  140523. */
  140524. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140525. /**
  140526. * Adds specific effects defines.
  140527. * @param defines The defines to add specifics to.
  140528. */
  140529. protected _addCustomEffectDefines(defines: string[]): void;
  140530. /**
  140531. * Sets the required values for both the emissive texture and and the main color.
  140532. */
  140533. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140534. /**
  140535. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140536. * @param mesh The mesh to exclude from the highlight layer
  140537. */
  140538. addExcludedMesh(mesh: Mesh): void;
  140539. /**
  140540. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140541. * @param mesh The mesh to highlight
  140542. */
  140543. removeExcludedMesh(mesh: Mesh): void;
  140544. /**
  140545. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140546. * @param mesh mesh to test
  140547. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140548. */
  140549. hasMesh(mesh: AbstractMesh): boolean;
  140550. /**
  140551. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140552. * @param mesh The mesh to highlight
  140553. * @param color The color of the highlight
  140554. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140555. */
  140556. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140557. /**
  140558. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140559. * @param mesh The mesh to highlight
  140560. */
  140561. removeMesh(mesh: Mesh): void;
  140562. /**
  140563. * Remove all the meshes currently referenced in the highlight layer
  140564. */
  140565. removeAllMeshes(): void;
  140566. /**
  140567. * Force the stencil to the normal expected value for none glowing parts
  140568. */
  140569. private _defaultStencilReference;
  140570. /**
  140571. * Free any resources and references associated to a mesh.
  140572. * Internal use
  140573. * @param mesh The mesh to free.
  140574. * @hidden
  140575. */
  140576. _disposeMesh(mesh: Mesh): void;
  140577. /**
  140578. * Dispose the highlight layer and free resources.
  140579. */
  140580. dispose(): void;
  140581. /**
  140582. * Gets the class name of the effect layer
  140583. * @returns the string with the class name of the effect layer
  140584. */
  140585. getClassName(): string;
  140586. /**
  140587. * Serializes this Highlight layer
  140588. * @returns a serialized Highlight layer object
  140589. */
  140590. serialize(): any;
  140591. /**
  140592. * Creates a Highlight layer from parsed Highlight layer data
  140593. * @param parsedHightlightLayer defines the Highlight layer data
  140594. * @param scene defines the current scene
  140595. * @param rootUrl defines the root URL containing the Highlight layer information
  140596. * @returns a parsed Highlight layer
  140597. */
  140598. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140599. }
  140600. }
  140601. declare module BABYLON {
  140602. interface AbstractScene {
  140603. /**
  140604. * The list of layers (background and foreground) of the scene
  140605. */
  140606. layers: Array<Layer>;
  140607. }
  140608. /**
  140609. * Defines the layer scene component responsible to manage any layers
  140610. * in a given scene.
  140611. */
  140612. export class LayerSceneComponent implements ISceneComponent {
  140613. /**
  140614. * The component name helpfull to identify the component in the list of scene components.
  140615. */
  140616. readonly name: string;
  140617. /**
  140618. * The scene the component belongs to.
  140619. */
  140620. scene: Scene;
  140621. private _engine;
  140622. /**
  140623. * Creates a new instance of the component for the given scene
  140624. * @param scene Defines the scene to register the component in
  140625. */
  140626. constructor(scene: Scene);
  140627. /**
  140628. * Registers the component in a given scene
  140629. */
  140630. register(): void;
  140631. /**
  140632. * Rebuilds the elements related to this component in case of
  140633. * context lost for instance.
  140634. */
  140635. rebuild(): void;
  140636. /**
  140637. * Disposes the component and the associated ressources.
  140638. */
  140639. dispose(): void;
  140640. private _draw;
  140641. private _drawCameraPredicate;
  140642. private _drawCameraBackground;
  140643. private _drawCameraForeground;
  140644. private _drawRenderTargetPredicate;
  140645. private _drawRenderTargetBackground;
  140646. private _drawRenderTargetForeground;
  140647. /**
  140648. * Adds all the elements from the container to the scene
  140649. * @param container the container holding the elements
  140650. */
  140651. addFromContainer(container: AbstractScene): void;
  140652. /**
  140653. * Removes all the elements in the container from the scene
  140654. * @param container contains the elements to remove
  140655. * @param dispose if the removed element should be disposed (default: false)
  140656. */
  140657. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140658. }
  140659. }
  140660. declare module BABYLON {
  140661. /** @hidden */
  140662. export var layerPixelShader: {
  140663. name: string;
  140664. shader: string;
  140665. };
  140666. }
  140667. declare module BABYLON {
  140668. /** @hidden */
  140669. export var layerVertexShader: {
  140670. name: string;
  140671. shader: string;
  140672. };
  140673. }
  140674. declare module BABYLON {
  140675. /**
  140676. * This represents a full screen 2d layer.
  140677. * This can be useful to display a picture in the background of your scene for instance.
  140678. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140679. */
  140680. export class Layer {
  140681. /**
  140682. * Define the name of the layer.
  140683. */
  140684. name: string;
  140685. /**
  140686. * Define the texture the layer should display.
  140687. */
  140688. texture: Nullable<Texture>;
  140689. /**
  140690. * Is the layer in background or foreground.
  140691. */
  140692. isBackground: boolean;
  140693. /**
  140694. * Define the color of the layer (instead of texture).
  140695. */
  140696. color: Color4;
  140697. /**
  140698. * Define the scale of the layer in order to zoom in out of the texture.
  140699. */
  140700. scale: Vector2;
  140701. /**
  140702. * Define an offset for the layer in order to shift the texture.
  140703. */
  140704. offset: Vector2;
  140705. /**
  140706. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140707. */
  140708. alphaBlendingMode: number;
  140709. /**
  140710. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140711. * Alpha test will not mix with the background color in case of transparency.
  140712. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140713. */
  140714. alphaTest: boolean;
  140715. /**
  140716. * Define a mask to restrict the layer to only some of the scene cameras.
  140717. */
  140718. layerMask: number;
  140719. /**
  140720. * Define the list of render target the layer is visible into.
  140721. */
  140722. renderTargetTextures: RenderTargetTexture[];
  140723. /**
  140724. * Define if the layer is only used in renderTarget or if it also
  140725. * renders in the main frame buffer of the canvas.
  140726. */
  140727. renderOnlyInRenderTargetTextures: boolean;
  140728. private _scene;
  140729. private _vertexBuffers;
  140730. private _indexBuffer;
  140731. private _effect;
  140732. private _previousDefines;
  140733. /**
  140734. * An event triggered when the layer is disposed.
  140735. */
  140736. onDisposeObservable: Observable<Layer>;
  140737. private _onDisposeObserver;
  140738. /**
  140739. * Back compatibility with callback before the onDisposeObservable existed.
  140740. * The set callback will be triggered when the layer has been disposed.
  140741. */
  140742. set onDispose(callback: () => void);
  140743. /**
  140744. * An event triggered before rendering the scene
  140745. */
  140746. onBeforeRenderObservable: Observable<Layer>;
  140747. private _onBeforeRenderObserver;
  140748. /**
  140749. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140750. * The set callback will be triggered just before rendering the layer.
  140751. */
  140752. set onBeforeRender(callback: () => void);
  140753. /**
  140754. * An event triggered after rendering the scene
  140755. */
  140756. onAfterRenderObservable: Observable<Layer>;
  140757. private _onAfterRenderObserver;
  140758. /**
  140759. * Back compatibility with callback before the onAfterRenderObservable existed.
  140760. * The set callback will be triggered just after rendering the layer.
  140761. */
  140762. set onAfterRender(callback: () => void);
  140763. /**
  140764. * Instantiates a new layer.
  140765. * This represents a full screen 2d layer.
  140766. * This can be useful to display a picture in the background of your scene for instance.
  140767. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140768. * @param name Define the name of the layer in the scene
  140769. * @param imgUrl Define the url of the texture to display in the layer
  140770. * @param scene Define the scene the layer belongs to
  140771. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140772. * @param color Defines a color for the layer
  140773. */
  140774. constructor(
  140775. /**
  140776. * Define the name of the layer.
  140777. */
  140778. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140779. private _createIndexBuffer;
  140780. /** @hidden */
  140781. _rebuild(): void;
  140782. /**
  140783. * Renders the layer in the scene.
  140784. */
  140785. render(): void;
  140786. /**
  140787. * Disposes and releases the associated ressources.
  140788. */
  140789. dispose(): void;
  140790. }
  140791. }
  140792. declare module BABYLON {
  140793. /** @hidden */
  140794. export var lensFlarePixelShader: {
  140795. name: string;
  140796. shader: string;
  140797. };
  140798. }
  140799. declare module BABYLON {
  140800. /** @hidden */
  140801. export var lensFlareVertexShader: {
  140802. name: string;
  140803. shader: string;
  140804. };
  140805. }
  140806. declare module BABYLON {
  140807. /**
  140808. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140809. * It is usually composed of several `lensFlare`.
  140810. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140811. */
  140812. export class LensFlareSystem {
  140813. /**
  140814. * Define the name of the lens flare system
  140815. */
  140816. name: string;
  140817. /**
  140818. * List of lens flares used in this system.
  140819. */
  140820. lensFlares: LensFlare[];
  140821. /**
  140822. * Define a limit from the border the lens flare can be visible.
  140823. */
  140824. borderLimit: number;
  140825. /**
  140826. * Define a viewport border we do not want to see the lens flare in.
  140827. */
  140828. viewportBorder: number;
  140829. /**
  140830. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140831. */
  140832. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140833. /**
  140834. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140835. */
  140836. layerMask: number;
  140837. /**
  140838. * Define the id of the lens flare system in the scene.
  140839. * (equal to name by default)
  140840. */
  140841. id: string;
  140842. private _scene;
  140843. private _emitter;
  140844. private _vertexBuffers;
  140845. private _indexBuffer;
  140846. private _effect;
  140847. private _positionX;
  140848. private _positionY;
  140849. private _isEnabled;
  140850. /** @hidden */
  140851. static _SceneComponentInitialization: (scene: Scene) => void;
  140852. /**
  140853. * Instantiates a lens flare system.
  140854. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140855. * It is usually composed of several `lensFlare`.
  140856. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140857. * @param name Define the name of the lens flare system in the scene
  140858. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140859. * @param scene Define the scene the lens flare system belongs to
  140860. */
  140861. constructor(
  140862. /**
  140863. * Define the name of the lens flare system
  140864. */
  140865. name: string, emitter: any, scene: Scene);
  140866. /**
  140867. * Define if the lens flare system is enabled.
  140868. */
  140869. get isEnabled(): boolean;
  140870. set isEnabled(value: boolean);
  140871. /**
  140872. * Get the scene the effects belongs to.
  140873. * @returns the scene holding the lens flare system
  140874. */
  140875. getScene(): Scene;
  140876. /**
  140877. * Get the emitter of the lens flare system.
  140878. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140879. * @returns the emitter of the lens flare system
  140880. */
  140881. getEmitter(): any;
  140882. /**
  140883. * Set the emitter of the lens flare system.
  140884. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140885. * @param newEmitter Define the new emitter of the system
  140886. */
  140887. setEmitter(newEmitter: any): void;
  140888. /**
  140889. * Get the lens flare system emitter position.
  140890. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140891. * @returns the position
  140892. */
  140893. getEmitterPosition(): Vector3;
  140894. /**
  140895. * @hidden
  140896. */
  140897. computeEffectivePosition(globalViewport: Viewport): boolean;
  140898. /** @hidden */
  140899. _isVisible(): boolean;
  140900. /**
  140901. * @hidden
  140902. */
  140903. render(): boolean;
  140904. /**
  140905. * Dispose and release the lens flare with its associated resources.
  140906. */
  140907. dispose(): void;
  140908. /**
  140909. * Parse a lens flare system from a JSON repressentation
  140910. * @param parsedLensFlareSystem Define the JSON to parse
  140911. * @param scene Define the scene the parsed system should be instantiated in
  140912. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140913. * @returns the parsed system
  140914. */
  140915. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140916. /**
  140917. * Serialize the current Lens Flare System into a JSON representation.
  140918. * @returns the serialized JSON
  140919. */
  140920. serialize(): any;
  140921. }
  140922. }
  140923. declare module BABYLON {
  140924. /**
  140925. * This represents one of the lens effect in a `lensFlareSystem`.
  140926. * It controls one of the indiviual texture used in the effect.
  140927. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140928. */
  140929. export class LensFlare {
  140930. /**
  140931. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140932. */
  140933. size: number;
  140934. /**
  140935. * 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.
  140936. */
  140937. position: number;
  140938. /**
  140939. * Define the lens color.
  140940. */
  140941. color: Color3;
  140942. /**
  140943. * Define the lens texture.
  140944. */
  140945. texture: Nullable<Texture>;
  140946. /**
  140947. * Define the alpha mode to render this particular lens.
  140948. */
  140949. alphaMode: number;
  140950. private _system;
  140951. /**
  140952. * Creates a new Lens Flare.
  140953. * This represents one of the lens effect in a `lensFlareSystem`.
  140954. * It controls one of the indiviual texture used in the effect.
  140955. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140956. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140957. * @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.
  140958. * @param color Define the lens color
  140959. * @param imgUrl Define the lens texture url
  140960. * @param system Define the `lensFlareSystem` this flare is part of
  140961. * @returns The newly created Lens Flare
  140962. */
  140963. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140964. /**
  140965. * Instantiates a new Lens Flare.
  140966. * This represents one of the lens effect in a `lensFlareSystem`.
  140967. * It controls one of the indiviual texture used in the effect.
  140968. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140969. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140970. * @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.
  140971. * @param color Define the lens color
  140972. * @param imgUrl Define the lens texture url
  140973. * @param system Define the `lensFlareSystem` this flare is part of
  140974. */
  140975. constructor(
  140976. /**
  140977. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140978. */
  140979. size: number,
  140980. /**
  140981. * 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.
  140982. */
  140983. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140984. /**
  140985. * Dispose and release the lens flare with its associated resources.
  140986. */
  140987. dispose(): void;
  140988. }
  140989. }
  140990. declare module BABYLON {
  140991. interface AbstractScene {
  140992. /**
  140993. * The list of lens flare system added to the scene
  140994. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140995. */
  140996. lensFlareSystems: Array<LensFlareSystem>;
  140997. /**
  140998. * Removes the given lens flare system from this scene.
  140999. * @param toRemove The lens flare system to remove
  141000. * @returns The index of the removed lens flare system
  141001. */
  141002. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141003. /**
  141004. * Adds the given lens flare system to this scene
  141005. * @param newLensFlareSystem The lens flare system to add
  141006. */
  141007. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141008. /**
  141009. * Gets a lens flare system using its name
  141010. * @param name defines the name to look for
  141011. * @returns the lens flare system or null if not found
  141012. */
  141013. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141014. /**
  141015. * Gets a lens flare system using its id
  141016. * @param id defines the id to look for
  141017. * @returns the lens flare system or null if not found
  141018. */
  141019. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141020. }
  141021. /**
  141022. * Defines the lens flare scene component responsible to manage any lens flares
  141023. * in a given scene.
  141024. */
  141025. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141026. /**
  141027. * The component name helpfull to identify the component in the list of scene components.
  141028. */
  141029. readonly name: string;
  141030. /**
  141031. * The scene the component belongs to.
  141032. */
  141033. scene: Scene;
  141034. /**
  141035. * Creates a new instance of the component for the given scene
  141036. * @param scene Defines the scene to register the component in
  141037. */
  141038. constructor(scene: Scene);
  141039. /**
  141040. * Registers the component in a given scene
  141041. */
  141042. register(): void;
  141043. /**
  141044. * Rebuilds the elements related to this component in case of
  141045. * context lost for instance.
  141046. */
  141047. rebuild(): void;
  141048. /**
  141049. * Adds all the elements from the container to the scene
  141050. * @param container the container holding the elements
  141051. */
  141052. addFromContainer(container: AbstractScene): void;
  141053. /**
  141054. * Removes all the elements in the container from the scene
  141055. * @param container contains the elements to remove
  141056. * @param dispose if the removed element should be disposed (default: false)
  141057. */
  141058. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141059. /**
  141060. * Serializes the component data to the specified json object
  141061. * @param serializationObject The object to serialize to
  141062. */
  141063. serialize(serializationObject: any): void;
  141064. /**
  141065. * Disposes the component and the associated ressources.
  141066. */
  141067. dispose(): void;
  141068. private _draw;
  141069. }
  141070. }
  141071. declare module BABYLON {
  141072. /** @hidden */
  141073. export var depthPixelShader: {
  141074. name: string;
  141075. shader: string;
  141076. };
  141077. }
  141078. declare module BABYLON {
  141079. /** @hidden */
  141080. export var depthVertexShader: {
  141081. name: string;
  141082. shader: string;
  141083. };
  141084. }
  141085. declare module BABYLON {
  141086. /**
  141087. * This represents a depth renderer in Babylon.
  141088. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141089. */
  141090. export class DepthRenderer {
  141091. private _scene;
  141092. private _depthMap;
  141093. private _effect;
  141094. private readonly _storeNonLinearDepth;
  141095. private readonly _clearColor;
  141096. /** Get if the depth renderer is using packed depth or not */
  141097. readonly isPacked: boolean;
  141098. private _cachedDefines;
  141099. private _camera;
  141100. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141101. enabled: boolean;
  141102. /**
  141103. * Specifiess that the depth renderer will only be used within
  141104. * the camera it is created for.
  141105. * This can help forcing its rendering during the camera processing.
  141106. */
  141107. useOnlyInActiveCamera: boolean;
  141108. /** @hidden */
  141109. static _SceneComponentInitialization: (scene: Scene) => void;
  141110. /**
  141111. * Instantiates a depth renderer
  141112. * @param scene The scene the renderer belongs to
  141113. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141114. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141115. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141116. */
  141117. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141118. /**
  141119. * Creates the depth rendering effect and checks if the effect is ready.
  141120. * @param subMesh The submesh to be used to render the depth map of
  141121. * @param useInstances If multiple world instances should be used
  141122. * @returns if the depth renderer is ready to render the depth map
  141123. */
  141124. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141125. /**
  141126. * Gets the texture which the depth map will be written to.
  141127. * @returns The depth map texture
  141128. */
  141129. getDepthMap(): RenderTargetTexture;
  141130. /**
  141131. * Disposes of the depth renderer.
  141132. */
  141133. dispose(): void;
  141134. }
  141135. }
  141136. declare module BABYLON {
  141137. /** @hidden */
  141138. export var minmaxReduxPixelShader: {
  141139. name: string;
  141140. shader: string;
  141141. };
  141142. }
  141143. declare module BABYLON {
  141144. /**
  141145. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141146. * and maximum values from all values of the texture.
  141147. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141148. * The source values are read from the red channel of the texture.
  141149. */
  141150. export class MinMaxReducer {
  141151. /**
  141152. * Observable triggered when the computation has been performed
  141153. */
  141154. onAfterReductionPerformed: Observable<{
  141155. min: number;
  141156. max: number;
  141157. }>;
  141158. protected _camera: Camera;
  141159. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141160. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141161. protected _postProcessManager: PostProcessManager;
  141162. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141163. protected _forceFullscreenViewport: boolean;
  141164. /**
  141165. * Creates a min/max reducer
  141166. * @param camera The camera to use for the post processes
  141167. */
  141168. constructor(camera: Camera);
  141169. /**
  141170. * Gets the texture used to read the values from.
  141171. */
  141172. get sourceTexture(): Nullable<RenderTargetTexture>;
  141173. /**
  141174. * Sets the source texture to read the values from.
  141175. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141176. * because in such textures '1' value must not be taken into account to compute the maximum
  141177. * as this value is used to clear the texture.
  141178. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141179. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141180. * @param depthRedux Indicates if the texture is a depth texture or not
  141181. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141182. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141183. */
  141184. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141185. /**
  141186. * Defines the refresh rate of the computation.
  141187. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141188. */
  141189. get refreshRate(): number;
  141190. set refreshRate(value: number);
  141191. protected _activated: boolean;
  141192. /**
  141193. * Gets the activation status of the reducer
  141194. */
  141195. get activated(): boolean;
  141196. /**
  141197. * Activates the reduction computation.
  141198. * When activated, the observers registered in onAfterReductionPerformed are
  141199. * called after the compuation is performed
  141200. */
  141201. activate(): void;
  141202. /**
  141203. * Deactivates the reduction computation.
  141204. */
  141205. deactivate(): void;
  141206. /**
  141207. * Disposes the min/max reducer
  141208. * @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.
  141209. */
  141210. dispose(disposeAll?: boolean): void;
  141211. }
  141212. }
  141213. declare module BABYLON {
  141214. /**
  141215. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141216. */
  141217. export class DepthReducer extends MinMaxReducer {
  141218. private _depthRenderer;
  141219. private _depthRendererId;
  141220. /**
  141221. * Gets the depth renderer used for the computation.
  141222. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141223. */
  141224. get depthRenderer(): Nullable<DepthRenderer>;
  141225. /**
  141226. * Creates a depth reducer
  141227. * @param camera The camera used to render the depth texture
  141228. */
  141229. constructor(camera: Camera);
  141230. /**
  141231. * Sets the depth renderer to use to generate the depth map
  141232. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141233. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141234. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141235. */
  141236. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141237. /** @hidden */
  141238. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141239. /**
  141240. * Activates the reduction computation.
  141241. * When activated, the observers registered in onAfterReductionPerformed are
  141242. * called after the compuation is performed
  141243. */
  141244. activate(): void;
  141245. /**
  141246. * Deactivates the reduction computation.
  141247. */
  141248. deactivate(): void;
  141249. /**
  141250. * Disposes the depth reducer
  141251. * @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.
  141252. */
  141253. dispose(disposeAll?: boolean): void;
  141254. }
  141255. }
  141256. declare module BABYLON {
  141257. /**
  141258. * A CSM implementation allowing casting shadows on large scenes.
  141259. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141260. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141261. */
  141262. export class CascadedShadowGenerator extends ShadowGenerator {
  141263. private static readonly frustumCornersNDCSpace;
  141264. /**
  141265. * Name of the CSM class
  141266. */
  141267. static CLASSNAME: string;
  141268. /**
  141269. * Defines the default number of cascades used by the CSM.
  141270. */
  141271. static readonly DEFAULT_CASCADES_COUNT: number;
  141272. /**
  141273. * Defines the minimum number of cascades used by the CSM.
  141274. */
  141275. static readonly MIN_CASCADES_COUNT: number;
  141276. /**
  141277. * Defines the maximum number of cascades used by the CSM.
  141278. */
  141279. static readonly MAX_CASCADES_COUNT: number;
  141280. protected _validateFilter(filter: number): number;
  141281. /**
  141282. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141283. */
  141284. penumbraDarkness: number;
  141285. private _numCascades;
  141286. /**
  141287. * Gets or set the number of cascades used by the CSM.
  141288. */
  141289. get numCascades(): number;
  141290. set numCascades(value: number);
  141291. /**
  141292. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141293. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141294. */
  141295. stabilizeCascades: boolean;
  141296. private _freezeShadowCastersBoundingInfo;
  141297. private _freezeShadowCastersBoundingInfoObservable;
  141298. /**
  141299. * Enables or disables the shadow casters bounding info computation.
  141300. * If your shadow casters don't move, you can disable this feature.
  141301. * If it is enabled, the bounding box computation is done every frame.
  141302. */
  141303. get freezeShadowCastersBoundingInfo(): boolean;
  141304. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141305. private _scbiMin;
  141306. private _scbiMax;
  141307. protected _computeShadowCastersBoundingInfo(): void;
  141308. protected _shadowCastersBoundingInfo: BoundingInfo;
  141309. /**
  141310. * Gets or sets the shadow casters bounding info.
  141311. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141312. * so that the system won't overwrite the bounds you provide
  141313. */
  141314. get shadowCastersBoundingInfo(): BoundingInfo;
  141315. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141316. protected _breaksAreDirty: boolean;
  141317. protected _minDistance: number;
  141318. protected _maxDistance: number;
  141319. /**
  141320. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141321. *
  141322. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141323. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141324. * @param min minimal distance for the breaks (default to 0.)
  141325. * @param max maximal distance for the breaks (default to 1.)
  141326. */
  141327. setMinMaxDistance(min: number, max: number): void;
  141328. /** Gets the minimal distance used in the cascade break computation */
  141329. get minDistance(): number;
  141330. /** Gets the maximal distance used in the cascade break computation */
  141331. get maxDistance(): number;
  141332. /**
  141333. * Gets the class name of that object
  141334. * @returns "CascadedShadowGenerator"
  141335. */
  141336. getClassName(): string;
  141337. private _cascadeMinExtents;
  141338. private _cascadeMaxExtents;
  141339. /**
  141340. * Gets a cascade minimum extents
  141341. * @param cascadeIndex index of the cascade
  141342. * @returns the minimum cascade extents
  141343. */
  141344. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141345. /**
  141346. * Gets a cascade maximum extents
  141347. * @param cascadeIndex index of the cascade
  141348. * @returns the maximum cascade extents
  141349. */
  141350. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141351. private _cascades;
  141352. private _currentLayer;
  141353. private _viewSpaceFrustumsZ;
  141354. private _viewMatrices;
  141355. private _projectionMatrices;
  141356. private _transformMatrices;
  141357. private _transformMatricesAsArray;
  141358. private _frustumLengths;
  141359. private _lightSizeUVCorrection;
  141360. private _depthCorrection;
  141361. private _frustumCornersWorldSpace;
  141362. private _frustumCenter;
  141363. private _shadowCameraPos;
  141364. private _shadowMaxZ;
  141365. /**
  141366. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141367. * It defaults to camera.maxZ
  141368. */
  141369. get shadowMaxZ(): number;
  141370. /**
  141371. * Sets the shadow max z distance.
  141372. */
  141373. set shadowMaxZ(value: number);
  141374. protected _debug: boolean;
  141375. /**
  141376. * Gets or sets the debug flag.
  141377. * When enabled, the cascades are materialized by different colors on the screen.
  141378. */
  141379. get debug(): boolean;
  141380. set debug(dbg: boolean);
  141381. private _depthClamp;
  141382. /**
  141383. * Gets or sets the depth clamping value.
  141384. *
  141385. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141386. * to account for the shadow casters far away.
  141387. *
  141388. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141389. */
  141390. get depthClamp(): boolean;
  141391. set depthClamp(value: boolean);
  141392. private _cascadeBlendPercentage;
  141393. /**
  141394. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141395. * It defaults to 0.1 (10% blending).
  141396. */
  141397. get cascadeBlendPercentage(): number;
  141398. set cascadeBlendPercentage(value: number);
  141399. private _lambda;
  141400. /**
  141401. * Gets or set the lambda parameter.
  141402. * This parameter is used to split the camera frustum and create the cascades.
  141403. * 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.
  141404. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141405. */
  141406. get lambda(): number;
  141407. set lambda(value: number);
  141408. /**
  141409. * Gets the view matrix corresponding to a given cascade
  141410. * @param cascadeNum cascade to retrieve the view matrix from
  141411. * @returns the cascade view matrix
  141412. */
  141413. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141414. /**
  141415. * Gets the projection matrix corresponding to a given cascade
  141416. * @param cascadeNum cascade to retrieve the projection matrix from
  141417. * @returns the cascade projection matrix
  141418. */
  141419. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141420. /**
  141421. * Gets the transformation matrix corresponding to a given cascade
  141422. * @param cascadeNum cascade to retrieve the transformation matrix from
  141423. * @returns the cascade transformation matrix
  141424. */
  141425. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141426. private _depthRenderer;
  141427. /**
  141428. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141429. *
  141430. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141431. *
  141432. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141433. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141434. * @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
  141435. */
  141436. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141437. private _depthReducer;
  141438. private _autoCalcDepthBounds;
  141439. /**
  141440. * Gets or sets the autoCalcDepthBounds property.
  141441. *
  141442. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141443. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141444. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141445. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141446. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141447. */
  141448. get autoCalcDepthBounds(): boolean;
  141449. set autoCalcDepthBounds(value: boolean);
  141450. /**
  141451. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141452. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141453. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141454. * for setting the refresh rate on the renderer yourself!
  141455. */
  141456. get autoCalcDepthBoundsRefreshRate(): number;
  141457. set autoCalcDepthBoundsRefreshRate(value: number);
  141458. /**
  141459. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141460. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141461. * you change the camera near/far planes!
  141462. */
  141463. splitFrustum(): void;
  141464. private _splitFrustum;
  141465. private _computeMatrices;
  141466. private _computeFrustumInWorldSpace;
  141467. private _computeCascadeFrustum;
  141468. /**
  141469. * Support test.
  141470. */
  141471. static get IsSupported(): boolean;
  141472. /** @hidden */
  141473. static _SceneComponentInitialization: (scene: Scene) => void;
  141474. /**
  141475. * Creates a Cascaded Shadow Generator object.
  141476. * A ShadowGenerator is the required tool to use the shadows.
  141477. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141478. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141479. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141480. * @param light The directional light object generating the shadows.
  141481. * @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.
  141482. */
  141483. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141484. protected _initializeGenerator(): void;
  141485. protected _createTargetRenderTexture(): void;
  141486. protected _initializeShadowMap(): void;
  141487. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141488. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141489. /**
  141490. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141491. * @param defines Defines of the material we want to update
  141492. * @param lightIndex Index of the light in the enabled light list of the material
  141493. */
  141494. prepareDefines(defines: any, lightIndex: number): void;
  141495. /**
  141496. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141497. * defined in the generator but impacting the effect).
  141498. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141499. * @param effect The effect we are binfing the information for
  141500. */
  141501. bindShadowLight(lightIndex: string, effect: Effect): void;
  141502. /**
  141503. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141504. * (eq to view projection * shadow projection matrices)
  141505. * @returns The transform matrix used to create the shadow map
  141506. */
  141507. getTransformMatrix(): Matrix;
  141508. /**
  141509. * Disposes the ShadowGenerator.
  141510. * Returns nothing.
  141511. */
  141512. dispose(): void;
  141513. /**
  141514. * Serializes the shadow generator setup to a json object.
  141515. * @returns The serialized JSON object
  141516. */
  141517. serialize(): any;
  141518. /**
  141519. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141520. * @param parsedShadowGenerator The JSON object to parse
  141521. * @param scene The scene to create the shadow map for
  141522. * @returns The parsed shadow generator
  141523. */
  141524. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141525. }
  141526. }
  141527. declare module BABYLON {
  141528. /**
  141529. * Defines the shadow generator component responsible to manage any shadow generators
  141530. * in a given scene.
  141531. */
  141532. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141533. /**
  141534. * The component name helpfull to identify the component in the list of scene components.
  141535. */
  141536. readonly name: string;
  141537. /**
  141538. * The scene the component belongs to.
  141539. */
  141540. scene: Scene;
  141541. /**
  141542. * Creates a new instance of the component for the given scene
  141543. * @param scene Defines the scene to register the component in
  141544. */
  141545. constructor(scene: Scene);
  141546. /**
  141547. * Registers the component in a given scene
  141548. */
  141549. register(): void;
  141550. /**
  141551. * Rebuilds the elements related to this component in case of
  141552. * context lost for instance.
  141553. */
  141554. rebuild(): void;
  141555. /**
  141556. * Serializes the component data to the specified json object
  141557. * @param serializationObject The object to serialize to
  141558. */
  141559. serialize(serializationObject: any): void;
  141560. /**
  141561. * Adds all the elements from the container to the scene
  141562. * @param container the container holding the elements
  141563. */
  141564. addFromContainer(container: AbstractScene): void;
  141565. /**
  141566. * Removes all the elements in the container from the scene
  141567. * @param container contains the elements to remove
  141568. * @param dispose if the removed element should be disposed (default: false)
  141569. */
  141570. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141571. /**
  141572. * Rebuilds the elements related to this component in case of
  141573. * context lost for instance.
  141574. */
  141575. dispose(): void;
  141576. private _gatherRenderTargets;
  141577. }
  141578. }
  141579. declare module BABYLON {
  141580. /**
  141581. * A point light is a light defined by an unique point in world space.
  141582. * The light is emitted in every direction from this point.
  141583. * A good example of a point light is a standard light bulb.
  141584. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141585. */
  141586. export class PointLight extends ShadowLight {
  141587. private _shadowAngle;
  141588. /**
  141589. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141590. * This specifies what angle the shadow will use to be created.
  141591. *
  141592. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141593. */
  141594. get shadowAngle(): number;
  141595. /**
  141596. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141597. * This specifies what angle the shadow will use to be created.
  141598. *
  141599. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141600. */
  141601. set shadowAngle(value: number);
  141602. /**
  141603. * Gets the direction if it has been set.
  141604. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141605. */
  141606. get direction(): Vector3;
  141607. /**
  141608. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141609. */
  141610. set direction(value: Vector3);
  141611. /**
  141612. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141613. * A PointLight emits the light in every direction.
  141614. * It can cast shadows.
  141615. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141616. * ```javascript
  141617. * var pointLight = new PointLight("pl", camera.position, scene);
  141618. * ```
  141619. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141620. * @param name The light friendly name
  141621. * @param position The position of the point light in the scene
  141622. * @param scene The scene the lights belongs to
  141623. */
  141624. constructor(name: string, position: Vector3, scene: Scene);
  141625. /**
  141626. * Returns the string "PointLight"
  141627. * @returns the class name
  141628. */
  141629. getClassName(): string;
  141630. /**
  141631. * Returns the integer 0.
  141632. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141633. */
  141634. getTypeID(): number;
  141635. /**
  141636. * Specifies wether or not the shadowmap should be a cube texture.
  141637. * @returns true if the shadowmap needs to be a cube texture.
  141638. */
  141639. needCube(): boolean;
  141640. /**
  141641. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141642. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141643. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141644. */
  141645. getShadowDirection(faceIndex?: number): Vector3;
  141646. /**
  141647. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141648. * - fov = PI / 2
  141649. * - aspect ratio : 1.0
  141650. * - z-near and far equal to the active camera minZ and maxZ.
  141651. * Returns the PointLight.
  141652. */
  141653. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141654. protected _buildUniformLayout(): void;
  141655. /**
  141656. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141657. * @param effect The effect to update
  141658. * @param lightIndex The index of the light in the effect to update
  141659. * @returns The point light
  141660. */
  141661. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141662. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141663. /**
  141664. * Prepares the list of defines specific to the light type.
  141665. * @param defines the list of defines
  141666. * @param lightIndex defines the index of the light for the effect
  141667. */
  141668. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141669. }
  141670. }
  141671. declare module BABYLON {
  141672. /**
  141673. * Header information of HDR texture files.
  141674. */
  141675. export interface HDRInfo {
  141676. /**
  141677. * The height of the texture in pixels.
  141678. */
  141679. height: number;
  141680. /**
  141681. * The width of the texture in pixels.
  141682. */
  141683. width: number;
  141684. /**
  141685. * The index of the beginning of the data in the binary file.
  141686. */
  141687. dataPosition: number;
  141688. }
  141689. /**
  141690. * This groups tools to convert HDR texture to native colors array.
  141691. */
  141692. export class HDRTools {
  141693. private static Ldexp;
  141694. private static Rgbe2float;
  141695. private static readStringLine;
  141696. /**
  141697. * Reads header information from an RGBE texture stored in a native array.
  141698. * More information on this format are available here:
  141699. * https://en.wikipedia.org/wiki/RGBE_image_format
  141700. *
  141701. * @param uint8array The binary file stored in native array.
  141702. * @return The header information.
  141703. */
  141704. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141705. /**
  141706. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141707. * This RGBE texture needs to store the information as a panorama.
  141708. *
  141709. * More information on this format are available here:
  141710. * https://en.wikipedia.org/wiki/RGBE_image_format
  141711. *
  141712. * @param buffer The binary file stored in an array buffer.
  141713. * @param size The expected size of the extracted cubemap.
  141714. * @return The Cube Map information.
  141715. */
  141716. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141717. /**
  141718. * Returns the pixels data extracted from an RGBE texture.
  141719. * This pixels will be stored left to right up to down in the R G B order in one array.
  141720. *
  141721. * More information on this format are available here:
  141722. * https://en.wikipedia.org/wiki/RGBE_image_format
  141723. *
  141724. * @param uint8array The binary file stored in an array buffer.
  141725. * @param hdrInfo The header information of the file.
  141726. * @return The pixels data in RGB right to left up to down order.
  141727. */
  141728. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141729. private static RGBE_ReadPixels_RLE;
  141730. private static RGBE_ReadPixels_NOT_RLE;
  141731. }
  141732. }
  141733. declare module BABYLON {
  141734. /**
  141735. * Effect Render Options
  141736. */
  141737. export interface IEffectRendererOptions {
  141738. /**
  141739. * Defines the vertices positions.
  141740. */
  141741. positions?: number[];
  141742. /**
  141743. * Defines the indices.
  141744. */
  141745. indices?: number[];
  141746. }
  141747. /**
  141748. * Helper class to render one or more effects.
  141749. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141750. */
  141751. export class EffectRenderer {
  141752. private engine;
  141753. private static _DefaultOptions;
  141754. private _vertexBuffers;
  141755. private _indexBuffer;
  141756. private _fullscreenViewport;
  141757. /**
  141758. * Creates an effect renderer
  141759. * @param engine the engine to use for rendering
  141760. * @param options defines the options of the effect renderer
  141761. */
  141762. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141763. /**
  141764. * Sets the current viewport in normalized coordinates 0-1
  141765. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141766. */
  141767. setViewport(viewport?: Viewport): void;
  141768. /**
  141769. * Binds the embedded attributes buffer to the effect.
  141770. * @param effect Defines the effect to bind the attributes for
  141771. */
  141772. bindBuffers(effect: Effect): void;
  141773. /**
  141774. * Sets the current effect wrapper to use during draw.
  141775. * The effect needs to be ready before calling this api.
  141776. * This also sets the default full screen position attribute.
  141777. * @param effectWrapper Defines the effect to draw with
  141778. */
  141779. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141780. /**
  141781. * Restores engine states
  141782. */
  141783. restoreStates(): void;
  141784. /**
  141785. * Draws a full screen quad.
  141786. */
  141787. draw(): void;
  141788. private isRenderTargetTexture;
  141789. /**
  141790. * renders one or more effects to a specified texture
  141791. * @param effectWrapper the effect to renderer
  141792. * @param outputTexture texture to draw to, if null it will render to the screen.
  141793. */
  141794. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141795. /**
  141796. * Disposes of the effect renderer
  141797. */
  141798. dispose(): void;
  141799. }
  141800. /**
  141801. * Options to create an EffectWrapper
  141802. */
  141803. interface EffectWrapperCreationOptions {
  141804. /**
  141805. * Engine to use to create the effect
  141806. */
  141807. engine: ThinEngine;
  141808. /**
  141809. * Fragment shader for the effect
  141810. */
  141811. fragmentShader: string;
  141812. /**
  141813. * Use the shader store instead of direct source code
  141814. */
  141815. useShaderStore?: boolean;
  141816. /**
  141817. * Vertex shader for the effect
  141818. */
  141819. vertexShader?: string;
  141820. /**
  141821. * Attributes to use in the shader
  141822. */
  141823. attributeNames?: Array<string>;
  141824. /**
  141825. * Uniforms to use in the shader
  141826. */
  141827. uniformNames?: Array<string>;
  141828. /**
  141829. * Texture sampler names to use in the shader
  141830. */
  141831. samplerNames?: Array<string>;
  141832. /**
  141833. * Defines to use in the shader
  141834. */
  141835. defines?: Array<string>;
  141836. /**
  141837. * Callback when effect is compiled
  141838. */
  141839. onCompiled?: Nullable<(effect: Effect) => void>;
  141840. /**
  141841. * The friendly name of the effect displayed in Spector.
  141842. */
  141843. name?: string;
  141844. }
  141845. /**
  141846. * Wraps an effect to be used for rendering
  141847. */
  141848. export class EffectWrapper {
  141849. /**
  141850. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141851. */
  141852. onApplyObservable: Observable<{}>;
  141853. /**
  141854. * The underlying effect
  141855. */
  141856. effect: Effect;
  141857. /**
  141858. * Creates an effect to be renderer
  141859. * @param creationOptions options to create the effect
  141860. */
  141861. constructor(creationOptions: EffectWrapperCreationOptions);
  141862. /**
  141863. * Disposes of the effect wrapper
  141864. */
  141865. dispose(): void;
  141866. }
  141867. }
  141868. declare module BABYLON {
  141869. /** @hidden */
  141870. export var hdrFilteringVertexShader: {
  141871. name: string;
  141872. shader: string;
  141873. };
  141874. }
  141875. declare module BABYLON {
  141876. /** @hidden */
  141877. export var hdrFilteringPixelShader: {
  141878. name: string;
  141879. shader: string;
  141880. };
  141881. }
  141882. declare module BABYLON {
  141883. /**
  141884. * Options for texture filtering
  141885. */
  141886. interface IHDRFilteringOptions {
  141887. /**
  141888. * Scales pixel intensity for the input HDR map.
  141889. */
  141890. hdrScale?: number;
  141891. /**
  141892. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141893. */
  141894. quality?: number;
  141895. }
  141896. /**
  141897. * Filters HDR maps to get correct renderings of PBR reflections
  141898. */
  141899. export class HDRFiltering {
  141900. private _engine;
  141901. private _effectRenderer;
  141902. private _effectWrapper;
  141903. private _lodGenerationOffset;
  141904. private _lodGenerationScale;
  141905. /**
  141906. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141907. * you care about baking speed.
  141908. */
  141909. quality: number;
  141910. /**
  141911. * Scales pixel intensity for the input HDR map.
  141912. */
  141913. hdrScale: number;
  141914. /**
  141915. * Instantiates HDR filter for reflection maps
  141916. *
  141917. * @param engine Thin engine
  141918. * @param options Options
  141919. */
  141920. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141921. private _createRenderTarget;
  141922. private _prefilterInternal;
  141923. private _createEffect;
  141924. /**
  141925. * Get a value indicating if the filter is ready to be used
  141926. * @param texture Texture to filter
  141927. * @returns true if the filter is ready
  141928. */
  141929. isReady(texture: BaseTexture): boolean;
  141930. /**
  141931. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141932. * Prefiltering will be invoked at the end of next rendering pass.
  141933. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141934. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141935. * @param texture Texture to filter
  141936. * @param onFinished Callback when filtering is done
  141937. * @return Promise called when prefiltering is done
  141938. */
  141939. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141940. }
  141941. }
  141942. declare module BABYLON {
  141943. /**
  141944. * This represents a texture coming from an HDR input.
  141945. *
  141946. * The only supported format is currently panorama picture stored in RGBE format.
  141947. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141948. */
  141949. export class HDRCubeTexture extends BaseTexture {
  141950. private static _facesMapping;
  141951. private _generateHarmonics;
  141952. private _noMipmap;
  141953. private _prefilterOnLoad;
  141954. private _textureMatrix;
  141955. private _size;
  141956. private _onLoad;
  141957. private _onError;
  141958. /**
  141959. * The texture URL.
  141960. */
  141961. url: string;
  141962. protected _isBlocking: boolean;
  141963. /**
  141964. * Sets wether or not the texture is blocking during loading.
  141965. */
  141966. set isBlocking(value: boolean);
  141967. /**
  141968. * Gets wether or not the texture is blocking during loading.
  141969. */
  141970. get isBlocking(): boolean;
  141971. protected _rotationY: number;
  141972. /**
  141973. * Sets texture matrix rotation angle around Y axis in radians.
  141974. */
  141975. set rotationY(value: number);
  141976. /**
  141977. * Gets texture matrix rotation angle around Y axis radians.
  141978. */
  141979. get rotationY(): number;
  141980. /**
  141981. * Gets or sets the center of the bounding box associated with the cube texture
  141982. * It must define where the camera used to render the texture was set
  141983. */
  141984. boundingBoxPosition: Vector3;
  141985. private _boundingBoxSize;
  141986. /**
  141987. * Gets or sets the size of the bounding box associated with the cube texture
  141988. * When defined, the cubemap will switch to local mode
  141989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141990. * @example https://www.babylonjs-playground.com/#RNASML
  141991. */
  141992. set boundingBoxSize(value: Vector3);
  141993. get boundingBoxSize(): Vector3;
  141994. /**
  141995. * Instantiates an HDRTexture from the following parameters.
  141996. *
  141997. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141998. * @param sceneOrEngine The scene or engine the texture will be used in
  141999. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142000. * @param noMipmap Forces to not generate the mipmap if true
  142001. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142002. * @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)
  142003. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142004. */
  142005. 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>);
  142006. /**
  142007. * Get the current class name of the texture useful for serialization or dynamic coding.
  142008. * @returns "HDRCubeTexture"
  142009. */
  142010. getClassName(): string;
  142011. /**
  142012. * Occurs when the file is raw .hdr file.
  142013. */
  142014. private loadTexture;
  142015. clone(): HDRCubeTexture;
  142016. delayLoad(): void;
  142017. /**
  142018. * Get the texture reflection matrix used to rotate/transform the reflection.
  142019. * @returns the reflection matrix
  142020. */
  142021. getReflectionTextureMatrix(): Matrix;
  142022. /**
  142023. * Set the texture reflection matrix used to rotate/transform the reflection.
  142024. * @param value Define the reflection matrix to set
  142025. */
  142026. setReflectionTextureMatrix(value: Matrix): void;
  142027. /**
  142028. * Parses a JSON representation of an HDR Texture in order to create the texture
  142029. * @param parsedTexture Define the JSON representation
  142030. * @param scene Define the scene the texture should be created in
  142031. * @param rootUrl Define the root url in case we need to load relative dependencies
  142032. * @returns the newly created texture after parsing
  142033. */
  142034. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142035. serialize(): any;
  142036. }
  142037. }
  142038. declare module BABYLON {
  142039. /**
  142040. * Class used to control physics engine
  142041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142042. */
  142043. export class PhysicsEngine implements IPhysicsEngine {
  142044. private _physicsPlugin;
  142045. /**
  142046. * Global value used to control the smallest number supported by the simulation
  142047. */
  142048. static Epsilon: number;
  142049. private _impostors;
  142050. private _joints;
  142051. private _subTimeStep;
  142052. /**
  142053. * Gets the gravity vector used by the simulation
  142054. */
  142055. gravity: Vector3;
  142056. /**
  142057. * Factory used to create the default physics plugin.
  142058. * @returns The default physics plugin
  142059. */
  142060. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142061. /**
  142062. * Creates a new Physics Engine
  142063. * @param gravity defines the gravity vector used by the simulation
  142064. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142065. */
  142066. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142067. /**
  142068. * Sets the gravity vector used by the simulation
  142069. * @param gravity defines the gravity vector to use
  142070. */
  142071. setGravity(gravity: Vector3): void;
  142072. /**
  142073. * Set the time step of the physics engine.
  142074. * Default is 1/60.
  142075. * To slow it down, enter 1/600 for example.
  142076. * To speed it up, 1/30
  142077. * @param newTimeStep defines the new timestep to apply to this world.
  142078. */
  142079. setTimeStep(newTimeStep?: number): void;
  142080. /**
  142081. * Get the time step of the physics engine.
  142082. * @returns the current time step
  142083. */
  142084. getTimeStep(): number;
  142085. /**
  142086. * Set the sub time step of the physics engine.
  142087. * Default is 0 meaning there is no sub steps
  142088. * To increase physics resolution precision, set a small value (like 1 ms)
  142089. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142090. */
  142091. setSubTimeStep(subTimeStep?: number): void;
  142092. /**
  142093. * Get the sub time step of the physics engine.
  142094. * @returns the current sub time step
  142095. */
  142096. getSubTimeStep(): number;
  142097. /**
  142098. * Release all resources
  142099. */
  142100. dispose(): void;
  142101. /**
  142102. * Gets the name of the current physics plugin
  142103. * @returns the name of the plugin
  142104. */
  142105. getPhysicsPluginName(): string;
  142106. /**
  142107. * Adding a new impostor for the impostor tracking.
  142108. * This will be done by the impostor itself.
  142109. * @param impostor the impostor to add
  142110. */
  142111. addImpostor(impostor: PhysicsImpostor): void;
  142112. /**
  142113. * Remove an impostor from the engine.
  142114. * This impostor and its mesh will not longer be updated by the physics engine.
  142115. * @param impostor the impostor to remove
  142116. */
  142117. removeImpostor(impostor: PhysicsImpostor): void;
  142118. /**
  142119. * Add a joint to the physics engine
  142120. * @param mainImpostor defines the main impostor to which the joint is added.
  142121. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142122. * @param joint defines the joint that will connect both impostors.
  142123. */
  142124. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142125. /**
  142126. * Removes a joint from the simulation
  142127. * @param mainImpostor defines the impostor used with the joint
  142128. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142129. * @param joint defines the joint to remove
  142130. */
  142131. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142132. /**
  142133. * Called by the scene. No need to call it.
  142134. * @param delta defines the timespam between frames
  142135. */
  142136. _step(delta: number): void;
  142137. /**
  142138. * Gets the current plugin used to run the simulation
  142139. * @returns current plugin
  142140. */
  142141. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142142. /**
  142143. * Gets the list of physic impostors
  142144. * @returns an array of PhysicsImpostor
  142145. */
  142146. getImpostors(): Array<PhysicsImpostor>;
  142147. /**
  142148. * Gets the impostor for a physics enabled object
  142149. * @param object defines the object impersonated by the impostor
  142150. * @returns the PhysicsImpostor or null if not found
  142151. */
  142152. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142153. /**
  142154. * Gets the impostor for a physics body object
  142155. * @param body defines physics body used by the impostor
  142156. * @returns the PhysicsImpostor or null if not found
  142157. */
  142158. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142159. /**
  142160. * Does a raycast in the physics world
  142161. * @param from when should the ray start?
  142162. * @param to when should the ray end?
  142163. * @returns PhysicsRaycastResult
  142164. */
  142165. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142166. }
  142167. }
  142168. declare module BABYLON {
  142169. /** @hidden */
  142170. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142171. private _useDeltaForWorldStep;
  142172. world: any;
  142173. name: string;
  142174. private _physicsMaterials;
  142175. private _fixedTimeStep;
  142176. private _cannonRaycastResult;
  142177. private _raycastResult;
  142178. private _physicsBodysToRemoveAfterStep;
  142179. private _firstFrame;
  142180. BJSCANNON: any;
  142181. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142182. setGravity(gravity: Vector3): void;
  142183. setTimeStep(timeStep: number): void;
  142184. getTimeStep(): number;
  142185. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142186. private _removeMarkedPhysicsBodiesFromWorld;
  142187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142190. private _processChildMeshes;
  142191. removePhysicsBody(impostor: PhysicsImpostor): void;
  142192. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142193. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142194. private _addMaterial;
  142195. private _checkWithEpsilon;
  142196. private _createShape;
  142197. private _createHeightmap;
  142198. private _minus90X;
  142199. private _plus90X;
  142200. private _tmpPosition;
  142201. private _tmpDeltaPosition;
  142202. private _tmpUnityRotation;
  142203. private _updatePhysicsBodyTransformation;
  142204. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142205. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142206. isSupported(): boolean;
  142207. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142208. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142209. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142210. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142211. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142212. getBodyMass(impostor: PhysicsImpostor): number;
  142213. getBodyFriction(impostor: PhysicsImpostor): number;
  142214. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142215. getBodyRestitution(impostor: PhysicsImpostor): number;
  142216. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142217. sleepBody(impostor: PhysicsImpostor): void;
  142218. wakeUpBody(impostor: PhysicsImpostor): void;
  142219. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142220. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142221. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142222. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142223. getRadius(impostor: PhysicsImpostor): number;
  142224. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142225. dispose(): void;
  142226. private _extendNamespace;
  142227. /**
  142228. * Does a raycast in the physics world
  142229. * @param from when should the ray start?
  142230. * @param to when should the ray end?
  142231. * @returns PhysicsRaycastResult
  142232. */
  142233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142234. }
  142235. }
  142236. declare module BABYLON {
  142237. /** @hidden */
  142238. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142239. private _useDeltaForWorldStep;
  142240. world: any;
  142241. name: string;
  142242. BJSOIMO: any;
  142243. private _raycastResult;
  142244. private _fixedTimeStep;
  142245. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142246. setGravity(gravity: Vector3): void;
  142247. setTimeStep(timeStep: number): void;
  142248. getTimeStep(): number;
  142249. private _tmpImpostorsArray;
  142250. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142251. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142252. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142253. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142254. private _tmpPositionVector;
  142255. removePhysicsBody(impostor: PhysicsImpostor): void;
  142256. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142257. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142258. isSupported(): boolean;
  142259. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142260. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142261. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142262. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142263. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142264. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142266. getBodyMass(impostor: PhysicsImpostor): number;
  142267. getBodyFriction(impostor: PhysicsImpostor): number;
  142268. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142269. getBodyRestitution(impostor: PhysicsImpostor): number;
  142270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142271. sleepBody(impostor: PhysicsImpostor): void;
  142272. wakeUpBody(impostor: PhysicsImpostor): void;
  142273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142274. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142275. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142276. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142277. getRadius(impostor: PhysicsImpostor): number;
  142278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142279. dispose(): void;
  142280. /**
  142281. * Does a raycast in the physics world
  142282. * @param from when should the ray start?
  142283. * @param to when should the ray end?
  142284. * @returns PhysicsRaycastResult
  142285. */
  142286. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142287. }
  142288. }
  142289. declare module BABYLON {
  142290. /**
  142291. * AmmoJS Physics plugin
  142292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142293. * @see https://github.com/kripken/ammo.js/
  142294. */
  142295. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142296. private _useDeltaForWorldStep;
  142297. /**
  142298. * Reference to the Ammo library
  142299. */
  142300. bjsAMMO: any;
  142301. /**
  142302. * Created ammoJS world which physics bodies are added to
  142303. */
  142304. world: any;
  142305. /**
  142306. * Name of the plugin
  142307. */
  142308. name: string;
  142309. private _timeStep;
  142310. private _fixedTimeStep;
  142311. private _maxSteps;
  142312. private _tmpQuaternion;
  142313. private _tmpAmmoTransform;
  142314. private _tmpAmmoQuaternion;
  142315. private _tmpAmmoConcreteContactResultCallback;
  142316. private _collisionConfiguration;
  142317. private _dispatcher;
  142318. private _overlappingPairCache;
  142319. private _solver;
  142320. private _softBodySolver;
  142321. private _tmpAmmoVectorA;
  142322. private _tmpAmmoVectorB;
  142323. private _tmpAmmoVectorC;
  142324. private _tmpAmmoVectorD;
  142325. private _tmpContactCallbackResult;
  142326. private _tmpAmmoVectorRCA;
  142327. private _tmpAmmoVectorRCB;
  142328. private _raycastResult;
  142329. private _tmpContactPoint;
  142330. private static readonly DISABLE_COLLISION_FLAG;
  142331. private static readonly KINEMATIC_FLAG;
  142332. private static readonly DISABLE_DEACTIVATION_FLAG;
  142333. /**
  142334. * Initializes the ammoJS plugin
  142335. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142336. * @param ammoInjection can be used to inject your own ammo reference
  142337. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142338. */
  142339. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142340. /**
  142341. * Sets the gravity of the physics world (m/(s^2))
  142342. * @param gravity Gravity to set
  142343. */
  142344. setGravity(gravity: Vector3): void;
  142345. /**
  142346. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142347. * @param timeStep timestep to use in seconds
  142348. */
  142349. setTimeStep(timeStep: number): void;
  142350. /**
  142351. * 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)
  142352. * @param fixedTimeStep fixedTimeStep to use in seconds
  142353. */
  142354. setFixedTimeStep(fixedTimeStep: number): void;
  142355. /**
  142356. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142357. * @param maxSteps the maximum number of steps by the physics engine per frame
  142358. */
  142359. setMaxSteps(maxSteps: number): void;
  142360. /**
  142361. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142362. * @returns the current timestep in seconds
  142363. */
  142364. getTimeStep(): number;
  142365. /**
  142366. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142367. */
  142368. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142369. private _isImpostorInContact;
  142370. private _isImpostorPairInContact;
  142371. private _stepSimulation;
  142372. /**
  142373. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142374. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142375. * After the step the babylon meshes are set to the position of the physics imposters
  142376. * @param delta amount of time to step forward
  142377. * @param impostors array of imposters to update before/after the step
  142378. */
  142379. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142380. /**
  142381. * Update babylon mesh to match physics world object
  142382. * @param impostor imposter to match
  142383. */
  142384. private _afterSoftStep;
  142385. /**
  142386. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142387. * @param impostor imposter to match
  142388. */
  142389. private _ropeStep;
  142390. /**
  142391. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142392. * @param impostor imposter to match
  142393. */
  142394. private _softbodyOrClothStep;
  142395. private _tmpMatrix;
  142396. /**
  142397. * Applies an impulse on the imposter
  142398. * @param impostor imposter to apply impulse to
  142399. * @param force amount of force to be applied to the imposter
  142400. * @param contactPoint the location to apply the impulse on the imposter
  142401. */
  142402. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142403. /**
  142404. * Applies a force on the imposter
  142405. * @param impostor imposter to apply force
  142406. * @param force amount of force to be applied to the imposter
  142407. * @param contactPoint the location to apply the force on the imposter
  142408. */
  142409. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142410. /**
  142411. * Creates a physics body using the plugin
  142412. * @param impostor the imposter to create the physics body on
  142413. */
  142414. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142415. /**
  142416. * Removes the physics body from the imposter and disposes of the body's memory
  142417. * @param impostor imposter to remove the physics body from
  142418. */
  142419. removePhysicsBody(impostor: PhysicsImpostor): void;
  142420. /**
  142421. * Generates a joint
  142422. * @param impostorJoint the imposter joint to create the joint with
  142423. */
  142424. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142425. /**
  142426. * Removes a joint
  142427. * @param impostorJoint the imposter joint to remove the joint from
  142428. */
  142429. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142430. private _addMeshVerts;
  142431. /**
  142432. * Initialise the soft body vertices to match its object's (mesh) vertices
  142433. * Softbody vertices (nodes) are in world space and to match this
  142434. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142435. * @param impostor to create the softbody for
  142436. */
  142437. private _softVertexData;
  142438. /**
  142439. * Create an impostor's soft body
  142440. * @param impostor to create the softbody for
  142441. */
  142442. private _createSoftbody;
  142443. /**
  142444. * Create cloth for an impostor
  142445. * @param impostor to create the softbody for
  142446. */
  142447. private _createCloth;
  142448. /**
  142449. * Create rope for an impostor
  142450. * @param impostor to create the softbody for
  142451. */
  142452. private _createRope;
  142453. /**
  142454. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142455. * @param impostor to create the custom physics shape for
  142456. */
  142457. private _createCustom;
  142458. private _addHullVerts;
  142459. private _createShape;
  142460. /**
  142461. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142462. * @param impostor imposter containing the physics body and babylon object
  142463. */
  142464. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142465. /**
  142466. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142467. * @param impostor imposter containing the physics body and babylon object
  142468. * @param newPosition new position
  142469. * @param newRotation new rotation
  142470. */
  142471. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142472. /**
  142473. * If this plugin is supported
  142474. * @returns true if its supported
  142475. */
  142476. isSupported(): boolean;
  142477. /**
  142478. * Sets the linear velocity of the physics body
  142479. * @param impostor imposter to set the velocity on
  142480. * @param velocity velocity to set
  142481. */
  142482. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142483. /**
  142484. * Sets the angular velocity of the physics body
  142485. * @param impostor imposter to set the velocity on
  142486. * @param velocity velocity to set
  142487. */
  142488. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142489. /**
  142490. * gets the linear velocity
  142491. * @param impostor imposter to get linear velocity from
  142492. * @returns linear velocity
  142493. */
  142494. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142495. /**
  142496. * gets the angular velocity
  142497. * @param impostor imposter to get angular velocity from
  142498. * @returns angular velocity
  142499. */
  142500. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142501. /**
  142502. * Sets the mass of physics body
  142503. * @param impostor imposter to set the mass on
  142504. * @param mass mass to set
  142505. */
  142506. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142507. /**
  142508. * Gets the mass of the physics body
  142509. * @param impostor imposter to get the mass from
  142510. * @returns mass
  142511. */
  142512. getBodyMass(impostor: PhysicsImpostor): number;
  142513. /**
  142514. * Gets friction of the impostor
  142515. * @param impostor impostor to get friction from
  142516. * @returns friction value
  142517. */
  142518. getBodyFriction(impostor: PhysicsImpostor): number;
  142519. /**
  142520. * Sets friction of the impostor
  142521. * @param impostor impostor to set friction on
  142522. * @param friction friction value
  142523. */
  142524. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142525. /**
  142526. * Gets restitution of the impostor
  142527. * @param impostor impostor to get restitution from
  142528. * @returns restitution value
  142529. */
  142530. getBodyRestitution(impostor: PhysicsImpostor): number;
  142531. /**
  142532. * Sets resitution of the impostor
  142533. * @param impostor impostor to set resitution on
  142534. * @param restitution resitution value
  142535. */
  142536. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142537. /**
  142538. * Gets pressure inside the impostor
  142539. * @param impostor impostor to get pressure from
  142540. * @returns pressure value
  142541. */
  142542. getBodyPressure(impostor: PhysicsImpostor): number;
  142543. /**
  142544. * Sets pressure inside a soft body impostor
  142545. * Cloth and rope must remain 0 pressure
  142546. * @param impostor impostor to set pressure on
  142547. * @param pressure pressure value
  142548. */
  142549. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142550. /**
  142551. * Gets stiffness of the impostor
  142552. * @param impostor impostor to get stiffness from
  142553. * @returns pressure value
  142554. */
  142555. getBodyStiffness(impostor: PhysicsImpostor): number;
  142556. /**
  142557. * Sets stiffness of the impostor
  142558. * @param impostor impostor to set stiffness on
  142559. * @param stiffness stiffness value from 0 to 1
  142560. */
  142561. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142562. /**
  142563. * Gets velocityIterations of the impostor
  142564. * @param impostor impostor to get velocity iterations from
  142565. * @returns velocityIterations value
  142566. */
  142567. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142568. /**
  142569. * Sets velocityIterations of the impostor
  142570. * @param impostor impostor to set velocity iterations on
  142571. * @param velocityIterations velocityIterations value
  142572. */
  142573. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142574. /**
  142575. * Gets positionIterations of the impostor
  142576. * @param impostor impostor to get position iterations from
  142577. * @returns positionIterations value
  142578. */
  142579. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142580. /**
  142581. * Sets positionIterations of the impostor
  142582. * @param impostor impostor to set position on
  142583. * @param positionIterations positionIterations value
  142584. */
  142585. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142586. /**
  142587. * Append an anchor to a cloth object
  142588. * @param impostor is the cloth impostor to add anchor to
  142589. * @param otherImpostor is the rigid impostor to anchor to
  142590. * @param width ratio across width from 0 to 1
  142591. * @param height ratio up height from 0 to 1
  142592. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142593. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142594. */
  142595. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142596. /**
  142597. * Append an hook to a rope object
  142598. * @param impostor is the rope impostor to add hook to
  142599. * @param otherImpostor is the rigid impostor to hook to
  142600. * @param length ratio along the rope from 0 to 1
  142601. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142602. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142603. */
  142604. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142605. /**
  142606. * Sleeps the physics body and stops it from being active
  142607. * @param impostor impostor to sleep
  142608. */
  142609. sleepBody(impostor: PhysicsImpostor): void;
  142610. /**
  142611. * Activates the physics body
  142612. * @param impostor impostor to activate
  142613. */
  142614. wakeUpBody(impostor: PhysicsImpostor): void;
  142615. /**
  142616. * Updates the distance parameters of the joint
  142617. * @param joint joint to update
  142618. * @param maxDistance maximum distance of the joint
  142619. * @param minDistance minimum distance of the joint
  142620. */
  142621. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142622. /**
  142623. * Sets a motor on the joint
  142624. * @param joint joint to set motor on
  142625. * @param speed speed of the motor
  142626. * @param maxForce maximum force of the motor
  142627. * @param motorIndex index of the motor
  142628. */
  142629. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142630. /**
  142631. * Sets the motors limit
  142632. * @param joint joint to set limit on
  142633. * @param upperLimit upper limit
  142634. * @param lowerLimit lower limit
  142635. */
  142636. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142637. /**
  142638. * Syncs the position and rotation of a mesh with the impostor
  142639. * @param mesh mesh to sync
  142640. * @param impostor impostor to update the mesh with
  142641. */
  142642. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142643. /**
  142644. * Gets the radius of the impostor
  142645. * @param impostor impostor to get radius from
  142646. * @returns the radius
  142647. */
  142648. getRadius(impostor: PhysicsImpostor): number;
  142649. /**
  142650. * Gets the box size of the impostor
  142651. * @param impostor impostor to get box size from
  142652. * @param result the resulting box size
  142653. */
  142654. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142655. /**
  142656. * Disposes of the impostor
  142657. */
  142658. dispose(): void;
  142659. /**
  142660. * Does a raycast in the physics world
  142661. * @param from when should the ray start?
  142662. * @param to when should the ray end?
  142663. * @returns PhysicsRaycastResult
  142664. */
  142665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142666. }
  142667. }
  142668. declare module BABYLON {
  142669. interface AbstractScene {
  142670. /**
  142671. * The list of reflection probes added to the scene
  142672. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142673. */
  142674. reflectionProbes: Array<ReflectionProbe>;
  142675. /**
  142676. * Removes the given reflection probe from this scene.
  142677. * @param toRemove The reflection probe to remove
  142678. * @returns The index of the removed reflection probe
  142679. */
  142680. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142681. /**
  142682. * Adds the given reflection probe to this scene.
  142683. * @param newReflectionProbe The reflection probe to add
  142684. */
  142685. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142686. }
  142687. /**
  142688. * Class used to generate realtime reflection / refraction cube textures
  142689. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142690. */
  142691. export class ReflectionProbe {
  142692. /** defines the name of the probe */
  142693. name: string;
  142694. private _scene;
  142695. private _renderTargetTexture;
  142696. private _projectionMatrix;
  142697. private _viewMatrix;
  142698. private _target;
  142699. private _add;
  142700. private _attachedMesh;
  142701. private _invertYAxis;
  142702. /** Gets or sets probe position (center of the cube map) */
  142703. position: Vector3;
  142704. /**
  142705. * Creates a new reflection probe
  142706. * @param name defines the name of the probe
  142707. * @param size defines the texture resolution (for each face)
  142708. * @param scene defines the hosting scene
  142709. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142710. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142711. */
  142712. constructor(
  142713. /** defines the name of the probe */
  142714. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142715. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142716. get samples(): number;
  142717. set samples(value: number);
  142718. /** Gets or sets the refresh rate to use (on every frame by default) */
  142719. get refreshRate(): number;
  142720. set refreshRate(value: number);
  142721. /**
  142722. * Gets the hosting scene
  142723. * @returns a Scene
  142724. */
  142725. getScene(): Scene;
  142726. /** Gets the internal CubeTexture used to render to */
  142727. get cubeTexture(): RenderTargetTexture;
  142728. /** Gets the list of meshes to render */
  142729. get renderList(): Nullable<AbstractMesh[]>;
  142730. /**
  142731. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142732. * @param mesh defines the mesh to attach to
  142733. */
  142734. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142735. /**
  142736. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142737. * @param renderingGroupId The rendering group id corresponding to its index
  142738. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142739. */
  142740. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142741. /**
  142742. * Clean all associated resources
  142743. */
  142744. dispose(): void;
  142745. /**
  142746. * Converts the reflection probe information to a readable string for debug purpose.
  142747. * @param fullDetails Supports for multiple levels of logging within scene loading
  142748. * @returns the human readable reflection probe info
  142749. */
  142750. toString(fullDetails?: boolean): string;
  142751. /**
  142752. * Get the class name of the relfection probe.
  142753. * @returns "ReflectionProbe"
  142754. */
  142755. getClassName(): string;
  142756. /**
  142757. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142758. * @returns The JSON representation of the texture
  142759. */
  142760. serialize(): any;
  142761. /**
  142762. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142763. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142764. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142765. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142766. * @returns The parsed reflection probe if successful
  142767. */
  142768. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142769. }
  142770. }
  142771. declare module BABYLON {
  142772. /** @hidden */
  142773. export var _BabylonLoaderRegistered: boolean;
  142774. /**
  142775. * Helps setting up some configuration for the babylon file loader.
  142776. */
  142777. export class BabylonFileLoaderConfiguration {
  142778. /**
  142779. * The loader does not allow injecting custom physix engine into the plugins.
  142780. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142781. * So you could set this variable to your engine import to make it work.
  142782. */
  142783. static LoaderInjectedPhysicsEngine: any;
  142784. }
  142785. }
  142786. declare module BABYLON {
  142787. /**
  142788. * The Physically based simple base material of BJS.
  142789. *
  142790. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142791. * It is used as the base class for both the specGloss and metalRough conventions.
  142792. */
  142793. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142794. /**
  142795. * Number of Simultaneous lights allowed on the material.
  142796. */
  142797. maxSimultaneousLights: number;
  142798. /**
  142799. * If sets to true, disables all the lights affecting the material.
  142800. */
  142801. disableLighting: boolean;
  142802. /**
  142803. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142804. */
  142805. environmentTexture: BaseTexture;
  142806. /**
  142807. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142808. */
  142809. invertNormalMapX: boolean;
  142810. /**
  142811. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142812. */
  142813. invertNormalMapY: boolean;
  142814. /**
  142815. * Normal map used in the model.
  142816. */
  142817. normalTexture: BaseTexture;
  142818. /**
  142819. * Emissivie color used to self-illuminate the model.
  142820. */
  142821. emissiveColor: Color3;
  142822. /**
  142823. * Emissivie texture used to self-illuminate the model.
  142824. */
  142825. emissiveTexture: BaseTexture;
  142826. /**
  142827. * Occlusion Channel Strenght.
  142828. */
  142829. occlusionStrength: number;
  142830. /**
  142831. * Occlusion Texture of the material (adding extra occlusion effects).
  142832. */
  142833. occlusionTexture: BaseTexture;
  142834. /**
  142835. * Defines the alpha limits in alpha test mode.
  142836. */
  142837. alphaCutOff: number;
  142838. /**
  142839. * Gets the current double sided mode.
  142840. */
  142841. get doubleSided(): boolean;
  142842. /**
  142843. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142844. */
  142845. set doubleSided(value: boolean);
  142846. /**
  142847. * Stores the pre-calculated light information of a mesh in a texture.
  142848. */
  142849. lightmapTexture: BaseTexture;
  142850. /**
  142851. * If true, the light map contains occlusion information instead of lighting info.
  142852. */
  142853. useLightmapAsShadowmap: boolean;
  142854. /**
  142855. * Instantiates a new PBRMaterial instance.
  142856. *
  142857. * @param name The material name
  142858. * @param scene The scene the material will be use in.
  142859. */
  142860. constructor(name: string, scene: Scene);
  142861. getClassName(): string;
  142862. }
  142863. }
  142864. declare module BABYLON {
  142865. /**
  142866. * The PBR material of BJS following the metal roughness convention.
  142867. *
  142868. * This fits to the PBR convention in the GLTF definition:
  142869. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142870. */
  142871. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142872. /**
  142873. * The base color has two different interpretations depending on the value of metalness.
  142874. * When the material is a metal, the base color is the specific measured reflectance value
  142875. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142876. * of the material.
  142877. */
  142878. baseColor: Color3;
  142879. /**
  142880. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142881. * well as opacity information in the alpha channel.
  142882. */
  142883. baseTexture: BaseTexture;
  142884. /**
  142885. * Specifies the metallic scalar value of the material.
  142886. * Can also be used to scale the metalness values of the metallic texture.
  142887. */
  142888. metallic: number;
  142889. /**
  142890. * Specifies the roughness scalar value of the material.
  142891. * Can also be used to scale the roughness values of the metallic texture.
  142892. */
  142893. roughness: number;
  142894. /**
  142895. * Texture containing both the metallic value in the B channel and the
  142896. * roughness value in the G channel to keep better precision.
  142897. */
  142898. metallicRoughnessTexture: BaseTexture;
  142899. /**
  142900. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142901. *
  142902. * @param name The material name
  142903. * @param scene The scene the material will be use in.
  142904. */
  142905. constructor(name: string, scene: Scene);
  142906. /**
  142907. * Return the currrent class name of the material.
  142908. */
  142909. getClassName(): string;
  142910. /**
  142911. * Makes a duplicate of the current material.
  142912. * @param name - name to use for the new material.
  142913. */
  142914. clone(name: string): PBRMetallicRoughnessMaterial;
  142915. /**
  142916. * Serialize the material to a parsable JSON object.
  142917. */
  142918. serialize(): any;
  142919. /**
  142920. * Parses a JSON object correponding to the serialize function.
  142921. */
  142922. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142923. }
  142924. }
  142925. declare module BABYLON {
  142926. /**
  142927. * The PBR material of BJS following the specular glossiness convention.
  142928. *
  142929. * This fits to the PBR convention in the GLTF definition:
  142930. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142931. */
  142932. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142933. /**
  142934. * Specifies the diffuse color of the material.
  142935. */
  142936. diffuseColor: Color3;
  142937. /**
  142938. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142939. * channel.
  142940. */
  142941. diffuseTexture: BaseTexture;
  142942. /**
  142943. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142944. */
  142945. specularColor: Color3;
  142946. /**
  142947. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142948. */
  142949. glossiness: number;
  142950. /**
  142951. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142952. */
  142953. specularGlossinessTexture: BaseTexture;
  142954. /**
  142955. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142956. *
  142957. * @param name The material name
  142958. * @param scene The scene the material will be use in.
  142959. */
  142960. constructor(name: string, scene: Scene);
  142961. /**
  142962. * Return the currrent class name of the material.
  142963. */
  142964. getClassName(): string;
  142965. /**
  142966. * Makes a duplicate of the current material.
  142967. * @param name - name to use for the new material.
  142968. */
  142969. clone(name: string): PBRSpecularGlossinessMaterial;
  142970. /**
  142971. * Serialize the material to a parsable JSON object.
  142972. */
  142973. serialize(): any;
  142974. /**
  142975. * Parses a JSON object correponding to the serialize function.
  142976. */
  142977. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142978. }
  142979. }
  142980. declare module BABYLON {
  142981. /**
  142982. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142983. * It can help converting any input color in a desired output one. This can then be used to create effects
  142984. * from sepia, black and white to sixties or futuristic rendering...
  142985. *
  142986. * The only supported format is currently 3dl.
  142987. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142988. */
  142989. export class ColorGradingTexture extends BaseTexture {
  142990. /**
  142991. * The texture URL.
  142992. */
  142993. url: string;
  142994. /**
  142995. * Empty line regex stored for GC.
  142996. */
  142997. private static _noneEmptyLineRegex;
  142998. private _textureMatrix;
  142999. private _onLoad;
  143000. /**
  143001. * Instantiates a ColorGradingTexture from the following parameters.
  143002. *
  143003. * @param url The location of the color gradind data (currently only supporting 3dl)
  143004. * @param sceneOrEngine The scene or engine the texture will be used in
  143005. * @param onLoad defines a callback triggered when the texture has been loaded
  143006. */
  143007. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143008. /**
  143009. * Fires the onload event from the constructor if requested.
  143010. */
  143011. private _triggerOnLoad;
  143012. /**
  143013. * Returns the texture matrix used in most of the material.
  143014. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143015. */
  143016. getTextureMatrix(): Matrix;
  143017. /**
  143018. * Occurs when the file being loaded is a .3dl LUT file.
  143019. */
  143020. private load3dlTexture;
  143021. /**
  143022. * Starts the loading process of the texture.
  143023. */
  143024. private loadTexture;
  143025. /**
  143026. * Clones the color gradind texture.
  143027. */
  143028. clone(): ColorGradingTexture;
  143029. /**
  143030. * Called during delayed load for textures.
  143031. */
  143032. delayLoad(): void;
  143033. /**
  143034. * Parses a color grading texture serialized by Babylon.
  143035. * @param parsedTexture The texture information being parsedTexture
  143036. * @param scene The scene to load the texture in
  143037. * @param rootUrl The root url of the data assets to load
  143038. * @return A color gradind texture
  143039. */
  143040. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143041. /**
  143042. * Serializes the LUT texture to json format.
  143043. */
  143044. serialize(): any;
  143045. }
  143046. }
  143047. declare module BABYLON {
  143048. /**
  143049. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143050. */
  143051. export class EquiRectangularCubeTexture extends BaseTexture {
  143052. /** The six faces of the cube. */
  143053. private static _FacesMapping;
  143054. private _noMipmap;
  143055. private _onLoad;
  143056. private _onError;
  143057. /** The size of the cubemap. */
  143058. private _size;
  143059. /** The buffer of the image. */
  143060. private _buffer;
  143061. /** The width of the input image. */
  143062. private _width;
  143063. /** The height of the input image. */
  143064. private _height;
  143065. /** The URL to the image. */
  143066. url: string;
  143067. /**
  143068. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143069. * @param url The location of the image
  143070. * @param scene The scene the texture will be used in
  143071. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143072. * @param noMipmap Forces to not generate the mipmap if true
  143073. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143074. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143075. * @param onLoad — defines a callback called when texture is loaded
  143076. * @param onError — defines a callback called if there is an error
  143077. */
  143078. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143079. /**
  143080. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143081. */
  143082. private loadImage;
  143083. /**
  143084. * Convert the image buffer into a cubemap and create a CubeTexture.
  143085. */
  143086. private loadTexture;
  143087. /**
  143088. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143089. * @param buffer The ArrayBuffer that should be converted.
  143090. * @returns The buffer as Float32Array.
  143091. */
  143092. private getFloat32ArrayFromArrayBuffer;
  143093. /**
  143094. * Get the current class name of the texture useful for serialization or dynamic coding.
  143095. * @returns "EquiRectangularCubeTexture"
  143096. */
  143097. getClassName(): string;
  143098. /**
  143099. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143100. * @returns A clone of the current EquiRectangularCubeTexture.
  143101. */
  143102. clone(): EquiRectangularCubeTexture;
  143103. }
  143104. }
  143105. declare module BABYLON {
  143106. /**
  143107. * Defines the options related to the creation of an HtmlElementTexture
  143108. */
  143109. export interface IHtmlElementTextureOptions {
  143110. /**
  143111. * Defines wether mip maps should be created or not.
  143112. */
  143113. generateMipMaps?: boolean;
  143114. /**
  143115. * Defines the sampling mode of the texture.
  143116. */
  143117. samplingMode?: number;
  143118. /**
  143119. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143120. */
  143121. engine: Nullable<ThinEngine>;
  143122. /**
  143123. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143124. */
  143125. scene: Nullable<Scene>;
  143126. }
  143127. /**
  143128. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143129. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143130. * is automatically managed.
  143131. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143132. * in your application.
  143133. *
  143134. * As the update is not automatic, you need to call them manually.
  143135. */
  143136. export class HtmlElementTexture extends BaseTexture {
  143137. /**
  143138. * The texture URL.
  143139. */
  143140. element: HTMLVideoElement | HTMLCanvasElement;
  143141. private static readonly DefaultOptions;
  143142. private _textureMatrix;
  143143. private _isVideo;
  143144. private _generateMipMaps;
  143145. private _samplingMode;
  143146. /**
  143147. * Instantiates a HtmlElementTexture from the following parameters.
  143148. *
  143149. * @param name Defines the name of the texture
  143150. * @param element Defines the video or canvas the texture is filled with
  143151. * @param options Defines the other none mandatory texture creation options
  143152. */
  143153. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143154. private _createInternalTexture;
  143155. /**
  143156. * Returns the texture matrix used in most of the material.
  143157. */
  143158. getTextureMatrix(): Matrix;
  143159. /**
  143160. * Updates the content of the texture.
  143161. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143162. */
  143163. update(invertY?: Nullable<boolean>): void;
  143164. }
  143165. }
  143166. declare module BABYLON {
  143167. /**
  143168. * Based on jsTGALoader - Javascript loader for TGA file
  143169. * By Vincent Thibault
  143170. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143171. */
  143172. export class TGATools {
  143173. private static _TYPE_INDEXED;
  143174. private static _TYPE_RGB;
  143175. private static _TYPE_GREY;
  143176. private static _TYPE_RLE_INDEXED;
  143177. private static _TYPE_RLE_RGB;
  143178. private static _TYPE_RLE_GREY;
  143179. private static _ORIGIN_MASK;
  143180. private static _ORIGIN_SHIFT;
  143181. private static _ORIGIN_BL;
  143182. private static _ORIGIN_BR;
  143183. private static _ORIGIN_UL;
  143184. private static _ORIGIN_UR;
  143185. /**
  143186. * Gets the header of a TGA file
  143187. * @param data defines the TGA data
  143188. * @returns the header
  143189. */
  143190. static GetTGAHeader(data: Uint8Array): any;
  143191. /**
  143192. * Uploads TGA content to a Babylon Texture
  143193. * @hidden
  143194. */
  143195. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143196. /** @hidden */
  143197. 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;
  143198. /** @hidden */
  143199. 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;
  143200. /** @hidden */
  143201. 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;
  143202. /** @hidden */
  143203. 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;
  143204. /** @hidden */
  143205. 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;
  143206. /** @hidden */
  143207. 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;
  143208. }
  143209. }
  143210. declare module BABYLON {
  143211. /**
  143212. * Implementation of the TGA Texture Loader.
  143213. * @hidden
  143214. */
  143215. export class _TGATextureLoader implements IInternalTextureLoader {
  143216. /**
  143217. * Defines wether the loader supports cascade loading the different faces.
  143218. */
  143219. readonly supportCascades: boolean;
  143220. /**
  143221. * This returns if the loader support the current file information.
  143222. * @param extension defines the file extension of the file being loaded
  143223. * @returns true if the loader can load the specified file
  143224. */
  143225. canLoad(extension: string): boolean;
  143226. /**
  143227. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143228. * @param data contains the texture data
  143229. * @param texture defines the BabylonJS internal texture
  143230. * @param createPolynomials will be true if polynomials have been requested
  143231. * @param onLoad defines the callback to trigger once the texture is ready
  143232. * @param onError defines the callback to trigger in case of error
  143233. */
  143234. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143235. /**
  143236. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143237. * @param data contains the texture data
  143238. * @param texture defines the BabylonJS internal texture
  143239. * @param callback defines the method to call once ready to upload
  143240. */
  143241. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143242. }
  143243. }
  143244. declare module BABYLON {
  143245. /**
  143246. * Info about the .basis files
  143247. */
  143248. class BasisFileInfo {
  143249. /**
  143250. * If the file has alpha
  143251. */
  143252. hasAlpha: boolean;
  143253. /**
  143254. * Info about each image of the basis file
  143255. */
  143256. images: Array<{
  143257. levels: Array<{
  143258. width: number;
  143259. height: number;
  143260. transcodedPixels: ArrayBufferView;
  143261. }>;
  143262. }>;
  143263. }
  143264. /**
  143265. * Result of transcoding a basis file
  143266. */
  143267. class TranscodeResult {
  143268. /**
  143269. * Info about the .basis file
  143270. */
  143271. fileInfo: BasisFileInfo;
  143272. /**
  143273. * Format to use when loading the file
  143274. */
  143275. format: number;
  143276. }
  143277. /**
  143278. * Configuration options for the Basis transcoder
  143279. */
  143280. export class BasisTranscodeConfiguration {
  143281. /**
  143282. * Supported compression formats used to determine the supported output format of the transcoder
  143283. */
  143284. supportedCompressionFormats?: {
  143285. /**
  143286. * etc1 compression format
  143287. */
  143288. etc1?: boolean;
  143289. /**
  143290. * s3tc compression format
  143291. */
  143292. s3tc?: boolean;
  143293. /**
  143294. * pvrtc compression format
  143295. */
  143296. pvrtc?: boolean;
  143297. /**
  143298. * etc2 compression format
  143299. */
  143300. etc2?: boolean;
  143301. };
  143302. /**
  143303. * If mipmap levels should be loaded for transcoded images (Default: true)
  143304. */
  143305. loadMipmapLevels?: boolean;
  143306. /**
  143307. * Index of a single image to load (Default: all images)
  143308. */
  143309. loadSingleImage?: number;
  143310. }
  143311. /**
  143312. * Used to load .Basis files
  143313. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143314. */
  143315. export class BasisTools {
  143316. private static _IgnoreSupportedFormats;
  143317. /**
  143318. * URL to use when loading the basis transcoder
  143319. */
  143320. static JSModuleURL: string;
  143321. /**
  143322. * URL to use when loading the wasm module for the transcoder
  143323. */
  143324. static WasmModuleURL: string;
  143325. /**
  143326. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143327. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143328. * @returns internal format corresponding to the Basis format
  143329. */
  143330. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143331. private static _WorkerPromise;
  143332. private static _Worker;
  143333. private static _actionId;
  143334. private static _CreateWorkerAsync;
  143335. /**
  143336. * Transcodes a loaded image file to compressed pixel data
  143337. * @param data image data to transcode
  143338. * @param config configuration options for the transcoding
  143339. * @returns a promise resulting in the transcoded image
  143340. */
  143341. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143342. /**
  143343. * Loads a texture from the transcode result
  143344. * @param texture texture load to
  143345. * @param transcodeResult the result of transcoding the basis file to load from
  143346. */
  143347. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143348. }
  143349. }
  143350. declare module BABYLON {
  143351. /**
  143352. * Loader for .basis file format
  143353. */
  143354. export class _BasisTextureLoader implements IInternalTextureLoader {
  143355. /**
  143356. * Defines whether the loader supports cascade loading the different faces.
  143357. */
  143358. readonly supportCascades: boolean;
  143359. /**
  143360. * This returns if the loader support the current file information.
  143361. * @param extension defines the file extension of the file being loaded
  143362. * @returns true if the loader can load the specified file
  143363. */
  143364. canLoad(extension: string): boolean;
  143365. /**
  143366. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143367. * @param data contains the texture data
  143368. * @param texture defines the BabylonJS internal texture
  143369. * @param createPolynomials will be true if polynomials have been requested
  143370. * @param onLoad defines the callback to trigger once the texture is ready
  143371. * @param onError defines the callback to trigger in case of error
  143372. */
  143373. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143374. /**
  143375. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143376. * @param data contains the texture data
  143377. * @param texture defines the BabylonJS internal texture
  143378. * @param callback defines the method to call once ready to upload
  143379. */
  143380. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143381. }
  143382. }
  143383. declare module BABYLON {
  143384. /**
  143385. * Defines the basic options interface of a TexturePacker Frame
  143386. */
  143387. export interface ITexturePackerFrame {
  143388. /**
  143389. * The frame ID
  143390. */
  143391. id: number;
  143392. /**
  143393. * The frames Scale
  143394. */
  143395. scale: Vector2;
  143396. /**
  143397. * The Frames offset
  143398. */
  143399. offset: Vector2;
  143400. }
  143401. /**
  143402. * This is a support class for frame Data on texture packer sets.
  143403. */
  143404. export class TexturePackerFrame implements ITexturePackerFrame {
  143405. /**
  143406. * The frame ID
  143407. */
  143408. id: number;
  143409. /**
  143410. * The frames Scale
  143411. */
  143412. scale: Vector2;
  143413. /**
  143414. * The Frames offset
  143415. */
  143416. offset: Vector2;
  143417. /**
  143418. * Initializes a texture package frame.
  143419. * @param id The numerical frame identifier
  143420. * @param scale Scalar Vector2 for UV frame
  143421. * @param offset Vector2 for the frame position in UV units.
  143422. * @returns TexturePackerFrame
  143423. */
  143424. constructor(id: number, scale: Vector2, offset: Vector2);
  143425. }
  143426. }
  143427. declare module BABYLON {
  143428. /**
  143429. * Defines the basic options interface of a TexturePacker
  143430. */
  143431. export interface ITexturePackerOptions {
  143432. /**
  143433. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143434. */
  143435. map?: string[];
  143436. /**
  143437. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143438. */
  143439. uvsIn?: string;
  143440. /**
  143441. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143442. */
  143443. uvsOut?: string;
  143444. /**
  143445. * number representing the layout style. Defaults to LAYOUT_STRIP
  143446. */
  143447. layout?: number;
  143448. /**
  143449. * number of columns if using custom column count layout(2). This defaults to 4.
  143450. */
  143451. colnum?: number;
  143452. /**
  143453. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143454. */
  143455. updateInputMeshes?: boolean;
  143456. /**
  143457. * boolean flag to dispose all the source textures. Defaults to true.
  143458. */
  143459. disposeSources?: boolean;
  143460. /**
  143461. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143462. */
  143463. fillBlanks?: boolean;
  143464. /**
  143465. * string value representing the context fill style color. Defaults to 'black'.
  143466. */
  143467. customFillColor?: string;
  143468. /**
  143469. * Width and Height Value of each Frame in the TexturePacker Sets
  143470. */
  143471. frameSize?: number;
  143472. /**
  143473. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143474. */
  143475. paddingRatio?: number;
  143476. /**
  143477. * Number that declares the fill method for the padding gutter.
  143478. */
  143479. paddingMode?: number;
  143480. /**
  143481. * If in SUBUV_COLOR padding mode what color to use.
  143482. */
  143483. paddingColor?: Color3 | Color4;
  143484. }
  143485. /**
  143486. * Defines the basic interface of a TexturePacker JSON File
  143487. */
  143488. export interface ITexturePackerJSON {
  143489. /**
  143490. * The frame ID
  143491. */
  143492. name: string;
  143493. /**
  143494. * The base64 channel data
  143495. */
  143496. sets: any;
  143497. /**
  143498. * The options of the Packer
  143499. */
  143500. options: ITexturePackerOptions;
  143501. /**
  143502. * The frame data of the Packer
  143503. */
  143504. frames: Array<number>;
  143505. }
  143506. /**
  143507. * This is a support class that generates a series of packed texture sets.
  143508. * @see https://doc.babylonjs.com/babylon101/materials
  143509. */
  143510. export class TexturePacker {
  143511. /** Packer Layout Constant 0 */
  143512. static readonly LAYOUT_STRIP: number;
  143513. /** Packer Layout Constant 1 */
  143514. static readonly LAYOUT_POWER2: number;
  143515. /** Packer Layout Constant 2 */
  143516. static readonly LAYOUT_COLNUM: number;
  143517. /** Packer Layout Constant 0 */
  143518. static readonly SUBUV_WRAP: number;
  143519. /** Packer Layout Constant 1 */
  143520. static readonly SUBUV_EXTEND: number;
  143521. /** Packer Layout Constant 2 */
  143522. static readonly SUBUV_COLOR: number;
  143523. /** The Name of the Texture Package */
  143524. name: string;
  143525. /** The scene scope of the TexturePacker */
  143526. scene: Scene;
  143527. /** The Meshes to target */
  143528. meshes: AbstractMesh[];
  143529. /** Arguments passed with the Constructor */
  143530. options: ITexturePackerOptions;
  143531. /** The promise that is started upon initialization */
  143532. promise: Nullable<Promise<TexturePacker | string>>;
  143533. /** The Container object for the channel sets that are generated */
  143534. sets: object;
  143535. /** The Container array for the frames that are generated */
  143536. frames: TexturePackerFrame[];
  143537. /** The expected number of textures the system is parsing. */
  143538. private _expecting;
  143539. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143540. private _paddingValue;
  143541. /**
  143542. * Initializes a texture package series from an array of meshes or a single mesh.
  143543. * @param name The name of the package
  143544. * @param meshes The target meshes to compose the package from
  143545. * @param options The arguments that texture packer should follow while building.
  143546. * @param scene The scene which the textures are scoped to.
  143547. * @returns TexturePacker
  143548. */
  143549. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143550. /**
  143551. * Starts the package process
  143552. * @param resolve The promises resolution function
  143553. * @returns TexturePacker
  143554. */
  143555. private _createFrames;
  143556. /**
  143557. * Calculates the Size of the Channel Sets
  143558. * @returns Vector2
  143559. */
  143560. private _calculateSize;
  143561. /**
  143562. * Calculates the UV data for the frames.
  143563. * @param baseSize the base frameSize
  143564. * @param padding the base frame padding
  143565. * @param dtSize size of the Dynamic Texture for that channel
  143566. * @param dtUnits is 1/dtSize
  143567. * @param update flag to update the input meshes
  143568. */
  143569. private _calculateMeshUVFrames;
  143570. /**
  143571. * Calculates the frames Offset.
  143572. * @param index of the frame
  143573. * @returns Vector2
  143574. */
  143575. private _getFrameOffset;
  143576. /**
  143577. * Updates a Mesh to the frame data
  143578. * @param mesh that is the target
  143579. * @param frameID or the frame index
  143580. */
  143581. private _updateMeshUV;
  143582. /**
  143583. * Updates a Meshes materials to use the texture packer channels
  143584. * @param m is the mesh to target
  143585. * @param force all channels on the packer to be set.
  143586. */
  143587. private _updateTextureReferences;
  143588. /**
  143589. * Public method to set a Mesh to a frame
  143590. * @param m that is the target
  143591. * @param frameID or the frame index
  143592. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143593. */
  143594. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143595. /**
  143596. * Starts the async promise to compile the texture packer.
  143597. * @returns Promise<void>
  143598. */
  143599. processAsync(): Promise<void>;
  143600. /**
  143601. * Disposes all textures associated with this packer
  143602. */
  143603. dispose(): void;
  143604. /**
  143605. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143606. * @param imageType is the image type to use.
  143607. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143608. */
  143609. download(imageType?: string, quality?: number): void;
  143610. /**
  143611. * Public method to load a texturePacker JSON file.
  143612. * @param data of the JSON file in string format.
  143613. */
  143614. updateFromJSON(data: string): void;
  143615. }
  143616. }
  143617. declare module BABYLON {
  143618. /**
  143619. * 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.
  143620. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143621. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143622. */
  143623. export class CustomProceduralTexture extends ProceduralTexture {
  143624. private _animate;
  143625. private _time;
  143626. private _config;
  143627. private _texturePath;
  143628. /**
  143629. * Instantiates a new Custom Procedural Texture.
  143630. * 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.
  143631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143632. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143633. * @param name Define the name of the texture
  143634. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143635. * @param size Define the size of the texture to create
  143636. * @param scene Define the scene the texture belongs to
  143637. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143638. * @param generateMipMaps Define if the texture should creates mip maps or not
  143639. */
  143640. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143641. private _loadJson;
  143642. /**
  143643. * Is the texture ready to be used ? (rendered at least once)
  143644. * @returns true if ready, otherwise, false.
  143645. */
  143646. isReady(): boolean;
  143647. /**
  143648. * Render the texture to its associated render target.
  143649. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143650. */
  143651. render(useCameraPostProcess?: boolean): void;
  143652. /**
  143653. * Update the list of dependant textures samplers in the shader.
  143654. */
  143655. updateTextures(): void;
  143656. /**
  143657. * Update the uniform values of the procedural texture in the shader.
  143658. */
  143659. updateShaderUniforms(): void;
  143660. /**
  143661. * Define if the texture animates or not.
  143662. */
  143663. get animate(): boolean;
  143664. set animate(value: boolean);
  143665. }
  143666. }
  143667. declare module BABYLON {
  143668. /** @hidden */
  143669. export var noisePixelShader: {
  143670. name: string;
  143671. shader: string;
  143672. };
  143673. }
  143674. declare module BABYLON {
  143675. /**
  143676. * Class used to generate noise procedural textures
  143677. */
  143678. export class NoiseProceduralTexture extends ProceduralTexture {
  143679. /** Gets or sets the start time (default is 0) */
  143680. time: number;
  143681. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143682. brightness: number;
  143683. /** Defines the number of octaves to process */
  143684. octaves: number;
  143685. /** Defines the level of persistence (0.8 by default) */
  143686. persistence: number;
  143687. /** Gets or sets animation speed factor (default is 1) */
  143688. animationSpeedFactor: number;
  143689. /**
  143690. * Creates a new NoiseProceduralTexture
  143691. * @param name defines the name fo the texture
  143692. * @param size defines the size of the texture (default is 256)
  143693. * @param scene defines the hosting scene
  143694. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143695. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143696. */
  143697. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143698. private _updateShaderUniforms;
  143699. protected _getDefines(): string;
  143700. /** Generate the current state of the procedural texture */
  143701. render(useCameraPostProcess?: boolean): void;
  143702. /**
  143703. * Serializes this noise procedural texture
  143704. * @returns a serialized noise procedural texture object
  143705. */
  143706. serialize(): any;
  143707. /**
  143708. * Clone the texture.
  143709. * @returns the cloned texture
  143710. */
  143711. clone(): NoiseProceduralTexture;
  143712. /**
  143713. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143714. * @param parsedTexture defines parsed texture data
  143715. * @param scene defines the current scene
  143716. * @param rootUrl defines the root URL containing noise procedural texture information
  143717. * @returns a parsed NoiseProceduralTexture
  143718. */
  143719. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143720. }
  143721. }
  143722. declare module BABYLON {
  143723. /**
  143724. * Raw cube texture where the raw buffers are passed in
  143725. */
  143726. export class RawCubeTexture extends CubeTexture {
  143727. /**
  143728. * Creates a cube texture where the raw buffers are passed in.
  143729. * @param scene defines the scene the texture is attached to
  143730. * @param data defines the array of data to use to create each face
  143731. * @param size defines the size of the textures
  143732. * @param format defines the format of the data
  143733. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143734. * @param generateMipMaps defines if the engine should generate the mip levels
  143735. * @param invertY defines if data must be stored with Y axis inverted
  143736. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143737. * @param compression defines the compression used (null by default)
  143738. */
  143739. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143740. /**
  143741. * Updates the raw cube texture.
  143742. * @param data defines the data to store
  143743. * @param format defines the data format
  143744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143745. * @param invertY defines if data must be stored with Y axis inverted
  143746. * @param compression defines the compression used (null by default)
  143747. * @param level defines which level of the texture to update
  143748. */
  143749. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143750. /**
  143751. * Updates a raw cube texture with RGBD encoded data.
  143752. * @param data defines the array of data [mipmap][face] to use to create each face
  143753. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143756. * @returns a promsie that resolves when the operation is complete
  143757. */
  143758. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143759. /**
  143760. * Clones the raw cube texture.
  143761. * @return a new cube texture
  143762. */
  143763. clone(): CubeTexture;
  143764. /** @hidden */
  143765. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143766. }
  143767. }
  143768. declare module BABYLON {
  143769. /**
  143770. * Class used to store 2D array textures containing user data
  143771. */
  143772. export class RawTexture2DArray extends Texture {
  143773. /** Gets or sets the texture format to use */
  143774. format: number;
  143775. /**
  143776. * Create a new RawTexture2DArray
  143777. * @param data defines the data of the texture
  143778. * @param width defines the width of the texture
  143779. * @param height defines the height of the texture
  143780. * @param depth defines the number of layers of the texture
  143781. * @param format defines the texture format to use
  143782. * @param scene defines the hosting scene
  143783. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143784. * @param invertY defines if texture must be stored with Y axis inverted
  143785. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143786. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143787. */
  143788. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143789. /** Gets or sets the texture format to use */
  143790. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143791. /**
  143792. * Update the texture with new data
  143793. * @param data defines the data to store in the texture
  143794. */
  143795. update(data: ArrayBufferView): void;
  143796. }
  143797. }
  143798. declare module BABYLON {
  143799. /**
  143800. * Class used to store 3D textures containing user data
  143801. */
  143802. export class RawTexture3D extends Texture {
  143803. /** Gets or sets the texture format to use */
  143804. format: number;
  143805. /**
  143806. * Create a new RawTexture3D
  143807. * @param data defines the data of the texture
  143808. * @param width defines the width of the texture
  143809. * @param height defines the height of the texture
  143810. * @param depth defines the depth of the texture
  143811. * @param format defines the texture format to use
  143812. * @param scene defines the hosting scene
  143813. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143814. * @param invertY defines if texture must be stored with Y axis inverted
  143815. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143816. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143817. */
  143818. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143819. /** Gets or sets the texture format to use */
  143820. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143821. /**
  143822. * Update the texture with new data
  143823. * @param data defines the data to store in the texture
  143824. */
  143825. update(data: ArrayBufferView): void;
  143826. }
  143827. }
  143828. declare module BABYLON {
  143829. /**
  143830. * Creates a refraction texture used by refraction channel of the standard material.
  143831. * It is like a mirror but to see through a material.
  143832. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143833. */
  143834. export class RefractionTexture extends RenderTargetTexture {
  143835. /**
  143836. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143837. * 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.
  143838. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143839. */
  143840. refractionPlane: Plane;
  143841. /**
  143842. * Define how deep under the surface we should see.
  143843. */
  143844. depth: number;
  143845. /**
  143846. * Creates a refraction texture used by refraction channel of the standard material.
  143847. * It is like a mirror but to see through a material.
  143848. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143849. * @param name Define the texture name
  143850. * @param size Define the size of the underlying texture
  143851. * @param scene Define the scene the refraction belongs to
  143852. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143853. */
  143854. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143855. /**
  143856. * Clone the refraction texture.
  143857. * @returns the cloned texture
  143858. */
  143859. clone(): RefractionTexture;
  143860. /**
  143861. * Serialize the texture to a JSON representation you could use in Parse later on
  143862. * @returns the serialized JSON representation
  143863. */
  143864. serialize(): any;
  143865. }
  143866. }
  143867. declare module BABYLON {
  143868. /**
  143869. * Block used to add support for vertex skinning (bones)
  143870. */
  143871. export class BonesBlock extends NodeMaterialBlock {
  143872. /**
  143873. * Creates a new BonesBlock
  143874. * @param name defines the block name
  143875. */
  143876. constructor(name: string);
  143877. /**
  143878. * Initialize the block and prepare the context for build
  143879. * @param state defines the state that will be used for the build
  143880. */
  143881. initialize(state: NodeMaterialBuildState): void;
  143882. /**
  143883. * Gets the current class name
  143884. * @returns the class name
  143885. */
  143886. getClassName(): string;
  143887. /**
  143888. * Gets the matrix indices input component
  143889. */
  143890. get matricesIndices(): NodeMaterialConnectionPoint;
  143891. /**
  143892. * Gets the matrix weights input component
  143893. */
  143894. get matricesWeights(): NodeMaterialConnectionPoint;
  143895. /**
  143896. * Gets the extra matrix indices input component
  143897. */
  143898. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143899. /**
  143900. * Gets the extra matrix weights input component
  143901. */
  143902. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143903. /**
  143904. * Gets the world input component
  143905. */
  143906. get world(): NodeMaterialConnectionPoint;
  143907. /**
  143908. * Gets the output component
  143909. */
  143910. get output(): NodeMaterialConnectionPoint;
  143911. autoConfigure(material: NodeMaterial): void;
  143912. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143915. protected _buildBlock(state: NodeMaterialBuildState): this;
  143916. }
  143917. }
  143918. declare module BABYLON {
  143919. /**
  143920. * Block used to add support for instances
  143921. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143922. */
  143923. export class InstancesBlock extends NodeMaterialBlock {
  143924. /**
  143925. * Creates a new InstancesBlock
  143926. * @param name defines the block name
  143927. */
  143928. constructor(name: string);
  143929. /**
  143930. * Gets the current class name
  143931. * @returns the class name
  143932. */
  143933. getClassName(): string;
  143934. /**
  143935. * Gets the first world row input component
  143936. */
  143937. get world0(): NodeMaterialConnectionPoint;
  143938. /**
  143939. * Gets the second world row input component
  143940. */
  143941. get world1(): NodeMaterialConnectionPoint;
  143942. /**
  143943. * Gets the third world row input component
  143944. */
  143945. get world2(): NodeMaterialConnectionPoint;
  143946. /**
  143947. * Gets the forth world row input component
  143948. */
  143949. get world3(): NodeMaterialConnectionPoint;
  143950. /**
  143951. * Gets the world input component
  143952. */
  143953. get world(): NodeMaterialConnectionPoint;
  143954. /**
  143955. * Gets the output component
  143956. */
  143957. get output(): NodeMaterialConnectionPoint;
  143958. /**
  143959. * Gets the isntanceID component
  143960. */
  143961. get instanceID(): NodeMaterialConnectionPoint;
  143962. autoConfigure(material: NodeMaterial): void;
  143963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143964. protected _buildBlock(state: NodeMaterialBuildState): this;
  143965. }
  143966. }
  143967. declare module BABYLON {
  143968. /**
  143969. * Block used to add morph targets support to vertex shader
  143970. */
  143971. export class MorphTargetsBlock extends NodeMaterialBlock {
  143972. private _repeatableContentAnchor;
  143973. /**
  143974. * Create a new MorphTargetsBlock
  143975. * @param name defines the block name
  143976. */
  143977. constructor(name: string);
  143978. /**
  143979. * Gets the current class name
  143980. * @returns the class name
  143981. */
  143982. getClassName(): string;
  143983. /**
  143984. * Gets the position input component
  143985. */
  143986. get position(): NodeMaterialConnectionPoint;
  143987. /**
  143988. * Gets the normal input component
  143989. */
  143990. get normal(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the tangent input component
  143993. */
  143994. get tangent(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the tangent input component
  143997. */
  143998. get uv(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the position output component
  144001. */
  144002. get positionOutput(): NodeMaterialConnectionPoint;
  144003. /**
  144004. * Gets the normal output component
  144005. */
  144006. get normalOutput(): NodeMaterialConnectionPoint;
  144007. /**
  144008. * Gets the tangent output component
  144009. */
  144010. get tangentOutput(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the tangent output component
  144013. */
  144014. get uvOutput(): NodeMaterialConnectionPoint;
  144015. initialize(state: NodeMaterialBuildState): void;
  144016. autoConfigure(material: NodeMaterial): void;
  144017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144019. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144020. protected _buildBlock(state: NodeMaterialBuildState): this;
  144021. }
  144022. }
  144023. declare module BABYLON {
  144024. /**
  144025. * Block used to get data information from a light
  144026. */
  144027. export class LightInformationBlock extends NodeMaterialBlock {
  144028. private _lightDataUniformName;
  144029. private _lightColorUniformName;
  144030. private _lightTypeDefineName;
  144031. /**
  144032. * Gets or sets the light associated with this block
  144033. */
  144034. light: Nullable<Light>;
  144035. /**
  144036. * Creates a new LightInformationBlock
  144037. * @param name defines the block name
  144038. */
  144039. constructor(name: string);
  144040. /**
  144041. * Gets the current class name
  144042. * @returns the class name
  144043. */
  144044. getClassName(): string;
  144045. /**
  144046. * Gets the world position input component
  144047. */
  144048. get worldPosition(): NodeMaterialConnectionPoint;
  144049. /**
  144050. * Gets the direction output component
  144051. */
  144052. get direction(): NodeMaterialConnectionPoint;
  144053. /**
  144054. * Gets the direction output component
  144055. */
  144056. get color(): NodeMaterialConnectionPoint;
  144057. /**
  144058. * Gets the direction output component
  144059. */
  144060. get intensity(): NodeMaterialConnectionPoint;
  144061. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144063. protected _buildBlock(state: NodeMaterialBuildState): this;
  144064. serialize(): any;
  144065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144066. }
  144067. }
  144068. declare module BABYLON {
  144069. /**
  144070. * Block used to add image processing support to fragment shader
  144071. */
  144072. export class ImageProcessingBlock extends NodeMaterialBlock {
  144073. /**
  144074. * Create a new ImageProcessingBlock
  144075. * @param name defines the block name
  144076. */
  144077. constructor(name: string);
  144078. /**
  144079. * Gets the current class name
  144080. * @returns the class name
  144081. */
  144082. getClassName(): string;
  144083. /**
  144084. * Gets the color input component
  144085. */
  144086. get color(): NodeMaterialConnectionPoint;
  144087. /**
  144088. * Gets the output component
  144089. */
  144090. get output(): NodeMaterialConnectionPoint;
  144091. /**
  144092. * Initialize the block and prepare the context for build
  144093. * @param state defines the state that will be used for the build
  144094. */
  144095. initialize(state: NodeMaterialBuildState): void;
  144096. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144097. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144098. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144099. protected _buildBlock(state: NodeMaterialBuildState): this;
  144100. }
  144101. }
  144102. declare module BABYLON {
  144103. /**
  144104. * Block used to pertub normals based on a normal map
  144105. */
  144106. export class PerturbNormalBlock extends NodeMaterialBlock {
  144107. private _tangentSpaceParameterName;
  144108. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144109. invertX: boolean;
  144110. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144111. invertY: boolean;
  144112. /**
  144113. * Create a new PerturbNormalBlock
  144114. * @param name defines the block name
  144115. */
  144116. constructor(name: string);
  144117. /**
  144118. * Gets the current class name
  144119. * @returns the class name
  144120. */
  144121. getClassName(): string;
  144122. /**
  144123. * Gets the world position input component
  144124. */
  144125. get worldPosition(): NodeMaterialConnectionPoint;
  144126. /**
  144127. * Gets the world normal input component
  144128. */
  144129. get worldNormal(): NodeMaterialConnectionPoint;
  144130. /**
  144131. * Gets the world tangent input component
  144132. */
  144133. get worldTangent(): NodeMaterialConnectionPoint;
  144134. /**
  144135. * Gets the uv input component
  144136. */
  144137. get uv(): NodeMaterialConnectionPoint;
  144138. /**
  144139. * Gets the normal map color input component
  144140. */
  144141. get normalMapColor(): NodeMaterialConnectionPoint;
  144142. /**
  144143. * Gets the strength input component
  144144. */
  144145. get strength(): NodeMaterialConnectionPoint;
  144146. /**
  144147. * Gets the output component
  144148. */
  144149. get output(): NodeMaterialConnectionPoint;
  144150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144152. autoConfigure(material: NodeMaterial): void;
  144153. protected _buildBlock(state: NodeMaterialBuildState): this;
  144154. protected _dumpPropertiesCode(): string;
  144155. serialize(): any;
  144156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144157. }
  144158. }
  144159. declare module BABYLON {
  144160. /**
  144161. * Block used to discard a pixel if a value is smaller than a cutoff
  144162. */
  144163. export class DiscardBlock extends NodeMaterialBlock {
  144164. /**
  144165. * Create a new DiscardBlock
  144166. * @param name defines the block name
  144167. */
  144168. constructor(name: string);
  144169. /**
  144170. * Gets the current class name
  144171. * @returns the class name
  144172. */
  144173. getClassName(): string;
  144174. /**
  144175. * Gets the color input component
  144176. */
  144177. get value(): NodeMaterialConnectionPoint;
  144178. /**
  144179. * Gets the cutoff input component
  144180. */
  144181. get cutoff(): NodeMaterialConnectionPoint;
  144182. protected _buildBlock(state: NodeMaterialBuildState): this;
  144183. }
  144184. }
  144185. declare module BABYLON {
  144186. /**
  144187. * Block used to test if the fragment shader is front facing
  144188. */
  144189. export class FrontFacingBlock extends NodeMaterialBlock {
  144190. /**
  144191. * Creates a new FrontFacingBlock
  144192. * @param name defines the block name
  144193. */
  144194. constructor(name: string);
  144195. /**
  144196. * Gets the current class name
  144197. * @returns the class name
  144198. */
  144199. getClassName(): string;
  144200. /**
  144201. * Gets the output component
  144202. */
  144203. get output(): NodeMaterialConnectionPoint;
  144204. protected _buildBlock(state: NodeMaterialBuildState): this;
  144205. }
  144206. }
  144207. declare module BABYLON {
  144208. /**
  144209. * Block used to get the derivative value on x and y of a given input
  144210. */
  144211. export class DerivativeBlock extends NodeMaterialBlock {
  144212. /**
  144213. * Create a new DerivativeBlock
  144214. * @param name defines the block name
  144215. */
  144216. constructor(name: string);
  144217. /**
  144218. * Gets the current class name
  144219. * @returns the class name
  144220. */
  144221. getClassName(): string;
  144222. /**
  144223. * Gets the input component
  144224. */
  144225. get input(): NodeMaterialConnectionPoint;
  144226. /**
  144227. * Gets the derivative output on x
  144228. */
  144229. get dx(): NodeMaterialConnectionPoint;
  144230. /**
  144231. * Gets the derivative output on y
  144232. */
  144233. get dy(): NodeMaterialConnectionPoint;
  144234. protected _buildBlock(state: NodeMaterialBuildState): this;
  144235. }
  144236. }
  144237. declare module BABYLON {
  144238. /**
  144239. * Block used to make gl_FragCoord available
  144240. */
  144241. export class FragCoordBlock extends NodeMaterialBlock {
  144242. /**
  144243. * Creates a new FragCoordBlock
  144244. * @param name defines the block name
  144245. */
  144246. constructor(name: string);
  144247. /**
  144248. * Gets the current class name
  144249. * @returns the class name
  144250. */
  144251. getClassName(): string;
  144252. /**
  144253. * Gets the xy component
  144254. */
  144255. get xy(): NodeMaterialConnectionPoint;
  144256. /**
  144257. * Gets the xyz component
  144258. */
  144259. get xyz(): NodeMaterialConnectionPoint;
  144260. /**
  144261. * Gets the xyzw component
  144262. */
  144263. get xyzw(): NodeMaterialConnectionPoint;
  144264. /**
  144265. * Gets the x component
  144266. */
  144267. get x(): NodeMaterialConnectionPoint;
  144268. /**
  144269. * Gets the y component
  144270. */
  144271. get y(): NodeMaterialConnectionPoint;
  144272. /**
  144273. * Gets the z component
  144274. */
  144275. get z(): NodeMaterialConnectionPoint;
  144276. /**
  144277. * Gets the w component
  144278. */
  144279. get output(): NodeMaterialConnectionPoint;
  144280. protected writeOutputs(state: NodeMaterialBuildState): string;
  144281. protected _buildBlock(state: NodeMaterialBuildState): this;
  144282. }
  144283. }
  144284. declare module BABYLON {
  144285. /**
  144286. * Block used to get the screen sizes
  144287. */
  144288. export class ScreenSizeBlock extends NodeMaterialBlock {
  144289. private _varName;
  144290. private _scene;
  144291. /**
  144292. * Creates a new ScreenSizeBlock
  144293. * @param name defines the block name
  144294. */
  144295. constructor(name: string);
  144296. /**
  144297. * Gets the current class name
  144298. * @returns the class name
  144299. */
  144300. getClassName(): string;
  144301. /**
  144302. * Gets the xy component
  144303. */
  144304. get xy(): NodeMaterialConnectionPoint;
  144305. /**
  144306. * Gets the x component
  144307. */
  144308. get x(): NodeMaterialConnectionPoint;
  144309. /**
  144310. * Gets the y component
  144311. */
  144312. get y(): NodeMaterialConnectionPoint;
  144313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144314. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144315. protected _buildBlock(state: NodeMaterialBuildState): this;
  144316. }
  144317. }
  144318. declare module BABYLON {
  144319. /**
  144320. * Block used to add support for scene fog
  144321. */
  144322. export class FogBlock extends NodeMaterialBlock {
  144323. private _fogDistanceName;
  144324. private _fogParameters;
  144325. /**
  144326. * Create a new FogBlock
  144327. * @param name defines the block name
  144328. */
  144329. constructor(name: string);
  144330. /**
  144331. * Gets the current class name
  144332. * @returns the class name
  144333. */
  144334. getClassName(): string;
  144335. /**
  144336. * Gets the world position input component
  144337. */
  144338. get worldPosition(): NodeMaterialConnectionPoint;
  144339. /**
  144340. * Gets the view input component
  144341. */
  144342. get view(): NodeMaterialConnectionPoint;
  144343. /**
  144344. * Gets the color input component
  144345. */
  144346. get input(): NodeMaterialConnectionPoint;
  144347. /**
  144348. * Gets the fog color input component
  144349. */
  144350. get fogColor(): NodeMaterialConnectionPoint;
  144351. /**
  144352. * Gets the output component
  144353. */
  144354. get output(): NodeMaterialConnectionPoint;
  144355. autoConfigure(material: NodeMaterial): void;
  144356. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144357. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144358. protected _buildBlock(state: NodeMaterialBuildState): this;
  144359. }
  144360. }
  144361. declare module BABYLON {
  144362. /**
  144363. * Block used to add light in the fragment shader
  144364. */
  144365. export class LightBlock extends NodeMaterialBlock {
  144366. private _lightId;
  144367. /**
  144368. * Gets or sets the light associated with this block
  144369. */
  144370. light: Nullable<Light>;
  144371. /**
  144372. * Create a new LightBlock
  144373. * @param name defines the block name
  144374. */
  144375. constructor(name: string);
  144376. /**
  144377. * Gets the current class name
  144378. * @returns the class name
  144379. */
  144380. getClassName(): string;
  144381. /**
  144382. * Gets the world position input component
  144383. */
  144384. get worldPosition(): NodeMaterialConnectionPoint;
  144385. /**
  144386. * Gets the world normal input component
  144387. */
  144388. get worldNormal(): NodeMaterialConnectionPoint;
  144389. /**
  144390. * Gets the camera (or eye) position component
  144391. */
  144392. get cameraPosition(): NodeMaterialConnectionPoint;
  144393. /**
  144394. * Gets the glossiness component
  144395. */
  144396. get glossiness(): NodeMaterialConnectionPoint;
  144397. /**
  144398. * Gets the glossinness power component
  144399. */
  144400. get glossPower(): NodeMaterialConnectionPoint;
  144401. /**
  144402. * Gets the diffuse color component
  144403. */
  144404. get diffuseColor(): NodeMaterialConnectionPoint;
  144405. /**
  144406. * Gets the specular color component
  144407. */
  144408. get specularColor(): NodeMaterialConnectionPoint;
  144409. /**
  144410. * Gets the diffuse output component
  144411. */
  144412. get diffuseOutput(): NodeMaterialConnectionPoint;
  144413. /**
  144414. * Gets the specular output component
  144415. */
  144416. get specularOutput(): NodeMaterialConnectionPoint;
  144417. /**
  144418. * Gets the shadow output component
  144419. */
  144420. get shadow(): NodeMaterialConnectionPoint;
  144421. autoConfigure(material: NodeMaterial): void;
  144422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144423. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144424. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144425. private _injectVertexCode;
  144426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144427. serialize(): any;
  144428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144429. }
  144430. }
  144431. declare module BABYLON {
  144432. /**
  144433. * Block used to read a reflection texture from a sampler
  144434. */
  144435. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144436. /**
  144437. * Create a new ReflectionTextureBlock
  144438. * @param name defines the block name
  144439. */
  144440. constructor(name: string);
  144441. /**
  144442. * Gets the current class name
  144443. * @returns the class name
  144444. */
  144445. getClassName(): string;
  144446. /**
  144447. * Gets the world position input component
  144448. */
  144449. get position(): NodeMaterialConnectionPoint;
  144450. /**
  144451. * Gets the world position input component
  144452. */
  144453. get worldPosition(): NodeMaterialConnectionPoint;
  144454. /**
  144455. * Gets the world normal input component
  144456. */
  144457. get worldNormal(): NodeMaterialConnectionPoint;
  144458. /**
  144459. * Gets the world input component
  144460. */
  144461. get world(): NodeMaterialConnectionPoint;
  144462. /**
  144463. * Gets the camera (or eye) position component
  144464. */
  144465. get cameraPosition(): NodeMaterialConnectionPoint;
  144466. /**
  144467. * Gets the view input component
  144468. */
  144469. get view(): NodeMaterialConnectionPoint;
  144470. /**
  144471. * Gets the rgb output component
  144472. */
  144473. get rgb(): NodeMaterialConnectionPoint;
  144474. /**
  144475. * Gets the rgba output component
  144476. */
  144477. get rgba(): NodeMaterialConnectionPoint;
  144478. /**
  144479. * Gets the r output component
  144480. */
  144481. get r(): NodeMaterialConnectionPoint;
  144482. /**
  144483. * Gets the g output component
  144484. */
  144485. get g(): NodeMaterialConnectionPoint;
  144486. /**
  144487. * Gets the b output component
  144488. */
  144489. get b(): NodeMaterialConnectionPoint;
  144490. /**
  144491. * Gets the a output component
  144492. */
  144493. get a(): NodeMaterialConnectionPoint;
  144494. autoConfigure(material: NodeMaterial): void;
  144495. protected _buildBlock(state: NodeMaterialBuildState): this;
  144496. }
  144497. }
  144498. declare module BABYLON {
  144499. /**
  144500. * Block used to add 2 vectors
  144501. */
  144502. export class AddBlock extends NodeMaterialBlock {
  144503. /**
  144504. * Creates a new AddBlock
  144505. * @param name defines the block name
  144506. */
  144507. constructor(name: string);
  144508. /**
  144509. * Gets the current class name
  144510. * @returns the class name
  144511. */
  144512. getClassName(): string;
  144513. /**
  144514. * Gets the left operand input component
  144515. */
  144516. get left(): NodeMaterialConnectionPoint;
  144517. /**
  144518. * Gets the right operand input component
  144519. */
  144520. get right(): NodeMaterialConnectionPoint;
  144521. /**
  144522. * Gets the output component
  144523. */
  144524. get output(): NodeMaterialConnectionPoint;
  144525. protected _buildBlock(state: NodeMaterialBuildState): this;
  144526. }
  144527. }
  144528. declare module BABYLON {
  144529. /**
  144530. * Block used to scale a vector by a float
  144531. */
  144532. export class ScaleBlock extends NodeMaterialBlock {
  144533. /**
  144534. * Creates a new ScaleBlock
  144535. * @param name defines the block name
  144536. */
  144537. constructor(name: string);
  144538. /**
  144539. * Gets the current class name
  144540. * @returns the class name
  144541. */
  144542. getClassName(): string;
  144543. /**
  144544. * Gets the input component
  144545. */
  144546. get input(): NodeMaterialConnectionPoint;
  144547. /**
  144548. * Gets the factor input component
  144549. */
  144550. get factor(): NodeMaterialConnectionPoint;
  144551. /**
  144552. * Gets the output component
  144553. */
  144554. get output(): NodeMaterialConnectionPoint;
  144555. protected _buildBlock(state: NodeMaterialBuildState): this;
  144556. }
  144557. }
  144558. declare module BABYLON {
  144559. /**
  144560. * Block used to clamp a float
  144561. */
  144562. export class ClampBlock extends NodeMaterialBlock {
  144563. /** Gets or sets the minimum range */
  144564. minimum: number;
  144565. /** Gets or sets the maximum range */
  144566. maximum: number;
  144567. /**
  144568. * Creates a new ClampBlock
  144569. * @param name defines the block name
  144570. */
  144571. constructor(name: string);
  144572. /**
  144573. * Gets the current class name
  144574. * @returns the class name
  144575. */
  144576. getClassName(): string;
  144577. /**
  144578. * Gets the value input component
  144579. */
  144580. get value(): NodeMaterialConnectionPoint;
  144581. /**
  144582. * Gets the output component
  144583. */
  144584. get output(): NodeMaterialConnectionPoint;
  144585. protected _buildBlock(state: NodeMaterialBuildState): this;
  144586. protected _dumpPropertiesCode(): string;
  144587. serialize(): any;
  144588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144589. }
  144590. }
  144591. declare module BABYLON {
  144592. /**
  144593. * Block used to apply a cross product between 2 vectors
  144594. */
  144595. export class CrossBlock extends NodeMaterialBlock {
  144596. /**
  144597. * Creates a new CrossBlock
  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 left operand input component
  144608. */
  144609. get left(): NodeMaterialConnectionPoint;
  144610. /**
  144611. * Gets the right operand input component
  144612. */
  144613. get right(): NodeMaterialConnectionPoint;
  144614. /**
  144615. * Gets the output component
  144616. */
  144617. get output(): NodeMaterialConnectionPoint;
  144618. protected _buildBlock(state: NodeMaterialBuildState): this;
  144619. }
  144620. }
  144621. declare module BABYLON {
  144622. /**
  144623. * Block used to apply a dot product between 2 vectors
  144624. */
  144625. export class DotBlock extends NodeMaterialBlock {
  144626. /**
  144627. * Creates a new DotBlock
  144628. * @param name defines the block name
  144629. */
  144630. constructor(name: string);
  144631. /**
  144632. * Gets the current class name
  144633. * @returns the class name
  144634. */
  144635. getClassName(): string;
  144636. /**
  144637. * Gets the left operand input component
  144638. */
  144639. get left(): NodeMaterialConnectionPoint;
  144640. /**
  144641. * Gets the right operand input component
  144642. */
  144643. get right(): NodeMaterialConnectionPoint;
  144644. /**
  144645. * Gets the output component
  144646. */
  144647. get output(): NodeMaterialConnectionPoint;
  144648. protected _buildBlock(state: NodeMaterialBuildState): this;
  144649. }
  144650. }
  144651. declare module BABYLON {
  144652. /**
  144653. * Block used to normalize a vector
  144654. */
  144655. export class NormalizeBlock extends NodeMaterialBlock {
  144656. /**
  144657. * Creates a new NormalizeBlock
  144658. * @param name defines the block name
  144659. */
  144660. constructor(name: string);
  144661. /**
  144662. * Gets the current class name
  144663. * @returns the class name
  144664. */
  144665. getClassName(): string;
  144666. /**
  144667. * Gets the input component
  144668. */
  144669. get input(): NodeMaterialConnectionPoint;
  144670. /**
  144671. * Gets the output component
  144672. */
  144673. get output(): NodeMaterialConnectionPoint;
  144674. protected _buildBlock(state: NodeMaterialBuildState): this;
  144675. }
  144676. }
  144677. declare module BABYLON {
  144678. /**
  144679. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144680. */
  144681. export class ColorMergerBlock extends NodeMaterialBlock {
  144682. /**
  144683. * Create a new ColorMergerBlock
  144684. * @param name defines the block name
  144685. */
  144686. constructor(name: string);
  144687. /**
  144688. * Gets the current class name
  144689. * @returns the class name
  144690. */
  144691. getClassName(): string;
  144692. /**
  144693. * Gets the rgb component (input)
  144694. */
  144695. get rgbIn(): NodeMaterialConnectionPoint;
  144696. /**
  144697. * Gets the r component (input)
  144698. */
  144699. get r(): NodeMaterialConnectionPoint;
  144700. /**
  144701. * Gets the g component (input)
  144702. */
  144703. get g(): NodeMaterialConnectionPoint;
  144704. /**
  144705. * Gets the b component (input)
  144706. */
  144707. get b(): NodeMaterialConnectionPoint;
  144708. /**
  144709. * Gets the a component (input)
  144710. */
  144711. get a(): NodeMaterialConnectionPoint;
  144712. /**
  144713. * Gets the rgba component (output)
  144714. */
  144715. get rgba(): NodeMaterialConnectionPoint;
  144716. /**
  144717. * Gets the rgb component (output)
  144718. */
  144719. get rgbOut(): NodeMaterialConnectionPoint;
  144720. /**
  144721. * Gets the rgb component (output)
  144722. * @deprecated Please use rgbOut instead.
  144723. */
  144724. get rgb(): NodeMaterialConnectionPoint;
  144725. protected _buildBlock(state: NodeMaterialBuildState): this;
  144726. }
  144727. }
  144728. declare module BABYLON {
  144729. /**
  144730. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144731. */
  144732. export class VectorSplitterBlock extends NodeMaterialBlock {
  144733. /**
  144734. * Create a new VectorSplitterBlock
  144735. * @param name defines the block name
  144736. */
  144737. constructor(name: string);
  144738. /**
  144739. * Gets the current class name
  144740. * @returns the class name
  144741. */
  144742. getClassName(): string;
  144743. /**
  144744. * Gets the xyzw component (input)
  144745. */
  144746. get xyzw(): NodeMaterialConnectionPoint;
  144747. /**
  144748. * Gets the xyz component (input)
  144749. */
  144750. get xyzIn(): NodeMaterialConnectionPoint;
  144751. /**
  144752. * Gets the xy component (input)
  144753. */
  144754. get xyIn(): NodeMaterialConnectionPoint;
  144755. /**
  144756. * Gets the xyz component (output)
  144757. */
  144758. get xyzOut(): NodeMaterialConnectionPoint;
  144759. /**
  144760. * Gets the xy component (output)
  144761. */
  144762. get xyOut(): NodeMaterialConnectionPoint;
  144763. /**
  144764. * Gets the x component (output)
  144765. */
  144766. get x(): NodeMaterialConnectionPoint;
  144767. /**
  144768. * Gets the y component (output)
  144769. */
  144770. get y(): NodeMaterialConnectionPoint;
  144771. /**
  144772. * Gets the z component (output)
  144773. */
  144774. get z(): NodeMaterialConnectionPoint;
  144775. /**
  144776. * Gets the w component (output)
  144777. */
  144778. get w(): NodeMaterialConnectionPoint;
  144779. protected _inputRename(name: string): string;
  144780. protected _outputRename(name: string): string;
  144781. protected _buildBlock(state: NodeMaterialBuildState): this;
  144782. }
  144783. }
  144784. declare module BABYLON {
  144785. /**
  144786. * Block used to lerp between 2 values
  144787. */
  144788. export class LerpBlock extends NodeMaterialBlock {
  144789. /**
  144790. * Creates a new LerpBlock
  144791. * @param name defines the block name
  144792. */
  144793. constructor(name: string);
  144794. /**
  144795. * Gets the current class name
  144796. * @returns the class name
  144797. */
  144798. getClassName(): string;
  144799. /**
  144800. * Gets the left operand input component
  144801. */
  144802. get left(): NodeMaterialConnectionPoint;
  144803. /**
  144804. * Gets the right operand input component
  144805. */
  144806. get right(): NodeMaterialConnectionPoint;
  144807. /**
  144808. * Gets the gradient operand input component
  144809. */
  144810. get gradient(): NodeMaterialConnectionPoint;
  144811. /**
  144812. * Gets the output component
  144813. */
  144814. get output(): NodeMaterialConnectionPoint;
  144815. protected _buildBlock(state: NodeMaterialBuildState): this;
  144816. }
  144817. }
  144818. declare module BABYLON {
  144819. /**
  144820. * Block used to divide 2 vectors
  144821. */
  144822. export class DivideBlock extends NodeMaterialBlock {
  144823. /**
  144824. * Creates a new DivideBlock
  144825. * @param name defines the block name
  144826. */
  144827. constructor(name: string);
  144828. /**
  144829. * Gets the current class name
  144830. * @returns the class name
  144831. */
  144832. getClassName(): string;
  144833. /**
  144834. * Gets the left operand input component
  144835. */
  144836. get left(): NodeMaterialConnectionPoint;
  144837. /**
  144838. * Gets the right operand input component
  144839. */
  144840. get right(): NodeMaterialConnectionPoint;
  144841. /**
  144842. * Gets the output component
  144843. */
  144844. get output(): NodeMaterialConnectionPoint;
  144845. protected _buildBlock(state: NodeMaterialBuildState): this;
  144846. }
  144847. }
  144848. declare module BABYLON {
  144849. /**
  144850. * Block used to subtract 2 vectors
  144851. */
  144852. export class SubtractBlock extends NodeMaterialBlock {
  144853. /**
  144854. * Creates a new SubtractBlock
  144855. * @param name defines the block name
  144856. */
  144857. constructor(name: string);
  144858. /**
  144859. * Gets the current class name
  144860. * @returns the class name
  144861. */
  144862. getClassName(): string;
  144863. /**
  144864. * Gets the left operand input component
  144865. */
  144866. get left(): NodeMaterialConnectionPoint;
  144867. /**
  144868. * Gets the right operand input component
  144869. */
  144870. get right(): NodeMaterialConnectionPoint;
  144871. /**
  144872. * Gets the output component
  144873. */
  144874. get output(): NodeMaterialConnectionPoint;
  144875. protected _buildBlock(state: NodeMaterialBuildState): this;
  144876. }
  144877. }
  144878. declare module BABYLON {
  144879. /**
  144880. * Block used to step a value
  144881. */
  144882. export class StepBlock extends NodeMaterialBlock {
  144883. /**
  144884. * Creates a new StepBlock
  144885. * @param name defines the block name
  144886. */
  144887. constructor(name: string);
  144888. /**
  144889. * Gets the current class name
  144890. * @returns the class name
  144891. */
  144892. getClassName(): string;
  144893. /**
  144894. * Gets the value operand input component
  144895. */
  144896. get value(): NodeMaterialConnectionPoint;
  144897. /**
  144898. * Gets the edge operand input component
  144899. */
  144900. get edge(): NodeMaterialConnectionPoint;
  144901. /**
  144902. * Gets the output component
  144903. */
  144904. get output(): NodeMaterialConnectionPoint;
  144905. protected _buildBlock(state: NodeMaterialBuildState): this;
  144906. }
  144907. }
  144908. declare module BABYLON {
  144909. /**
  144910. * Block used to get the opposite (1 - x) of a value
  144911. */
  144912. export class OneMinusBlock extends NodeMaterialBlock {
  144913. /**
  144914. * Creates a new OneMinusBlock
  144915. * @param name defines the block name
  144916. */
  144917. constructor(name: string);
  144918. /**
  144919. * Gets the current class name
  144920. * @returns the class name
  144921. */
  144922. getClassName(): string;
  144923. /**
  144924. * Gets the input component
  144925. */
  144926. get input(): NodeMaterialConnectionPoint;
  144927. /**
  144928. * Gets the output component
  144929. */
  144930. get output(): NodeMaterialConnectionPoint;
  144931. protected _buildBlock(state: NodeMaterialBuildState): this;
  144932. }
  144933. }
  144934. declare module BABYLON {
  144935. /**
  144936. * Block used to get the view direction
  144937. */
  144938. export class ViewDirectionBlock extends NodeMaterialBlock {
  144939. /**
  144940. * Creates a new ViewDirectionBlock
  144941. * @param name defines the block name
  144942. */
  144943. constructor(name: string);
  144944. /**
  144945. * Gets the current class name
  144946. * @returns the class name
  144947. */
  144948. getClassName(): string;
  144949. /**
  144950. * Gets the world position component
  144951. */
  144952. get worldPosition(): NodeMaterialConnectionPoint;
  144953. /**
  144954. * Gets the camera position component
  144955. */
  144956. get cameraPosition(): NodeMaterialConnectionPoint;
  144957. /**
  144958. * Gets the output component
  144959. */
  144960. get output(): NodeMaterialConnectionPoint;
  144961. autoConfigure(material: NodeMaterial): void;
  144962. protected _buildBlock(state: NodeMaterialBuildState): this;
  144963. }
  144964. }
  144965. declare module BABYLON {
  144966. /**
  144967. * Block used to compute fresnel value
  144968. */
  144969. export class FresnelBlock extends NodeMaterialBlock {
  144970. /**
  144971. * Create a new FresnelBlock
  144972. * @param name defines the block name
  144973. */
  144974. constructor(name: string);
  144975. /**
  144976. * Gets the current class name
  144977. * @returns the class name
  144978. */
  144979. getClassName(): string;
  144980. /**
  144981. * Gets the world normal input component
  144982. */
  144983. get worldNormal(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the view direction input component
  144986. */
  144987. get viewDirection(): NodeMaterialConnectionPoint;
  144988. /**
  144989. * Gets the bias input component
  144990. */
  144991. get bias(): NodeMaterialConnectionPoint;
  144992. /**
  144993. * Gets the camera (or eye) position component
  144994. */
  144995. get power(): NodeMaterialConnectionPoint;
  144996. /**
  144997. * Gets the fresnel output component
  144998. */
  144999. get fresnel(): NodeMaterialConnectionPoint;
  145000. autoConfigure(material: NodeMaterial): void;
  145001. protected _buildBlock(state: NodeMaterialBuildState): this;
  145002. }
  145003. }
  145004. declare module BABYLON {
  145005. /**
  145006. * Block used to get the max of 2 values
  145007. */
  145008. export class MaxBlock extends NodeMaterialBlock {
  145009. /**
  145010. * Creates a new MaxBlock
  145011. * @param name defines the block name
  145012. */
  145013. constructor(name: string);
  145014. /**
  145015. * Gets the current class name
  145016. * @returns the class name
  145017. */
  145018. getClassName(): string;
  145019. /**
  145020. * Gets the left operand input component
  145021. */
  145022. get left(): NodeMaterialConnectionPoint;
  145023. /**
  145024. * Gets the right operand input component
  145025. */
  145026. get right(): NodeMaterialConnectionPoint;
  145027. /**
  145028. * Gets the output component
  145029. */
  145030. get output(): NodeMaterialConnectionPoint;
  145031. protected _buildBlock(state: NodeMaterialBuildState): this;
  145032. }
  145033. }
  145034. declare module BABYLON {
  145035. /**
  145036. * Block used to get the min of 2 values
  145037. */
  145038. export class MinBlock extends NodeMaterialBlock {
  145039. /**
  145040. * Creates a new MinBlock
  145041. * @param name defines the block name
  145042. */
  145043. constructor(name: string);
  145044. /**
  145045. * Gets the current class name
  145046. * @returns the class name
  145047. */
  145048. getClassName(): string;
  145049. /**
  145050. * Gets the left operand input component
  145051. */
  145052. get left(): NodeMaterialConnectionPoint;
  145053. /**
  145054. * Gets the right operand input component
  145055. */
  145056. get right(): NodeMaterialConnectionPoint;
  145057. /**
  145058. * Gets the output component
  145059. */
  145060. get output(): NodeMaterialConnectionPoint;
  145061. protected _buildBlock(state: NodeMaterialBuildState): this;
  145062. }
  145063. }
  145064. declare module BABYLON {
  145065. /**
  145066. * Block used to get the distance between 2 values
  145067. */
  145068. export class DistanceBlock extends NodeMaterialBlock {
  145069. /**
  145070. * Creates a new DistanceBlock
  145071. * @param name defines the block name
  145072. */
  145073. constructor(name: string);
  145074. /**
  145075. * Gets the current class name
  145076. * @returns the class name
  145077. */
  145078. getClassName(): string;
  145079. /**
  145080. * Gets the left operand input component
  145081. */
  145082. get left(): NodeMaterialConnectionPoint;
  145083. /**
  145084. * Gets the right operand input component
  145085. */
  145086. get right(): NodeMaterialConnectionPoint;
  145087. /**
  145088. * Gets the output component
  145089. */
  145090. get output(): NodeMaterialConnectionPoint;
  145091. protected _buildBlock(state: NodeMaterialBuildState): this;
  145092. }
  145093. }
  145094. declare module BABYLON {
  145095. /**
  145096. * Block used to get the length of a vector
  145097. */
  145098. export class LengthBlock extends NodeMaterialBlock {
  145099. /**
  145100. * Creates a new LengthBlock
  145101. * @param name defines the block name
  145102. */
  145103. constructor(name: string);
  145104. /**
  145105. * Gets the current class name
  145106. * @returns the class name
  145107. */
  145108. getClassName(): string;
  145109. /**
  145110. * Gets the value input component
  145111. */
  145112. get value(): NodeMaterialConnectionPoint;
  145113. /**
  145114. * Gets the output component
  145115. */
  145116. get output(): NodeMaterialConnectionPoint;
  145117. protected _buildBlock(state: NodeMaterialBuildState): this;
  145118. }
  145119. }
  145120. declare module BABYLON {
  145121. /**
  145122. * Block used to get negative version of a value (i.e. x * -1)
  145123. */
  145124. export class NegateBlock extends NodeMaterialBlock {
  145125. /**
  145126. * Creates a new NegateBlock
  145127. * @param name defines the block name
  145128. */
  145129. constructor(name: string);
  145130. /**
  145131. * Gets the current class name
  145132. * @returns the class name
  145133. */
  145134. getClassName(): string;
  145135. /**
  145136. * Gets the value input component
  145137. */
  145138. get value(): NodeMaterialConnectionPoint;
  145139. /**
  145140. * Gets the output component
  145141. */
  145142. get output(): NodeMaterialConnectionPoint;
  145143. protected _buildBlock(state: NodeMaterialBuildState): this;
  145144. }
  145145. }
  145146. declare module BABYLON {
  145147. /**
  145148. * Block used to get the value of the first parameter raised to the power of the second
  145149. */
  145150. export class PowBlock extends NodeMaterialBlock {
  145151. /**
  145152. * Creates a new PowBlock
  145153. * @param name defines the block name
  145154. */
  145155. constructor(name: string);
  145156. /**
  145157. * Gets the current class name
  145158. * @returns the class name
  145159. */
  145160. getClassName(): string;
  145161. /**
  145162. * Gets the value operand input component
  145163. */
  145164. get value(): NodeMaterialConnectionPoint;
  145165. /**
  145166. * Gets the power operand input component
  145167. */
  145168. get power(): NodeMaterialConnectionPoint;
  145169. /**
  145170. * Gets the output component
  145171. */
  145172. get output(): NodeMaterialConnectionPoint;
  145173. protected _buildBlock(state: NodeMaterialBuildState): this;
  145174. }
  145175. }
  145176. declare module BABYLON {
  145177. /**
  145178. * Block used to get a random number
  145179. */
  145180. export class RandomNumberBlock extends NodeMaterialBlock {
  145181. /**
  145182. * Creates a new RandomNumberBlock
  145183. * @param name defines the block name
  145184. */
  145185. constructor(name: string);
  145186. /**
  145187. * Gets the current class name
  145188. * @returns the class name
  145189. */
  145190. getClassName(): string;
  145191. /**
  145192. * Gets the seed input component
  145193. */
  145194. get seed(): NodeMaterialConnectionPoint;
  145195. /**
  145196. * Gets the output component
  145197. */
  145198. get output(): NodeMaterialConnectionPoint;
  145199. protected _buildBlock(state: NodeMaterialBuildState): this;
  145200. }
  145201. }
  145202. declare module BABYLON {
  145203. /**
  145204. * Block used to compute arc tangent of 2 values
  145205. */
  145206. export class ArcTan2Block extends NodeMaterialBlock {
  145207. /**
  145208. * Creates a new ArcTan2Block
  145209. * @param name defines the block name
  145210. */
  145211. constructor(name: string);
  145212. /**
  145213. * Gets the current class name
  145214. * @returns the class name
  145215. */
  145216. getClassName(): string;
  145217. /**
  145218. * Gets the x operand input component
  145219. */
  145220. get x(): NodeMaterialConnectionPoint;
  145221. /**
  145222. * Gets the y operand input component
  145223. */
  145224. get y(): NodeMaterialConnectionPoint;
  145225. /**
  145226. * Gets the output component
  145227. */
  145228. get output(): NodeMaterialConnectionPoint;
  145229. protected _buildBlock(state: NodeMaterialBuildState): this;
  145230. }
  145231. }
  145232. declare module BABYLON {
  145233. /**
  145234. * Block used to smooth step a value
  145235. */
  145236. export class SmoothStepBlock extends NodeMaterialBlock {
  145237. /**
  145238. * Creates a new SmoothStepBlock
  145239. * @param name defines the block name
  145240. */
  145241. constructor(name: string);
  145242. /**
  145243. * Gets the current class name
  145244. * @returns the class name
  145245. */
  145246. getClassName(): string;
  145247. /**
  145248. * Gets the value operand input component
  145249. */
  145250. get value(): NodeMaterialConnectionPoint;
  145251. /**
  145252. * Gets the first edge operand input component
  145253. */
  145254. get edge0(): NodeMaterialConnectionPoint;
  145255. /**
  145256. * Gets the second edge operand input component
  145257. */
  145258. get edge1(): NodeMaterialConnectionPoint;
  145259. /**
  145260. * Gets the output component
  145261. */
  145262. get output(): NodeMaterialConnectionPoint;
  145263. protected _buildBlock(state: NodeMaterialBuildState): this;
  145264. }
  145265. }
  145266. declare module BABYLON {
  145267. /**
  145268. * Block used to get the reciprocal (1 / x) of a value
  145269. */
  145270. export class ReciprocalBlock extends NodeMaterialBlock {
  145271. /**
  145272. * Creates a new ReciprocalBlock
  145273. * @param name defines the block name
  145274. */
  145275. constructor(name: string);
  145276. /**
  145277. * Gets the current class name
  145278. * @returns the class name
  145279. */
  145280. getClassName(): string;
  145281. /**
  145282. * Gets the input component
  145283. */
  145284. get input(): NodeMaterialConnectionPoint;
  145285. /**
  145286. * Gets the output component
  145287. */
  145288. get output(): NodeMaterialConnectionPoint;
  145289. protected _buildBlock(state: NodeMaterialBuildState): this;
  145290. }
  145291. }
  145292. declare module BABYLON {
  145293. /**
  145294. * Block used to replace a color by another one
  145295. */
  145296. export class ReplaceColorBlock extends NodeMaterialBlock {
  145297. /**
  145298. * Creates a new ReplaceColorBlock
  145299. * @param name defines the block name
  145300. */
  145301. constructor(name: string);
  145302. /**
  145303. * Gets the current class name
  145304. * @returns the class name
  145305. */
  145306. getClassName(): string;
  145307. /**
  145308. * Gets the value input component
  145309. */
  145310. get value(): NodeMaterialConnectionPoint;
  145311. /**
  145312. * Gets the reference input component
  145313. */
  145314. get reference(): NodeMaterialConnectionPoint;
  145315. /**
  145316. * Gets the distance input component
  145317. */
  145318. get distance(): NodeMaterialConnectionPoint;
  145319. /**
  145320. * Gets the replacement input component
  145321. */
  145322. get replacement(): NodeMaterialConnectionPoint;
  145323. /**
  145324. * Gets the output component
  145325. */
  145326. get output(): NodeMaterialConnectionPoint;
  145327. protected _buildBlock(state: NodeMaterialBuildState): this;
  145328. }
  145329. }
  145330. declare module BABYLON {
  145331. /**
  145332. * Block used to posterize a value
  145333. * @see https://en.wikipedia.org/wiki/Posterization
  145334. */
  145335. export class PosterizeBlock extends NodeMaterialBlock {
  145336. /**
  145337. * Creates a new PosterizeBlock
  145338. * @param name defines the block name
  145339. */
  145340. constructor(name: string);
  145341. /**
  145342. * Gets the current class name
  145343. * @returns the class name
  145344. */
  145345. getClassName(): string;
  145346. /**
  145347. * Gets the value input component
  145348. */
  145349. get value(): NodeMaterialConnectionPoint;
  145350. /**
  145351. * Gets the steps input component
  145352. */
  145353. get steps(): NodeMaterialConnectionPoint;
  145354. /**
  145355. * Gets the output component
  145356. */
  145357. get output(): NodeMaterialConnectionPoint;
  145358. protected _buildBlock(state: NodeMaterialBuildState): this;
  145359. }
  145360. }
  145361. declare module BABYLON {
  145362. /**
  145363. * Operations supported by the Wave block
  145364. */
  145365. export enum WaveBlockKind {
  145366. /** SawTooth */
  145367. SawTooth = 0,
  145368. /** Square */
  145369. Square = 1,
  145370. /** Triangle */
  145371. Triangle = 2
  145372. }
  145373. /**
  145374. * Block used to apply wave operation to floats
  145375. */
  145376. export class WaveBlock extends NodeMaterialBlock {
  145377. /**
  145378. * Gets or sets the kibnd of wave to be applied by the block
  145379. */
  145380. kind: WaveBlockKind;
  145381. /**
  145382. * Creates a new WaveBlock
  145383. * @param name defines the block name
  145384. */
  145385. constructor(name: string);
  145386. /**
  145387. * Gets the current class name
  145388. * @returns the class name
  145389. */
  145390. getClassName(): string;
  145391. /**
  145392. * Gets the input component
  145393. */
  145394. get input(): NodeMaterialConnectionPoint;
  145395. /**
  145396. * Gets the output component
  145397. */
  145398. get output(): NodeMaterialConnectionPoint;
  145399. protected _buildBlock(state: NodeMaterialBuildState): this;
  145400. serialize(): any;
  145401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145402. }
  145403. }
  145404. declare module BABYLON {
  145405. /**
  145406. * Class used to store a color step for the GradientBlock
  145407. */
  145408. export class GradientBlockColorStep {
  145409. private _step;
  145410. /**
  145411. * Gets value indicating which step this color is associated with (between 0 and 1)
  145412. */
  145413. get step(): number;
  145414. /**
  145415. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145416. */
  145417. set step(val: number);
  145418. private _color;
  145419. /**
  145420. * Gets the color associated with this step
  145421. */
  145422. get color(): Color3;
  145423. /**
  145424. * Sets the color associated with this step
  145425. */
  145426. set color(val: Color3);
  145427. /**
  145428. * Creates a new GradientBlockColorStep
  145429. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145430. * @param color defines the color associated with this step
  145431. */
  145432. constructor(step: number, color: Color3);
  145433. }
  145434. /**
  145435. * Block used to return a color from a gradient based on an input value between 0 and 1
  145436. */
  145437. export class GradientBlock extends NodeMaterialBlock {
  145438. /**
  145439. * Gets or sets the list of color steps
  145440. */
  145441. colorSteps: GradientBlockColorStep[];
  145442. /** Gets an observable raised when the value is changed */
  145443. onValueChangedObservable: Observable<GradientBlock>;
  145444. /** calls observable when the value is changed*/
  145445. colorStepsUpdated(): void;
  145446. /**
  145447. * Creates a new GradientBlock
  145448. * @param name defines the block name
  145449. */
  145450. constructor(name: string);
  145451. /**
  145452. * Gets the current class name
  145453. * @returns the class name
  145454. */
  145455. getClassName(): string;
  145456. /**
  145457. * Gets the gradient input component
  145458. */
  145459. get gradient(): NodeMaterialConnectionPoint;
  145460. /**
  145461. * Gets the output component
  145462. */
  145463. get output(): NodeMaterialConnectionPoint;
  145464. private _writeColorConstant;
  145465. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145466. serialize(): any;
  145467. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145468. protected _dumpPropertiesCode(): string;
  145469. }
  145470. }
  145471. declare module BABYLON {
  145472. /**
  145473. * Block used to normalize lerp between 2 values
  145474. */
  145475. export class NLerpBlock extends NodeMaterialBlock {
  145476. /**
  145477. * Creates a new NLerpBlock
  145478. * @param name defines the block name
  145479. */
  145480. constructor(name: string);
  145481. /**
  145482. * Gets the current class name
  145483. * @returns the class name
  145484. */
  145485. getClassName(): string;
  145486. /**
  145487. * Gets the left operand input component
  145488. */
  145489. get left(): NodeMaterialConnectionPoint;
  145490. /**
  145491. * Gets the right operand input component
  145492. */
  145493. get right(): NodeMaterialConnectionPoint;
  145494. /**
  145495. * Gets the gradient operand input component
  145496. */
  145497. get gradient(): NodeMaterialConnectionPoint;
  145498. /**
  145499. * Gets the output component
  145500. */
  145501. get output(): NodeMaterialConnectionPoint;
  145502. protected _buildBlock(state: NodeMaterialBuildState): this;
  145503. }
  145504. }
  145505. declare module BABYLON {
  145506. /**
  145507. * block used to Generate a Worley Noise 3D Noise Pattern
  145508. */
  145509. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145510. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145511. manhattanDistance: boolean;
  145512. /**
  145513. * Creates a new WorleyNoise3DBlock
  145514. * @param name defines the block name
  145515. */
  145516. constructor(name: string);
  145517. /**
  145518. * Gets the current class name
  145519. * @returns the class name
  145520. */
  145521. getClassName(): string;
  145522. /**
  145523. * Gets the seed input component
  145524. */
  145525. get seed(): NodeMaterialConnectionPoint;
  145526. /**
  145527. * Gets the jitter input component
  145528. */
  145529. get jitter(): NodeMaterialConnectionPoint;
  145530. /**
  145531. * Gets the output component
  145532. */
  145533. get output(): NodeMaterialConnectionPoint;
  145534. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145535. /**
  145536. * Exposes the properties to the UI?
  145537. */
  145538. protected _dumpPropertiesCode(): string;
  145539. /**
  145540. * Exposes the properties to the Seralize?
  145541. */
  145542. serialize(): any;
  145543. /**
  145544. * Exposes the properties to the deseralize?
  145545. */
  145546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145547. }
  145548. }
  145549. declare module BABYLON {
  145550. /**
  145551. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145552. */
  145553. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145554. /**
  145555. * Creates a new SimplexPerlin3DBlock
  145556. * @param name defines the block name
  145557. */
  145558. constructor(name: string);
  145559. /**
  145560. * Gets the current class name
  145561. * @returns the class name
  145562. */
  145563. getClassName(): string;
  145564. /**
  145565. * Gets the seed operand input component
  145566. */
  145567. get seed(): NodeMaterialConnectionPoint;
  145568. /**
  145569. * Gets the output component
  145570. */
  145571. get output(): NodeMaterialConnectionPoint;
  145572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145573. }
  145574. }
  145575. declare module BABYLON {
  145576. /**
  145577. * Block used to blend normals
  145578. */
  145579. export class NormalBlendBlock extends NodeMaterialBlock {
  145580. /**
  145581. * Creates a new NormalBlendBlock
  145582. * @param name defines the block name
  145583. */
  145584. constructor(name: string);
  145585. /**
  145586. * Gets the current class name
  145587. * @returns the class name
  145588. */
  145589. getClassName(): string;
  145590. /**
  145591. * Gets the first input component
  145592. */
  145593. get normalMap0(): NodeMaterialConnectionPoint;
  145594. /**
  145595. * Gets the second input component
  145596. */
  145597. get normalMap1(): NodeMaterialConnectionPoint;
  145598. /**
  145599. * Gets the output component
  145600. */
  145601. get output(): NodeMaterialConnectionPoint;
  145602. protected _buildBlock(state: NodeMaterialBuildState): this;
  145603. }
  145604. }
  145605. declare module BABYLON {
  145606. /**
  145607. * Block used to rotate a 2d vector by a given angle
  145608. */
  145609. export class Rotate2dBlock extends NodeMaterialBlock {
  145610. /**
  145611. * Creates a new Rotate2dBlock
  145612. * @param name defines the block name
  145613. */
  145614. constructor(name: string);
  145615. /**
  145616. * Gets the current class name
  145617. * @returns the class name
  145618. */
  145619. getClassName(): string;
  145620. /**
  145621. * Gets the input vector
  145622. */
  145623. get input(): NodeMaterialConnectionPoint;
  145624. /**
  145625. * Gets the input angle
  145626. */
  145627. get angle(): NodeMaterialConnectionPoint;
  145628. /**
  145629. * Gets the output component
  145630. */
  145631. get output(): NodeMaterialConnectionPoint;
  145632. autoConfigure(material: NodeMaterial): void;
  145633. protected _buildBlock(state: NodeMaterialBuildState): this;
  145634. }
  145635. }
  145636. declare module BABYLON {
  145637. /**
  145638. * Block used to get the reflected vector from a direction and a normal
  145639. */
  145640. export class ReflectBlock extends NodeMaterialBlock {
  145641. /**
  145642. * Creates a new ReflectBlock
  145643. * @param name defines the block name
  145644. */
  145645. constructor(name: string);
  145646. /**
  145647. * Gets the current class name
  145648. * @returns the class name
  145649. */
  145650. getClassName(): string;
  145651. /**
  145652. * Gets the incident component
  145653. */
  145654. get incident(): NodeMaterialConnectionPoint;
  145655. /**
  145656. * Gets the normal component
  145657. */
  145658. get normal(): NodeMaterialConnectionPoint;
  145659. /**
  145660. * Gets the output component
  145661. */
  145662. get output(): NodeMaterialConnectionPoint;
  145663. protected _buildBlock(state: NodeMaterialBuildState): this;
  145664. }
  145665. }
  145666. declare module BABYLON {
  145667. /**
  145668. * Block used to get the refracted vector from a direction and a normal
  145669. */
  145670. export class RefractBlock extends NodeMaterialBlock {
  145671. /**
  145672. * Creates a new RefractBlock
  145673. * @param name defines the block name
  145674. */
  145675. constructor(name: string);
  145676. /**
  145677. * Gets the current class name
  145678. * @returns the class name
  145679. */
  145680. getClassName(): string;
  145681. /**
  145682. * Gets the incident component
  145683. */
  145684. get incident(): NodeMaterialConnectionPoint;
  145685. /**
  145686. * Gets the normal component
  145687. */
  145688. get normal(): NodeMaterialConnectionPoint;
  145689. /**
  145690. * Gets the index of refraction component
  145691. */
  145692. get ior(): NodeMaterialConnectionPoint;
  145693. /**
  145694. * Gets the output component
  145695. */
  145696. get output(): NodeMaterialConnectionPoint;
  145697. protected _buildBlock(state: NodeMaterialBuildState): this;
  145698. }
  145699. }
  145700. declare module BABYLON {
  145701. /**
  145702. * Block used to desaturate a color
  145703. */
  145704. export class DesaturateBlock extends NodeMaterialBlock {
  145705. /**
  145706. * Creates a new DesaturateBlock
  145707. * @param name defines the block name
  145708. */
  145709. constructor(name: string);
  145710. /**
  145711. * Gets the current class name
  145712. * @returns the class name
  145713. */
  145714. getClassName(): string;
  145715. /**
  145716. * Gets the color operand input component
  145717. */
  145718. get color(): NodeMaterialConnectionPoint;
  145719. /**
  145720. * Gets the level operand input component
  145721. */
  145722. get level(): NodeMaterialConnectionPoint;
  145723. /**
  145724. * Gets the output component
  145725. */
  145726. get output(): NodeMaterialConnectionPoint;
  145727. protected _buildBlock(state: NodeMaterialBuildState): this;
  145728. }
  145729. }
  145730. declare module BABYLON {
  145731. /**
  145732. * Block used to implement the ambient occlusion module of the PBR material
  145733. */
  145734. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145735. /**
  145736. * Create a new AmbientOcclusionBlock
  145737. * @param name defines the block name
  145738. */
  145739. constructor(name: string);
  145740. /**
  145741. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145742. */
  145743. useAmbientInGrayScale: boolean;
  145744. /**
  145745. * Initialize the block and prepare the context for build
  145746. * @param state defines the state that will be used for the build
  145747. */
  145748. initialize(state: NodeMaterialBuildState): void;
  145749. /**
  145750. * Gets the current class name
  145751. * @returns the class name
  145752. */
  145753. getClassName(): string;
  145754. /**
  145755. * Gets the texture input component
  145756. */
  145757. get texture(): NodeMaterialConnectionPoint;
  145758. /**
  145759. * Gets the texture intensity component
  145760. */
  145761. get intensity(): NodeMaterialConnectionPoint;
  145762. /**
  145763. * Gets the direct light intensity input component
  145764. */
  145765. get directLightIntensity(): NodeMaterialConnectionPoint;
  145766. /**
  145767. * Gets the ambient occlusion object output component
  145768. */
  145769. get ambientOcc(): NodeMaterialConnectionPoint;
  145770. /**
  145771. * Gets the main code of the block (fragment side)
  145772. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145773. * @returns the shader code
  145774. */
  145775. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145777. protected _buildBlock(state: NodeMaterialBuildState): this;
  145778. protected _dumpPropertiesCode(): string;
  145779. serialize(): any;
  145780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145781. }
  145782. }
  145783. declare module BABYLON {
  145784. /**
  145785. * Block used to implement the reflection module of the PBR material
  145786. */
  145787. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145788. /** @hidden */
  145789. _defineLODReflectionAlpha: string;
  145790. /** @hidden */
  145791. _defineLinearSpecularReflection: string;
  145792. private _vEnvironmentIrradianceName;
  145793. /** @hidden */
  145794. _vReflectionMicrosurfaceInfosName: string;
  145795. /** @hidden */
  145796. _vReflectionInfosName: string;
  145797. /** @hidden */
  145798. _vReflectionFilteringInfoName: string;
  145799. private _scene;
  145800. /**
  145801. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145802. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145803. * It's less burden on the user side in the editor part.
  145804. */
  145805. /** @hidden */
  145806. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145807. /** @hidden */
  145808. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145809. /** @hidden */
  145810. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145811. /**
  145812. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145813. * diffuse part of the IBL.
  145814. */
  145815. useSphericalHarmonics: boolean;
  145816. /**
  145817. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145818. */
  145819. forceIrradianceInFragment: boolean;
  145820. /**
  145821. * Create a new ReflectionBlock
  145822. * @param name defines the block name
  145823. */
  145824. constructor(name: string);
  145825. /**
  145826. * Gets the current class name
  145827. * @returns the class name
  145828. */
  145829. getClassName(): string;
  145830. /**
  145831. * Gets the position input component
  145832. */
  145833. get position(): NodeMaterialConnectionPoint;
  145834. /**
  145835. * Gets the world position input component
  145836. */
  145837. get worldPosition(): NodeMaterialConnectionPoint;
  145838. /**
  145839. * Gets the world normal input component
  145840. */
  145841. get worldNormal(): NodeMaterialConnectionPoint;
  145842. /**
  145843. * Gets the world input component
  145844. */
  145845. get world(): NodeMaterialConnectionPoint;
  145846. /**
  145847. * Gets the camera (or eye) position component
  145848. */
  145849. get cameraPosition(): NodeMaterialConnectionPoint;
  145850. /**
  145851. * Gets the view input component
  145852. */
  145853. get view(): NodeMaterialConnectionPoint;
  145854. /**
  145855. * Gets the color input component
  145856. */
  145857. get color(): NodeMaterialConnectionPoint;
  145858. /**
  145859. * Gets the reflection object output component
  145860. */
  145861. get reflection(): NodeMaterialConnectionPoint;
  145862. /**
  145863. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145864. */
  145865. get hasTexture(): boolean;
  145866. /**
  145867. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145868. */
  145869. get reflectionColor(): string;
  145870. protected _getTexture(): Nullable<BaseTexture>;
  145871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145873. /**
  145874. * Gets the code to inject in the vertex shader
  145875. * @param state current state of the node material building
  145876. * @returns the shader code
  145877. */
  145878. handleVertexSide(state: NodeMaterialBuildState): string;
  145879. /**
  145880. * Gets the main code of the block (fragment side)
  145881. * @param state current state of the node material building
  145882. * @param normalVarName name of the existing variable corresponding to the normal
  145883. * @returns the shader code
  145884. */
  145885. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145886. protected _buildBlock(state: NodeMaterialBuildState): this;
  145887. protected _dumpPropertiesCode(): string;
  145888. serialize(): any;
  145889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145890. }
  145891. }
  145892. declare module BABYLON {
  145893. /**
  145894. * Block used to implement the sheen module of the PBR material
  145895. */
  145896. export class SheenBlock extends NodeMaterialBlock {
  145897. /**
  145898. * Create a new SheenBlock
  145899. * @param name defines the block name
  145900. */
  145901. constructor(name: string);
  145902. /**
  145903. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145904. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145905. * making it easier to setup and tweak the effect
  145906. */
  145907. albedoScaling: boolean;
  145908. /**
  145909. * Defines if the sheen is linked to the sheen color.
  145910. */
  145911. linkSheenWithAlbedo: boolean;
  145912. /**
  145913. * Initialize the block and prepare the context for build
  145914. * @param state defines the state that will be used for the build
  145915. */
  145916. initialize(state: NodeMaterialBuildState): void;
  145917. /**
  145918. * Gets the current class name
  145919. * @returns the class name
  145920. */
  145921. getClassName(): string;
  145922. /**
  145923. * Gets the intensity input component
  145924. */
  145925. get intensity(): NodeMaterialConnectionPoint;
  145926. /**
  145927. * Gets the color input component
  145928. */
  145929. get color(): NodeMaterialConnectionPoint;
  145930. /**
  145931. * Gets the roughness input component
  145932. */
  145933. get roughness(): NodeMaterialConnectionPoint;
  145934. /**
  145935. * Gets the sheen object output component
  145936. */
  145937. get sheen(): NodeMaterialConnectionPoint;
  145938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145939. /**
  145940. * Gets the main code of the block (fragment side)
  145941. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145942. * @returns the shader code
  145943. */
  145944. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145945. protected _buildBlock(state: NodeMaterialBuildState): this;
  145946. protected _dumpPropertiesCode(): string;
  145947. serialize(): any;
  145948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145949. }
  145950. }
  145951. declare module BABYLON {
  145952. /**
  145953. * Block used to implement the reflectivity module of the PBR material
  145954. */
  145955. export class ReflectivityBlock extends NodeMaterialBlock {
  145956. private _metallicReflectanceColor;
  145957. private _metallicF0Factor;
  145958. /** @hidden */
  145959. _vMetallicReflectanceFactorsName: string;
  145960. /**
  145961. * The property below is set by the main PBR block prior to calling methods of this class.
  145962. */
  145963. /** @hidden */
  145964. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145965. /**
  145966. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145967. */
  145968. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145969. /**
  145970. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145971. */
  145972. useMetallnessFromMetallicTextureBlue: boolean;
  145973. /**
  145974. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145975. */
  145976. useRoughnessFromMetallicTextureAlpha: boolean;
  145977. /**
  145978. * Specifies if the metallic texture contains the roughness information in its green channel.
  145979. */
  145980. useRoughnessFromMetallicTextureGreen: boolean;
  145981. /**
  145982. * Create a new ReflectivityBlock
  145983. * @param name defines the block name
  145984. */
  145985. constructor(name: string);
  145986. /**
  145987. * Initialize the block and prepare the context for build
  145988. * @param state defines the state that will be used for the build
  145989. */
  145990. initialize(state: NodeMaterialBuildState): void;
  145991. /**
  145992. * Gets the current class name
  145993. * @returns the class name
  145994. */
  145995. getClassName(): string;
  145996. /**
  145997. * Gets the metallic input component
  145998. */
  145999. get metallic(): NodeMaterialConnectionPoint;
  146000. /**
  146001. * Gets the roughness input component
  146002. */
  146003. get roughness(): NodeMaterialConnectionPoint;
  146004. /**
  146005. * Gets the texture input component
  146006. */
  146007. get texture(): NodeMaterialConnectionPoint;
  146008. /**
  146009. * Gets the reflectivity object output component
  146010. */
  146011. get reflectivity(): NodeMaterialConnectionPoint;
  146012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146013. /**
  146014. * Gets the main code of the block (fragment side)
  146015. * @param state current state of the node material building
  146016. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146017. * @returns the shader code
  146018. */
  146019. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146021. protected _buildBlock(state: NodeMaterialBuildState): this;
  146022. protected _dumpPropertiesCode(): string;
  146023. serialize(): any;
  146024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146025. }
  146026. }
  146027. declare module BABYLON {
  146028. /**
  146029. * Block used to implement the anisotropy module of the PBR material
  146030. */
  146031. export class AnisotropyBlock extends NodeMaterialBlock {
  146032. /**
  146033. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146034. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146035. * It's less burden on the user side in the editor part.
  146036. */
  146037. /** @hidden */
  146038. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146039. /** @hidden */
  146040. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146041. /**
  146042. * Create a new AnisotropyBlock
  146043. * @param name defines the block name
  146044. */
  146045. constructor(name: string);
  146046. /**
  146047. * Initialize the block and prepare the context for build
  146048. * @param state defines the state that will be used for the build
  146049. */
  146050. initialize(state: NodeMaterialBuildState): void;
  146051. /**
  146052. * Gets the current class name
  146053. * @returns the class name
  146054. */
  146055. getClassName(): string;
  146056. /**
  146057. * Gets the intensity input component
  146058. */
  146059. get intensity(): NodeMaterialConnectionPoint;
  146060. /**
  146061. * Gets the direction input component
  146062. */
  146063. get direction(): NodeMaterialConnectionPoint;
  146064. /**
  146065. * Gets the texture input component
  146066. */
  146067. get texture(): NodeMaterialConnectionPoint;
  146068. /**
  146069. * Gets the uv input component
  146070. */
  146071. get uv(): NodeMaterialConnectionPoint;
  146072. /**
  146073. * Gets the worldTangent input component
  146074. */
  146075. get worldTangent(): NodeMaterialConnectionPoint;
  146076. /**
  146077. * Gets the anisotropy object output component
  146078. */
  146079. get anisotropy(): NodeMaterialConnectionPoint;
  146080. private _generateTBNSpace;
  146081. /**
  146082. * Gets the main code of the block (fragment side)
  146083. * @param state current state of the node material building
  146084. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146085. * @returns the shader code
  146086. */
  146087. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146089. protected _buildBlock(state: NodeMaterialBuildState): this;
  146090. }
  146091. }
  146092. declare module BABYLON {
  146093. /**
  146094. * Block used to implement the clear coat module of the PBR material
  146095. */
  146096. export class ClearCoatBlock extends NodeMaterialBlock {
  146097. private _scene;
  146098. /**
  146099. * Create a new ClearCoatBlock
  146100. * @param name defines the block name
  146101. */
  146102. constructor(name: string);
  146103. /**
  146104. * Initialize the block and prepare the context for build
  146105. * @param state defines the state that will be used for the build
  146106. */
  146107. initialize(state: NodeMaterialBuildState): void;
  146108. /**
  146109. * Gets the current class name
  146110. * @returns the class name
  146111. */
  146112. getClassName(): string;
  146113. /**
  146114. * Gets the intensity input component
  146115. */
  146116. get intensity(): NodeMaterialConnectionPoint;
  146117. /**
  146118. * Gets the roughness input component
  146119. */
  146120. get roughness(): NodeMaterialConnectionPoint;
  146121. /**
  146122. * Gets the ior input component
  146123. */
  146124. get ior(): NodeMaterialConnectionPoint;
  146125. /**
  146126. * Gets the texture input component
  146127. */
  146128. get texture(): NodeMaterialConnectionPoint;
  146129. /**
  146130. * Gets the bump texture input component
  146131. */
  146132. get bumpTexture(): NodeMaterialConnectionPoint;
  146133. /**
  146134. * Gets the uv input component
  146135. */
  146136. get uv(): NodeMaterialConnectionPoint;
  146137. /**
  146138. * Gets the tint color input component
  146139. */
  146140. get tintColor(): NodeMaterialConnectionPoint;
  146141. /**
  146142. * Gets the tint "at distance" input component
  146143. */
  146144. get tintAtDistance(): NodeMaterialConnectionPoint;
  146145. /**
  146146. * Gets the tint thickness input component
  146147. */
  146148. get tintThickness(): NodeMaterialConnectionPoint;
  146149. /**
  146150. * Gets the world tangent input component
  146151. */
  146152. get worldTangent(): NodeMaterialConnectionPoint;
  146153. /**
  146154. * Gets the clear coat object output component
  146155. */
  146156. get clearcoat(): NodeMaterialConnectionPoint;
  146157. autoConfigure(material: NodeMaterial): void;
  146158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146160. private _generateTBNSpace;
  146161. /**
  146162. * Gets the main code of the block (fragment side)
  146163. * @param state current state of the node material building
  146164. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146165. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146166. * @param worldPosVarName name of the variable holding the world position
  146167. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146168. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146169. * @param worldNormalVarName name of the variable holding the world normal
  146170. * @returns the shader code
  146171. */
  146172. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146173. protected _buildBlock(state: NodeMaterialBuildState): this;
  146174. }
  146175. }
  146176. declare module BABYLON {
  146177. /**
  146178. * Block used to implement the sub surface module of the PBR material
  146179. */
  146180. export class SubSurfaceBlock extends NodeMaterialBlock {
  146181. /**
  146182. * Create a new SubSurfaceBlock
  146183. * @param name defines the block name
  146184. */
  146185. constructor(name: string);
  146186. /**
  146187. * Stores the intensity of the different subsurface effects in the thickness texture.
  146188. * * the green channel is the translucency intensity.
  146189. * * the blue channel is the scattering intensity.
  146190. * * the alpha channel is the refraction intensity.
  146191. */
  146192. useMaskFromThicknessTexture: boolean;
  146193. /**
  146194. * Initialize the block and prepare the context for build
  146195. * @param state defines the state that will be used for the build
  146196. */
  146197. initialize(state: NodeMaterialBuildState): void;
  146198. /**
  146199. * Gets the current class name
  146200. * @returns the class name
  146201. */
  146202. getClassName(): string;
  146203. /**
  146204. * Gets the min thickness input component
  146205. */
  146206. get minThickness(): NodeMaterialConnectionPoint;
  146207. /**
  146208. * Gets the max thickness input component
  146209. */
  146210. get maxThickness(): NodeMaterialConnectionPoint;
  146211. /**
  146212. * Gets the thickness texture component
  146213. */
  146214. get thicknessTexture(): NodeMaterialConnectionPoint;
  146215. /**
  146216. * Gets the tint color input component
  146217. */
  146218. get tintColor(): NodeMaterialConnectionPoint;
  146219. /**
  146220. * Gets the translucency intensity input component
  146221. */
  146222. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146223. /**
  146224. * Gets the translucency diffusion distance input component
  146225. */
  146226. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146227. /**
  146228. * Gets the refraction object parameters
  146229. */
  146230. get refraction(): NodeMaterialConnectionPoint;
  146231. /**
  146232. * Gets the sub surface object output component
  146233. */
  146234. get subsurface(): NodeMaterialConnectionPoint;
  146235. autoConfigure(material: NodeMaterial): void;
  146236. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146237. /**
  146238. * Gets the main code of the block (fragment side)
  146239. * @param state current state of the node material building
  146240. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146241. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146242. * @param worldPosVarName name of the variable holding the world position
  146243. * @returns the shader code
  146244. */
  146245. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146246. protected _buildBlock(state: NodeMaterialBuildState): this;
  146247. }
  146248. }
  146249. declare module BABYLON {
  146250. /**
  146251. * Block used to implement the PBR metallic/roughness model
  146252. */
  146253. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146254. /**
  146255. * Gets or sets the light associated with this block
  146256. */
  146257. light: Nullable<Light>;
  146258. private _lightId;
  146259. private _scene;
  146260. private _environmentBRDFTexture;
  146261. private _environmentBrdfSamplerName;
  146262. private _vNormalWName;
  146263. private _invertNormalName;
  146264. /**
  146265. * Create a new ReflectionBlock
  146266. * @param name defines the block name
  146267. */
  146268. constructor(name: string);
  146269. /**
  146270. * Intensity of the direct lights e.g. the four lights available in your scene.
  146271. * This impacts both the direct diffuse and specular highlights.
  146272. */
  146273. directIntensity: number;
  146274. /**
  146275. * Intensity of the environment e.g. how much the environment will light the object
  146276. * either through harmonics for rough material or through the refelction for shiny ones.
  146277. */
  146278. environmentIntensity: number;
  146279. /**
  146280. * This is a special control allowing the reduction of the specular highlights coming from the
  146281. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146282. */
  146283. specularIntensity: number;
  146284. /**
  146285. * Defines the falloff type used in this material.
  146286. * It by default is Physical.
  146287. */
  146288. lightFalloff: number;
  146289. /**
  146290. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146291. */
  146292. useAlphaFromAlbedoTexture: boolean;
  146293. /**
  146294. * Specifies that alpha test should be used
  146295. */
  146296. useAlphaTest: boolean;
  146297. /**
  146298. * Defines the alpha limits in alpha test mode.
  146299. */
  146300. alphaTestCutoff: number;
  146301. /**
  146302. * Specifies that alpha blending should be used
  146303. */
  146304. useAlphaBlending: boolean;
  146305. /**
  146306. * Defines if the alpha value should be determined via the rgb values.
  146307. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146308. */
  146309. opacityRGB: boolean;
  146310. /**
  146311. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146312. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146313. */
  146314. useRadianceOverAlpha: boolean;
  146315. /**
  146316. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146317. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146318. */
  146319. useSpecularOverAlpha: boolean;
  146320. /**
  146321. * Enables specular anti aliasing in the PBR shader.
  146322. * It will both interacts on the Geometry for analytical and IBL lighting.
  146323. * It also prefilter the roughness map based on the bump values.
  146324. */
  146325. enableSpecularAntiAliasing: boolean;
  146326. /**
  146327. * Enables realtime filtering on the texture.
  146328. */
  146329. realTimeFiltering: boolean;
  146330. /**
  146331. * Quality switch for realtime filtering
  146332. */
  146333. realTimeFilteringQuality: number;
  146334. /**
  146335. * Defines if the material uses energy conservation.
  146336. */
  146337. useEnergyConservation: boolean;
  146338. /**
  146339. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146340. * too much the area relying on ambient texture to define their ambient occlusion.
  146341. */
  146342. useRadianceOcclusion: boolean;
  146343. /**
  146344. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146345. * makes the reflect vector face the model (under horizon).
  146346. */
  146347. useHorizonOcclusion: boolean;
  146348. /**
  146349. * If set to true, no lighting calculations will be applied.
  146350. */
  146351. unlit: boolean;
  146352. /**
  146353. * Force normal to face away from face.
  146354. */
  146355. forceNormalForward: boolean;
  146356. /**
  146357. * Defines the material debug mode.
  146358. * It helps seeing only some components of the material while troubleshooting.
  146359. */
  146360. debugMode: number;
  146361. /**
  146362. * Specify from where on screen the debug mode should start.
  146363. * The value goes from -1 (full screen) to 1 (not visible)
  146364. * It helps with side by side comparison against the final render
  146365. * This defaults to 0
  146366. */
  146367. debugLimit: number;
  146368. /**
  146369. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146370. * You can use the factor to better multiply the final value.
  146371. */
  146372. debugFactor: number;
  146373. /**
  146374. * Initialize the block and prepare the context for build
  146375. * @param state defines the state that will be used for the build
  146376. */
  146377. initialize(state: NodeMaterialBuildState): void;
  146378. /**
  146379. * Gets the current class name
  146380. * @returns the class name
  146381. */
  146382. getClassName(): string;
  146383. /**
  146384. * Gets the world position input component
  146385. */
  146386. get worldPosition(): NodeMaterialConnectionPoint;
  146387. /**
  146388. * Gets the world normal input component
  146389. */
  146390. get worldNormal(): NodeMaterialConnectionPoint;
  146391. /**
  146392. * Gets the perturbed normal input component
  146393. */
  146394. get perturbedNormal(): NodeMaterialConnectionPoint;
  146395. /**
  146396. * Gets the camera position input component
  146397. */
  146398. get cameraPosition(): NodeMaterialConnectionPoint;
  146399. /**
  146400. * Gets the base color input component
  146401. */
  146402. get baseColor(): NodeMaterialConnectionPoint;
  146403. /**
  146404. * Gets the opacity texture input component
  146405. */
  146406. get opacityTexture(): NodeMaterialConnectionPoint;
  146407. /**
  146408. * Gets the ambient color input component
  146409. */
  146410. get ambientColor(): NodeMaterialConnectionPoint;
  146411. /**
  146412. * Gets the reflectivity object parameters
  146413. */
  146414. get reflectivity(): NodeMaterialConnectionPoint;
  146415. /**
  146416. * Gets the ambient occlusion object parameters
  146417. */
  146418. get ambientOcc(): NodeMaterialConnectionPoint;
  146419. /**
  146420. * Gets the reflection object parameters
  146421. */
  146422. get reflection(): NodeMaterialConnectionPoint;
  146423. /**
  146424. * Gets the sheen object parameters
  146425. */
  146426. get sheen(): NodeMaterialConnectionPoint;
  146427. /**
  146428. * Gets the clear coat object parameters
  146429. */
  146430. get clearcoat(): NodeMaterialConnectionPoint;
  146431. /**
  146432. * Gets the sub surface object parameters
  146433. */
  146434. get subsurface(): NodeMaterialConnectionPoint;
  146435. /**
  146436. * Gets the anisotropy object parameters
  146437. */
  146438. get anisotropy(): NodeMaterialConnectionPoint;
  146439. /**
  146440. * Gets the ambient output component
  146441. */
  146442. get ambient(): NodeMaterialConnectionPoint;
  146443. /**
  146444. * Gets the diffuse output component
  146445. */
  146446. get diffuse(): NodeMaterialConnectionPoint;
  146447. /**
  146448. * Gets the specular output component
  146449. */
  146450. get specular(): NodeMaterialConnectionPoint;
  146451. /**
  146452. * Gets the sheen output component
  146453. */
  146454. get sheenDir(): NodeMaterialConnectionPoint;
  146455. /**
  146456. * Gets the clear coat output component
  146457. */
  146458. get clearcoatDir(): NodeMaterialConnectionPoint;
  146459. /**
  146460. * Gets the indirect diffuse output component
  146461. */
  146462. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146463. /**
  146464. * Gets the indirect specular output component
  146465. */
  146466. get specularIndirect(): NodeMaterialConnectionPoint;
  146467. /**
  146468. * Gets the indirect sheen output component
  146469. */
  146470. get sheenIndirect(): NodeMaterialConnectionPoint;
  146471. /**
  146472. * Gets the indirect clear coat output component
  146473. */
  146474. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146475. /**
  146476. * Gets the refraction output component
  146477. */
  146478. get refraction(): NodeMaterialConnectionPoint;
  146479. /**
  146480. * Gets the global lighting output component
  146481. */
  146482. get lighting(): NodeMaterialConnectionPoint;
  146483. /**
  146484. * Gets the shadow output component
  146485. */
  146486. get shadow(): NodeMaterialConnectionPoint;
  146487. /**
  146488. * Gets the alpha output component
  146489. */
  146490. get alpha(): NodeMaterialConnectionPoint;
  146491. autoConfigure(material: NodeMaterial): void;
  146492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146493. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146495. private _injectVertexCode;
  146496. /**
  146497. * Gets the code corresponding to the albedo/opacity module
  146498. * @returns the shader code
  146499. */
  146500. getAlbedoOpacityCode(): string;
  146501. protected _buildBlock(state: NodeMaterialBuildState): this;
  146502. protected _dumpPropertiesCode(): string;
  146503. serialize(): any;
  146504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146505. }
  146506. }
  146507. declare module BABYLON {
  146508. /**
  146509. * Block used to compute value of one parameter modulo another
  146510. */
  146511. export class ModBlock extends NodeMaterialBlock {
  146512. /**
  146513. * Creates a new ModBlock
  146514. * @param name defines the block name
  146515. */
  146516. constructor(name: string);
  146517. /**
  146518. * Gets the current class name
  146519. * @returns the class name
  146520. */
  146521. getClassName(): string;
  146522. /**
  146523. * Gets the left operand input component
  146524. */
  146525. get left(): NodeMaterialConnectionPoint;
  146526. /**
  146527. * Gets the right operand input component
  146528. */
  146529. get right(): NodeMaterialConnectionPoint;
  146530. /**
  146531. * Gets the output component
  146532. */
  146533. get output(): NodeMaterialConnectionPoint;
  146534. protected _buildBlock(state: NodeMaterialBuildState): this;
  146535. }
  146536. }
  146537. declare module BABYLON {
  146538. /**
  146539. * Configuration for Draco compression
  146540. */
  146541. export interface IDracoCompressionConfiguration {
  146542. /**
  146543. * Configuration for the decoder.
  146544. */
  146545. decoder: {
  146546. /**
  146547. * The url to the WebAssembly module.
  146548. */
  146549. wasmUrl?: string;
  146550. /**
  146551. * The url to the WebAssembly binary.
  146552. */
  146553. wasmBinaryUrl?: string;
  146554. /**
  146555. * The url to the fallback JavaScript module.
  146556. */
  146557. fallbackUrl?: string;
  146558. };
  146559. }
  146560. /**
  146561. * Draco compression (https://google.github.io/draco/)
  146562. *
  146563. * This class wraps the Draco module.
  146564. *
  146565. * **Encoder**
  146566. *
  146567. * The encoder is not currently implemented.
  146568. *
  146569. * **Decoder**
  146570. *
  146571. * 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.
  146572. *
  146573. * To update the configuration, use the following code:
  146574. * ```javascript
  146575. * DracoCompression.Configuration = {
  146576. * decoder: {
  146577. * wasmUrl: "<url to the WebAssembly library>",
  146578. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146579. * fallbackUrl: "<url to the fallback JavaScript library>",
  146580. * }
  146581. * };
  146582. * ```
  146583. *
  146584. * 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.
  146585. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146586. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146587. *
  146588. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146589. * ```javascript
  146590. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146591. * ```
  146592. *
  146593. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146594. */
  146595. export class DracoCompression implements IDisposable {
  146596. private _workerPoolPromise?;
  146597. private _decoderModulePromise?;
  146598. /**
  146599. * The configuration. Defaults to the following urls:
  146600. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146601. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146602. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146603. */
  146604. static Configuration: IDracoCompressionConfiguration;
  146605. /**
  146606. * Returns true if the decoder configuration is available.
  146607. */
  146608. static get DecoderAvailable(): boolean;
  146609. /**
  146610. * Default number of workers to create when creating the draco compression object.
  146611. */
  146612. static DefaultNumWorkers: number;
  146613. private static GetDefaultNumWorkers;
  146614. private static _Default;
  146615. /**
  146616. * Default instance for the draco compression object.
  146617. */
  146618. static get Default(): DracoCompression;
  146619. /**
  146620. * Constructor
  146621. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146622. */
  146623. constructor(numWorkers?: number);
  146624. /**
  146625. * Stop all async operations and release resources.
  146626. */
  146627. dispose(): void;
  146628. /**
  146629. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146630. * @returns a promise that resolves when ready
  146631. */
  146632. whenReadyAsync(): Promise<void>;
  146633. /**
  146634. * Decode Draco compressed mesh data to vertex data.
  146635. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146636. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146637. * @returns A promise that resolves with the decoded vertex data
  146638. */
  146639. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146640. [kind: string]: number;
  146641. }): Promise<VertexData>;
  146642. }
  146643. }
  146644. declare module BABYLON {
  146645. /**
  146646. * Class for building Constructive Solid Geometry
  146647. */
  146648. export class CSG {
  146649. private polygons;
  146650. /**
  146651. * The world matrix
  146652. */
  146653. matrix: Matrix;
  146654. /**
  146655. * Stores the position
  146656. */
  146657. position: Vector3;
  146658. /**
  146659. * Stores the rotation
  146660. */
  146661. rotation: Vector3;
  146662. /**
  146663. * Stores the rotation quaternion
  146664. */
  146665. rotationQuaternion: Nullable<Quaternion>;
  146666. /**
  146667. * Stores the scaling vector
  146668. */
  146669. scaling: Vector3;
  146670. /**
  146671. * Convert the Mesh to CSG
  146672. * @param mesh The Mesh to convert to CSG
  146673. * @returns A new CSG from the Mesh
  146674. */
  146675. static FromMesh(mesh: Mesh): CSG;
  146676. /**
  146677. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146678. * @param polygons Polygons used to construct a CSG solid
  146679. */
  146680. private static FromPolygons;
  146681. /**
  146682. * Clones, or makes a deep copy, of the CSG
  146683. * @returns A new CSG
  146684. */
  146685. clone(): CSG;
  146686. /**
  146687. * Unions this CSG with another CSG
  146688. * @param csg The CSG to union against this CSG
  146689. * @returns The unioned CSG
  146690. */
  146691. union(csg: CSG): CSG;
  146692. /**
  146693. * Unions this CSG with another CSG in place
  146694. * @param csg The CSG to union against this CSG
  146695. */
  146696. unionInPlace(csg: CSG): void;
  146697. /**
  146698. * Subtracts this CSG with another CSG
  146699. * @param csg The CSG to subtract against this CSG
  146700. * @returns A new CSG
  146701. */
  146702. subtract(csg: CSG): CSG;
  146703. /**
  146704. * Subtracts this CSG with another CSG in place
  146705. * @param csg The CSG to subtact against this CSG
  146706. */
  146707. subtractInPlace(csg: CSG): void;
  146708. /**
  146709. * Intersect this CSG with another CSG
  146710. * @param csg The CSG to intersect against this CSG
  146711. * @returns A new CSG
  146712. */
  146713. intersect(csg: CSG): CSG;
  146714. /**
  146715. * Intersects this CSG with another CSG in place
  146716. * @param csg The CSG to intersect against this CSG
  146717. */
  146718. intersectInPlace(csg: CSG): void;
  146719. /**
  146720. * Return a new CSG solid with solid and empty space switched. This solid is
  146721. * not modified.
  146722. * @returns A new CSG solid with solid and empty space switched
  146723. */
  146724. inverse(): CSG;
  146725. /**
  146726. * Inverses the CSG in place
  146727. */
  146728. inverseInPlace(): void;
  146729. /**
  146730. * This is used to keep meshes transformations so they can be restored
  146731. * when we build back a Babylon Mesh
  146732. * NB : All CSG operations are performed in world coordinates
  146733. * @param csg The CSG to copy the transform attributes from
  146734. * @returns This CSG
  146735. */
  146736. copyTransformAttributes(csg: CSG): CSG;
  146737. /**
  146738. * Build Raw mesh from CSG
  146739. * Coordinates here are in world space
  146740. * @param name The name of the mesh geometry
  146741. * @param scene The Scene
  146742. * @param keepSubMeshes Specifies if the submeshes should be kept
  146743. * @returns A new Mesh
  146744. */
  146745. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146746. /**
  146747. * Build Mesh from CSG taking material and transforms into account
  146748. * @param name The name of the Mesh
  146749. * @param material The material of the Mesh
  146750. * @param scene The Scene
  146751. * @param keepSubMeshes Specifies if submeshes should be kept
  146752. * @returns The new Mesh
  146753. */
  146754. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146755. }
  146756. }
  146757. declare module BABYLON {
  146758. /**
  146759. * Class used to create a trail following a mesh
  146760. */
  146761. export class TrailMesh extends Mesh {
  146762. private _generator;
  146763. private _autoStart;
  146764. private _running;
  146765. private _diameter;
  146766. private _length;
  146767. private _sectionPolygonPointsCount;
  146768. private _sectionVectors;
  146769. private _sectionNormalVectors;
  146770. private _beforeRenderObserver;
  146771. /**
  146772. * @constructor
  146773. * @param name The value used by scene.getMeshByName() to do a lookup.
  146774. * @param generator The mesh or transform node to generate a trail.
  146775. * @param scene The scene to add this mesh to.
  146776. * @param diameter Diameter of trailing mesh. Default is 1.
  146777. * @param length Length of trailing mesh. Default is 60.
  146778. * @param autoStart Automatically start trailing mesh. Default true.
  146779. */
  146780. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146781. /**
  146782. * "TrailMesh"
  146783. * @returns "TrailMesh"
  146784. */
  146785. getClassName(): string;
  146786. private _createMesh;
  146787. /**
  146788. * Start trailing mesh.
  146789. */
  146790. start(): void;
  146791. /**
  146792. * Stop trailing mesh.
  146793. */
  146794. stop(): void;
  146795. /**
  146796. * Update trailing mesh geometry.
  146797. */
  146798. update(): void;
  146799. /**
  146800. * Returns a new TrailMesh object.
  146801. * @param name is a string, the name given to the new mesh
  146802. * @param newGenerator use new generator object for cloned trail mesh
  146803. * @returns a new mesh
  146804. */
  146805. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146806. /**
  146807. * Serializes this trail mesh
  146808. * @param serializationObject object to write serialization to
  146809. */
  146810. serialize(serializationObject: any): void;
  146811. /**
  146812. * Parses a serialized trail mesh
  146813. * @param parsedMesh the serialized mesh
  146814. * @param scene the scene to create the trail mesh in
  146815. * @returns the created trail mesh
  146816. */
  146817. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146818. }
  146819. }
  146820. declare module BABYLON {
  146821. /**
  146822. * Class containing static functions to help procedurally build meshes
  146823. */
  146824. export class TiledBoxBuilder {
  146825. /**
  146826. * Creates a box mesh
  146827. * 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)
  146828. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146832. * @param name defines the name of the mesh
  146833. * @param options defines the options used to create the mesh
  146834. * @param scene defines the hosting scene
  146835. * @returns the box mesh
  146836. */
  146837. static CreateTiledBox(name: string, options: {
  146838. pattern?: number;
  146839. width?: number;
  146840. height?: number;
  146841. depth?: number;
  146842. tileSize?: number;
  146843. tileWidth?: number;
  146844. tileHeight?: number;
  146845. alignHorizontal?: number;
  146846. alignVertical?: number;
  146847. faceUV?: Vector4[];
  146848. faceColors?: Color4[];
  146849. sideOrientation?: number;
  146850. updatable?: boolean;
  146851. }, scene?: Nullable<Scene>): Mesh;
  146852. }
  146853. }
  146854. declare module BABYLON {
  146855. /**
  146856. * Class containing static functions to help procedurally build meshes
  146857. */
  146858. export class TorusKnotBuilder {
  146859. /**
  146860. * Creates a torus knot mesh
  146861. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146862. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146863. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146864. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146868. * @param name defines the name of the mesh
  146869. * @param options defines the options used to create the mesh
  146870. * @param scene defines the hosting scene
  146871. * @returns the torus knot mesh
  146872. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146873. */
  146874. static CreateTorusKnot(name: string, options: {
  146875. radius?: number;
  146876. tube?: number;
  146877. radialSegments?: number;
  146878. tubularSegments?: number;
  146879. p?: number;
  146880. q?: number;
  146881. updatable?: boolean;
  146882. sideOrientation?: number;
  146883. frontUVs?: Vector4;
  146884. backUVs?: Vector4;
  146885. }, scene: any): Mesh;
  146886. }
  146887. }
  146888. declare module BABYLON {
  146889. /**
  146890. * Polygon
  146891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146892. */
  146893. export class Polygon {
  146894. /**
  146895. * Creates a rectangle
  146896. * @param xmin bottom X coord
  146897. * @param ymin bottom Y coord
  146898. * @param xmax top X coord
  146899. * @param ymax top Y coord
  146900. * @returns points that make the resulting rectation
  146901. */
  146902. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146903. /**
  146904. * Creates a circle
  146905. * @param radius radius of circle
  146906. * @param cx scale in x
  146907. * @param cy scale in y
  146908. * @param numberOfSides number of sides that make up the circle
  146909. * @returns points that make the resulting circle
  146910. */
  146911. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146912. /**
  146913. * Creates a polygon from input string
  146914. * @param input Input polygon data
  146915. * @returns the parsed points
  146916. */
  146917. static Parse(input: string): Vector2[];
  146918. /**
  146919. * Starts building a polygon from x and y coordinates
  146920. * @param x x coordinate
  146921. * @param y y coordinate
  146922. * @returns the started path2
  146923. */
  146924. static StartingAt(x: number, y: number): Path2;
  146925. }
  146926. /**
  146927. * Builds a polygon
  146928. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146929. */
  146930. export class PolygonMeshBuilder {
  146931. private _points;
  146932. private _outlinepoints;
  146933. private _holes;
  146934. private _name;
  146935. private _scene;
  146936. private _epoints;
  146937. private _eholes;
  146938. private _addToepoint;
  146939. /**
  146940. * Babylon reference to the earcut plugin.
  146941. */
  146942. bjsEarcut: any;
  146943. /**
  146944. * Creates a PolygonMeshBuilder
  146945. * @param name name of the builder
  146946. * @param contours Path of the polygon
  146947. * @param scene scene to add to when creating the mesh
  146948. * @param earcutInjection can be used to inject your own earcut reference
  146949. */
  146950. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146951. /**
  146952. * Adds a whole within the polygon
  146953. * @param hole Array of points defining the hole
  146954. * @returns this
  146955. */
  146956. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146957. /**
  146958. * Creates the polygon
  146959. * @param updatable If the mesh should be updatable
  146960. * @param depth The depth of the mesh created
  146961. * @returns the created mesh
  146962. */
  146963. build(updatable?: boolean, depth?: number): Mesh;
  146964. /**
  146965. * Creates the polygon
  146966. * @param depth The depth of the mesh created
  146967. * @returns the created VertexData
  146968. */
  146969. buildVertexData(depth?: number): VertexData;
  146970. /**
  146971. * Adds a side to the polygon
  146972. * @param positions points that make the polygon
  146973. * @param normals normals of the polygon
  146974. * @param uvs uvs of the polygon
  146975. * @param indices indices of the polygon
  146976. * @param bounds bounds of the polygon
  146977. * @param points points of the polygon
  146978. * @param depth depth of the polygon
  146979. * @param flip flip of the polygon
  146980. */
  146981. private addSide;
  146982. }
  146983. }
  146984. declare module BABYLON {
  146985. /**
  146986. * Class containing static functions to help procedurally build meshes
  146987. */
  146988. export class PolygonBuilder {
  146989. /**
  146990. * Creates a polygon mesh
  146991. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146992. * * 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
  146993. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146996. * * Remember you can only change the shape positions, not their number when updating a polygon
  146997. * @param name defines the name of the mesh
  146998. * @param options defines the options used to create the mesh
  146999. * @param scene defines the hosting scene
  147000. * @param earcutInjection can be used to inject your own earcut reference
  147001. * @returns the polygon mesh
  147002. */
  147003. static CreatePolygon(name: string, options: {
  147004. shape: Vector3[];
  147005. holes?: Vector3[][];
  147006. depth?: number;
  147007. faceUV?: Vector4[];
  147008. faceColors?: Color4[];
  147009. updatable?: boolean;
  147010. sideOrientation?: number;
  147011. frontUVs?: Vector4;
  147012. backUVs?: Vector4;
  147013. wrap?: boolean;
  147014. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147015. /**
  147016. * Creates an extruded polygon mesh, with depth in the Y direction.
  147017. * * 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)
  147018. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147019. * @param name defines the name of the mesh
  147020. * @param options defines the options used to create the mesh
  147021. * @param scene defines the hosting scene
  147022. * @param earcutInjection can be used to inject your own earcut reference
  147023. * @returns the polygon mesh
  147024. */
  147025. static ExtrudePolygon(name: string, options: {
  147026. shape: Vector3[];
  147027. holes?: Vector3[][];
  147028. depth?: number;
  147029. faceUV?: Vector4[];
  147030. faceColors?: Color4[];
  147031. updatable?: boolean;
  147032. sideOrientation?: number;
  147033. frontUVs?: Vector4;
  147034. backUVs?: Vector4;
  147035. wrap?: boolean;
  147036. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147037. }
  147038. }
  147039. declare module BABYLON {
  147040. /**
  147041. * Class containing static functions to help procedurally build meshes
  147042. */
  147043. export class LatheBuilder {
  147044. /**
  147045. * Creates lathe mesh.
  147046. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147047. * * 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
  147048. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147049. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147050. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147051. * * 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
  147052. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147053. * * 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
  147054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147058. * @param name defines the name of the mesh
  147059. * @param options defines the options used to create the mesh
  147060. * @param scene defines the hosting scene
  147061. * @returns the lathe mesh
  147062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147063. */
  147064. static CreateLathe(name: string, options: {
  147065. shape: Vector3[];
  147066. radius?: number;
  147067. tessellation?: number;
  147068. clip?: number;
  147069. arc?: number;
  147070. closed?: boolean;
  147071. updatable?: boolean;
  147072. sideOrientation?: number;
  147073. frontUVs?: Vector4;
  147074. backUVs?: Vector4;
  147075. cap?: number;
  147076. invertUV?: boolean;
  147077. }, scene?: Nullable<Scene>): Mesh;
  147078. }
  147079. }
  147080. declare module BABYLON {
  147081. /**
  147082. * Class containing static functions to help procedurally build meshes
  147083. */
  147084. export class TiledPlaneBuilder {
  147085. /**
  147086. * Creates a tiled plane mesh
  147087. * * The parameter `pattern` will, depending on value, do nothing or
  147088. * * * flip (reflect about central vertical) alternate tiles across and up
  147089. * * * flip every tile on alternate rows
  147090. * * * rotate (180 degs) alternate tiles across and up
  147091. * * * rotate every tile on alternate rows
  147092. * * * flip and rotate alternate tiles across and up
  147093. * * * flip and rotate every tile on alternate rows
  147094. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147095. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147098. * * 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)
  147099. * * 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)
  147100. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147101. * @param name defines the name of the mesh
  147102. * @param options defines the options used to create the mesh
  147103. * @param scene defines the hosting scene
  147104. * @returns the box mesh
  147105. */
  147106. static CreateTiledPlane(name: string, options: {
  147107. pattern?: number;
  147108. tileSize?: number;
  147109. tileWidth?: number;
  147110. tileHeight?: number;
  147111. size?: number;
  147112. width?: number;
  147113. height?: number;
  147114. alignHorizontal?: number;
  147115. alignVertical?: number;
  147116. sideOrientation?: number;
  147117. frontUVs?: Vector4;
  147118. backUVs?: Vector4;
  147119. updatable?: boolean;
  147120. }, scene?: Nullable<Scene>): Mesh;
  147121. }
  147122. }
  147123. declare module BABYLON {
  147124. /**
  147125. * Class containing static functions to help procedurally build meshes
  147126. */
  147127. export class TubeBuilder {
  147128. /**
  147129. * Creates a tube mesh.
  147130. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147131. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147132. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147133. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147134. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147135. * * 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)
  147136. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147137. * * 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
  147138. * * 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
  147139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147143. * @param name defines the name of the mesh
  147144. * @param options defines the options used to create the mesh
  147145. * @param scene defines the hosting scene
  147146. * @returns the tube mesh
  147147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147148. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147149. */
  147150. static CreateTube(name: string, options: {
  147151. path: Vector3[];
  147152. radius?: number;
  147153. tessellation?: number;
  147154. radiusFunction?: {
  147155. (i: number, distance: number): number;
  147156. };
  147157. cap?: number;
  147158. arc?: number;
  147159. updatable?: boolean;
  147160. sideOrientation?: number;
  147161. frontUVs?: Vector4;
  147162. backUVs?: Vector4;
  147163. instance?: Mesh;
  147164. invertUV?: boolean;
  147165. }, scene?: Nullable<Scene>): Mesh;
  147166. }
  147167. }
  147168. declare module BABYLON {
  147169. /**
  147170. * Class containing static functions to help procedurally build meshes
  147171. */
  147172. export class IcoSphereBuilder {
  147173. /**
  147174. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147175. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147176. * * 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`)
  147177. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147178. * * 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
  147179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147182. * @param name defines the name of the mesh
  147183. * @param options defines the options used to create the mesh
  147184. * @param scene defines the hosting scene
  147185. * @returns the icosahedron mesh
  147186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147187. */
  147188. static CreateIcoSphere(name: string, options: {
  147189. radius?: number;
  147190. radiusX?: number;
  147191. radiusY?: number;
  147192. radiusZ?: number;
  147193. flat?: boolean;
  147194. subdivisions?: number;
  147195. sideOrientation?: number;
  147196. frontUVs?: Vector4;
  147197. backUVs?: Vector4;
  147198. updatable?: boolean;
  147199. }, scene?: Nullable<Scene>): Mesh;
  147200. }
  147201. }
  147202. declare module BABYLON {
  147203. /**
  147204. * Class containing static functions to help procedurally build meshes
  147205. */
  147206. export class DecalBuilder {
  147207. /**
  147208. * Creates a decal mesh.
  147209. * 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
  147210. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147211. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147212. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147213. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147214. * @param name defines the name of the mesh
  147215. * @param sourceMesh defines the mesh where the decal must be applied
  147216. * @param options defines the options used to create the mesh
  147217. * @param scene defines the hosting scene
  147218. * @returns the decal mesh
  147219. * @see https://doc.babylonjs.com/how_to/decals
  147220. */
  147221. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147222. position?: Vector3;
  147223. normal?: Vector3;
  147224. size?: Vector3;
  147225. angle?: number;
  147226. }): Mesh;
  147227. }
  147228. }
  147229. declare module BABYLON {
  147230. /**
  147231. * Class containing static functions to help procedurally build meshes
  147232. */
  147233. export class MeshBuilder {
  147234. /**
  147235. * Creates a box mesh
  147236. * * The parameter `size` sets the size (float) of each box side (default 1)
  147237. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147238. * * 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)
  147239. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147244. * @param name defines the name of the mesh
  147245. * @param options defines the options used to create the mesh
  147246. * @param scene defines the hosting scene
  147247. * @returns the box mesh
  147248. */
  147249. static CreateBox(name: string, options: {
  147250. size?: number;
  147251. width?: number;
  147252. height?: number;
  147253. depth?: number;
  147254. faceUV?: Vector4[];
  147255. faceColors?: Color4[];
  147256. sideOrientation?: number;
  147257. frontUVs?: Vector4;
  147258. backUVs?: Vector4;
  147259. wrap?: boolean;
  147260. topBaseAt?: number;
  147261. bottomBaseAt?: number;
  147262. updatable?: boolean;
  147263. }, scene?: Nullable<Scene>): Mesh;
  147264. /**
  147265. * Creates a tiled box mesh
  147266. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147268. * @param name defines the name of the mesh
  147269. * @param options defines the options used to create the mesh
  147270. * @param scene defines the hosting scene
  147271. * @returns the tiled box mesh
  147272. */
  147273. static CreateTiledBox(name: string, options: {
  147274. pattern?: number;
  147275. size?: number;
  147276. width?: number;
  147277. height?: number;
  147278. depth: number;
  147279. tileSize?: number;
  147280. tileWidth?: number;
  147281. tileHeight?: number;
  147282. faceUV?: Vector4[];
  147283. faceColors?: Color4[];
  147284. alignHorizontal?: number;
  147285. alignVertical?: number;
  147286. sideOrientation?: number;
  147287. updatable?: boolean;
  147288. }, scene?: Nullable<Scene>): Mesh;
  147289. /**
  147290. * Creates a sphere mesh
  147291. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147292. * * 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`)
  147293. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147294. * * 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
  147295. * * 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)
  147296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147299. * @param name defines the name of the mesh
  147300. * @param options defines the options used to create the mesh
  147301. * @param scene defines the hosting scene
  147302. * @returns the sphere mesh
  147303. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147304. */
  147305. static CreateSphere(name: string, options: {
  147306. segments?: number;
  147307. diameter?: number;
  147308. diameterX?: number;
  147309. diameterY?: number;
  147310. diameterZ?: number;
  147311. arc?: number;
  147312. slice?: number;
  147313. sideOrientation?: number;
  147314. frontUVs?: Vector4;
  147315. backUVs?: Vector4;
  147316. updatable?: boolean;
  147317. }, scene?: Nullable<Scene>): Mesh;
  147318. /**
  147319. * Creates a plane polygonal mesh. By default, this is a disc
  147320. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147321. * * 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
  147322. * * 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
  147323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147326. * @param name defines the name of the mesh
  147327. * @param options defines the options used to create the mesh
  147328. * @param scene defines the hosting scene
  147329. * @returns the plane polygonal mesh
  147330. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147331. */
  147332. static CreateDisc(name: string, options: {
  147333. radius?: number;
  147334. tessellation?: number;
  147335. arc?: number;
  147336. updatable?: boolean;
  147337. sideOrientation?: number;
  147338. frontUVs?: Vector4;
  147339. backUVs?: Vector4;
  147340. }, scene?: Nullable<Scene>): Mesh;
  147341. /**
  147342. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147343. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147344. * * 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`)
  147345. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147346. * * 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
  147347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147350. * @param name defines the name of the mesh
  147351. * @param options defines the options used to create the mesh
  147352. * @param scene defines the hosting scene
  147353. * @returns the icosahedron mesh
  147354. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147355. */
  147356. static CreateIcoSphere(name: string, options: {
  147357. radius?: number;
  147358. radiusX?: number;
  147359. radiusY?: number;
  147360. radiusZ?: number;
  147361. flat?: boolean;
  147362. subdivisions?: number;
  147363. sideOrientation?: number;
  147364. frontUVs?: Vector4;
  147365. backUVs?: Vector4;
  147366. updatable?: boolean;
  147367. }, scene?: Nullable<Scene>): Mesh;
  147368. /**
  147369. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147370. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147371. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147372. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147373. * * 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
  147374. * * 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
  147375. * * 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
  147376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147379. * * 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
  147380. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147381. * * 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
  147382. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147384. * @param name defines the name of the mesh
  147385. * @param options defines the options used to create the mesh
  147386. * @param scene defines the hosting scene
  147387. * @returns the ribbon mesh
  147388. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147390. */
  147391. static CreateRibbon(name: string, options: {
  147392. pathArray: Vector3[][];
  147393. closeArray?: boolean;
  147394. closePath?: boolean;
  147395. offset?: number;
  147396. updatable?: boolean;
  147397. sideOrientation?: number;
  147398. frontUVs?: Vector4;
  147399. backUVs?: Vector4;
  147400. instance?: Mesh;
  147401. invertUV?: boolean;
  147402. uvs?: Vector2[];
  147403. colors?: Color4[];
  147404. }, scene?: Nullable<Scene>): Mesh;
  147405. /**
  147406. * Creates a cylinder or a cone mesh
  147407. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147408. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147409. * * 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.
  147410. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147411. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147412. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147413. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147414. * * 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).
  147415. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147416. * * 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).
  147417. * * 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
  147418. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147419. * * 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
  147420. * * 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.
  147421. * * If `enclose` is false, a ring surface is one element.
  147422. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147423. * * 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
  147424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147427. * @param name defines the name of the mesh
  147428. * @param options defines the options used to create the mesh
  147429. * @param scene defines the hosting scene
  147430. * @returns the cylinder mesh
  147431. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147432. */
  147433. static CreateCylinder(name: string, options: {
  147434. height?: number;
  147435. diameterTop?: number;
  147436. diameterBottom?: number;
  147437. diameter?: number;
  147438. tessellation?: number;
  147439. subdivisions?: number;
  147440. arc?: number;
  147441. faceColors?: Color4[];
  147442. faceUV?: Vector4[];
  147443. updatable?: boolean;
  147444. hasRings?: boolean;
  147445. enclose?: boolean;
  147446. cap?: number;
  147447. sideOrientation?: number;
  147448. frontUVs?: Vector4;
  147449. backUVs?: Vector4;
  147450. }, scene?: Nullable<Scene>): Mesh;
  147451. /**
  147452. * Creates a torus mesh
  147453. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147454. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147455. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147459. * @param name defines the name of the mesh
  147460. * @param options defines the options used to create the mesh
  147461. * @param scene defines the hosting scene
  147462. * @returns the torus mesh
  147463. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147464. */
  147465. static CreateTorus(name: string, options: {
  147466. diameter?: number;
  147467. thickness?: number;
  147468. tessellation?: number;
  147469. updatable?: boolean;
  147470. sideOrientation?: number;
  147471. frontUVs?: Vector4;
  147472. backUVs?: Vector4;
  147473. }, scene?: Nullable<Scene>): Mesh;
  147474. /**
  147475. * Creates a torus knot mesh
  147476. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147477. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147478. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147479. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147483. * @param name defines the name of the mesh
  147484. * @param options defines the options used to create the mesh
  147485. * @param scene defines the hosting scene
  147486. * @returns the torus knot mesh
  147487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147488. */
  147489. static CreateTorusKnot(name: string, options: {
  147490. radius?: number;
  147491. tube?: number;
  147492. radialSegments?: number;
  147493. tubularSegments?: number;
  147494. p?: number;
  147495. q?: number;
  147496. updatable?: boolean;
  147497. sideOrientation?: number;
  147498. frontUVs?: Vector4;
  147499. backUVs?: Vector4;
  147500. }, scene?: Nullable<Scene>): Mesh;
  147501. /**
  147502. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147503. * * 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
  147504. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147505. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147506. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147507. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147508. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147509. * * 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
  147510. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147513. * @param name defines the name of the new line system
  147514. * @param options defines the options used to create the line system
  147515. * @param scene defines the hosting scene
  147516. * @returns a new line system mesh
  147517. */
  147518. static CreateLineSystem(name: string, options: {
  147519. lines: Vector3[][];
  147520. updatable?: boolean;
  147521. instance?: Nullable<LinesMesh>;
  147522. colors?: Nullable<Color4[][]>;
  147523. useVertexAlpha?: boolean;
  147524. }, scene: Nullable<Scene>): LinesMesh;
  147525. /**
  147526. * Creates a line mesh
  147527. * 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
  147528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147529. * * The parameter `points` is an array successive Vector3
  147530. * * 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
  147531. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147532. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147533. * * When updating an instance, remember that only point positions can change, not the number of points
  147534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147536. * @param name defines the name of the new line system
  147537. * @param options defines the options used to create the line system
  147538. * @param scene defines the hosting scene
  147539. * @returns a new line mesh
  147540. */
  147541. static CreateLines(name: string, options: {
  147542. points: Vector3[];
  147543. updatable?: boolean;
  147544. instance?: Nullable<LinesMesh>;
  147545. colors?: Color4[];
  147546. useVertexAlpha?: boolean;
  147547. }, scene?: Nullable<Scene>): LinesMesh;
  147548. /**
  147549. * Creates a dashed line mesh
  147550. * * 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
  147551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147552. * * The parameter `points` is an array successive Vector3
  147553. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147554. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147555. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147556. * * 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
  147557. * * When updating an instance, remember that only point positions can change, not the number of points
  147558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147559. * @param name defines the name of the mesh
  147560. * @param options defines the options used to create the mesh
  147561. * @param scene defines the hosting scene
  147562. * @returns the dashed line mesh
  147563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147564. */
  147565. static CreateDashedLines(name: string, options: {
  147566. points: Vector3[];
  147567. dashSize?: number;
  147568. gapSize?: number;
  147569. dashNb?: number;
  147570. updatable?: boolean;
  147571. instance?: LinesMesh;
  147572. }, scene?: Nullable<Scene>): LinesMesh;
  147573. /**
  147574. * 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.
  147575. * * 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.
  147576. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147577. * * 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.
  147578. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147579. * * 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
  147580. * * 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
  147581. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147586. * @param name defines the name of the mesh
  147587. * @param options defines the options used to create the mesh
  147588. * @param scene defines the hosting scene
  147589. * @returns the extruded shape mesh
  147590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147592. */
  147593. static ExtrudeShape(name: string, options: {
  147594. shape: Vector3[];
  147595. path: Vector3[];
  147596. scale?: number;
  147597. rotation?: number;
  147598. cap?: number;
  147599. updatable?: boolean;
  147600. sideOrientation?: number;
  147601. frontUVs?: Vector4;
  147602. backUVs?: Vector4;
  147603. instance?: Mesh;
  147604. invertUV?: boolean;
  147605. }, scene?: Nullable<Scene>): Mesh;
  147606. /**
  147607. * Creates an custom extruded shape mesh.
  147608. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147609. * * 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.
  147610. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147611. * * 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
  147612. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147613. * * 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
  147614. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147615. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147616. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147617. * * 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
  147618. * * 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
  147619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147624. * @param name defines the name of the mesh
  147625. * @param options defines the options used to create the mesh
  147626. * @param scene defines the hosting scene
  147627. * @returns the custom extruded shape mesh
  147628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147631. */
  147632. static ExtrudeShapeCustom(name: string, options: {
  147633. shape: Vector3[];
  147634. path: Vector3[];
  147635. scaleFunction?: any;
  147636. rotationFunction?: any;
  147637. ribbonCloseArray?: boolean;
  147638. ribbonClosePath?: boolean;
  147639. cap?: number;
  147640. updatable?: boolean;
  147641. sideOrientation?: number;
  147642. frontUVs?: Vector4;
  147643. backUVs?: Vector4;
  147644. instance?: Mesh;
  147645. invertUV?: boolean;
  147646. }, scene?: Nullable<Scene>): Mesh;
  147647. /**
  147648. * Creates lathe mesh.
  147649. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147650. * * 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
  147651. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147652. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147653. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147654. * * 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
  147655. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147656. * * 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
  147657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147661. * @param name defines the name of the mesh
  147662. * @param options defines the options used to create the mesh
  147663. * @param scene defines the hosting scene
  147664. * @returns the lathe mesh
  147665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147666. */
  147667. static CreateLathe(name: string, options: {
  147668. shape: Vector3[];
  147669. radius?: number;
  147670. tessellation?: number;
  147671. clip?: number;
  147672. arc?: number;
  147673. closed?: boolean;
  147674. updatable?: boolean;
  147675. sideOrientation?: number;
  147676. frontUVs?: Vector4;
  147677. backUVs?: Vector4;
  147678. cap?: number;
  147679. invertUV?: boolean;
  147680. }, scene?: Nullable<Scene>): Mesh;
  147681. /**
  147682. * Creates a tiled plane mesh
  147683. * * You can set a limited pattern arrangement with the tiles
  147684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147687. * @param name defines the name of the mesh
  147688. * @param options defines the options used to create the mesh
  147689. * @param scene defines the hosting scene
  147690. * @returns the plane mesh
  147691. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147692. */
  147693. static CreateTiledPlane(name: string, options: {
  147694. pattern?: number;
  147695. tileSize?: number;
  147696. tileWidth?: number;
  147697. tileHeight?: number;
  147698. size?: number;
  147699. width?: number;
  147700. height?: number;
  147701. alignHorizontal?: number;
  147702. alignVertical?: number;
  147703. sideOrientation?: number;
  147704. frontUVs?: Vector4;
  147705. backUVs?: Vector4;
  147706. updatable?: boolean;
  147707. }, scene?: Nullable<Scene>): Mesh;
  147708. /**
  147709. * Creates a plane mesh
  147710. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147711. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147712. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147716. * @param name defines the name of the mesh
  147717. * @param options defines the options used to create the mesh
  147718. * @param scene defines the hosting scene
  147719. * @returns the plane mesh
  147720. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147721. */
  147722. static CreatePlane(name: string, options: {
  147723. size?: number;
  147724. width?: number;
  147725. height?: number;
  147726. sideOrientation?: number;
  147727. frontUVs?: Vector4;
  147728. backUVs?: Vector4;
  147729. updatable?: boolean;
  147730. sourcePlane?: Plane;
  147731. }, scene?: Nullable<Scene>): Mesh;
  147732. /**
  147733. * Creates a ground mesh
  147734. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147735. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147737. * @param name defines the name of the mesh
  147738. * @param options defines the options used to create the mesh
  147739. * @param scene defines the hosting scene
  147740. * @returns the ground mesh
  147741. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147742. */
  147743. static CreateGround(name: string, options: {
  147744. width?: number;
  147745. height?: number;
  147746. subdivisions?: number;
  147747. subdivisionsX?: number;
  147748. subdivisionsY?: number;
  147749. updatable?: boolean;
  147750. }, scene?: Nullable<Scene>): Mesh;
  147751. /**
  147752. * Creates a tiled ground mesh
  147753. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147754. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147755. * * 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
  147756. * * 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
  147757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147758. * @param name defines the name of the mesh
  147759. * @param options defines the options used to create the mesh
  147760. * @param scene defines the hosting scene
  147761. * @returns the tiled ground mesh
  147762. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147763. */
  147764. static CreateTiledGround(name: string, options: {
  147765. xmin: number;
  147766. zmin: number;
  147767. xmax: number;
  147768. zmax: number;
  147769. subdivisions?: {
  147770. w: number;
  147771. h: number;
  147772. };
  147773. precision?: {
  147774. w: number;
  147775. h: number;
  147776. };
  147777. updatable?: boolean;
  147778. }, scene?: Nullable<Scene>): Mesh;
  147779. /**
  147780. * Creates a ground mesh from a height map
  147781. * * The parameter `url` sets the URL of the height map image resource.
  147782. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147783. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147784. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147785. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147786. * * 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.
  147787. * * 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).
  147788. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147790. * @param name defines the name of the mesh
  147791. * @param url defines the url to the height map
  147792. * @param options defines the options used to create the mesh
  147793. * @param scene defines the hosting scene
  147794. * @returns the ground mesh
  147795. * @see https://doc.babylonjs.com/babylon101/height_map
  147796. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147797. */
  147798. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147799. width?: number;
  147800. height?: number;
  147801. subdivisions?: number;
  147802. minHeight?: number;
  147803. maxHeight?: number;
  147804. colorFilter?: Color3;
  147805. alphaFilter?: number;
  147806. updatable?: boolean;
  147807. onReady?: (mesh: GroundMesh) => void;
  147808. }, scene?: Nullable<Scene>): GroundMesh;
  147809. /**
  147810. * Creates a polygon mesh
  147811. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147812. * * 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
  147813. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147816. * * Remember you can only change the shape positions, not their number when updating a polygon
  147817. * @param name defines the name of the mesh
  147818. * @param options defines the options used to create the mesh
  147819. * @param scene defines the hosting scene
  147820. * @param earcutInjection can be used to inject your own earcut reference
  147821. * @returns the polygon mesh
  147822. */
  147823. static CreatePolygon(name: string, options: {
  147824. shape: Vector3[];
  147825. holes?: Vector3[][];
  147826. depth?: number;
  147827. faceUV?: Vector4[];
  147828. faceColors?: Color4[];
  147829. updatable?: boolean;
  147830. sideOrientation?: number;
  147831. frontUVs?: Vector4;
  147832. backUVs?: Vector4;
  147833. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147834. /**
  147835. * Creates an extruded polygon mesh, with depth in the Y direction.
  147836. * * 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)
  147837. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147838. * @param name defines the name of the mesh
  147839. * @param options defines the options used to create the mesh
  147840. * @param scene defines the hosting scene
  147841. * @param earcutInjection can be used to inject your own earcut reference
  147842. * @returns the polygon mesh
  147843. */
  147844. static ExtrudePolygon(name: string, options: {
  147845. shape: Vector3[];
  147846. holes?: Vector3[][];
  147847. depth?: number;
  147848. faceUV?: Vector4[];
  147849. faceColors?: Color4[];
  147850. updatable?: boolean;
  147851. sideOrientation?: number;
  147852. frontUVs?: Vector4;
  147853. backUVs?: Vector4;
  147854. wrap?: boolean;
  147855. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147856. /**
  147857. * Creates a tube mesh.
  147858. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147859. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147860. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147861. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147862. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147863. * * 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)
  147864. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147865. * * 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
  147866. * * 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
  147867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147871. * @param name defines the name of the mesh
  147872. * @param options defines the options used to create the mesh
  147873. * @param scene defines the hosting scene
  147874. * @returns the tube mesh
  147875. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147876. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147877. */
  147878. static CreateTube(name: string, options: {
  147879. path: Vector3[];
  147880. radius?: number;
  147881. tessellation?: number;
  147882. radiusFunction?: {
  147883. (i: number, distance: number): number;
  147884. };
  147885. cap?: number;
  147886. arc?: number;
  147887. updatable?: boolean;
  147888. sideOrientation?: number;
  147889. frontUVs?: Vector4;
  147890. backUVs?: Vector4;
  147891. instance?: Mesh;
  147892. invertUV?: boolean;
  147893. }, scene?: Nullable<Scene>): Mesh;
  147894. /**
  147895. * Creates a polyhedron mesh
  147896. * * 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
  147897. * * The parameter `size` (positive float, default 1) sets the polygon size
  147898. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147899. * * 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`
  147900. * * 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
  147901. * * 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)`)
  147902. * * 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
  147903. * * 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
  147904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147907. * @param name defines the name of the mesh
  147908. * @param options defines the options used to create the mesh
  147909. * @param scene defines the hosting scene
  147910. * @returns the polyhedron mesh
  147911. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147912. */
  147913. static CreatePolyhedron(name: string, options: {
  147914. type?: number;
  147915. size?: number;
  147916. sizeX?: number;
  147917. sizeY?: number;
  147918. sizeZ?: number;
  147919. custom?: any;
  147920. faceUV?: Vector4[];
  147921. faceColors?: Color4[];
  147922. flat?: boolean;
  147923. updatable?: boolean;
  147924. sideOrientation?: number;
  147925. frontUVs?: Vector4;
  147926. backUVs?: Vector4;
  147927. }, scene?: Nullable<Scene>): Mesh;
  147928. /**
  147929. * Creates a decal mesh.
  147930. * 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
  147931. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147932. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147933. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147934. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147935. * @param name defines the name of the mesh
  147936. * @param sourceMesh defines the mesh where the decal must be applied
  147937. * @param options defines the options used to create the mesh
  147938. * @param scene defines the hosting scene
  147939. * @returns the decal mesh
  147940. * @see https://doc.babylonjs.com/how_to/decals
  147941. */
  147942. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147943. position?: Vector3;
  147944. normal?: Vector3;
  147945. size?: Vector3;
  147946. angle?: number;
  147947. }): Mesh;
  147948. /**
  147949. * Creates a Capsule Mesh
  147950. * @param name defines the name of the mesh.
  147951. * @param options the constructors options used to shape the mesh.
  147952. * @param scene defines the scene the mesh is scoped to.
  147953. * @returns the capsule mesh
  147954. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147955. */
  147956. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147957. }
  147958. }
  147959. declare module BABYLON {
  147960. /**
  147961. * A simplifier interface for future simplification implementations
  147962. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147963. */
  147964. export interface ISimplifier {
  147965. /**
  147966. * Simplification of a given mesh according to the given settings.
  147967. * Since this requires computation, it is assumed that the function runs async.
  147968. * @param settings The settings of the simplification, including quality and distance
  147969. * @param successCallback A callback that will be called after the mesh was simplified.
  147970. * @param errorCallback in case of an error, this callback will be called. optional.
  147971. */
  147972. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147973. }
  147974. /**
  147975. * Expected simplification settings.
  147976. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147977. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147978. */
  147979. export interface ISimplificationSettings {
  147980. /**
  147981. * Gets or sets the expected quality
  147982. */
  147983. quality: number;
  147984. /**
  147985. * Gets or sets the distance when this optimized version should be used
  147986. */
  147987. distance: number;
  147988. /**
  147989. * Gets an already optimized mesh
  147990. */
  147991. optimizeMesh?: boolean;
  147992. }
  147993. /**
  147994. * Class used to specify simplification options
  147995. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147996. */
  147997. export class SimplificationSettings implements ISimplificationSettings {
  147998. /** expected quality */
  147999. quality: number;
  148000. /** distance when this optimized version should be used */
  148001. distance: number;
  148002. /** already optimized mesh */
  148003. optimizeMesh?: boolean | undefined;
  148004. /**
  148005. * Creates a SimplificationSettings
  148006. * @param quality expected quality
  148007. * @param distance distance when this optimized version should be used
  148008. * @param optimizeMesh already optimized mesh
  148009. */
  148010. constructor(
  148011. /** expected quality */
  148012. quality: number,
  148013. /** distance when this optimized version should be used */
  148014. distance: number,
  148015. /** already optimized mesh */
  148016. optimizeMesh?: boolean | undefined);
  148017. }
  148018. /**
  148019. * Interface used to define a simplification task
  148020. */
  148021. export interface ISimplificationTask {
  148022. /**
  148023. * Array of settings
  148024. */
  148025. settings: Array<ISimplificationSettings>;
  148026. /**
  148027. * Simplification type
  148028. */
  148029. simplificationType: SimplificationType;
  148030. /**
  148031. * Mesh to simplify
  148032. */
  148033. mesh: Mesh;
  148034. /**
  148035. * Callback called on success
  148036. */
  148037. successCallback?: () => void;
  148038. /**
  148039. * Defines if parallel processing can be used
  148040. */
  148041. parallelProcessing: boolean;
  148042. }
  148043. /**
  148044. * Queue used to order the simplification tasks
  148045. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148046. */
  148047. export class SimplificationQueue {
  148048. private _simplificationArray;
  148049. /**
  148050. * Gets a boolean indicating that the process is still running
  148051. */
  148052. running: boolean;
  148053. /**
  148054. * Creates a new queue
  148055. */
  148056. constructor();
  148057. /**
  148058. * Adds a new simplification task
  148059. * @param task defines a task to add
  148060. */
  148061. addTask(task: ISimplificationTask): void;
  148062. /**
  148063. * Execute next task
  148064. */
  148065. executeNext(): void;
  148066. /**
  148067. * Execute a simplification task
  148068. * @param task defines the task to run
  148069. */
  148070. runSimplification(task: ISimplificationTask): void;
  148071. private getSimplifier;
  148072. }
  148073. /**
  148074. * The implemented types of simplification
  148075. * At the moment only Quadratic Error Decimation is implemented
  148076. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148077. */
  148078. export enum SimplificationType {
  148079. /** Quadratic error decimation */
  148080. QUADRATIC = 0
  148081. }
  148082. /**
  148083. * An implementation of the Quadratic Error simplification algorithm.
  148084. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148085. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148086. * @author RaananW
  148087. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148088. */
  148089. export class QuadraticErrorSimplification implements ISimplifier {
  148090. private _mesh;
  148091. private triangles;
  148092. private vertices;
  148093. private references;
  148094. private _reconstructedMesh;
  148095. /** Gets or sets the number pf sync interations */
  148096. syncIterations: number;
  148097. /** Gets or sets the aggressiveness of the simplifier */
  148098. aggressiveness: number;
  148099. /** Gets or sets the number of allowed iterations for decimation */
  148100. decimationIterations: number;
  148101. /** Gets or sets the espilon to use for bounding box computation */
  148102. boundingBoxEpsilon: number;
  148103. /**
  148104. * Creates a new QuadraticErrorSimplification
  148105. * @param _mesh defines the target mesh
  148106. */
  148107. constructor(_mesh: Mesh);
  148108. /**
  148109. * Simplification of a given mesh according to the given settings.
  148110. * Since this requires computation, it is assumed that the function runs async.
  148111. * @param settings The settings of the simplification, including quality and distance
  148112. * @param successCallback A callback that will be called after the mesh was simplified.
  148113. */
  148114. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148115. private runDecimation;
  148116. private initWithMesh;
  148117. private init;
  148118. private reconstructMesh;
  148119. private initDecimatedMesh;
  148120. private isFlipped;
  148121. private updateTriangles;
  148122. private identifyBorder;
  148123. private updateMesh;
  148124. private vertexError;
  148125. private calculateError;
  148126. }
  148127. }
  148128. declare module BABYLON {
  148129. interface Scene {
  148130. /** @hidden (Backing field) */
  148131. _simplificationQueue: SimplificationQueue;
  148132. /**
  148133. * Gets or sets the simplification queue attached to the scene
  148134. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148135. */
  148136. simplificationQueue: SimplificationQueue;
  148137. }
  148138. interface Mesh {
  148139. /**
  148140. * Simplify the mesh according to the given array of settings.
  148141. * Function will return immediately and will simplify async
  148142. * @param settings a collection of simplification settings
  148143. * @param parallelProcessing should all levels calculate parallel or one after the other
  148144. * @param simplificationType the type of simplification to run
  148145. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148146. * @returns the current mesh
  148147. */
  148148. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148149. }
  148150. /**
  148151. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148152. * created in a scene
  148153. */
  148154. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148155. /**
  148156. * The component name helpfull to identify the component in the list of scene components.
  148157. */
  148158. readonly name: string;
  148159. /**
  148160. * The scene the component belongs to.
  148161. */
  148162. scene: Scene;
  148163. /**
  148164. * Creates a new instance of the component for the given scene
  148165. * @param scene Defines the scene to register the component in
  148166. */
  148167. constructor(scene: Scene);
  148168. /**
  148169. * Registers the component in a given scene
  148170. */
  148171. register(): void;
  148172. /**
  148173. * Rebuilds the elements related to this component in case of
  148174. * context lost for instance.
  148175. */
  148176. rebuild(): void;
  148177. /**
  148178. * Disposes the component and the associated ressources
  148179. */
  148180. dispose(): void;
  148181. private _beforeCameraUpdate;
  148182. }
  148183. }
  148184. declare module BABYLON {
  148185. interface Mesh {
  148186. /**
  148187. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148188. */
  148189. thinInstanceEnablePicking: boolean;
  148190. /**
  148191. * Creates a new thin instance
  148192. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148193. * @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
  148194. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148195. */
  148196. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148197. /**
  148198. * Adds the transformation (matrix) of the current mesh as a thin instance
  148199. * @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
  148200. * @returns the thin instance index number
  148201. */
  148202. thinInstanceAddSelf(refresh: boolean): number;
  148203. /**
  148204. * Registers a custom attribute to be used with thin instances
  148205. * @param kind name of the attribute
  148206. * @param stride size in floats of the attribute
  148207. */
  148208. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148209. /**
  148210. * Sets the matrix of a thin instance
  148211. * @param index index of the thin instance
  148212. * @param matrix matrix to set
  148213. * @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
  148214. */
  148215. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148216. /**
  148217. * Sets the value of a custom attribute for a thin instance
  148218. * @param kind name of the attribute
  148219. * @param index index of the thin instance
  148220. * @param value value to set
  148221. * @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
  148222. */
  148223. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148224. /**
  148225. * 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.
  148226. */
  148227. thinInstanceCount: number;
  148228. /**
  148229. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148230. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148231. * @param buffer buffer to set
  148232. * @param stride size in floats of each value of the buffer
  148233. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148234. */
  148235. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148236. /**
  148237. * Gets the list of world matrices
  148238. * @return an array containing all the world matrices from the thin instances
  148239. */
  148240. thinInstanceGetWorldMatrices(): Matrix[];
  148241. /**
  148242. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148243. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148244. */
  148245. thinInstanceBufferUpdated(kind: string): void;
  148246. /**
  148247. * Applies a partial update to a buffer directly on the GPU
  148248. * 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
  148249. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148250. * @param data the data to set in the GPU buffer
  148251. * @param offset the offset in the GPU buffer where to update the data
  148252. */
  148253. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148254. /**
  148255. * Refreshes the bounding info, taking into account all the thin instances defined
  148256. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148257. */
  148258. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148259. /** @hidden */
  148260. _thinInstanceInitializeUserStorage(): void;
  148261. /** @hidden */
  148262. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148263. /** @hidden */
  148264. _userThinInstanceBuffersStorage: {
  148265. data: {
  148266. [key: string]: Float32Array;
  148267. };
  148268. sizes: {
  148269. [key: string]: number;
  148270. };
  148271. vertexBuffers: {
  148272. [key: string]: Nullable<VertexBuffer>;
  148273. };
  148274. strides: {
  148275. [key: string]: number;
  148276. };
  148277. };
  148278. }
  148279. }
  148280. declare module BABYLON {
  148281. /**
  148282. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148283. */
  148284. export interface INavigationEnginePlugin {
  148285. /**
  148286. * plugin name
  148287. */
  148288. name: string;
  148289. /**
  148290. * Creates a navigation mesh
  148291. * @param meshes array of all the geometry used to compute the navigatio mesh
  148292. * @param parameters bunch of parameters used to filter geometry
  148293. */
  148294. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148295. /**
  148296. * Create a navigation mesh debug mesh
  148297. * @param scene is where the mesh will be added
  148298. * @returns debug display mesh
  148299. */
  148300. createDebugNavMesh(scene: Scene): Mesh;
  148301. /**
  148302. * Get a navigation mesh constrained position, closest to the parameter position
  148303. * @param position world position
  148304. * @returns the closest point to position constrained by the navigation mesh
  148305. */
  148306. getClosestPoint(position: Vector3): Vector3;
  148307. /**
  148308. * Get a navigation mesh constrained position, closest to the parameter position
  148309. * @param position world position
  148310. * @param result output the closest point to position constrained by the navigation mesh
  148311. */
  148312. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148313. /**
  148314. * Get a navigation mesh constrained position, within a particular radius
  148315. * @param position world position
  148316. * @param maxRadius the maximum distance to the constrained world position
  148317. * @returns the closest point to position constrained by the navigation mesh
  148318. */
  148319. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148320. /**
  148321. * Get a navigation mesh constrained position, within a particular radius
  148322. * @param position world position
  148323. * @param maxRadius the maximum distance to the constrained world position
  148324. * @param result output the closest point to position constrained by the navigation mesh
  148325. */
  148326. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148327. /**
  148328. * Compute the final position from a segment made of destination-position
  148329. * @param position world position
  148330. * @param destination world position
  148331. * @returns the resulting point along the navmesh
  148332. */
  148333. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148334. /**
  148335. * Compute the final position from a segment made of destination-position
  148336. * @param position world position
  148337. * @param destination world position
  148338. * @param result output the resulting point along the navmesh
  148339. */
  148340. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148341. /**
  148342. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148343. * @param start world position
  148344. * @param end world position
  148345. * @returns array containing world position composing the path
  148346. */
  148347. computePath(start: Vector3, end: Vector3): Vector3[];
  148348. /**
  148349. * If this plugin is supported
  148350. * @returns true if plugin is supported
  148351. */
  148352. isSupported(): boolean;
  148353. /**
  148354. * Create a new Crowd so you can add agents
  148355. * @param maxAgents the maximum agent count in the crowd
  148356. * @param maxAgentRadius the maximum radius an agent can have
  148357. * @param scene to attach the crowd to
  148358. * @returns the crowd you can add agents to
  148359. */
  148360. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148361. /**
  148362. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148363. * The queries will try to find a solution within those bounds
  148364. * default is (1,1,1)
  148365. * @param extent x,y,z value that define the extent around the queries point of reference
  148366. */
  148367. setDefaultQueryExtent(extent: Vector3): void;
  148368. /**
  148369. * Get the Bounding box extent specified by setDefaultQueryExtent
  148370. * @returns the box extent values
  148371. */
  148372. getDefaultQueryExtent(): Vector3;
  148373. /**
  148374. * build the navmesh from a previously saved state using getNavmeshData
  148375. * @param data the Uint8Array returned by getNavmeshData
  148376. */
  148377. buildFromNavmeshData(data: Uint8Array): void;
  148378. /**
  148379. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148380. * @returns data the Uint8Array that can be saved and reused
  148381. */
  148382. getNavmeshData(): Uint8Array;
  148383. /**
  148384. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148385. * @param result output the box extent values
  148386. */
  148387. getDefaultQueryExtentToRef(result: Vector3): void;
  148388. /**
  148389. * Release all resources
  148390. */
  148391. dispose(): void;
  148392. }
  148393. /**
  148394. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148395. */
  148396. export interface ICrowd {
  148397. /**
  148398. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148399. * You can attach anything to that node. The node position is updated in the scene update tick.
  148400. * @param pos world position that will be constrained by the navigation mesh
  148401. * @param parameters agent parameters
  148402. * @param transform hooked to the agent that will be update by the scene
  148403. * @returns agent index
  148404. */
  148405. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148406. /**
  148407. * Returns the agent position in world space
  148408. * @param index agent index returned by addAgent
  148409. * @returns world space position
  148410. */
  148411. getAgentPosition(index: number): Vector3;
  148412. /**
  148413. * Gets the agent position result in world space
  148414. * @param index agent index returned by addAgent
  148415. * @param result output world space position
  148416. */
  148417. getAgentPositionToRef(index: number, result: Vector3): void;
  148418. /**
  148419. * Gets the agent velocity in world space
  148420. * @param index agent index returned by addAgent
  148421. * @returns world space velocity
  148422. */
  148423. getAgentVelocity(index: number): Vector3;
  148424. /**
  148425. * Gets the agent velocity result in world space
  148426. * @param index agent index returned by addAgent
  148427. * @param result output world space velocity
  148428. */
  148429. getAgentVelocityToRef(index: number, result: Vector3): void;
  148430. /**
  148431. * remove a particular agent previously created
  148432. * @param index agent index returned by addAgent
  148433. */
  148434. removeAgent(index: number): void;
  148435. /**
  148436. * get the list of all agents attached to this crowd
  148437. * @returns list of agent indices
  148438. */
  148439. getAgents(): number[];
  148440. /**
  148441. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148442. * @param deltaTime in seconds
  148443. */
  148444. update(deltaTime: number): void;
  148445. /**
  148446. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148447. * @param index agent index returned by addAgent
  148448. * @param destination targeted world position
  148449. */
  148450. agentGoto(index: number, destination: Vector3): void;
  148451. /**
  148452. * Teleport the agent to a new position
  148453. * @param index agent index returned by addAgent
  148454. * @param destination targeted world position
  148455. */
  148456. agentTeleport(index: number, destination: Vector3): void;
  148457. /**
  148458. * Update agent parameters
  148459. * @param index agent index returned by addAgent
  148460. * @param parameters agent parameters
  148461. */
  148462. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148463. /**
  148464. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148465. * The queries will try to find a solution within those bounds
  148466. * default is (1,1,1)
  148467. * @param extent x,y,z value that define the extent around the queries point of reference
  148468. */
  148469. setDefaultQueryExtent(extent: Vector3): void;
  148470. /**
  148471. * Get the Bounding box extent specified by setDefaultQueryExtent
  148472. * @returns the box extent values
  148473. */
  148474. getDefaultQueryExtent(): Vector3;
  148475. /**
  148476. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148477. * @param result output the box extent values
  148478. */
  148479. getDefaultQueryExtentToRef(result: Vector3): void;
  148480. /**
  148481. * Release all resources
  148482. */
  148483. dispose(): void;
  148484. }
  148485. /**
  148486. * Configures an agent
  148487. */
  148488. export interface IAgentParameters {
  148489. /**
  148490. * Agent radius. [Limit: >= 0]
  148491. */
  148492. radius: number;
  148493. /**
  148494. * Agent height. [Limit: > 0]
  148495. */
  148496. height: number;
  148497. /**
  148498. * Maximum allowed acceleration. [Limit: >= 0]
  148499. */
  148500. maxAcceleration: number;
  148501. /**
  148502. * Maximum allowed speed. [Limit: >= 0]
  148503. */
  148504. maxSpeed: number;
  148505. /**
  148506. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148507. */
  148508. collisionQueryRange: number;
  148509. /**
  148510. * The path visibility optimization range. [Limit: > 0]
  148511. */
  148512. pathOptimizationRange: number;
  148513. /**
  148514. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148515. */
  148516. separationWeight: number;
  148517. }
  148518. /**
  148519. * Configures the navigation mesh creation
  148520. */
  148521. export interface INavMeshParameters {
  148522. /**
  148523. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148524. */
  148525. cs: number;
  148526. /**
  148527. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148528. */
  148529. ch: number;
  148530. /**
  148531. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148532. */
  148533. walkableSlopeAngle: number;
  148534. /**
  148535. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148536. * be considered walkable. [Limit: >= 3] [Units: vx]
  148537. */
  148538. walkableHeight: number;
  148539. /**
  148540. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148541. */
  148542. walkableClimb: number;
  148543. /**
  148544. * The distance to erode/shrink the walkable area of the heightfield away from
  148545. * obstructions. [Limit: >=0] [Units: vx]
  148546. */
  148547. walkableRadius: number;
  148548. /**
  148549. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148550. */
  148551. maxEdgeLen: number;
  148552. /**
  148553. * The maximum distance a simplfied contour's border edges should deviate
  148554. * the original raw contour. [Limit: >=0] [Units: vx]
  148555. */
  148556. maxSimplificationError: number;
  148557. /**
  148558. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148559. */
  148560. minRegionArea: number;
  148561. /**
  148562. * Any regions with a span count smaller than this value will, if possible,
  148563. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148564. */
  148565. mergeRegionArea: number;
  148566. /**
  148567. * The maximum number of vertices allowed for polygons generated during the
  148568. * contour to polygon conversion process. [Limit: >= 3]
  148569. */
  148570. maxVertsPerPoly: number;
  148571. /**
  148572. * Sets the sampling distance to use when generating the detail mesh.
  148573. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148574. */
  148575. detailSampleDist: number;
  148576. /**
  148577. * The maximum distance the detail mesh surface should deviate from heightfield
  148578. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148579. */
  148580. detailSampleMaxError: number;
  148581. }
  148582. }
  148583. declare module BABYLON {
  148584. /**
  148585. * RecastJS navigation plugin
  148586. */
  148587. export class RecastJSPlugin implements INavigationEnginePlugin {
  148588. /**
  148589. * Reference to the Recast library
  148590. */
  148591. bjsRECAST: any;
  148592. /**
  148593. * plugin name
  148594. */
  148595. name: string;
  148596. /**
  148597. * the first navmesh created. We might extend this to support multiple navmeshes
  148598. */
  148599. navMesh: any;
  148600. /**
  148601. * Initializes the recastJS plugin
  148602. * @param recastInjection can be used to inject your own recast reference
  148603. */
  148604. constructor(recastInjection?: any);
  148605. /**
  148606. * Creates a navigation mesh
  148607. * @param meshes array of all the geometry used to compute the navigatio mesh
  148608. * @param parameters bunch of parameters used to filter geometry
  148609. */
  148610. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148611. /**
  148612. * Create a navigation mesh debug mesh
  148613. * @param scene is where the mesh will be added
  148614. * @returns debug display mesh
  148615. */
  148616. createDebugNavMesh(scene: Scene): Mesh;
  148617. /**
  148618. * Get a navigation mesh constrained position, closest to the parameter position
  148619. * @param position world position
  148620. * @returns the closest point to position constrained by the navigation mesh
  148621. */
  148622. getClosestPoint(position: Vector3): Vector3;
  148623. /**
  148624. * Get a navigation mesh constrained position, closest to the parameter position
  148625. * @param position world position
  148626. * @param result output the closest point to position constrained by the navigation mesh
  148627. */
  148628. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148629. /**
  148630. * Get a navigation mesh constrained position, within a particular radius
  148631. * @param position world position
  148632. * @param maxRadius the maximum distance to the constrained world position
  148633. * @returns the closest point to position constrained by the navigation mesh
  148634. */
  148635. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148636. /**
  148637. * Get a navigation mesh constrained position, within a particular radius
  148638. * @param position world position
  148639. * @param maxRadius the maximum distance to the constrained world position
  148640. * @param result output the closest point to position constrained by the navigation mesh
  148641. */
  148642. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148643. /**
  148644. * Compute the final position from a segment made of destination-position
  148645. * @param position world position
  148646. * @param destination world position
  148647. * @returns the resulting point along the navmesh
  148648. */
  148649. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148650. /**
  148651. * Compute the final position from a segment made of destination-position
  148652. * @param position world position
  148653. * @param destination world position
  148654. * @param result output the resulting point along the navmesh
  148655. */
  148656. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148657. /**
  148658. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148659. * @param start world position
  148660. * @param end world position
  148661. * @returns array containing world position composing the path
  148662. */
  148663. computePath(start: Vector3, end: Vector3): Vector3[];
  148664. /**
  148665. * Create a new Crowd so you can add agents
  148666. * @param maxAgents the maximum agent count in the crowd
  148667. * @param maxAgentRadius the maximum radius an agent can have
  148668. * @param scene to attach the crowd to
  148669. * @returns the crowd you can add agents to
  148670. */
  148671. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148672. /**
  148673. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148674. * The queries will try to find a solution within those bounds
  148675. * default is (1,1,1)
  148676. * @param extent x,y,z value that define the extent around the queries point of reference
  148677. */
  148678. setDefaultQueryExtent(extent: Vector3): void;
  148679. /**
  148680. * Get the Bounding box extent specified by setDefaultQueryExtent
  148681. * @returns the box extent values
  148682. */
  148683. getDefaultQueryExtent(): Vector3;
  148684. /**
  148685. * build the navmesh from a previously saved state using getNavmeshData
  148686. * @param data the Uint8Array returned by getNavmeshData
  148687. */
  148688. buildFromNavmeshData(data: Uint8Array): void;
  148689. /**
  148690. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148691. * @returns data the Uint8Array that can be saved and reused
  148692. */
  148693. getNavmeshData(): Uint8Array;
  148694. /**
  148695. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148696. * @param result output the box extent values
  148697. */
  148698. getDefaultQueryExtentToRef(result: Vector3): void;
  148699. /**
  148700. * Disposes
  148701. */
  148702. dispose(): void;
  148703. /**
  148704. * If this plugin is supported
  148705. * @returns true if plugin is supported
  148706. */
  148707. isSupported(): boolean;
  148708. }
  148709. /**
  148710. * Recast detour crowd implementation
  148711. */
  148712. export class RecastJSCrowd implements ICrowd {
  148713. /**
  148714. * Recast/detour plugin
  148715. */
  148716. bjsRECASTPlugin: RecastJSPlugin;
  148717. /**
  148718. * Link to the detour crowd
  148719. */
  148720. recastCrowd: any;
  148721. /**
  148722. * One transform per agent
  148723. */
  148724. transforms: TransformNode[];
  148725. /**
  148726. * All agents created
  148727. */
  148728. agents: number[];
  148729. /**
  148730. * Link to the scene is kept to unregister the crowd from the scene
  148731. */
  148732. private _scene;
  148733. /**
  148734. * Observer for crowd updates
  148735. */
  148736. private _onBeforeAnimationsObserver;
  148737. /**
  148738. * Constructor
  148739. * @param plugin recastJS plugin
  148740. * @param maxAgents the maximum agent count in the crowd
  148741. * @param maxAgentRadius the maximum radius an agent can have
  148742. * @param scene to attach the crowd to
  148743. * @returns the crowd you can add agents to
  148744. */
  148745. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148746. /**
  148747. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148748. * You can attach anything to that node. The node position is updated in the scene update tick.
  148749. * @param pos world position that will be constrained by the navigation mesh
  148750. * @param parameters agent parameters
  148751. * @param transform hooked to the agent that will be update by the scene
  148752. * @returns agent index
  148753. */
  148754. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148755. /**
  148756. * Returns the agent position in world space
  148757. * @param index agent index returned by addAgent
  148758. * @returns world space position
  148759. */
  148760. getAgentPosition(index: number): Vector3;
  148761. /**
  148762. * Returns the agent position result in world space
  148763. * @param index agent index returned by addAgent
  148764. * @param result output world space position
  148765. */
  148766. getAgentPositionToRef(index: number, result: Vector3): void;
  148767. /**
  148768. * Returns the agent velocity in world space
  148769. * @param index agent index returned by addAgent
  148770. * @returns world space velocity
  148771. */
  148772. getAgentVelocity(index: number): Vector3;
  148773. /**
  148774. * Returns the agent velocity result in world space
  148775. * @param index agent index returned by addAgent
  148776. * @param result output world space velocity
  148777. */
  148778. getAgentVelocityToRef(index: number, result: Vector3): void;
  148779. /**
  148780. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148781. * @param index agent index returned by addAgent
  148782. * @param destination targeted world position
  148783. */
  148784. agentGoto(index: number, destination: Vector3): void;
  148785. /**
  148786. * Teleport the agent to a new position
  148787. * @param index agent index returned by addAgent
  148788. * @param destination targeted world position
  148789. */
  148790. agentTeleport(index: number, destination: Vector3): void;
  148791. /**
  148792. * Update agent parameters
  148793. * @param index agent index returned by addAgent
  148794. * @param parameters agent parameters
  148795. */
  148796. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148797. /**
  148798. * remove a particular agent previously created
  148799. * @param index agent index returned by addAgent
  148800. */
  148801. removeAgent(index: number): void;
  148802. /**
  148803. * get the list of all agents attached to this crowd
  148804. * @returns list of agent indices
  148805. */
  148806. getAgents(): number[];
  148807. /**
  148808. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148809. * @param deltaTime in seconds
  148810. */
  148811. update(deltaTime: number): void;
  148812. /**
  148813. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148814. * The queries will try to find a solution within those bounds
  148815. * default is (1,1,1)
  148816. * @param extent x,y,z value that define the extent around the queries point of reference
  148817. */
  148818. setDefaultQueryExtent(extent: Vector3): void;
  148819. /**
  148820. * Get the Bounding box extent specified by setDefaultQueryExtent
  148821. * @returns the box extent values
  148822. */
  148823. getDefaultQueryExtent(): Vector3;
  148824. /**
  148825. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148826. * @param result output the box extent values
  148827. */
  148828. getDefaultQueryExtentToRef(result: Vector3): void;
  148829. /**
  148830. * Release all resources
  148831. */
  148832. dispose(): void;
  148833. }
  148834. }
  148835. declare module BABYLON {
  148836. /**
  148837. * Class used to enable access to IndexedDB
  148838. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148839. */
  148840. export class Database implements IOfflineProvider {
  148841. private _callbackManifestChecked;
  148842. private _currentSceneUrl;
  148843. private _db;
  148844. private _enableSceneOffline;
  148845. private _enableTexturesOffline;
  148846. private _manifestVersionFound;
  148847. private _mustUpdateRessources;
  148848. private _hasReachedQuota;
  148849. private _isSupported;
  148850. private _idbFactory;
  148851. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148852. private static IsUASupportingBlobStorage;
  148853. /**
  148854. * Gets a boolean indicating if Database storate is enabled (off by default)
  148855. */
  148856. static IDBStorageEnabled: boolean;
  148857. /**
  148858. * Gets a boolean indicating if scene must be saved in the database
  148859. */
  148860. get enableSceneOffline(): boolean;
  148861. /**
  148862. * Gets a boolean indicating if textures must be saved in the database
  148863. */
  148864. get enableTexturesOffline(): boolean;
  148865. /**
  148866. * Creates a new Database
  148867. * @param urlToScene defines the url to load the scene
  148868. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148869. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148870. */
  148871. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148872. private static _ParseURL;
  148873. private static _ReturnFullUrlLocation;
  148874. private _checkManifestFile;
  148875. /**
  148876. * Open the database and make it available
  148877. * @param successCallback defines the callback to call on success
  148878. * @param errorCallback defines the callback to call on error
  148879. */
  148880. open(successCallback: () => void, errorCallback: () => void): void;
  148881. /**
  148882. * Loads an image from the database
  148883. * @param url defines the url to load from
  148884. * @param image defines the target DOM image
  148885. */
  148886. loadImage(url: string, image: HTMLImageElement): void;
  148887. private _loadImageFromDBAsync;
  148888. private _saveImageIntoDBAsync;
  148889. private _checkVersionFromDB;
  148890. private _loadVersionFromDBAsync;
  148891. private _saveVersionIntoDBAsync;
  148892. /**
  148893. * Loads a file from database
  148894. * @param url defines the URL to load from
  148895. * @param sceneLoaded defines a callback to call on success
  148896. * @param progressCallBack defines a callback to call when progress changed
  148897. * @param errorCallback defines a callback to call on error
  148898. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148899. */
  148900. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148901. private _loadFileAsync;
  148902. private _saveFileAsync;
  148903. /**
  148904. * Validates if xhr data is correct
  148905. * @param xhr defines the request to validate
  148906. * @param dataType defines the expected data type
  148907. * @returns true if data is correct
  148908. */
  148909. private static _ValidateXHRData;
  148910. }
  148911. }
  148912. declare module BABYLON {
  148913. /** @hidden */
  148914. export var gpuUpdateParticlesPixelShader: {
  148915. name: string;
  148916. shader: string;
  148917. };
  148918. }
  148919. declare module BABYLON {
  148920. /** @hidden */
  148921. export var gpuUpdateParticlesVertexShader: {
  148922. name: string;
  148923. shader: string;
  148924. };
  148925. }
  148926. declare module BABYLON {
  148927. /** @hidden */
  148928. export var clipPlaneFragmentDeclaration2: {
  148929. name: string;
  148930. shader: string;
  148931. };
  148932. }
  148933. declare module BABYLON {
  148934. /** @hidden */
  148935. export var gpuRenderParticlesPixelShader: {
  148936. name: string;
  148937. shader: string;
  148938. };
  148939. }
  148940. declare module BABYLON {
  148941. /** @hidden */
  148942. export var clipPlaneVertexDeclaration2: {
  148943. name: string;
  148944. shader: string;
  148945. };
  148946. }
  148947. declare module BABYLON {
  148948. /** @hidden */
  148949. export var gpuRenderParticlesVertexShader: {
  148950. name: string;
  148951. shader: string;
  148952. };
  148953. }
  148954. declare module BABYLON {
  148955. /**
  148956. * This represents a GPU particle system in Babylon
  148957. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148958. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148959. */
  148960. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148961. /**
  148962. * The layer mask we are rendering the particles through.
  148963. */
  148964. layerMask: number;
  148965. private _capacity;
  148966. private _activeCount;
  148967. private _currentActiveCount;
  148968. private _accumulatedCount;
  148969. private _renderEffect;
  148970. private _updateEffect;
  148971. private _buffer0;
  148972. private _buffer1;
  148973. private _spriteBuffer;
  148974. private _updateVAO;
  148975. private _renderVAO;
  148976. private _targetIndex;
  148977. private _sourceBuffer;
  148978. private _targetBuffer;
  148979. private _currentRenderId;
  148980. private _started;
  148981. private _stopped;
  148982. private _timeDelta;
  148983. private _randomTexture;
  148984. private _randomTexture2;
  148985. private _attributesStrideSize;
  148986. private _updateEffectOptions;
  148987. private _randomTextureSize;
  148988. private _actualFrame;
  148989. private _customEffect;
  148990. private readonly _rawTextureWidth;
  148991. /**
  148992. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148993. */
  148994. static get IsSupported(): boolean;
  148995. /**
  148996. * An event triggered when the system is disposed.
  148997. */
  148998. onDisposeObservable: Observable<IParticleSystem>;
  148999. /**
  149000. * An event triggered when the system is stopped
  149001. */
  149002. onStoppedObservable: Observable<IParticleSystem>;
  149003. /**
  149004. * Gets the maximum number of particles active at the same time.
  149005. * @returns The max number of active particles.
  149006. */
  149007. getCapacity(): number;
  149008. /**
  149009. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149010. * to override the particles.
  149011. */
  149012. forceDepthWrite: boolean;
  149013. /**
  149014. * Gets or set the number of active particles
  149015. */
  149016. get activeParticleCount(): number;
  149017. set activeParticleCount(value: number);
  149018. private _preWarmDone;
  149019. /**
  149020. * Specifies if the particles are updated in emitter local space or world space.
  149021. */
  149022. isLocal: boolean;
  149023. /** Gets or sets a matrix to use to compute projection */
  149024. defaultProjectionMatrix: Matrix;
  149025. /**
  149026. * Is this system ready to be used/rendered
  149027. * @return true if the system is ready
  149028. */
  149029. isReady(): boolean;
  149030. /**
  149031. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149032. * @returns True if it has been started, otherwise false.
  149033. */
  149034. isStarted(): boolean;
  149035. /**
  149036. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149037. * @returns True if it has been stopped, otherwise false.
  149038. */
  149039. isStopped(): boolean;
  149040. /**
  149041. * Gets a boolean indicating that the system is stopping
  149042. * @returns true if the system is currently stopping
  149043. */
  149044. isStopping(): boolean;
  149045. /**
  149046. * Gets the number of particles active at the same time.
  149047. * @returns The number of active particles.
  149048. */
  149049. getActiveCount(): number;
  149050. /**
  149051. * Starts the particle system and begins to emit
  149052. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149053. */
  149054. start(delay?: number): void;
  149055. /**
  149056. * Stops the particle system.
  149057. */
  149058. stop(): void;
  149059. /**
  149060. * Remove all active particles
  149061. */
  149062. reset(): void;
  149063. /**
  149064. * Returns the string "GPUParticleSystem"
  149065. * @returns a string containing the class name
  149066. */
  149067. getClassName(): string;
  149068. /**
  149069. * Gets the custom effect used to render the particles
  149070. * @param blendMode Blend mode for which the effect should be retrieved
  149071. * @returns The effect
  149072. */
  149073. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149074. /**
  149075. * Sets the custom effect used to render the particles
  149076. * @param effect The effect to set
  149077. * @param blendMode Blend mode for which the effect should be set
  149078. */
  149079. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149080. /** @hidden */
  149081. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149082. /**
  149083. * Observable that will be called just before the particles are drawn
  149084. */
  149085. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149086. /**
  149087. * Gets the name of the particle vertex shader
  149088. */
  149089. get vertexShaderName(): string;
  149090. private _colorGradientsTexture;
  149091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149092. /**
  149093. * Adds a new color gradient
  149094. * @param gradient defines the gradient to use (between 0 and 1)
  149095. * @param color1 defines the color to affect to the specified gradient
  149096. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149097. * @returns the current particle system
  149098. */
  149099. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149100. private _refreshColorGradient;
  149101. /** Force the system to rebuild all gradients that need to be resync */
  149102. forceRefreshGradients(): void;
  149103. /**
  149104. * Remove a specific color gradient
  149105. * @param gradient defines the gradient to remove
  149106. * @returns the current particle system
  149107. */
  149108. removeColorGradient(gradient: number): GPUParticleSystem;
  149109. private _angularSpeedGradientsTexture;
  149110. private _sizeGradientsTexture;
  149111. private _velocityGradientsTexture;
  149112. private _limitVelocityGradientsTexture;
  149113. private _dragGradientsTexture;
  149114. private _addFactorGradient;
  149115. /**
  149116. * Adds a new size gradient
  149117. * @param gradient defines the gradient to use (between 0 and 1)
  149118. * @param factor defines the size factor to affect to the specified gradient
  149119. * @returns the current particle system
  149120. */
  149121. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149122. /**
  149123. * Remove a specific size gradient
  149124. * @param gradient defines the gradient to remove
  149125. * @returns the current particle system
  149126. */
  149127. removeSizeGradient(gradient: number): GPUParticleSystem;
  149128. private _refreshFactorGradient;
  149129. /**
  149130. * Adds a new angular speed gradient
  149131. * @param gradient defines the gradient to use (between 0 and 1)
  149132. * @param factor defines the angular speed to affect to the specified gradient
  149133. * @returns the current particle system
  149134. */
  149135. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149136. /**
  149137. * Remove a specific angular speed gradient
  149138. * @param gradient defines the gradient to remove
  149139. * @returns the current particle system
  149140. */
  149141. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149142. /**
  149143. * Adds a new velocity gradient
  149144. * @param gradient defines the gradient to use (between 0 and 1)
  149145. * @param factor defines the velocity to affect to the specified gradient
  149146. * @returns the current particle system
  149147. */
  149148. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149149. /**
  149150. * Remove a specific velocity gradient
  149151. * @param gradient defines the gradient to remove
  149152. * @returns the current particle system
  149153. */
  149154. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149155. /**
  149156. * Adds a new limit velocity gradient
  149157. * @param gradient defines the gradient to use (between 0 and 1)
  149158. * @param factor defines the limit velocity value to affect to the specified gradient
  149159. * @returns the current particle system
  149160. */
  149161. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149162. /**
  149163. * Remove a specific limit velocity gradient
  149164. * @param gradient defines the gradient to remove
  149165. * @returns the current particle system
  149166. */
  149167. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149168. /**
  149169. * Adds a new drag gradient
  149170. * @param gradient defines the gradient to use (between 0 and 1)
  149171. * @param factor defines the drag value to affect to the specified gradient
  149172. * @returns the current particle system
  149173. */
  149174. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149175. /**
  149176. * Remove a specific drag gradient
  149177. * @param gradient defines the gradient to remove
  149178. * @returns the current particle system
  149179. */
  149180. removeDragGradient(gradient: number): GPUParticleSystem;
  149181. /**
  149182. * Not supported by GPUParticleSystem
  149183. * @param gradient defines the gradient to use (between 0 and 1)
  149184. * @param factor defines the emit rate value to affect to the specified gradient
  149185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149186. * @returns the current particle system
  149187. */
  149188. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149189. /**
  149190. * Not supported by GPUParticleSystem
  149191. * @param gradient defines the gradient to remove
  149192. * @returns the current particle system
  149193. */
  149194. removeEmitRateGradient(gradient: number): IParticleSystem;
  149195. /**
  149196. * Not supported by GPUParticleSystem
  149197. * @param gradient defines the gradient to use (between 0 and 1)
  149198. * @param factor defines the start size value to affect to the specified gradient
  149199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149200. * @returns the current particle system
  149201. */
  149202. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149203. /**
  149204. * Not supported by GPUParticleSystem
  149205. * @param gradient defines the gradient to remove
  149206. * @returns the current particle system
  149207. */
  149208. removeStartSizeGradient(gradient: number): IParticleSystem;
  149209. /**
  149210. * Not supported by GPUParticleSystem
  149211. * @param gradient defines the gradient to use (between 0 and 1)
  149212. * @param min defines the color remap minimal range
  149213. * @param max defines the color remap maximal range
  149214. * @returns the current particle system
  149215. */
  149216. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149217. /**
  149218. * Not supported by GPUParticleSystem
  149219. * @param gradient defines the gradient to remove
  149220. * @returns the current particle system
  149221. */
  149222. removeColorRemapGradient(): IParticleSystem;
  149223. /**
  149224. * Not supported by GPUParticleSystem
  149225. * @param gradient defines the gradient to use (between 0 and 1)
  149226. * @param min defines the alpha remap minimal range
  149227. * @param max defines the alpha remap maximal range
  149228. * @returns the current particle system
  149229. */
  149230. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149231. /**
  149232. * Not supported by GPUParticleSystem
  149233. * @param gradient defines the gradient to remove
  149234. * @returns the current particle system
  149235. */
  149236. removeAlphaRemapGradient(): IParticleSystem;
  149237. /**
  149238. * Not supported by GPUParticleSystem
  149239. * @param gradient defines the gradient to use (between 0 and 1)
  149240. * @param color defines the color to affect to the specified gradient
  149241. * @returns the current particle system
  149242. */
  149243. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149244. /**
  149245. * Not supported by GPUParticleSystem
  149246. * @param gradient defines the gradient to remove
  149247. * @returns the current particle system
  149248. */
  149249. removeRampGradient(): IParticleSystem;
  149250. /**
  149251. * Not supported by GPUParticleSystem
  149252. * @returns the list of ramp gradients
  149253. */
  149254. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149255. /**
  149256. * Not supported by GPUParticleSystem
  149257. * Gets or sets a boolean indicating that ramp gradients must be used
  149258. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149259. */
  149260. get useRampGradients(): boolean;
  149261. set useRampGradients(value: boolean);
  149262. /**
  149263. * Not supported by GPUParticleSystem
  149264. * @param gradient defines the gradient to use (between 0 and 1)
  149265. * @param factor defines the life time factor to affect to the specified gradient
  149266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149267. * @returns the current particle system
  149268. */
  149269. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149270. /**
  149271. * Not supported by GPUParticleSystem
  149272. * @param gradient defines the gradient to remove
  149273. * @returns the current particle system
  149274. */
  149275. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149276. /**
  149277. * Instantiates a GPU particle system.
  149278. * 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.
  149279. * @param name The name of the particle system
  149280. * @param options The options used to create the system
  149281. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149282. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149283. * @param customEffect a custom effect used to change the way particles are rendered by default
  149284. */
  149285. constructor(name: string, options: Partial<{
  149286. capacity: number;
  149287. randomTextureSize: number;
  149288. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149289. protected _reset(): void;
  149290. private _createUpdateVAO;
  149291. private _createRenderVAO;
  149292. private _initialize;
  149293. /** @hidden */
  149294. _recreateUpdateEffect(): void;
  149295. private _getEffect;
  149296. /**
  149297. * Fill the defines array according to the current settings of the particle system
  149298. * @param defines Array to be updated
  149299. * @param blendMode blend mode to take into account when updating the array
  149300. */
  149301. fillDefines(defines: Array<string>, blendMode?: number): void;
  149302. /**
  149303. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149304. * @param uniforms Uniforms array to fill
  149305. * @param attributes Attributes array to fill
  149306. * @param samplers Samplers array to fill
  149307. */
  149308. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149309. /** @hidden */
  149310. _recreateRenderEffect(): Effect;
  149311. /**
  149312. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149313. * @param preWarm defines if we are in the pre-warmimg phase
  149314. */
  149315. animate(preWarm?: boolean): void;
  149316. private _createFactorGradientTexture;
  149317. private _createSizeGradientTexture;
  149318. private _createAngularSpeedGradientTexture;
  149319. private _createVelocityGradientTexture;
  149320. private _createLimitVelocityGradientTexture;
  149321. private _createDragGradientTexture;
  149322. private _createColorGradientTexture;
  149323. /**
  149324. * Renders the particle system in its current state
  149325. * @param preWarm defines if the system should only update the particles but not render them
  149326. * @returns the current number of particles
  149327. */
  149328. render(preWarm?: boolean): number;
  149329. /**
  149330. * Rebuilds the particle system
  149331. */
  149332. rebuild(): void;
  149333. private _releaseBuffers;
  149334. private _releaseVAOs;
  149335. /**
  149336. * Disposes the particle system and free the associated resources
  149337. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149338. */
  149339. dispose(disposeTexture?: boolean): void;
  149340. /**
  149341. * Clones the particle system.
  149342. * @param name The name of the cloned object
  149343. * @param newEmitter The new emitter to use
  149344. * @returns the cloned particle system
  149345. */
  149346. clone(name: string, newEmitter: any): GPUParticleSystem;
  149347. /**
  149348. * Serializes the particle system to a JSON object
  149349. * @param serializeTexture defines if the texture must be serialized as well
  149350. * @returns the JSON object
  149351. */
  149352. serialize(serializeTexture?: boolean): any;
  149353. /**
  149354. * Parses a JSON object to create a GPU particle system.
  149355. * @param parsedParticleSystem The JSON object to parse
  149356. * @param sceneOrEngine The scene or the engine to create the particle system in
  149357. * @param rootUrl The root url to use to load external dependencies like texture
  149358. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149359. * @returns the parsed GPU particle system
  149360. */
  149361. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149362. }
  149363. }
  149364. declare module BABYLON {
  149365. /**
  149366. * Represents a set of particle systems working together to create a specific effect
  149367. */
  149368. export class ParticleSystemSet implements IDisposable {
  149369. /**
  149370. * Gets or sets base Assets URL
  149371. */
  149372. static BaseAssetsUrl: string;
  149373. private _emitterCreationOptions;
  149374. private _emitterNode;
  149375. /**
  149376. * Gets the particle system list
  149377. */
  149378. systems: IParticleSystem[];
  149379. /**
  149380. * Gets the emitter node used with this set
  149381. */
  149382. get emitterNode(): Nullable<TransformNode>;
  149383. /**
  149384. * Creates a new emitter mesh as a sphere
  149385. * @param options defines the options used to create the sphere
  149386. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149387. * @param scene defines the hosting scene
  149388. */
  149389. setEmitterAsSphere(options: {
  149390. diameter: number;
  149391. segments: number;
  149392. color: Color3;
  149393. }, renderingGroupId: number, scene: Scene): void;
  149394. /**
  149395. * Starts all particle systems of the set
  149396. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149397. */
  149398. start(emitter?: AbstractMesh): void;
  149399. /**
  149400. * Release all associated resources
  149401. */
  149402. dispose(): void;
  149403. /**
  149404. * Serialize the set into a JSON compatible object
  149405. * @param serializeTexture defines if the texture must be serialized as well
  149406. * @returns a JSON compatible representation of the set
  149407. */
  149408. serialize(serializeTexture?: boolean): any;
  149409. /**
  149410. * Parse a new ParticleSystemSet from a serialized source
  149411. * @param data defines a JSON compatible representation of the set
  149412. * @param scene defines the hosting scene
  149413. * @param gpu defines if we want GPU particles or CPU particles
  149414. * @returns a new ParticleSystemSet
  149415. */
  149416. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149417. }
  149418. }
  149419. declare module BABYLON {
  149420. /**
  149421. * This class is made for on one-liner static method to help creating particle system set.
  149422. */
  149423. export class ParticleHelper {
  149424. /**
  149425. * Gets or sets base Assets URL
  149426. */
  149427. static BaseAssetsUrl: string;
  149428. /** Define the Url to load snippets */
  149429. static SnippetUrl: string;
  149430. /**
  149431. * Create a default particle system that you can tweak
  149432. * @param emitter defines the emitter to use
  149433. * @param capacity defines the system capacity (default is 500 particles)
  149434. * @param scene defines the hosting scene
  149435. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149436. * @returns the new Particle system
  149437. */
  149438. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149439. /**
  149440. * This is the main static method (one-liner) of this helper to create different particle systems
  149441. * @param type This string represents the type to the particle system to create
  149442. * @param scene The scene where the particle system should live
  149443. * @param gpu If the system will use gpu
  149444. * @returns the ParticleSystemSet created
  149445. */
  149446. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149447. /**
  149448. * Static function used to export a particle system to a ParticleSystemSet variable.
  149449. * Please note that the emitter shape is not exported
  149450. * @param systems defines the particle systems to export
  149451. * @returns the created particle system set
  149452. */
  149453. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149454. /**
  149455. * Creates a particle system from a snippet saved in a remote file
  149456. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149457. * @param url defines the url to load from
  149458. * @param scene defines the hosting scene
  149459. * @param gpu If the system will use gpu
  149460. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149461. * @returns a promise that will resolve to the new particle system
  149462. */
  149463. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149464. /**
  149465. * Creates a particle system from a snippet saved by the particle system editor
  149466. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149467. * @param scene defines the hosting scene
  149468. * @param gpu If the system will use gpu
  149469. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149470. * @returns a promise that will resolve to the new particle system
  149471. */
  149472. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149473. }
  149474. }
  149475. declare module BABYLON {
  149476. interface Engine {
  149477. /**
  149478. * Create an effect to use with particle systems.
  149479. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149480. * the particle system for which you want to create a custom effect in the last parameter
  149481. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149482. * @param uniformsNames defines a list of attribute names
  149483. * @param samplers defines an array of string used to represent textures
  149484. * @param defines defines the string containing the defines to use to compile the shaders
  149485. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149486. * @param onCompiled defines a function to call when the effect creation is successful
  149487. * @param onError defines a function to call when the effect creation has failed
  149488. * @param particleSystem the particle system you want to create the effect for
  149489. * @returns the new Effect
  149490. */
  149491. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149492. }
  149493. interface Mesh {
  149494. /**
  149495. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149496. * @returns an array of IParticleSystem
  149497. */
  149498. getEmittedParticleSystems(): IParticleSystem[];
  149499. /**
  149500. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149501. * @returns an array of IParticleSystem
  149502. */
  149503. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149504. }
  149505. }
  149506. declare module BABYLON {
  149507. /** Defines the 4 color options */
  149508. export enum PointColor {
  149509. /** color value */
  149510. Color = 2,
  149511. /** uv value */
  149512. UV = 1,
  149513. /** random value */
  149514. Random = 0,
  149515. /** stated value */
  149516. Stated = 3
  149517. }
  149518. /**
  149519. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149520. * 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.
  149521. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149522. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149523. *
  149524. * Full documentation here : TO BE ENTERED
  149525. */
  149526. export class PointsCloudSystem implements IDisposable {
  149527. /**
  149528. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149529. * Example : var p = SPS.particles[i];
  149530. */
  149531. particles: CloudPoint[];
  149532. /**
  149533. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149534. */
  149535. nbParticles: number;
  149536. /**
  149537. * This a counter for your own usage. It's not set by any SPS functions.
  149538. */
  149539. counter: number;
  149540. /**
  149541. * The PCS name. This name is also given to the underlying mesh.
  149542. */
  149543. name: string;
  149544. /**
  149545. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149546. */
  149547. mesh: Mesh;
  149548. /**
  149549. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149550. * Please read :
  149551. */
  149552. vars: any;
  149553. /**
  149554. * @hidden
  149555. */
  149556. _size: number;
  149557. private _scene;
  149558. private _promises;
  149559. private _positions;
  149560. private _indices;
  149561. private _normals;
  149562. private _colors;
  149563. private _uvs;
  149564. private _indices32;
  149565. private _positions32;
  149566. private _colors32;
  149567. private _uvs32;
  149568. private _updatable;
  149569. private _isVisibilityBoxLocked;
  149570. private _alwaysVisible;
  149571. private _groups;
  149572. private _groupCounter;
  149573. private _computeParticleColor;
  149574. private _computeParticleTexture;
  149575. private _computeParticleRotation;
  149576. private _computeBoundingBox;
  149577. private _isReady;
  149578. /**
  149579. * Creates a PCS (Points Cloud System) object
  149580. * @param name (String) is the PCS name, this will be the underlying mesh name
  149581. * @param pointSize (number) is the size for each point
  149582. * @param scene (Scene) is the scene in which the PCS is added
  149583. * @param options defines the options of the PCS e.g.
  149584. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149585. */
  149586. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149587. updatable?: boolean;
  149588. });
  149589. /**
  149590. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149591. * If no points were added to the PCS, the returned mesh is just a single point.
  149592. * @returns a promise for the created mesh
  149593. */
  149594. buildMeshAsync(): Promise<Mesh>;
  149595. /**
  149596. * @hidden
  149597. */
  149598. private _buildMesh;
  149599. private _addParticle;
  149600. private _randomUnitVector;
  149601. private _getColorIndicesForCoord;
  149602. private _setPointsColorOrUV;
  149603. private _colorFromTexture;
  149604. private _calculateDensity;
  149605. /**
  149606. * Adds points to the PCS in random positions within a unit sphere
  149607. * @param nb (positive integer) the number of particles to be created from this model
  149608. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149609. * @returns the number of groups in the system
  149610. */
  149611. addPoints(nb: number, pointFunction?: any): number;
  149612. /**
  149613. * Adds points to the PCS from the surface of the model shape
  149614. * @param mesh is any Mesh object that will be used as a surface model for the points
  149615. * @param nb (positive integer) the number of particles to be created from this model
  149616. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149617. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149618. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149619. * @returns the number of groups in the system
  149620. */
  149621. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149622. /**
  149623. * Adds points to the PCS inside the model shape
  149624. * @param mesh is any Mesh object that will be used as a surface model for the points
  149625. * @param nb (positive integer) the number of particles to be created from this model
  149626. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149627. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149628. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149629. * @returns the number of groups in the system
  149630. */
  149631. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149632. /**
  149633. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149634. * This method calls `updateParticle()` for each particle of the SPS.
  149635. * For an animated SPS, it is usually called within the render loop.
  149636. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149637. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149638. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149639. * @returns the PCS.
  149640. */
  149641. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149642. /**
  149643. * Disposes the PCS.
  149644. */
  149645. dispose(): void;
  149646. /**
  149647. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149648. * doc :
  149649. * @returns the PCS.
  149650. */
  149651. refreshVisibleSize(): PointsCloudSystem;
  149652. /**
  149653. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149654. * @param size the size (float) of the visibility box
  149655. * note : this doesn't lock the PCS mesh bounding box.
  149656. * doc :
  149657. */
  149658. setVisibilityBox(size: number): void;
  149659. /**
  149660. * Gets whether the PCS is always visible or not
  149661. * doc :
  149662. */
  149663. get isAlwaysVisible(): boolean;
  149664. /**
  149665. * Sets the PCS as always visible or not
  149666. * doc :
  149667. */
  149668. set isAlwaysVisible(val: boolean);
  149669. /**
  149670. * Tells to `setParticles()` to compute the particle rotations or not
  149671. * Default value : false. The PCS is faster when it's set to false
  149672. * Note : particle rotations are only applied to parent particles
  149673. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149674. */
  149675. set computeParticleRotation(val: boolean);
  149676. /**
  149677. * Tells to `setParticles()` to compute the particle colors or not.
  149678. * Default value : true. The PCS is faster when it's set to false.
  149679. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149680. */
  149681. set computeParticleColor(val: boolean);
  149682. set computeParticleTexture(val: boolean);
  149683. /**
  149684. * Gets if `setParticles()` computes the particle colors or not.
  149685. * Default value : false. The PCS is faster when it's set to false.
  149686. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149687. */
  149688. get computeParticleColor(): boolean;
  149689. /**
  149690. * Gets if `setParticles()` computes the particle textures or not.
  149691. * Default value : false. The PCS is faster when it's set to false.
  149692. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149693. */
  149694. get computeParticleTexture(): boolean;
  149695. /**
  149696. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149697. */
  149698. set computeBoundingBox(val: boolean);
  149699. /**
  149700. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149701. */
  149702. get computeBoundingBox(): boolean;
  149703. /**
  149704. * This function does nothing. It may be overwritten to set all the particle first values.
  149705. * The PCS doesn't call this function, you may have to call it by your own.
  149706. * doc :
  149707. */
  149708. initParticles(): void;
  149709. /**
  149710. * This function does nothing. It may be overwritten to recycle a particle
  149711. * The PCS doesn't call this function, you can to call it
  149712. * doc :
  149713. * @param particle The particle to recycle
  149714. * @returns the recycled particle
  149715. */
  149716. recycleParticle(particle: CloudPoint): CloudPoint;
  149717. /**
  149718. * Updates a particle : this function should be overwritten by the user.
  149719. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149720. * doc :
  149721. * @example : just set a particle position or velocity and recycle conditions
  149722. * @param particle The particle to update
  149723. * @returns the updated particle
  149724. */
  149725. updateParticle(particle: CloudPoint): CloudPoint;
  149726. /**
  149727. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149728. * This does nothing and may be overwritten by the user.
  149729. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149730. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149731. * @param update the boolean update value actually passed to setParticles()
  149732. */
  149733. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149734. /**
  149735. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149736. * This will be passed three parameters.
  149737. * This does nothing and may be overwritten by the user.
  149738. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149739. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149740. * @param update the boolean update value actually passed to setParticles()
  149741. */
  149742. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149743. }
  149744. }
  149745. declare module BABYLON {
  149746. /**
  149747. * Represents one particle of a points cloud system.
  149748. */
  149749. export class CloudPoint {
  149750. /**
  149751. * particle global index
  149752. */
  149753. idx: number;
  149754. /**
  149755. * The color of the particle
  149756. */
  149757. color: Nullable<Color4>;
  149758. /**
  149759. * The world space position of the particle.
  149760. */
  149761. position: Vector3;
  149762. /**
  149763. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149764. */
  149765. rotation: Vector3;
  149766. /**
  149767. * The world space rotation quaternion of the particle.
  149768. */
  149769. rotationQuaternion: Nullable<Quaternion>;
  149770. /**
  149771. * The uv of the particle.
  149772. */
  149773. uv: Nullable<Vector2>;
  149774. /**
  149775. * The current speed of the particle.
  149776. */
  149777. velocity: Vector3;
  149778. /**
  149779. * The pivot point in the particle local space.
  149780. */
  149781. pivot: Vector3;
  149782. /**
  149783. * Must the particle be translated from its pivot point in its local space ?
  149784. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149785. * Default : false
  149786. */
  149787. translateFromPivot: boolean;
  149788. /**
  149789. * Index of this particle in the global "positions" array (Internal use)
  149790. * @hidden
  149791. */
  149792. _pos: number;
  149793. /**
  149794. * @hidden Index of this particle in the global "indices" array (Internal use)
  149795. */
  149796. _ind: number;
  149797. /**
  149798. * Group this particle belongs to
  149799. */
  149800. _group: PointsGroup;
  149801. /**
  149802. * Group id of this particle
  149803. */
  149804. groupId: number;
  149805. /**
  149806. * Index of the particle in its group id (Internal use)
  149807. */
  149808. idxInGroup: number;
  149809. /**
  149810. * @hidden Particle BoundingInfo object (Internal use)
  149811. */
  149812. _boundingInfo: BoundingInfo;
  149813. /**
  149814. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149815. */
  149816. _pcs: PointsCloudSystem;
  149817. /**
  149818. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149819. */
  149820. _stillInvisible: boolean;
  149821. /**
  149822. * @hidden Last computed particle rotation matrix
  149823. */
  149824. _rotationMatrix: number[];
  149825. /**
  149826. * Parent particle Id, if any.
  149827. * Default null.
  149828. */
  149829. parentId: Nullable<number>;
  149830. /**
  149831. * @hidden Internal global position in the PCS.
  149832. */
  149833. _globalPosition: Vector3;
  149834. /**
  149835. * Creates a Point Cloud object.
  149836. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149837. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149838. * @param group (PointsGroup) is the group the particle belongs to
  149839. * @param groupId (integer) is the group identifier in the PCS.
  149840. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149841. * @param pcs defines the PCS it is associated to
  149842. */
  149843. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149844. /**
  149845. * get point size
  149846. */
  149847. get size(): Vector3;
  149848. /**
  149849. * Set point size
  149850. */
  149851. set size(scale: Vector3);
  149852. /**
  149853. * Legacy support, changed quaternion to rotationQuaternion
  149854. */
  149855. get quaternion(): Nullable<Quaternion>;
  149856. /**
  149857. * Legacy support, changed quaternion to rotationQuaternion
  149858. */
  149859. set quaternion(q: Nullable<Quaternion>);
  149860. /**
  149861. * Returns a boolean. True if the particle intersects a mesh, else false
  149862. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149863. * @param target is the object (point or mesh) what the intersection is computed against
  149864. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149865. * @returns true if it intersects
  149866. */
  149867. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149868. /**
  149869. * get the rotation matrix of the particle
  149870. * @hidden
  149871. */
  149872. getRotationMatrix(m: Matrix): void;
  149873. }
  149874. /**
  149875. * Represents a group of points in a points cloud system
  149876. * * PCS internal tool, don't use it manually.
  149877. */
  149878. export class PointsGroup {
  149879. /**
  149880. * The group id
  149881. * @hidden
  149882. */
  149883. groupID: number;
  149884. /**
  149885. * image data for group (internal use)
  149886. * @hidden
  149887. */
  149888. _groupImageData: Nullable<ArrayBufferView>;
  149889. /**
  149890. * Image Width (internal use)
  149891. * @hidden
  149892. */
  149893. _groupImgWidth: number;
  149894. /**
  149895. * Image Height (internal use)
  149896. * @hidden
  149897. */
  149898. _groupImgHeight: number;
  149899. /**
  149900. * Custom position function (internal use)
  149901. * @hidden
  149902. */
  149903. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149904. /**
  149905. * density per facet for surface points
  149906. * @hidden
  149907. */
  149908. _groupDensity: number[];
  149909. /**
  149910. * Only when points are colored by texture carries pointer to texture list array
  149911. * @hidden
  149912. */
  149913. _textureNb: number;
  149914. /**
  149915. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149916. * PCS internal tool, don't use it manually.
  149917. * @hidden
  149918. */
  149919. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149920. }
  149921. }
  149922. declare module BABYLON {
  149923. interface Scene {
  149924. /** @hidden (Backing field) */
  149925. _physicsEngine: Nullable<IPhysicsEngine>;
  149926. /** @hidden */
  149927. _physicsTimeAccumulator: number;
  149928. /**
  149929. * Gets the current physics engine
  149930. * @returns a IPhysicsEngine or null if none attached
  149931. */
  149932. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149933. /**
  149934. * Enables physics to the current scene
  149935. * @param gravity defines the scene's gravity for the physics engine
  149936. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149937. * @return a boolean indicating if the physics engine was initialized
  149938. */
  149939. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149940. /**
  149941. * Disables and disposes the physics engine associated with the scene
  149942. */
  149943. disablePhysicsEngine(): void;
  149944. /**
  149945. * Gets a boolean indicating if there is an active physics engine
  149946. * @returns a boolean indicating if there is an active physics engine
  149947. */
  149948. isPhysicsEnabled(): boolean;
  149949. /**
  149950. * Deletes a physics compound impostor
  149951. * @param compound defines the compound to delete
  149952. */
  149953. deleteCompoundImpostor(compound: any): void;
  149954. /**
  149955. * An event triggered when physic simulation is about to be run
  149956. */
  149957. onBeforePhysicsObservable: Observable<Scene>;
  149958. /**
  149959. * An event triggered when physic simulation has been done
  149960. */
  149961. onAfterPhysicsObservable: Observable<Scene>;
  149962. }
  149963. interface AbstractMesh {
  149964. /** @hidden */
  149965. _physicsImpostor: Nullable<PhysicsImpostor>;
  149966. /**
  149967. * Gets or sets impostor used for physic simulation
  149968. * @see https://doc.babylonjs.com/features/physics_engine
  149969. */
  149970. physicsImpostor: Nullable<PhysicsImpostor>;
  149971. /**
  149972. * Gets the current physics impostor
  149973. * @see https://doc.babylonjs.com/features/physics_engine
  149974. * @returns a physics impostor or null
  149975. */
  149976. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149977. /** Apply a physic impulse to the mesh
  149978. * @param force defines the force to apply
  149979. * @param contactPoint defines where to apply the force
  149980. * @returns the current mesh
  149981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149982. */
  149983. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149984. /**
  149985. * Creates a physic joint between two meshes
  149986. * @param otherMesh defines the other mesh to use
  149987. * @param pivot1 defines the pivot to use on this mesh
  149988. * @param pivot2 defines the pivot to use on the other mesh
  149989. * @param options defines additional options (can be plugin dependent)
  149990. * @returns the current mesh
  149991. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149992. */
  149993. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149994. /** @hidden */
  149995. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149996. }
  149997. /**
  149998. * Defines the physics engine scene component responsible to manage a physics engine
  149999. */
  150000. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150001. /**
  150002. * The component name helpful to identify the component in the list of scene components.
  150003. */
  150004. readonly name: string;
  150005. /**
  150006. * The scene the component belongs to.
  150007. */
  150008. scene: Scene;
  150009. /**
  150010. * Creates a new instance of the component for the given scene
  150011. * @param scene Defines the scene to register the component in
  150012. */
  150013. constructor(scene: Scene);
  150014. /**
  150015. * Registers the component in a given scene
  150016. */
  150017. register(): void;
  150018. /**
  150019. * Rebuilds the elements related to this component in case of
  150020. * context lost for instance.
  150021. */
  150022. rebuild(): void;
  150023. /**
  150024. * Disposes the component and the associated ressources
  150025. */
  150026. dispose(): void;
  150027. }
  150028. }
  150029. declare module BABYLON {
  150030. /**
  150031. * A helper for physics simulations
  150032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150033. */
  150034. export class PhysicsHelper {
  150035. private _scene;
  150036. private _physicsEngine;
  150037. /**
  150038. * Initializes the Physics helper
  150039. * @param scene Babylon.js scene
  150040. */
  150041. constructor(scene: Scene);
  150042. /**
  150043. * Applies a radial explosion impulse
  150044. * @param origin the origin of the explosion
  150045. * @param radiusOrEventOptions the radius or the options of radial explosion
  150046. * @param strength the explosion strength
  150047. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150048. * @returns A physics radial explosion event, or null
  150049. */
  150050. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150051. /**
  150052. * Applies a radial explosion force
  150053. * @param origin the origin of the explosion
  150054. * @param radiusOrEventOptions the radius or the options of radial explosion
  150055. * @param strength the explosion strength
  150056. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150057. * @returns A physics radial explosion event, or null
  150058. */
  150059. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150060. /**
  150061. * Creates a gravitational field
  150062. * @param origin the origin of the explosion
  150063. * @param radiusOrEventOptions the radius or the options of radial explosion
  150064. * @param strength the explosion strength
  150065. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150066. * @returns A physics gravitational field event, or null
  150067. */
  150068. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150069. /**
  150070. * Creates a physics updraft event
  150071. * @param origin the origin of the updraft
  150072. * @param radiusOrEventOptions the radius or the options of the updraft
  150073. * @param strength the strength of the updraft
  150074. * @param height the height of the updraft
  150075. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150076. * @returns A physics updraft event, or null
  150077. */
  150078. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150079. /**
  150080. * Creates a physics vortex event
  150081. * @param origin the of the vortex
  150082. * @param radiusOrEventOptions the radius or the options of the vortex
  150083. * @param strength the strength of the vortex
  150084. * @param height the height of the vortex
  150085. * @returns a Physics vortex event, or null
  150086. * A physics vortex event or null
  150087. */
  150088. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150089. }
  150090. /**
  150091. * Represents a physics radial explosion event
  150092. */
  150093. class PhysicsRadialExplosionEvent {
  150094. private _scene;
  150095. private _options;
  150096. private _sphere;
  150097. private _dataFetched;
  150098. /**
  150099. * Initializes a radial explosioin event
  150100. * @param _scene BabylonJS scene
  150101. * @param _options The options for the vortex event
  150102. */
  150103. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150104. /**
  150105. * Returns the data related to the radial explosion event (sphere).
  150106. * @returns The radial explosion event data
  150107. */
  150108. getData(): PhysicsRadialExplosionEventData;
  150109. /**
  150110. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150111. * @param impostor A physics imposter
  150112. * @param origin the origin of the explosion
  150113. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150114. */
  150115. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150116. /**
  150117. * Triggers affecterd impostors callbacks
  150118. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150119. */
  150120. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150121. /**
  150122. * Disposes the sphere.
  150123. * @param force Specifies if the sphere should be disposed by force
  150124. */
  150125. dispose(force?: boolean): void;
  150126. /*** Helpers ***/
  150127. private _prepareSphere;
  150128. private _intersectsWithSphere;
  150129. }
  150130. /**
  150131. * Represents a gravitational field event
  150132. */
  150133. class PhysicsGravitationalFieldEvent {
  150134. private _physicsHelper;
  150135. private _scene;
  150136. private _origin;
  150137. private _options;
  150138. private _tickCallback;
  150139. private _sphere;
  150140. private _dataFetched;
  150141. /**
  150142. * Initializes the physics gravitational field event
  150143. * @param _physicsHelper A physics helper
  150144. * @param _scene BabylonJS scene
  150145. * @param _origin The origin position of the gravitational field event
  150146. * @param _options The options for the vortex event
  150147. */
  150148. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150149. /**
  150150. * Returns the data related to the gravitational field event (sphere).
  150151. * @returns A gravitational field event
  150152. */
  150153. getData(): PhysicsGravitationalFieldEventData;
  150154. /**
  150155. * Enables the gravitational field.
  150156. */
  150157. enable(): void;
  150158. /**
  150159. * Disables the gravitational field.
  150160. */
  150161. disable(): void;
  150162. /**
  150163. * Disposes the sphere.
  150164. * @param force The force to dispose from the gravitational field event
  150165. */
  150166. dispose(force?: boolean): void;
  150167. private _tick;
  150168. }
  150169. /**
  150170. * Represents a physics updraft event
  150171. */
  150172. class PhysicsUpdraftEvent {
  150173. private _scene;
  150174. private _origin;
  150175. private _options;
  150176. private _physicsEngine;
  150177. private _originTop;
  150178. private _originDirection;
  150179. private _tickCallback;
  150180. private _cylinder;
  150181. private _cylinderPosition;
  150182. private _dataFetched;
  150183. /**
  150184. * Initializes the physics updraft event
  150185. * @param _scene BabylonJS scene
  150186. * @param _origin The origin position of the updraft
  150187. * @param _options The options for the updraft event
  150188. */
  150189. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150190. /**
  150191. * Returns the data related to the updraft event (cylinder).
  150192. * @returns A physics updraft event
  150193. */
  150194. getData(): PhysicsUpdraftEventData;
  150195. /**
  150196. * Enables the updraft.
  150197. */
  150198. enable(): void;
  150199. /**
  150200. * Disables the updraft.
  150201. */
  150202. disable(): void;
  150203. /**
  150204. * Disposes the cylinder.
  150205. * @param force Specifies if the updraft should be disposed by force
  150206. */
  150207. dispose(force?: boolean): void;
  150208. private getImpostorHitData;
  150209. private _tick;
  150210. /*** Helpers ***/
  150211. private _prepareCylinder;
  150212. private _intersectsWithCylinder;
  150213. }
  150214. /**
  150215. * Represents a physics vortex event
  150216. */
  150217. class PhysicsVortexEvent {
  150218. private _scene;
  150219. private _origin;
  150220. private _options;
  150221. private _physicsEngine;
  150222. private _originTop;
  150223. private _tickCallback;
  150224. private _cylinder;
  150225. private _cylinderPosition;
  150226. private _dataFetched;
  150227. /**
  150228. * Initializes the physics vortex event
  150229. * @param _scene The BabylonJS scene
  150230. * @param _origin The origin position of the vortex
  150231. * @param _options The options for the vortex event
  150232. */
  150233. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150234. /**
  150235. * Returns the data related to the vortex event (cylinder).
  150236. * @returns The physics vortex event data
  150237. */
  150238. getData(): PhysicsVortexEventData;
  150239. /**
  150240. * Enables the vortex.
  150241. */
  150242. enable(): void;
  150243. /**
  150244. * Disables the cortex.
  150245. */
  150246. disable(): void;
  150247. /**
  150248. * Disposes the sphere.
  150249. * @param force
  150250. */
  150251. dispose(force?: boolean): void;
  150252. private getImpostorHitData;
  150253. private _tick;
  150254. /*** Helpers ***/
  150255. private _prepareCylinder;
  150256. private _intersectsWithCylinder;
  150257. }
  150258. /**
  150259. * Options fot the radial explosion event
  150260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150261. */
  150262. export class PhysicsRadialExplosionEventOptions {
  150263. /**
  150264. * The radius of the sphere for the radial explosion.
  150265. */
  150266. radius: number;
  150267. /**
  150268. * The strenth of the explosion.
  150269. */
  150270. strength: number;
  150271. /**
  150272. * The strenght of the force in correspondence to the distance of the affected object
  150273. */
  150274. falloff: PhysicsRadialImpulseFalloff;
  150275. /**
  150276. * Sphere options for the radial explosion.
  150277. */
  150278. sphere: {
  150279. segments: number;
  150280. diameter: number;
  150281. };
  150282. /**
  150283. * Sphere options for the radial explosion.
  150284. */
  150285. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150286. }
  150287. /**
  150288. * Options fot the updraft event
  150289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150290. */
  150291. export class PhysicsUpdraftEventOptions {
  150292. /**
  150293. * The radius of the cylinder for the vortex
  150294. */
  150295. radius: number;
  150296. /**
  150297. * The strenth of the updraft.
  150298. */
  150299. strength: number;
  150300. /**
  150301. * The height of the cylinder for the updraft.
  150302. */
  150303. height: number;
  150304. /**
  150305. * The mode for the the updraft.
  150306. */
  150307. updraftMode: PhysicsUpdraftMode;
  150308. }
  150309. /**
  150310. * Options fot the vortex event
  150311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150312. */
  150313. export class PhysicsVortexEventOptions {
  150314. /**
  150315. * The radius of the cylinder for the vortex
  150316. */
  150317. radius: number;
  150318. /**
  150319. * The strenth of the vortex.
  150320. */
  150321. strength: number;
  150322. /**
  150323. * The height of the cylinder for the vortex.
  150324. */
  150325. height: number;
  150326. /**
  150327. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150328. */
  150329. centripetalForceThreshold: number;
  150330. /**
  150331. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150332. */
  150333. centripetalForceMultiplier: number;
  150334. /**
  150335. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150336. */
  150337. centrifugalForceMultiplier: number;
  150338. /**
  150339. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150340. */
  150341. updraftForceMultiplier: number;
  150342. }
  150343. /**
  150344. * The strenght of the force in correspondence to the distance of the affected object
  150345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150346. */
  150347. export enum PhysicsRadialImpulseFalloff {
  150348. /** Defines that impulse is constant in strength across it's whole radius */
  150349. Constant = 0,
  150350. /** Defines that impulse gets weaker if it's further from the origin */
  150351. Linear = 1
  150352. }
  150353. /**
  150354. * The strength of the force in correspondence to the distance of the affected object
  150355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150356. */
  150357. export enum PhysicsUpdraftMode {
  150358. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150359. Center = 0,
  150360. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150361. Perpendicular = 1
  150362. }
  150363. /**
  150364. * Interface for a physics hit data
  150365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150366. */
  150367. export interface PhysicsHitData {
  150368. /**
  150369. * The force applied at the contact point
  150370. */
  150371. force: Vector3;
  150372. /**
  150373. * The contact point
  150374. */
  150375. contactPoint: Vector3;
  150376. /**
  150377. * The distance from the origin to the contact point
  150378. */
  150379. distanceFromOrigin: number;
  150380. }
  150381. /**
  150382. * Interface for radial explosion event data
  150383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150384. */
  150385. export interface PhysicsRadialExplosionEventData {
  150386. /**
  150387. * A sphere used for the radial explosion event
  150388. */
  150389. sphere: Mesh;
  150390. }
  150391. /**
  150392. * Interface for gravitational field event data
  150393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150394. */
  150395. export interface PhysicsGravitationalFieldEventData {
  150396. /**
  150397. * A sphere mesh used for the gravitational field event
  150398. */
  150399. sphere: Mesh;
  150400. }
  150401. /**
  150402. * Interface for updraft event data
  150403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150404. */
  150405. export interface PhysicsUpdraftEventData {
  150406. /**
  150407. * A cylinder used for the updraft event
  150408. */
  150409. cylinder: Mesh;
  150410. }
  150411. /**
  150412. * Interface for vortex event data
  150413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150414. */
  150415. export interface PhysicsVortexEventData {
  150416. /**
  150417. * A cylinder used for the vortex event
  150418. */
  150419. cylinder: Mesh;
  150420. }
  150421. /**
  150422. * Interface for an affected physics impostor
  150423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150424. */
  150425. export interface PhysicsAffectedImpostorWithData {
  150426. /**
  150427. * The impostor affected by the effect
  150428. */
  150429. impostor: PhysicsImpostor;
  150430. /**
  150431. * The data about the hit/horce from the explosion
  150432. */
  150433. hitData: PhysicsHitData;
  150434. }
  150435. }
  150436. declare module BABYLON {
  150437. /** @hidden */
  150438. export var blackAndWhitePixelShader: {
  150439. name: string;
  150440. shader: string;
  150441. };
  150442. }
  150443. declare module BABYLON {
  150444. /**
  150445. * Post process used to render in black and white
  150446. */
  150447. export class BlackAndWhitePostProcess extends PostProcess {
  150448. /**
  150449. * Linear about to convert he result to black and white (default: 1)
  150450. */
  150451. degree: number;
  150452. /**
  150453. * Gets a string identifying the name of the class
  150454. * @returns "BlackAndWhitePostProcess" string
  150455. */
  150456. getClassName(): string;
  150457. /**
  150458. * Creates a black and white post process
  150459. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150460. * @param name The name of the effect.
  150461. * @param options The required width/height ratio to downsize to before computing the render pass.
  150462. * @param camera The camera to apply the render pass to.
  150463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150464. * @param engine The engine which the post process will be applied. (default: current engine)
  150465. * @param reusable If the post process can be reused on the same frame. (default: false)
  150466. */
  150467. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150468. /** @hidden */
  150469. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150470. }
  150471. }
  150472. declare module BABYLON {
  150473. /**
  150474. * This represents a set of one or more post processes in Babylon.
  150475. * A post process can be used to apply a shader to a texture after it is rendered.
  150476. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150477. */
  150478. export class PostProcessRenderEffect {
  150479. private _postProcesses;
  150480. private _getPostProcesses;
  150481. private _singleInstance;
  150482. private _cameras;
  150483. private _indicesForCamera;
  150484. /**
  150485. * Name of the effect
  150486. * @hidden
  150487. */
  150488. _name: string;
  150489. /**
  150490. * Instantiates a post process render effect.
  150491. * A post process can be used to apply a shader to a texture after it is rendered.
  150492. * @param engine The engine the effect is tied to
  150493. * @param name The name of the effect
  150494. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150495. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150496. */
  150497. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150498. /**
  150499. * Checks if all the post processes in the effect are supported.
  150500. */
  150501. get isSupported(): boolean;
  150502. /**
  150503. * Updates the current state of the effect
  150504. * @hidden
  150505. */
  150506. _update(): void;
  150507. /**
  150508. * Attaches the effect on cameras
  150509. * @param cameras The camera to attach to.
  150510. * @hidden
  150511. */
  150512. _attachCameras(cameras: Camera): void;
  150513. /**
  150514. * Attaches the effect on cameras
  150515. * @param cameras The camera to attach to.
  150516. * @hidden
  150517. */
  150518. _attachCameras(cameras: Camera[]): void;
  150519. /**
  150520. * Detaches the effect on cameras
  150521. * @param cameras The camera to detatch from.
  150522. * @hidden
  150523. */
  150524. _detachCameras(cameras: Camera): void;
  150525. /**
  150526. * Detatches the effect on cameras
  150527. * @param cameras The camera to detatch from.
  150528. * @hidden
  150529. */
  150530. _detachCameras(cameras: Camera[]): void;
  150531. /**
  150532. * Enables the effect on given cameras
  150533. * @param cameras The camera to enable.
  150534. * @hidden
  150535. */
  150536. _enable(cameras: Camera): void;
  150537. /**
  150538. * Enables the effect on given cameras
  150539. * @param cameras The camera to enable.
  150540. * @hidden
  150541. */
  150542. _enable(cameras: Nullable<Camera[]>): void;
  150543. /**
  150544. * Disables the effect on the given cameras
  150545. * @param cameras The camera to disable.
  150546. * @hidden
  150547. */
  150548. _disable(cameras: Camera): void;
  150549. /**
  150550. * Disables the effect on the given cameras
  150551. * @param cameras The camera to disable.
  150552. * @hidden
  150553. */
  150554. _disable(cameras: Nullable<Camera[]>): void;
  150555. /**
  150556. * Gets a list of the post processes contained in the effect.
  150557. * @param camera The camera to get the post processes on.
  150558. * @returns The list of the post processes in the effect.
  150559. */
  150560. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150561. }
  150562. }
  150563. declare module BABYLON {
  150564. /** @hidden */
  150565. export var extractHighlightsPixelShader: {
  150566. name: string;
  150567. shader: string;
  150568. };
  150569. }
  150570. declare module BABYLON {
  150571. /**
  150572. * 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.
  150573. */
  150574. export class ExtractHighlightsPostProcess extends PostProcess {
  150575. /**
  150576. * The luminance threshold, pixels below this value will be set to black.
  150577. */
  150578. threshold: number;
  150579. /** @hidden */
  150580. _exposure: number;
  150581. /**
  150582. * Post process which has the input texture to be used when performing highlight extraction
  150583. * @hidden
  150584. */
  150585. _inputPostProcess: Nullable<PostProcess>;
  150586. /**
  150587. * Gets a string identifying the name of the class
  150588. * @returns "ExtractHighlightsPostProcess" string
  150589. */
  150590. getClassName(): string;
  150591. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150592. }
  150593. }
  150594. declare module BABYLON {
  150595. /** @hidden */
  150596. export var bloomMergePixelShader: {
  150597. name: string;
  150598. shader: string;
  150599. };
  150600. }
  150601. declare module BABYLON {
  150602. /**
  150603. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150604. */
  150605. export class BloomMergePostProcess extends PostProcess {
  150606. /** Weight of the bloom to be added to the original input. */
  150607. weight: number;
  150608. /**
  150609. * Gets a string identifying the name of the class
  150610. * @returns "BloomMergePostProcess" string
  150611. */
  150612. getClassName(): string;
  150613. /**
  150614. * Creates a new instance of @see BloomMergePostProcess
  150615. * @param name The name of the effect.
  150616. * @param originalFromInput Post process which's input will be used for the merge.
  150617. * @param blurred Blurred highlights post process which's output will be used.
  150618. * @param weight Weight of the bloom to be added to the original input.
  150619. * @param options The required width/height ratio to downsize to before computing the render pass.
  150620. * @param camera The camera to apply the render pass to.
  150621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150622. * @param engine The engine which the post process will be applied. (default: current engine)
  150623. * @param reusable If the post process can be reused on the same frame. (default: false)
  150624. * @param textureType Type of textures used when performing the post process. (default: 0)
  150625. * @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)
  150626. */
  150627. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150628. /** Weight of the bloom to be added to the original input. */
  150629. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150630. }
  150631. }
  150632. declare module BABYLON {
  150633. /**
  150634. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150635. */
  150636. export class BloomEffect extends PostProcessRenderEffect {
  150637. private bloomScale;
  150638. /**
  150639. * @hidden Internal
  150640. */
  150641. _effects: Array<PostProcess>;
  150642. /**
  150643. * @hidden Internal
  150644. */
  150645. _downscale: ExtractHighlightsPostProcess;
  150646. private _blurX;
  150647. private _blurY;
  150648. private _merge;
  150649. /**
  150650. * The luminance threshold to find bright areas of the image to bloom.
  150651. */
  150652. get threshold(): number;
  150653. set threshold(value: number);
  150654. /**
  150655. * The strength of the bloom.
  150656. */
  150657. get weight(): number;
  150658. set weight(value: number);
  150659. /**
  150660. * Specifies the size of the bloom blur kernel, relative to the final output size
  150661. */
  150662. get kernel(): number;
  150663. set kernel(value: number);
  150664. /**
  150665. * Creates a new instance of @see BloomEffect
  150666. * @param scene The scene the effect belongs to.
  150667. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150668. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150669. * @param bloomWeight The the strength of bloom.
  150670. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150671. * @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)
  150672. */
  150673. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150674. /**
  150675. * Disposes each of the internal effects for a given camera.
  150676. * @param camera The camera to dispose the effect on.
  150677. */
  150678. disposeEffects(camera: Camera): void;
  150679. /**
  150680. * @hidden Internal
  150681. */
  150682. _updateEffects(): void;
  150683. /**
  150684. * Internal
  150685. * @returns if all the contained post processes are ready.
  150686. * @hidden
  150687. */
  150688. _isReady(): boolean;
  150689. }
  150690. }
  150691. declare module BABYLON {
  150692. /** @hidden */
  150693. export var chromaticAberrationPixelShader: {
  150694. name: string;
  150695. shader: string;
  150696. };
  150697. }
  150698. declare module BABYLON {
  150699. /**
  150700. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150701. */
  150702. export class ChromaticAberrationPostProcess extends PostProcess {
  150703. /**
  150704. * The amount of seperation of rgb channels (default: 30)
  150705. */
  150706. aberrationAmount: number;
  150707. /**
  150708. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150709. */
  150710. radialIntensity: number;
  150711. /**
  150712. * 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))
  150713. */
  150714. direction: Vector2;
  150715. /**
  150716. * 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))
  150717. */
  150718. centerPosition: Vector2;
  150719. /** The width of the screen to apply the effect on */
  150720. screenWidth: number;
  150721. /** The height of the screen to apply the effect on */
  150722. screenHeight: number;
  150723. /**
  150724. * Gets a string identifying the name of the class
  150725. * @returns "ChromaticAberrationPostProcess" string
  150726. */
  150727. getClassName(): string;
  150728. /**
  150729. * Creates a new instance ChromaticAberrationPostProcess
  150730. * @param name The name of the effect.
  150731. * @param screenWidth The width of the screen to apply the effect on.
  150732. * @param screenHeight The height of the screen to apply the effect on.
  150733. * @param options The required width/height ratio to downsize to before computing the render pass.
  150734. * @param camera The camera to apply the render pass to.
  150735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150736. * @param engine The engine which the post process will be applied. (default: current engine)
  150737. * @param reusable If the post process can be reused on the same frame. (default: false)
  150738. * @param textureType Type of textures used when performing the post process. (default: 0)
  150739. * @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)
  150740. */
  150741. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150742. /** @hidden */
  150743. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150744. }
  150745. }
  150746. declare module BABYLON {
  150747. /** @hidden */
  150748. export var circleOfConfusionPixelShader: {
  150749. name: string;
  150750. shader: string;
  150751. };
  150752. }
  150753. declare module BABYLON {
  150754. /**
  150755. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150756. */
  150757. export class CircleOfConfusionPostProcess extends PostProcess {
  150758. /**
  150759. * 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.
  150760. */
  150761. lensSize: number;
  150762. /**
  150763. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150764. */
  150765. fStop: number;
  150766. /**
  150767. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150768. */
  150769. focusDistance: number;
  150770. /**
  150771. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150772. */
  150773. focalLength: number;
  150774. /**
  150775. * Gets a string identifying the name of the class
  150776. * @returns "CircleOfConfusionPostProcess" string
  150777. */
  150778. getClassName(): string;
  150779. private _depthTexture;
  150780. /**
  150781. * Creates a new instance CircleOfConfusionPostProcess
  150782. * @param name The name of the effect.
  150783. * @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.
  150784. * @param options The required width/height ratio to downsize to before computing the render pass.
  150785. * @param camera The camera to apply the render pass to.
  150786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150787. * @param engine The engine which the post process will be applied. (default: current engine)
  150788. * @param reusable If the post process can be reused on the same frame. (default: false)
  150789. * @param textureType Type of textures used when performing the post process. (default: 0)
  150790. * @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)
  150791. */
  150792. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150793. /**
  150794. * 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.
  150795. */
  150796. set depthTexture(value: RenderTargetTexture);
  150797. }
  150798. }
  150799. declare module BABYLON {
  150800. /** @hidden */
  150801. export var colorCorrectionPixelShader: {
  150802. name: string;
  150803. shader: string;
  150804. };
  150805. }
  150806. declare module BABYLON {
  150807. /**
  150808. *
  150809. * This post-process allows the modification of rendered colors by using
  150810. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150811. *
  150812. * The object needs to be provided an url to a texture containing the color
  150813. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150814. * Use an image editing software to tweak the LUT to match your needs.
  150815. *
  150816. * For an example of a color LUT, see here:
  150817. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150818. * For explanations on color grading, see here:
  150819. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150820. *
  150821. */
  150822. export class ColorCorrectionPostProcess extends PostProcess {
  150823. private _colorTableTexture;
  150824. /**
  150825. * Gets the color table url used to create the LUT texture
  150826. */
  150827. colorTableUrl: string;
  150828. /**
  150829. * Gets a string identifying the name of the class
  150830. * @returns "ColorCorrectionPostProcess" string
  150831. */
  150832. getClassName(): string;
  150833. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150834. /** @hidden */
  150835. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150836. }
  150837. }
  150838. declare module BABYLON {
  150839. /** @hidden */
  150840. export var convolutionPixelShader: {
  150841. name: string;
  150842. shader: string;
  150843. };
  150844. }
  150845. declare module BABYLON {
  150846. /**
  150847. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150848. * input texture to perform effects such as edge detection or sharpening
  150849. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150850. */
  150851. export class ConvolutionPostProcess extends PostProcess {
  150852. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150853. kernel: number[];
  150854. /**
  150855. * Gets a string identifying the name of the class
  150856. * @returns "ConvolutionPostProcess" string
  150857. */
  150858. getClassName(): string;
  150859. /**
  150860. * Creates a new instance ConvolutionPostProcess
  150861. * @param name The name of the effect.
  150862. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150863. * @param options The required width/height ratio to downsize to before computing the render pass.
  150864. * @param camera The camera to apply the render pass to.
  150865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150866. * @param engine The engine which the post process will be applied. (default: current engine)
  150867. * @param reusable If the post process can be reused on the same frame. (default: false)
  150868. * @param textureType Type of textures used when performing the post process. (default: 0)
  150869. */
  150870. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150871. /** @hidden */
  150872. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150873. /**
  150874. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150875. */
  150876. static EdgeDetect0Kernel: number[];
  150877. /**
  150878. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150879. */
  150880. static EdgeDetect1Kernel: number[];
  150881. /**
  150882. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150883. */
  150884. static EdgeDetect2Kernel: number[];
  150885. /**
  150886. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150887. */
  150888. static SharpenKernel: number[];
  150889. /**
  150890. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150891. */
  150892. static EmbossKernel: number[];
  150893. /**
  150894. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150895. */
  150896. static GaussianKernel: number[];
  150897. }
  150898. }
  150899. declare module BABYLON {
  150900. /**
  150901. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150902. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150903. * based on samples that have a large difference in distance than the center pixel.
  150904. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150905. */
  150906. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150907. /**
  150908. * The direction the blur should be applied
  150909. */
  150910. direction: Vector2;
  150911. /**
  150912. * Gets a string identifying the name of the class
  150913. * @returns "DepthOfFieldBlurPostProcess" string
  150914. */
  150915. getClassName(): string;
  150916. /**
  150917. * Creates a new instance CircleOfConfusionPostProcess
  150918. * @param name The name of the effect.
  150919. * @param scene The scene the effect belongs to.
  150920. * @param direction The direction the blur should be applied.
  150921. * @param kernel The size of the kernel used to blur.
  150922. * @param options The required width/height ratio to downsize to before computing the render pass.
  150923. * @param camera The camera to apply the render pass to.
  150924. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150925. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150927. * @param engine The engine which the post process will be applied. (default: current engine)
  150928. * @param reusable If the post process can be reused on the same frame. (default: false)
  150929. * @param textureType Type of textures used when performing the post process. (default: 0)
  150930. * @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)
  150931. */
  150932. 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);
  150933. }
  150934. }
  150935. declare module BABYLON {
  150936. /** @hidden */
  150937. export var depthOfFieldMergePixelShader: {
  150938. name: string;
  150939. shader: string;
  150940. };
  150941. }
  150942. declare module BABYLON {
  150943. /**
  150944. * Options to be set when merging outputs from the default pipeline.
  150945. */
  150946. export class DepthOfFieldMergePostProcessOptions {
  150947. /**
  150948. * The original image to merge on top of
  150949. */
  150950. originalFromInput: PostProcess;
  150951. /**
  150952. * Parameters to perform the merge of the depth of field effect
  150953. */
  150954. depthOfField?: {
  150955. circleOfConfusion: PostProcess;
  150956. blurSteps: Array<PostProcess>;
  150957. };
  150958. /**
  150959. * Parameters to perform the merge of bloom effect
  150960. */
  150961. bloom?: {
  150962. blurred: PostProcess;
  150963. weight: number;
  150964. };
  150965. }
  150966. /**
  150967. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150968. */
  150969. export class DepthOfFieldMergePostProcess extends PostProcess {
  150970. private blurSteps;
  150971. /**
  150972. * Gets a string identifying the name of the class
  150973. * @returns "DepthOfFieldMergePostProcess" string
  150974. */
  150975. getClassName(): string;
  150976. /**
  150977. * Creates a new instance of DepthOfFieldMergePostProcess
  150978. * @param name The name of the effect.
  150979. * @param originalFromInput Post process which's input will be used for the merge.
  150980. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150981. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  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, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150991. /**
  150992. * Updates the effect with the current post process compile time values and recompiles the shader.
  150993. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150994. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150995. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150996. * @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
  150997. * @param onCompiled Called when the shader has been compiled.
  150998. * @param onError Called if there is an error when compiling a shader.
  150999. */
  151000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151001. }
  151002. }
  151003. declare module BABYLON {
  151004. /**
  151005. * Specifies the level of max blur that should be applied when using the depth of field effect
  151006. */
  151007. export enum DepthOfFieldEffectBlurLevel {
  151008. /**
  151009. * Subtle blur
  151010. */
  151011. Low = 0,
  151012. /**
  151013. * Medium blur
  151014. */
  151015. Medium = 1,
  151016. /**
  151017. * Large blur
  151018. */
  151019. High = 2
  151020. }
  151021. /**
  151022. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151023. */
  151024. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151025. private _circleOfConfusion;
  151026. /**
  151027. * @hidden Internal, blurs from high to low
  151028. */
  151029. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151030. private _depthOfFieldBlurY;
  151031. private _dofMerge;
  151032. /**
  151033. * @hidden Internal post processes in depth of field effect
  151034. */
  151035. _effects: Array<PostProcess>;
  151036. /**
  151037. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151038. */
  151039. set focalLength(value: number);
  151040. get focalLength(): number;
  151041. /**
  151042. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151043. */
  151044. set fStop(value: number);
  151045. get fStop(): number;
  151046. /**
  151047. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151048. */
  151049. set focusDistance(value: number);
  151050. get focusDistance(): number;
  151051. /**
  151052. * 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.
  151053. */
  151054. set lensSize(value: number);
  151055. get lensSize(): number;
  151056. /**
  151057. * Creates a new instance DepthOfFieldEffect
  151058. * @param scene The scene the effect belongs to.
  151059. * @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.
  151060. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151061. * @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)
  151062. */
  151063. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151064. /**
  151065. * Get the current class name of the current effet
  151066. * @returns "DepthOfFieldEffect"
  151067. */
  151068. getClassName(): string;
  151069. /**
  151070. * 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.
  151071. */
  151072. set depthTexture(value: RenderTargetTexture);
  151073. /**
  151074. * Disposes each of the internal effects for a given camera.
  151075. * @param camera The camera to dispose the effect on.
  151076. */
  151077. disposeEffects(camera: Camera): void;
  151078. /**
  151079. * @hidden Internal
  151080. */
  151081. _updateEffects(): void;
  151082. /**
  151083. * Internal
  151084. * @returns if all the contained post processes are ready.
  151085. * @hidden
  151086. */
  151087. _isReady(): boolean;
  151088. }
  151089. }
  151090. declare module BABYLON {
  151091. /** @hidden */
  151092. export var displayPassPixelShader: {
  151093. name: string;
  151094. shader: string;
  151095. };
  151096. }
  151097. declare module BABYLON {
  151098. /**
  151099. * DisplayPassPostProcess which produces an output the same as it's input
  151100. */
  151101. export class DisplayPassPostProcess extends PostProcess {
  151102. /**
  151103. * Gets a string identifying the name of the class
  151104. * @returns "DisplayPassPostProcess" string
  151105. */
  151106. getClassName(): string;
  151107. /**
  151108. * Creates the DisplayPassPostProcess
  151109. * @param name The name of the effect.
  151110. * @param options The required width/height ratio to downsize to before computing the render pass.
  151111. * @param camera The camera to apply the render pass to.
  151112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151113. * @param engine The engine which the post process will be applied. (default: current engine)
  151114. * @param reusable If the post process can be reused on the same frame. (default: false)
  151115. */
  151116. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151117. /** @hidden */
  151118. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151119. }
  151120. }
  151121. declare module BABYLON {
  151122. /** @hidden */
  151123. export var filterPixelShader: {
  151124. name: string;
  151125. shader: string;
  151126. };
  151127. }
  151128. declare module BABYLON {
  151129. /**
  151130. * Applies a kernel filter to the image
  151131. */
  151132. export class FilterPostProcess extends PostProcess {
  151133. /** The matrix to be applied to the image */
  151134. kernelMatrix: Matrix;
  151135. /**
  151136. * Gets a string identifying the name of the class
  151137. * @returns "FilterPostProcess" string
  151138. */
  151139. getClassName(): string;
  151140. /**
  151141. *
  151142. * @param name The name of the effect.
  151143. * @param kernelMatrix The matrix to be applied to the image
  151144. * @param options The required width/height ratio to downsize to before computing the render pass.
  151145. * @param camera The camera to apply the render pass to.
  151146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151147. * @param engine The engine which the post process will be applied. (default: current engine)
  151148. * @param reusable If the post process can be reused on the same frame. (default: false)
  151149. */
  151150. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151151. /** @hidden */
  151152. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151153. }
  151154. }
  151155. declare module BABYLON {
  151156. /** @hidden */
  151157. export var fxaaPixelShader: {
  151158. name: string;
  151159. shader: string;
  151160. };
  151161. }
  151162. declare module BABYLON {
  151163. /** @hidden */
  151164. export var fxaaVertexShader: {
  151165. name: string;
  151166. shader: string;
  151167. };
  151168. }
  151169. declare module BABYLON {
  151170. /**
  151171. * Fxaa post process
  151172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151173. */
  151174. export class FxaaPostProcess extends PostProcess {
  151175. /**
  151176. * Gets a string identifying the name of the class
  151177. * @returns "FxaaPostProcess" string
  151178. */
  151179. getClassName(): string;
  151180. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151181. private _getDefines;
  151182. /** @hidden */
  151183. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151184. }
  151185. }
  151186. declare module BABYLON {
  151187. /** @hidden */
  151188. export var grainPixelShader: {
  151189. name: string;
  151190. shader: string;
  151191. };
  151192. }
  151193. declare module BABYLON {
  151194. /**
  151195. * The GrainPostProcess adds noise to the image at mid luminance levels
  151196. */
  151197. export class GrainPostProcess extends PostProcess {
  151198. /**
  151199. * The intensity of the grain added (default: 30)
  151200. */
  151201. intensity: number;
  151202. /**
  151203. * If the grain should be randomized on every frame
  151204. */
  151205. animated: boolean;
  151206. /**
  151207. * Gets a string identifying the name of the class
  151208. * @returns "GrainPostProcess" string
  151209. */
  151210. getClassName(): string;
  151211. /**
  151212. * Creates a new instance of @see GrainPostProcess
  151213. * @param name The name of the effect.
  151214. * @param options The required width/height ratio to downsize to before computing the render pass.
  151215. * @param camera The camera to apply the render pass to.
  151216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151217. * @param engine The engine which the post process will be applied. (default: current engine)
  151218. * @param reusable If the post process can be reused on the same frame. (default: false)
  151219. * @param textureType Type of textures used when performing the post process. (default: 0)
  151220. * @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)
  151221. */
  151222. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151223. /** @hidden */
  151224. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151225. }
  151226. }
  151227. declare module BABYLON {
  151228. /** @hidden */
  151229. export var highlightsPixelShader: {
  151230. name: string;
  151231. shader: string;
  151232. };
  151233. }
  151234. declare module BABYLON {
  151235. /**
  151236. * Extracts highlights from the image
  151237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151238. */
  151239. export class HighlightsPostProcess extends PostProcess {
  151240. /**
  151241. * Gets a string identifying the name of the class
  151242. * @returns "HighlightsPostProcess" string
  151243. */
  151244. getClassName(): string;
  151245. /**
  151246. * Extracts highlights from the image
  151247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151248. * @param name The name of the effect.
  151249. * @param options The required width/height ratio to downsize to before computing the render pass.
  151250. * @param camera The camera to apply the render pass to.
  151251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151252. * @param engine The engine which the post process will be applied. (default: current engine)
  151253. * @param reusable If the post process can be reused on the same frame. (default: false)
  151254. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151255. */
  151256. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151257. }
  151258. }
  151259. declare module BABYLON {
  151260. /**
  151261. * Contains all parameters needed for the prepass to perform
  151262. * motion blur
  151263. */
  151264. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151265. /**
  151266. * Is motion blur enabled
  151267. */
  151268. enabled: boolean;
  151269. /**
  151270. * Name of the configuration
  151271. */
  151272. name: string;
  151273. /**
  151274. * Textures that should be present in the MRT for this effect to work
  151275. */
  151276. readonly texturesRequired: number[];
  151277. }
  151278. }
  151279. declare module BABYLON {
  151280. interface Scene {
  151281. /** @hidden (Backing field) */
  151282. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151283. /**
  151284. * Gets or Sets the current geometry buffer associated to the scene.
  151285. */
  151286. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151287. /**
  151288. * Enables a GeometryBufferRender and associates it with the scene
  151289. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151290. * @returns the GeometryBufferRenderer
  151291. */
  151292. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151293. /**
  151294. * Disables the GeometryBufferRender associated with the scene
  151295. */
  151296. disableGeometryBufferRenderer(): void;
  151297. }
  151298. /**
  151299. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151300. * in several rendering techniques.
  151301. */
  151302. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151303. /**
  151304. * The component name helpful to identify the component in the list of scene components.
  151305. */
  151306. readonly name: string;
  151307. /**
  151308. * The scene the component belongs to.
  151309. */
  151310. scene: Scene;
  151311. /**
  151312. * Creates a new instance of the component for the given scene
  151313. * @param scene Defines the scene to register the component in
  151314. */
  151315. constructor(scene: Scene);
  151316. /**
  151317. * Registers the component in a given scene
  151318. */
  151319. register(): void;
  151320. /**
  151321. * Rebuilds the elements related to this component in case of
  151322. * context lost for instance.
  151323. */
  151324. rebuild(): void;
  151325. /**
  151326. * Disposes the component and the associated ressources
  151327. */
  151328. dispose(): void;
  151329. private _gatherRenderTargets;
  151330. }
  151331. }
  151332. declare module BABYLON {
  151333. /** @hidden */
  151334. export var motionBlurPixelShader: {
  151335. name: string;
  151336. shader: string;
  151337. };
  151338. }
  151339. declare module BABYLON {
  151340. /**
  151341. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151342. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151343. * As an example, all you have to do is to create the post-process:
  151344. * var mb = new BABYLON.MotionBlurPostProcess(
  151345. * 'mb', // The name of the effect.
  151346. * scene, // The scene containing the objects to blur according to their velocity.
  151347. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151348. * camera // The camera to apply the render pass to.
  151349. * );
  151350. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151351. */
  151352. export class MotionBlurPostProcess extends PostProcess {
  151353. /**
  151354. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151355. */
  151356. motionStrength: number;
  151357. /**
  151358. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151359. */
  151360. get motionBlurSamples(): number;
  151361. /**
  151362. * Sets the number of iterations to be used for motion blur quality
  151363. */
  151364. set motionBlurSamples(samples: number);
  151365. private _motionBlurSamples;
  151366. private _forceGeometryBuffer;
  151367. private _geometryBufferRenderer;
  151368. private _prePassRenderer;
  151369. /**
  151370. * Gets a string identifying the name of the class
  151371. * @returns "MotionBlurPostProcess" string
  151372. */
  151373. getClassName(): string;
  151374. /**
  151375. * Creates a new instance MotionBlurPostProcess
  151376. * @param name The name of the effect.
  151377. * @param scene The scene containing the objects to blur according to their velocity.
  151378. * @param options The required width/height ratio to downsize to before computing the render pass.
  151379. * @param camera The camera to apply the render pass to.
  151380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151381. * @param engine The engine which the post process will be applied. (default: current engine)
  151382. * @param reusable If the post process can be reused on the same frame. (default: false)
  151383. * @param textureType Type of textures used when performing the post process. (default: 0)
  151384. * @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)
  151385. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151386. */
  151387. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151388. /**
  151389. * Excludes the given skinned mesh from computing bones velocities.
  151390. * 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.
  151391. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151392. */
  151393. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151394. /**
  151395. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151396. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151397. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151398. */
  151399. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151400. /**
  151401. * Disposes the post process.
  151402. * @param camera The camera to dispose the post process on.
  151403. */
  151404. dispose(camera?: Camera): void;
  151405. /** @hidden */
  151406. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151407. }
  151408. }
  151409. declare module BABYLON {
  151410. /** @hidden */
  151411. export var refractionPixelShader: {
  151412. name: string;
  151413. shader: string;
  151414. };
  151415. }
  151416. declare module BABYLON {
  151417. /**
  151418. * Post process which applies a refractin texture
  151419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151420. */
  151421. export class RefractionPostProcess extends PostProcess {
  151422. private _refTexture;
  151423. private _ownRefractionTexture;
  151424. /** the base color of the refraction (used to taint the rendering) */
  151425. color: Color3;
  151426. /** simulated refraction depth */
  151427. depth: number;
  151428. /** the coefficient of the base color (0 to remove base color tainting) */
  151429. colorLevel: number;
  151430. /** Gets the url used to load the refraction texture */
  151431. refractionTextureUrl: string;
  151432. /**
  151433. * Gets or sets the refraction texture
  151434. * Please note that you are responsible for disposing the texture if you set it manually
  151435. */
  151436. get refractionTexture(): Texture;
  151437. set refractionTexture(value: Texture);
  151438. /**
  151439. * Gets a string identifying the name of the class
  151440. * @returns "RefractionPostProcess" string
  151441. */
  151442. getClassName(): string;
  151443. /**
  151444. * Initializes the RefractionPostProcess
  151445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151446. * @param name The name of the effect.
  151447. * @param refractionTextureUrl Url of the refraction texture to use
  151448. * @param color the base color of the refraction (used to taint the rendering)
  151449. * @param depth simulated refraction depth
  151450. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151451. * @param camera The camera to apply the render pass to.
  151452. * @param options The required width/height ratio to downsize to before computing the render pass.
  151453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151454. * @param engine The engine which the post process will be applied. (default: current engine)
  151455. * @param reusable If the post process can be reused on the same frame. (default: false)
  151456. */
  151457. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151458. /**
  151459. * Disposes of the post process
  151460. * @param camera Camera to dispose post process on
  151461. */
  151462. dispose(camera: Camera): void;
  151463. /** @hidden */
  151464. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151465. }
  151466. }
  151467. declare module BABYLON {
  151468. /** @hidden */
  151469. export var sharpenPixelShader: {
  151470. name: string;
  151471. shader: string;
  151472. };
  151473. }
  151474. declare module BABYLON {
  151475. /**
  151476. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151477. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151478. */
  151479. export class SharpenPostProcess extends PostProcess {
  151480. /**
  151481. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151482. */
  151483. colorAmount: number;
  151484. /**
  151485. * How much sharpness should be applied (default: 0.3)
  151486. */
  151487. edgeAmount: number;
  151488. /**
  151489. * Gets a string identifying the name of the class
  151490. * @returns "SharpenPostProcess" string
  151491. */
  151492. getClassName(): string;
  151493. /**
  151494. * Creates a new instance ConvolutionPostProcess
  151495. * @param name The name of the effect.
  151496. * @param options The required width/height ratio to downsize to before computing the render pass.
  151497. * @param camera The camera to apply the render pass to.
  151498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151499. * @param engine The engine which the post process will be applied. (default: current engine)
  151500. * @param reusable If the post process can be reused on the same frame. (default: false)
  151501. * @param textureType Type of textures used when performing the post process. (default: 0)
  151502. * @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)
  151503. */
  151504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151505. /** @hidden */
  151506. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151507. }
  151508. }
  151509. declare module BABYLON {
  151510. /**
  151511. * PostProcessRenderPipeline
  151512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151513. */
  151514. export class PostProcessRenderPipeline {
  151515. private engine;
  151516. private _renderEffects;
  151517. private _renderEffectsForIsolatedPass;
  151518. /**
  151519. * List of inspectable custom properties (used by the Inspector)
  151520. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151521. */
  151522. inspectableCustomProperties: IInspectable[];
  151523. /**
  151524. * @hidden
  151525. */
  151526. protected _cameras: Camera[];
  151527. /** @hidden */
  151528. _name: string;
  151529. /**
  151530. * Gets pipeline name
  151531. */
  151532. get name(): string;
  151533. /** Gets the list of attached cameras */
  151534. get cameras(): Camera[];
  151535. /**
  151536. * Initializes a PostProcessRenderPipeline
  151537. * @param engine engine to add the pipeline to
  151538. * @param name name of the pipeline
  151539. */
  151540. constructor(engine: Engine, name: string);
  151541. /**
  151542. * Gets the class name
  151543. * @returns "PostProcessRenderPipeline"
  151544. */
  151545. getClassName(): string;
  151546. /**
  151547. * If all the render effects in the pipeline are supported
  151548. */
  151549. get isSupported(): boolean;
  151550. /**
  151551. * Adds an effect to the pipeline
  151552. * @param renderEffect the effect to add
  151553. */
  151554. addEffect(renderEffect: PostProcessRenderEffect): void;
  151555. /** @hidden */
  151556. _rebuild(): void;
  151557. /** @hidden */
  151558. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151559. /** @hidden */
  151560. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151561. /** @hidden */
  151562. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151563. /** @hidden */
  151564. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151565. /** @hidden */
  151566. _attachCameras(cameras: Camera, unique: boolean): void;
  151567. /** @hidden */
  151568. _attachCameras(cameras: Camera[], unique: boolean): void;
  151569. /** @hidden */
  151570. _detachCameras(cameras: Camera): void;
  151571. /** @hidden */
  151572. _detachCameras(cameras: Nullable<Camera[]>): void;
  151573. /** @hidden */
  151574. _update(): void;
  151575. /** @hidden */
  151576. _reset(): void;
  151577. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151578. /**
  151579. * Sets the required values to the prepass renderer.
  151580. * @param prePassRenderer defines the prepass renderer to setup.
  151581. * @returns true if the pre pass is needed.
  151582. */
  151583. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151584. /**
  151585. * Disposes of the pipeline
  151586. */
  151587. dispose(): void;
  151588. }
  151589. }
  151590. declare module BABYLON {
  151591. /**
  151592. * PostProcessRenderPipelineManager class
  151593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151594. */
  151595. export class PostProcessRenderPipelineManager {
  151596. private _renderPipelines;
  151597. /**
  151598. * Initializes a PostProcessRenderPipelineManager
  151599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151600. */
  151601. constructor();
  151602. /**
  151603. * Gets the list of supported render pipelines
  151604. */
  151605. get supportedPipelines(): PostProcessRenderPipeline[];
  151606. /**
  151607. * Adds a pipeline to the manager
  151608. * @param renderPipeline The pipeline to add
  151609. */
  151610. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151611. /**
  151612. * Attaches a camera to the pipeline
  151613. * @param renderPipelineName The name of the pipeline to attach to
  151614. * @param cameras the camera to attach
  151615. * @param unique if the camera can be attached multiple times to the pipeline
  151616. */
  151617. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151618. /**
  151619. * Detaches a camera from the pipeline
  151620. * @param renderPipelineName The name of the pipeline to detach from
  151621. * @param cameras the camera to detach
  151622. */
  151623. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151624. /**
  151625. * Enables an effect by name on a pipeline
  151626. * @param renderPipelineName the name of the pipeline to enable the effect in
  151627. * @param renderEffectName the name of the effect to enable
  151628. * @param cameras the cameras that the effect should be enabled on
  151629. */
  151630. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151631. /**
  151632. * Disables an effect by name on a pipeline
  151633. * @param renderPipelineName the name of the pipeline to disable the effect in
  151634. * @param renderEffectName the name of the effect to disable
  151635. * @param cameras the cameras that the effect should be disabled on
  151636. */
  151637. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151638. /**
  151639. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151640. */
  151641. update(): void;
  151642. /** @hidden */
  151643. _rebuild(): void;
  151644. /**
  151645. * Disposes of the manager and pipelines
  151646. */
  151647. dispose(): void;
  151648. }
  151649. }
  151650. declare module BABYLON {
  151651. interface Scene {
  151652. /** @hidden (Backing field) */
  151653. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151654. /**
  151655. * Gets the postprocess render pipeline manager
  151656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151657. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151658. */
  151659. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151660. }
  151661. /**
  151662. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151663. */
  151664. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151665. /**
  151666. * The component name helpfull to identify the component in the list of scene components.
  151667. */
  151668. readonly name: string;
  151669. /**
  151670. * The scene the component belongs to.
  151671. */
  151672. scene: Scene;
  151673. /**
  151674. * Creates a new instance of the component for the given scene
  151675. * @param scene Defines the scene to register the component in
  151676. */
  151677. constructor(scene: Scene);
  151678. /**
  151679. * Registers the component in a given scene
  151680. */
  151681. register(): void;
  151682. /**
  151683. * Rebuilds the elements related to this component in case of
  151684. * context lost for instance.
  151685. */
  151686. rebuild(): void;
  151687. /**
  151688. * Disposes the component and the associated ressources
  151689. */
  151690. dispose(): void;
  151691. private _gatherRenderTargets;
  151692. }
  151693. }
  151694. declare module BABYLON {
  151695. /**
  151696. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151697. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151698. */
  151699. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151700. private _scene;
  151701. private _camerasToBeAttached;
  151702. /**
  151703. * ID of the sharpen post process,
  151704. */
  151705. private readonly SharpenPostProcessId;
  151706. /**
  151707. * @ignore
  151708. * ID of the image processing post process;
  151709. */
  151710. readonly ImageProcessingPostProcessId: string;
  151711. /**
  151712. * @ignore
  151713. * ID of the Fast Approximate Anti-Aliasing post process;
  151714. */
  151715. readonly FxaaPostProcessId: string;
  151716. /**
  151717. * ID of the chromatic aberration post process,
  151718. */
  151719. private readonly ChromaticAberrationPostProcessId;
  151720. /**
  151721. * ID of the grain post process
  151722. */
  151723. private readonly GrainPostProcessId;
  151724. /**
  151725. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151726. */
  151727. sharpen: SharpenPostProcess;
  151728. private _sharpenEffect;
  151729. private bloom;
  151730. /**
  151731. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151732. */
  151733. depthOfField: DepthOfFieldEffect;
  151734. /**
  151735. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151736. */
  151737. fxaa: FxaaPostProcess;
  151738. /**
  151739. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151740. */
  151741. imageProcessing: ImageProcessingPostProcess;
  151742. /**
  151743. * Chromatic aberration post process which will shift rgb colors in the image
  151744. */
  151745. chromaticAberration: ChromaticAberrationPostProcess;
  151746. private _chromaticAberrationEffect;
  151747. /**
  151748. * Grain post process which add noise to the image
  151749. */
  151750. grain: GrainPostProcess;
  151751. private _grainEffect;
  151752. /**
  151753. * Glow post process which adds a glow to emissive areas of the image
  151754. */
  151755. private _glowLayer;
  151756. /**
  151757. * Animations which can be used to tweak settings over a period of time
  151758. */
  151759. animations: Animation[];
  151760. private _imageProcessingConfigurationObserver;
  151761. private _sharpenEnabled;
  151762. private _bloomEnabled;
  151763. private _depthOfFieldEnabled;
  151764. private _depthOfFieldBlurLevel;
  151765. private _fxaaEnabled;
  151766. private _imageProcessingEnabled;
  151767. private _defaultPipelineTextureType;
  151768. private _bloomScale;
  151769. private _chromaticAberrationEnabled;
  151770. private _grainEnabled;
  151771. private _buildAllowed;
  151772. /**
  151773. * Gets active scene
  151774. */
  151775. get scene(): Scene;
  151776. /**
  151777. * Enable or disable the sharpen process from the pipeline
  151778. */
  151779. set sharpenEnabled(enabled: boolean);
  151780. get sharpenEnabled(): boolean;
  151781. private _resizeObserver;
  151782. private _hardwareScaleLevel;
  151783. private _bloomKernel;
  151784. /**
  151785. * Specifies the size of the bloom blur kernel, relative to the final output size
  151786. */
  151787. get bloomKernel(): number;
  151788. set bloomKernel(value: number);
  151789. /**
  151790. * Specifies the weight of the bloom in the final rendering
  151791. */
  151792. private _bloomWeight;
  151793. /**
  151794. * Specifies the luma threshold for the area that will be blurred by the bloom
  151795. */
  151796. private _bloomThreshold;
  151797. private _hdr;
  151798. /**
  151799. * The strength of the bloom.
  151800. */
  151801. set bloomWeight(value: number);
  151802. get bloomWeight(): number;
  151803. /**
  151804. * The strength of the bloom.
  151805. */
  151806. set bloomThreshold(value: number);
  151807. get bloomThreshold(): number;
  151808. /**
  151809. * The scale of the bloom, lower value will provide better performance.
  151810. */
  151811. set bloomScale(value: number);
  151812. get bloomScale(): number;
  151813. /**
  151814. * Enable or disable the bloom from the pipeline
  151815. */
  151816. set bloomEnabled(enabled: boolean);
  151817. get bloomEnabled(): boolean;
  151818. private _rebuildBloom;
  151819. /**
  151820. * If the depth of field is enabled.
  151821. */
  151822. get depthOfFieldEnabled(): boolean;
  151823. set depthOfFieldEnabled(enabled: boolean);
  151824. /**
  151825. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151826. */
  151827. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151828. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151829. /**
  151830. * If the anti aliasing is enabled.
  151831. */
  151832. set fxaaEnabled(enabled: boolean);
  151833. get fxaaEnabled(): boolean;
  151834. private _samples;
  151835. /**
  151836. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151837. */
  151838. set samples(sampleCount: number);
  151839. get samples(): number;
  151840. /**
  151841. * If image processing is enabled.
  151842. */
  151843. set imageProcessingEnabled(enabled: boolean);
  151844. get imageProcessingEnabled(): boolean;
  151845. /**
  151846. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151847. */
  151848. set glowLayerEnabled(enabled: boolean);
  151849. get glowLayerEnabled(): boolean;
  151850. /**
  151851. * Gets the glow layer (or null if not defined)
  151852. */
  151853. get glowLayer(): Nullable<GlowLayer>;
  151854. /**
  151855. * Enable or disable the chromaticAberration process from the pipeline
  151856. */
  151857. set chromaticAberrationEnabled(enabled: boolean);
  151858. get chromaticAberrationEnabled(): boolean;
  151859. /**
  151860. * Enable or disable the grain process from the pipeline
  151861. */
  151862. set grainEnabled(enabled: boolean);
  151863. get grainEnabled(): boolean;
  151864. /**
  151865. * @constructor
  151866. * @param name - The rendering pipeline name (default: "")
  151867. * @param hdr - If high dynamic range textures should be used (default: true)
  151868. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151869. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151870. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151871. */
  151872. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151873. /**
  151874. * Get the class name
  151875. * @returns "DefaultRenderingPipeline"
  151876. */
  151877. getClassName(): string;
  151878. /**
  151879. * Force the compilation of the entire pipeline.
  151880. */
  151881. prepare(): void;
  151882. private _hasCleared;
  151883. private _prevPostProcess;
  151884. private _prevPrevPostProcess;
  151885. private _setAutoClearAndTextureSharing;
  151886. private _depthOfFieldSceneObserver;
  151887. private _buildPipeline;
  151888. private _disposePostProcesses;
  151889. /**
  151890. * Adds a camera to the pipeline
  151891. * @param camera the camera to be added
  151892. */
  151893. addCamera(camera: Camera): void;
  151894. /**
  151895. * Removes a camera from the pipeline
  151896. * @param camera the camera to remove
  151897. */
  151898. removeCamera(camera: Camera): void;
  151899. /**
  151900. * Dispose of the pipeline and stop all post processes
  151901. */
  151902. dispose(): void;
  151903. /**
  151904. * Serialize the rendering pipeline (Used when exporting)
  151905. * @returns the serialized object
  151906. */
  151907. serialize(): any;
  151908. /**
  151909. * Parse the serialized pipeline
  151910. * @param source Source pipeline.
  151911. * @param scene The scene to load the pipeline to.
  151912. * @param rootUrl The URL of the serialized pipeline.
  151913. * @returns An instantiated pipeline from the serialized object.
  151914. */
  151915. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151916. }
  151917. }
  151918. declare module BABYLON {
  151919. /** @hidden */
  151920. export var lensHighlightsPixelShader: {
  151921. name: string;
  151922. shader: string;
  151923. };
  151924. }
  151925. declare module BABYLON {
  151926. /** @hidden */
  151927. export var depthOfFieldPixelShader: {
  151928. name: string;
  151929. shader: string;
  151930. };
  151931. }
  151932. declare module BABYLON {
  151933. /**
  151934. * BABYLON.JS Chromatic Aberration GLSL Shader
  151935. * Author: Olivier Guyot
  151936. * Separates very slightly R, G and B colors on the edges of the screen
  151937. * Inspired by Francois Tarlier & Martins Upitis
  151938. */
  151939. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151940. /**
  151941. * @ignore
  151942. * The chromatic aberration PostProcess id in the pipeline
  151943. */
  151944. LensChromaticAberrationEffect: string;
  151945. /**
  151946. * @ignore
  151947. * The highlights enhancing PostProcess id in the pipeline
  151948. */
  151949. HighlightsEnhancingEffect: string;
  151950. /**
  151951. * @ignore
  151952. * The depth-of-field PostProcess id in the pipeline
  151953. */
  151954. LensDepthOfFieldEffect: string;
  151955. private _scene;
  151956. private _depthTexture;
  151957. private _grainTexture;
  151958. private _chromaticAberrationPostProcess;
  151959. private _highlightsPostProcess;
  151960. private _depthOfFieldPostProcess;
  151961. private _edgeBlur;
  151962. private _grainAmount;
  151963. private _chromaticAberration;
  151964. private _distortion;
  151965. private _highlightsGain;
  151966. private _highlightsThreshold;
  151967. private _dofDistance;
  151968. private _dofAperture;
  151969. private _dofDarken;
  151970. private _dofPentagon;
  151971. private _blurNoise;
  151972. /**
  151973. * @constructor
  151974. *
  151975. * Effect parameters are as follow:
  151976. * {
  151977. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151978. * edge_blur: number; // from 0 to x (1 for realism)
  151979. * distortion: number; // from 0 to x (1 for realism)
  151980. * grain_amount: number; // from 0 to 1
  151981. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151982. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151983. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151984. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151985. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151986. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151987. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151988. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151989. * }
  151990. * Note: if an effect parameter is unset, effect is disabled
  151991. *
  151992. * @param name The rendering pipeline name
  151993. * @param parameters - An object containing all parameters (see above)
  151994. * @param scene The scene linked to this pipeline
  151995. * @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)
  151996. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151997. */
  151998. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151999. /**
  152000. * Get the class name
  152001. * @returns "LensRenderingPipeline"
  152002. */
  152003. getClassName(): string;
  152004. /**
  152005. * Gets associated scene
  152006. */
  152007. get scene(): Scene;
  152008. /**
  152009. * Gets or sets the edge blur
  152010. */
  152011. get edgeBlur(): number;
  152012. set edgeBlur(value: number);
  152013. /**
  152014. * Gets or sets the grain amount
  152015. */
  152016. get grainAmount(): number;
  152017. set grainAmount(value: number);
  152018. /**
  152019. * Gets or sets the chromatic aberration amount
  152020. */
  152021. get chromaticAberration(): number;
  152022. set chromaticAberration(value: number);
  152023. /**
  152024. * Gets or sets the depth of field aperture
  152025. */
  152026. get dofAperture(): number;
  152027. set dofAperture(value: number);
  152028. /**
  152029. * Gets or sets the edge distortion
  152030. */
  152031. get edgeDistortion(): number;
  152032. set edgeDistortion(value: number);
  152033. /**
  152034. * Gets or sets the depth of field distortion
  152035. */
  152036. get dofDistortion(): number;
  152037. set dofDistortion(value: number);
  152038. /**
  152039. * Gets or sets the darken out of focus amount
  152040. */
  152041. get darkenOutOfFocus(): number;
  152042. set darkenOutOfFocus(value: number);
  152043. /**
  152044. * Gets or sets a boolean indicating if blur noise is enabled
  152045. */
  152046. get blurNoise(): boolean;
  152047. set blurNoise(value: boolean);
  152048. /**
  152049. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152050. */
  152051. get pentagonBokeh(): boolean;
  152052. set pentagonBokeh(value: boolean);
  152053. /**
  152054. * Gets or sets the highlight grain amount
  152055. */
  152056. get highlightsGain(): number;
  152057. set highlightsGain(value: number);
  152058. /**
  152059. * Gets or sets the highlight threshold
  152060. */
  152061. get highlightsThreshold(): number;
  152062. set highlightsThreshold(value: number);
  152063. /**
  152064. * Sets the amount of blur at the edges
  152065. * @param amount blur amount
  152066. */
  152067. setEdgeBlur(amount: number): void;
  152068. /**
  152069. * Sets edge blur to 0
  152070. */
  152071. disableEdgeBlur(): void;
  152072. /**
  152073. * Sets the amout of grain
  152074. * @param amount Amount of grain
  152075. */
  152076. setGrainAmount(amount: number): void;
  152077. /**
  152078. * Set grain amount to 0
  152079. */
  152080. disableGrain(): void;
  152081. /**
  152082. * Sets the chromatic aberration amount
  152083. * @param amount amount of chromatic aberration
  152084. */
  152085. setChromaticAberration(amount: number): void;
  152086. /**
  152087. * Sets chromatic aberration amount to 0
  152088. */
  152089. disableChromaticAberration(): void;
  152090. /**
  152091. * Sets the EdgeDistortion amount
  152092. * @param amount amount of EdgeDistortion
  152093. */
  152094. setEdgeDistortion(amount: number): void;
  152095. /**
  152096. * Sets edge distortion to 0
  152097. */
  152098. disableEdgeDistortion(): void;
  152099. /**
  152100. * Sets the FocusDistance amount
  152101. * @param amount amount of FocusDistance
  152102. */
  152103. setFocusDistance(amount: number): void;
  152104. /**
  152105. * Disables depth of field
  152106. */
  152107. disableDepthOfField(): void;
  152108. /**
  152109. * Sets the Aperture amount
  152110. * @param amount amount of Aperture
  152111. */
  152112. setAperture(amount: number): void;
  152113. /**
  152114. * Sets the DarkenOutOfFocus amount
  152115. * @param amount amount of DarkenOutOfFocus
  152116. */
  152117. setDarkenOutOfFocus(amount: number): void;
  152118. private _pentagonBokehIsEnabled;
  152119. /**
  152120. * Creates a pentagon bokeh effect
  152121. */
  152122. enablePentagonBokeh(): void;
  152123. /**
  152124. * Disables the pentagon bokeh effect
  152125. */
  152126. disablePentagonBokeh(): void;
  152127. /**
  152128. * Enables noise blur
  152129. */
  152130. enableNoiseBlur(): void;
  152131. /**
  152132. * Disables noise blur
  152133. */
  152134. disableNoiseBlur(): void;
  152135. /**
  152136. * Sets the HighlightsGain amount
  152137. * @param amount amount of HighlightsGain
  152138. */
  152139. setHighlightsGain(amount: number): void;
  152140. /**
  152141. * Sets the HighlightsThreshold amount
  152142. * @param amount amount of HighlightsThreshold
  152143. */
  152144. setHighlightsThreshold(amount: number): void;
  152145. /**
  152146. * Disables highlights
  152147. */
  152148. disableHighlights(): void;
  152149. /**
  152150. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152151. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152152. */
  152153. dispose(disableDepthRender?: boolean): void;
  152154. private _createChromaticAberrationPostProcess;
  152155. private _createHighlightsPostProcess;
  152156. private _createDepthOfFieldPostProcess;
  152157. private _createGrainTexture;
  152158. }
  152159. }
  152160. declare module BABYLON {
  152161. /**
  152162. * Contains all parameters needed for the prepass to perform
  152163. * screen space subsurface scattering
  152164. */
  152165. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152166. /**
  152167. * Is subsurface enabled
  152168. */
  152169. enabled: boolean;
  152170. /**
  152171. * Name of the configuration
  152172. */
  152173. name: string;
  152174. /**
  152175. * Textures that should be present in the MRT for this effect to work
  152176. */
  152177. readonly texturesRequired: number[];
  152178. }
  152179. }
  152180. declare module BABYLON {
  152181. /** @hidden */
  152182. export var ssao2PixelShader: {
  152183. name: string;
  152184. shader: string;
  152185. };
  152186. }
  152187. declare module BABYLON {
  152188. /** @hidden */
  152189. export var ssaoCombinePixelShader: {
  152190. name: string;
  152191. shader: string;
  152192. };
  152193. }
  152194. declare module BABYLON {
  152195. /**
  152196. * Render pipeline to produce ssao effect
  152197. */
  152198. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152199. /**
  152200. * @ignore
  152201. * The PassPostProcess id in the pipeline that contains the original scene color
  152202. */
  152203. SSAOOriginalSceneColorEffect: string;
  152204. /**
  152205. * @ignore
  152206. * The SSAO PostProcess id in the pipeline
  152207. */
  152208. SSAORenderEffect: string;
  152209. /**
  152210. * @ignore
  152211. * The horizontal blur PostProcess id in the pipeline
  152212. */
  152213. SSAOBlurHRenderEffect: string;
  152214. /**
  152215. * @ignore
  152216. * The vertical blur PostProcess id in the pipeline
  152217. */
  152218. SSAOBlurVRenderEffect: string;
  152219. /**
  152220. * @ignore
  152221. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152222. */
  152223. SSAOCombineRenderEffect: string;
  152224. /**
  152225. * The output strength of the SSAO post-process. Default value is 1.0.
  152226. */
  152227. totalStrength: number;
  152228. /**
  152229. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152230. */
  152231. maxZ: number;
  152232. /**
  152233. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152234. */
  152235. minZAspect: number;
  152236. private _samples;
  152237. /**
  152238. * Number of samples used for the SSAO calculations. Default value is 8
  152239. */
  152240. set samples(n: number);
  152241. get samples(): number;
  152242. private _textureSamples;
  152243. /**
  152244. * Number of samples to use for antialiasing
  152245. */
  152246. set textureSamples(n: number);
  152247. get textureSamples(): number;
  152248. /**
  152249. * Force rendering the geometry through geometry buffer
  152250. */
  152251. private _forceGeometryBuffer;
  152252. /**
  152253. * Ratio object used for SSAO ratio and blur ratio
  152254. */
  152255. private _ratio;
  152256. /**
  152257. * Dynamically generated sphere sampler.
  152258. */
  152259. private _sampleSphere;
  152260. /**
  152261. * Blur filter offsets
  152262. */
  152263. private _samplerOffsets;
  152264. private _expensiveBlur;
  152265. /**
  152266. * If bilateral blur should be used
  152267. */
  152268. set expensiveBlur(b: boolean);
  152269. get expensiveBlur(): boolean;
  152270. /**
  152271. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152272. */
  152273. radius: number;
  152274. /**
  152275. * The base color of the SSAO post-process
  152276. * The final result is "base + ssao" between [0, 1]
  152277. */
  152278. base: number;
  152279. /**
  152280. * Support test.
  152281. */
  152282. static get IsSupported(): boolean;
  152283. private _scene;
  152284. private _randomTexture;
  152285. private _originalColorPostProcess;
  152286. private _ssaoPostProcess;
  152287. private _blurHPostProcess;
  152288. private _blurVPostProcess;
  152289. private _ssaoCombinePostProcess;
  152290. private _prePassRenderer;
  152291. /**
  152292. * Gets active scene
  152293. */
  152294. get scene(): Scene;
  152295. /**
  152296. * @constructor
  152297. * @param name The rendering pipeline name
  152298. * @param scene The scene linked to this pipeline
  152299. * @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 }
  152300. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152301. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152302. */
  152303. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152304. /**
  152305. * Get the class name
  152306. * @returns "SSAO2RenderingPipeline"
  152307. */
  152308. getClassName(): string;
  152309. /**
  152310. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152311. */
  152312. dispose(disableGeometryBufferRenderer?: boolean): void;
  152313. private _createBlurPostProcess;
  152314. /** @hidden */
  152315. _rebuild(): void;
  152316. private _bits;
  152317. private _radicalInverse_VdC;
  152318. private _hammersley;
  152319. private _hemisphereSample_uniform;
  152320. private _generateHemisphere;
  152321. private _getDefinesForSSAO;
  152322. private _createSSAOPostProcess;
  152323. private _createSSAOCombinePostProcess;
  152324. private _createRandomTexture;
  152325. /**
  152326. * Serialize the rendering pipeline (Used when exporting)
  152327. * @returns the serialized object
  152328. */
  152329. serialize(): any;
  152330. /**
  152331. * Parse the serialized pipeline
  152332. * @param source Source pipeline.
  152333. * @param scene The scene to load the pipeline to.
  152334. * @param rootUrl The URL of the serialized pipeline.
  152335. * @returns An instantiated pipeline from the serialized object.
  152336. */
  152337. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152338. }
  152339. }
  152340. declare module BABYLON {
  152341. /** @hidden */
  152342. export var ssaoPixelShader: {
  152343. name: string;
  152344. shader: string;
  152345. };
  152346. }
  152347. declare module BABYLON {
  152348. /**
  152349. * Render pipeline to produce ssao effect
  152350. */
  152351. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152352. /**
  152353. * @ignore
  152354. * The PassPostProcess id in the pipeline that contains the original scene color
  152355. */
  152356. SSAOOriginalSceneColorEffect: string;
  152357. /**
  152358. * @ignore
  152359. * The SSAO PostProcess id in the pipeline
  152360. */
  152361. SSAORenderEffect: string;
  152362. /**
  152363. * @ignore
  152364. * The horizontal blur PostProcess id in the pipeline
  152365. */
  152366. SSAOBlurHRenderEffect: string;
  152367. /**
  152368. * @ignore
  152369. * The vertical blur PostProcess id in the pipeline
  152370. */
  152371. SSAOBlurVRenderEffect: string;
  152372. /**
  152373. * @ignore
  152374. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152375. */
  152376. SSAOCombineRenderEffect: string;
  152377. /**
  152378. * The output strength of the SSAO post-process. Default value is 1.0.
  152379. */
  152380. totalStrength: number;
  152381. /**
  152382. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152383. */
  152384. radius: number;
  152385. /**
  152386. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152387. * Must not be equal to fallOff and superior to fallOff.
  152388. * Default value is 0.0075
  152389. */
  152390. area: number;
  152391. /**
  152392. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152393. * Must not be equal to area and inferior to area.
  152394. * Default value is 0.000001
  152395. */
  152396. fallOff: number;
  152397. /**
  152398. * The base color of the SSAO post-process
  152399. * The final result is "base + ssao" between [0, 1]
  152400. */
  152401. base: number;
  152402. private _scene;
  152403. private _depthTexture;
  152404. private _randomTexture;
  152405. private _originalColorPostProcess;
  152406. private _ssaoPostProcess;
  152407. private _blurHPostProcess;
  152408. private _blurVPostProcess;
  152409. private _ssaoCombinePostProcess;
  152410. private _firstUpdate;
  152411. /**
  152412. * Gets active scene
  152413. */
  152414. get scene(): Scene;
  152415. /**
  152416. * @constructor
  152417. * @param name - The rendering pipeline name
  152418. * @param scene - The scene linked to this pipeline
  152419. * @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 }
  152420. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152421. */
  152422. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152423. /**
  152424. * Get the class name
  152425. * @returns "SSAORenderingPipeline"
  152426. */
  152427. getClassName(): string;
  152428. /**
  152429. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152430. */
  152431. dispose(disableDepthRender?: boolean): void;
  152432. private _createBlurPostProcess;
  152433. /** @hidden */
  152434. _rebuild(): void;
  152435. private _createSSAOPostProcess;
  152436. private _createSSAOCombinePostProcess;
  152437. private _createRandomTexture;
  152438. }
  152439. }
  152440. declare module BABYLON {
  152441. /**
  152442. * Contains all parameters needed for the prepass to perform
  152443. * screen space reflections
  152444. */
  152445. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152446. /**
  152447. * Is ssr enabled
  152448. */
  152449. enabled: boolean;
  152450. /**
  152451. * Name of the configuration
  152452. */
  152453. name: string;
  152454. /**
  152455. * Textures that should be present in the MRT for this effect to work
  152456. */
  152457. readonly texturesRequired: number[];
  152458. }
  152459. }
  152460. declare module BABYLON {
  152461. /** @hidden */
  152462. export var screenSpaceReflectionPixelShader: {
  152463. name: string;
  152464. shader: string;
  152465. };
  152466. }
  152467. declare module BABYLON {
  152468. /**
  152469. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152470. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152471. */
  152472. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152473. /**
  152474. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152475. */
  152476. threshold: number;
  152477. /**
  152478. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152479. */
  152480. strength: number;
  152481. /**
  152482. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152483. */
  152484. reflectionSpecularFalloffExponent: number;
  152485. /**
  152486. * 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]
  152487. */
  152488. step: number;
  152489. /**
  152490. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152491. */
  152492. roughnessFactor: number;
  152493. private _forceGeometryBuffer;
  152494. private _geometryBufferRenderer;
  152495. private _prePassRenderer;
  152496. private _enableSmoothReflections;
  152497. private _reflectionSamples;
  152498. private _smoothSteps;
  152499. /**
  152500. * Gets a string identifying the name of the class
  152501. * @returns "ScreenSpaceReflectionPostProcess" string
  152502. */
  152503. getClassName(): string;
  152504. /**
  152505. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152506. * @param name The name of the effect.
  152507. * @param scene The scene containing the objects to calculate reflections.
  152508. * @param options The required width/height ratio to downsize to before computing the render pass.
  152509. * @param camera The camera to apply the render pass to.
  152510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152511. * @param engine The engine which the post process will be applied. (default: current engine)
  152512. * @param reusable If the post process can be reused on the same frame. (default: false)
  152513. * @param textureType Type of textures used when performing the post process. (default: 0)
  152514. * @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)
  152515. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152516. */
  152517. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152518. /**
  152519. * Gets wether or not smoothing reflections is enabled.
  152520. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152521. */
  152522. get enableSmoothReflections(): boolean;
  152523. /**
  152524. * Sets wether or not smoothing reflections is enabled.
  152525. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152526. */
  152527. set enableSmoothReflections(enabled: boolean);
  152528. /**
  152529. * Gets the number of samples taken while computing reflections. More samples count is high,
  152530. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152531. */
  152532. get reflectionSamples(): number;
  152533. /**
  152534. * Sets the number of samples taken while computing reflections. More samples count is high,
  152535. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152536. */
  152537. set reflectionSamples(samples: number);
  152538. /**
  152539. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152540. * more the post-process will require GPU power and can generate a drop in FPS.
  152541. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152542. */
  152543. get smoothSteps(): number;
  152544. set smoothSteps(steps: number);
  152545. private _updateEffectDefines;
  152546. /** @hidden */
  152547. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152548. }
  152549. }
  152550. declare module BABYLON {
  152551. /** @hidden */
  152552. export var standardPixelShader: {
  152553. name: string;
  152554. shader: string;
  152555. };
  152556. }
  152557. declare module BABYLON {
  152558. /**
  152559. * Standard rendering pipeline
  152560. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152561. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152562. */
  152563. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152564. /**
  152565. * Public members
  152566. */
  152567. /**
  152568. * Post-process which contains the original scene color before the pipeline applies all the effects
  152569. */
  152570. originalPostProcess: Nullable<PostProcess>;
  152571. /**
  152572. * Post-process used to down scale an image x4
  152573. */
  152574. downSampleX4PostProcess: Nullable<PostProcess>;
  152575. /**
  152576. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152577. */
  152578. brightPassPostProcess: Nullable<PostProcess>;
  152579. /**
  152580. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152581. */
  152582. blurHPostProcesses: PostProcess[];
  152583. /**
  152584. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152585. */
  152586. blurVPostProcesses: PostProcess[];
  152587. /**
  152588. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152589. */
  152590. textureAdderPostProcess: Nullable<PostProcess>;
  152591. /**
  152592. * Post-process used to create volumetric lighting effect
  152593. */
  152594. volumetricLightPostProcess: Nullable<PostProcess>;
  152595. /**
  152596. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152597. */
  152598. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152599. /**
  152600. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152601. */
  152602. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152603. /**
  152604. * Post-process used to merge the volumetric light effect and the real scene color
  152605. */
  152606. volumetricLightMergePostProces: Nullable<PostProcess>;
  152607. /**
  152608. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152609. */
  152610. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152611. /**
  152612. * Base post-process used to calculate the average luminance of the final image for HDR
  152613. */
  152614. luminancePostProcess: Nullable<PostProcess>;
  152615. /**
  152616. * Post-processes used to create down sample post-processes in order to get
  152617. * the average luminance of the final image for HDR
  152618. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152619. */
  152620. luminanceDownSamplePostProcesses: PostProcess[];
  152621. /**
  152622. * Post-process used to create a HDR effect (light adaptation)
  152623. */
  152624. hdrPostProcess: Nullable<PostProcess>;
  152625. /**
  152626. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152627. */
  152628. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152629. /**
  152630. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152631. */
  152632. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152633. /**
  152634. * Post-process used to merge the final HDR post-process and the real scene color
  152635. */
  152636. hdrFinalPostProcess: Nullable<PostProcess>;
  152637. /**
  152638. * Post-process used to create a lens flare effect
  152639. */
  152640. lensFlarePostProcess: Nullable<PostProcess>;
  152641. /**
  152642. * Post-process that merges the result of the lens flare post-process and the real scene color
  152643. */
  152644. lensFlareComposePostProcess: Nullable<PostProcess>;
  152645. /**
  152646. * Post-process used to create a motion blur effect
  152647. */
  152648. motionBlurPostProcess: Nullable<PostProcess>;
  152649. /**
  152650. * Post-process used to create a depth of field effect
  152651. */
  152652. depthOfFieldPostProcess: Nullable<PostProcess>;
  152653. /**
  152654. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152655. */
  152656. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152657. /**
  152658. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152659. */
  152660. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152661. /**
  152662. * Represents the brightness threshold in order to configure the illuminated surfaces
  152663. */
  152664. brightThreshold: number;
  152665. /**
  152666. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152667. */
  152668. blurWidth: number;
  152669. /**
  152670. * Sets if the blur for highlighted surfaces must be only horizontal
  152671. */
  152672. horizontalBlur: boolean;
  152673. /**
  152674. * Gets the overall exposure used by the pipeline
  152675. */
  152676. get exposure(): number;
  152677. /**
  152678. * Sets the overall exposure used by the pipeline
  152679. */
  152680. set exposure(value: number);
  152681. /**
  152682. * Texture used typically to simulate "dirty" on camera lens
  152683. */
  152684. lensTexture: Nullable<Texture>;
  152685. /**
  152686. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152687. */
  152688. volumetricLightCoefficient: number;
  152689. /**
  152690. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152691. */
  152692. volumetricLightPower: number;
  152693. /**
  152694. * Used the set the blur intensity to smooth the volumetric lights
  152695. */
  152696. volumetricLightBlurScale: number;
  152697. /**
  152698. * Light (spot or directional) used to generate the volumetric lights rays
  152699. * The source light must have a shadow generate so the pipeline can get its
  152700. * depth map
  152701. */
  152702. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152703. /**
  152704. * For eye adaptation, represents the minimum luminance the eye can see
  152705. */
  152706. hdrMinimumLuminance: number;
  152707. /**
  152708. * For eye adaptation, represents the decrease luminance speed
  152709. */
  152710. hdrDecreaseRate: number;
  152711. /**
  152712. * For eye adaptation, represents the increase luminance speed
  152713. */
  152714. hdrIncreaseRate: number;
  152715. /**
  152716. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152717. */
  152718. get hdrAutoExposure(): boolean;
  152719. /**
  152720. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152721. */
  152722. set hdrAutoExposure(value: boolean);
  152723. /**
  152724. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152725. */
  152726. lensColorTexture: Nullable<Texture>;
  152727. /**
  152728. * The overall strengh for the lens flare effect
  152729. */
  152730. lensFlareStrength: number;
  152731. /**
  152732. * Dispersion coefficient for lens flare ghosts
  152733. */
  152734. lensFlareGhostDispersal: number;
  152735. /**
  152736. * Main lens flare halo width
  152737. */
  152738. lensFlareHaloWidth: number;
  152739. /**
  152740. * Based on the lens distortion effect, defines how much the lens flare result
  152741. * is distorted
  152742. */
  152743. lensFlareDistortionStrength: number;
  152744. /**
  152745. * Configures the blur intensity used for for lens flare (halo)
  152746. */
  152747. lensFlareBlurWidth: number;
  152748. /**
  152749. * Lens star texture must be used to simulate rays on the flares and is available
  152750. * in the documentation
  152751. */
  152752. lensStarTexture: Nullable<Texture>;
  152753. /**
  152754. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152755. * flare effect by taking account of the dirt texture
  152756. */
  152757. lensFlareDirtTexture: Nullable<Texture>;
  152758. /**
  152759. * Represents the focal length for the depth of field effect
  152760. */
  152761. depthOfFieldDistance: number;
  152762. /**
  152763. * Represents the blur intensity for the blurred part of the depth of field effect
  152764. */
  152765. depthOfFieldBlurWidth: number;
  152766. /**
  152767. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152768. */
  152769. get motionStrength(): number;
  152770. /**
  152771. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152772. */
  152773. set motionStrength(strength: number);
  152774. /**
  152775. * Gets wether or not the motion blur post-process is object based or screen based.
  152776. */
  152777. get objectBasedMotionBlur(): boolean;
  152778. /**
  152779. * Sets wether or not the motion blur post-process should be object based or screen based
  152780. */
  152781. set objectBasedMotionBlur(value: boolean);
  152782. /**
  152783. * List of animations for the pipeline (IAnimatable implementation)
  152784. */
  152785. animations: Animation[];
  152786. /**
  152787. * Private members
  152788. */
  152789. private _scene;
  152790. private _currentDepthOfFieldSource;
  152791. private _basePostProcess;
  152792. private _fixedExposure;
  152793. private _currentExposure;
  152794. private _hdrAutoExposure;
  152795. private _hdrCurrentLuminance;
  152796. private _motionStrength;
  152797. private _isObjectBasedMotionBlur;
  152798. private _floatTextureType;
  152799. private _camerasToBeAttached;
  152800. private _ratio;
  152801. private _bloomEnabled;
  152802. private _depthOfFieldEnabled;
  152803. private _vlsEnabled;
  152804. private _lensFlareEnabled;
  152805. private _hdrEnabled;
  152806. private _motionBlurEnabled;
  152807. private _fxaaEnabled;
  152808. private _screenSpaceReflectionsEnabled;
  152809. private _motionBlurSamples;
  152810. private _volumetricLightStepsCount;
  152811. private _samples;
  152812. /**
  152813. * @ignore
  152814. * Specifies if the bloom pipeline is enabled
  152815. */
  152816. get BloomEnabled(): boolean;
  152817. set BloomEnabled(enabled: boolean);
  152818. /**
  152819. * @ignore
  152820. * Specifies if the depth of field pipeline is enabed
  152821. */
  152822. get DepthOfFieldEnabled(): boolean;
  152823. set DepthOfFieldEnabled(enabled: boolean);
  152824. /**
  152825. * @ignore
  152826. * Specifies if the lens flare pipeline is enabed
  152827. */
  152828. get LensFlareEnabled(): boolean;
  152829. set LensFlareEnabled(enabled: boolean);
  152830. /**
  152831. * @ignore
  152832. * Specifies if the HDR pipeline is enabled
  152833. */
  152834. get HDREnabled(): boolean;
  152835. set HDREnabled(enabled: boolean);
  152836. /**
  152837. * @ignore
  152838. * Specifies if the volumetric lights scattering effect is enabled
  152839. */
  152840. get VLSEnabled(): boolean;
  152841. set VLSEnabled(enabled: boolean);
  152842. /**
  152843. * @ignore
  152844. * Specifies if the motion blur effect is enabled
  152845. */
  152846. get MotionBlurEnabled(): boolean;
  152847. set MotionBlurEnabled(enabled: boolean);
  152848. /**
  152849. * Specifies if anti-aliasing is enabled
  152850. */
  152851. get fxaaEnabled(): boolean;
  152852. set fxaaEnabled(enabled: boolean);
  152853. /**
  152854. * Specifies if screen space reflections are enabled.
  152855. */
  152856. get screenSpaceReflectionsEnabled(): boolean;
  152857. set screenSpaceReflectionsEnabled(enabled: boolean);
  152858. /**
  152859. * Specifies the number of steps used to calculate the volumetric lights
  152860. * Typically in interval [50, 200]
  152861. */
  152862. get volumetricLightStepsCount(): number;
  152863. set volumetricLightStepsCount(count: number);
  152864. /**
  152865. * Specifies the number of samples used for the motion blur effect
  152866. * Typically in interval [16, 64]
  152867. */
  152868. get motionBlurSamples(): number;
  152869. set motionBlurSamples(samples: number);
  152870. /**
  152871. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152872. */
  152873. get samples(): number;
  152874. set samples(sampleCount: number);
  152875. /**
  152876. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152877. * @constructor
  152878. * @param name The rendering pipeline name
  152879. * @param scene The scene linked to this pipeline
  152880. * @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)
  152881. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152882. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152883. */
  152884. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152885. private _buildPipeline;
  152886. private _createDownSampleX4PostProcess;
  152887. private _createBrightPassPostProcess;
  152888. private _createBlurPostProcesses;
  152889. private _createTextureAdderPostProcess;
  152890. private _createVolumetricLightPostProcess;
  152891. private _createLuminancePostProcesses;
  152892. private _createHdrPostProcess;
  152893. private _createLensFlarePostProcess;
  152894. private _createDepthOfFieldPostProcess;
  152895. private _createMotionBlurPostProcess;
  152896. private _getDepthTexture;
  152897. private _disposePostProcesses;
  152898. /**
  152899. * Dispose of the pipeline and stop all post processes
  152900. */
  152901. dispose(): void;
  152902. /**
  152903. * Serialize the rendering pipeline (Used when exporting)
  152904. * @returns the serialized object
  152905. */
  152906. serialize(): any;
  152907. /**
  152908. * Parse the serialized pipeline
  152909. * @param source Source pipeline.
  152910. * @param scene The scene to load the pipeline to.
  152911. * @param rootUrl The URL of the serialized pipeline.
  152912. * @returns An instantiated pipeline from the serialized object.
  152913. */
  152914. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152915. /**
  152916. * Luminance steps
  152917. */
  152918. static LuminanceSteps: number;
  152919. }
  152920. }
  152921. declare module BABYLON {
  152922. /** @hidden */
  152923. export var stereoscopicInterlacePixelShader: {
  152924. name: string;
  152925. shader: string;
  152926. };
  152927. }
  152928. declare module BABYLON {
  152929. /**
  152930. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152931. */
  152932. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152933. private _stepSize;
  152934. private _passedProcess;
  152935. /**
  152936. * Gets a string identifying the name of the class
  152937. * @returns "StereoscopicInterlacePostProcessI" string
  152938. */
  152939. getClassName(): string;
  152940. /**
  152941. * Initializes a StereoscopicInterlacePostProcessI
  152942. * @param name The name of the effect.
  152943. * @param rigCameras The rig cameras to be appled to the post process
  152944. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152945. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152947. * @param engine The engine which the post process will be applied. (default: current engine)
  152948. * @param reusable If the post process can be reused on the same frame. (default: false)
  152949. */
  152950. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152951. }
  152952. /**
  152953. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152954. */
  152955. export class StereoscopicInterlacePostProcess extends PostProcess {
  152956. private _stepSize;
  152957. private _passedProcess;
  152958. /**
  152959. * Gets a string identifying the name of the class
  152960. * @returns "StereoscopicInterlacePostProcess" string
  152961. */
  152962. getClassName(): string;
  152963. /**
  152964. * Initializes a StereoscopicInterlacePostProcess
  152965. * @param name The name of the effect.
  152966. * @param rigCameras The rig cameras to be appled to the post process
  152967. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152969. * @param engine The engine which the post process will be applied. (default: current engine)
  152970. * @param reusable If the post process can be reused on the same frame. (default: false)
  152971. */
  152972. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152973. }
  152974. }
  152975. declare module BABYLON {
  152976. /** @hidden */
  152977. export var tonemapPixelShader: {
  152978. name: string;
  152979. shader: string;
  152980. };
  152981. }
  152982. declare module BABYLON {
  152983. /** Defines operator used for tonemapping */
  152984. export enum TonemappingOperator {
  152985. /** Hable */
  152986. Hable = 0,
  152987. /** Reinhard */
  152988. Reinhard = 1,
  152989. /** HejiDawson */
  152990. HejiDawson = 2,
  152991. /** Photographic */
  152992. Photographic = 3
  152993. }
  152994. /**
  152995. * Defines a post process to apply tone mapping
  152996. */
  152997. export class TonemapPostProcess extends PostProcess {
  152998. private _operator;
  152999. /** Defines the required exposure adjustement */
  153000. exposureAdjustment: number;
  153001. /**
  153002. * Gets a string identifying the name of the class
  153003. * @returns "TonemapPostProcess" string
  153004. */
  153005. getClassName(): string;
  153006. /**
  153007. * Creates a new TonemapPostProcess
  153008. * @param name defines the name of the postprocess
  153009. * @param _operator defines the operator to use
  153010. * @param exposureAdjustment defines the required exposure adjustement
  153011. * @param camera defines the camera to use (can be null)
  153012. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153013. * @param engine defines the hosting engine (can be ignore if camera is set)
  153014. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153015. */
  153016. constructor(name: string, _operator: TonemappingOperator,
  153017. /** Defines the required exposure adjustement */
  153018. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153019. }
  153020. }
  153021. declare module BABYLON {
  153022. /** @hidden */
  153023. export var volumetricLightScatteringPixelShader: {
  153024. name: string;
  153025. shader: string;
  153026. };
  153027. }
  153028. declare module BABYLON {
  153029. /** @hidden */
  153030. export var volumetricLightScatteringPassVertexShader: {
  153031. name: string;
  153032. shader: string;
  153033. };
  153034. }
  153035. declare module BABYLON {
  153036. /** @hidden */
  153037. export var volumetricLightScatteringPassPixelShader: {
  153038. name: string;
  153039. shader: string;
  153040. };
  153041. }
  153042. declare module BABYLON {
  153043. /**
  153044. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153045. */
  153046. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153047. private _volumetricLightScatteringPass;
  153048. private _volumetricLightScatteringRTT;
  153049. private _viewPort;
  153050. private _screenCoordinates;
  153051. private _cachedDefines;
  153052. /**
  153053. * If not undefined, the mesh position is computed from the attached node position
  153054. */
  153055. attachedNode: {
  153056. position: Vector3;
  153057. };
  153058. /**
  153059. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153060. */
  153061. customMeshPosition: Vector3;
  153062. /**
  153063. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153064. */
  153065. useCustomMeshPosition: boolean;
  153066. /**
  153067. * If the post-process should inverse the light scattering direction
  153068. */
  153069. invert: boolean;
  153070. /**
  153071. * The internal mesh used by the post-process
  153072. */
  153073. mesh: Mesh;
  153074. /**
  153075. * @hidden
  153076. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153077. */
  153078. get useDiffuseColor(): boolean;
  153079. set useDiffuseColor(useDiffuseColor: boolean);
  153080. /**
  153081. * Array containing the excluded meshes not rendered in the internal pass
  153082. */
  153083. excludedMeshes: AbstractMesh[];
  153084. /**
  153085. * Controls the overall intensity of the post-process
  153086. */
  153087. exposure: number;
  153088. /**
  153089. * Dissipates each sample's contribution in range [0, 1]
  153090. */
  153091. decay: number;
  153092. /**
  153093. * Controls the overall intensity of each sample
  153094. */
  153095. weight: number;
  153096. /**
  153097. * Controls the density of each sample
  153098. */
  153099. density: number;
  153100. /**
  153101. * @constructor
  153102. * @param name The post-process name
  153103. * @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)
  153104. * @param camera The camera that the post-process will be attached to
  153105. * @param mesh The mesh used to create the light scattering
  153106. * @param samples The post-process quality, default 100
  153107. * @param samplingModeThe post-process filtering mode
  153108. * @param engine The babylon engine
  153109. * @param reusable If the post-process is reusable
  153110. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153111. */
  153112. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153113. /**
  153114. * Returns the string "VolumetricLightScatteringPostProcess"
  153115. * @returns "VolumetricLightScatteringPostProcess"
  153116. */
  153117. getClassName(): string;
  153118. private _isReady;
  153119. /**
  153120. * Sets the new light position for light scattering effect
  153121. * @param position The new custom light position
  153122. */
  153123. setCustomMeshPosition(position: Vector3): void;
  153124. /**
  153125. * Returns the light position for light scattering effect
  153126. * @return Vector3 The custom light position
  153127. */
  153128. getCustomMeshPosition(): Vector3;
  153129. /**
  153130. * Disposes the internal assets and detaches the post-process from the camera
  153131. */
  153132. dispose(camera: Camera): void;
  153133. /**
  153134. * Returns the render target texture used by the post-process
  153135. * @return the render target texture used by the post-process
  153136. */
  153137. getPass(): RenderTargetTexture;
  153138. private _meshExcluded;
  153139. private _createPass;
  153140. private _updateMeshScreenCoordinates;
  153141. /**
  153142. * Creates a default mesh for the Volumeric Light Scattering post-process
  153143. * @param name The mesh name
  153144. * @param scene The scene where to create the mesh
  153145. * @return the default mesh
  153146. */
  153147. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153148. }
  153149. }
  153150. declare module BABYLON {
  153151. /** @hidden */
  153152. export var screenSpaceCurvaturePixelShader: {
  153153. name: string;
  153154. shader: string;
  153155. };
  153156. }
  153157. declare module BABYLON {
  153158. /**
  153159. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153160. */
  153161. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153162. /**
  153163. * Defines how much ridge the curvature effect displays.
  153164. */
  153165. ridge: number;
  153166. /**
  153167. * Defines how much valley the curvature effect displays.
  153168. */
  153169. valley: number;
  153170. private _geometryBufferRenderer;
  153171. /**
  153172. * Gets a string identifying the name of the class
  153173. * @returns "ScreenSpaceCurvaturePostProcess" string
  153174. */
  153175. getClassName(): string;
  153176. /**
  153177. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153178. * @param name The name of the effect.
  153179. * @param scene The scene containing the objects to blur according to their velocity.
  153180. * @param options The required width/height ratio to downsize to before computing the render pass.
  153181. * @param camera The camera to apply the render pass to.
  153182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153183. * @param engine The engine which the post process will be applied. (default: current engine)
  153184. * @param reusable If the post process can be reused on the same frame. (default: false)
  153185. * @param textureType Type of textures used when performing the post process. (default: 0)
  153186. * @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)
  153187. */
  153188. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153189. /**
  153190. * Support test.
  153191. */
  153192. static get IsSupported(): boolean;
  153193. /** @hidden */
  153194. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153195. }
  153196. }
  153197. declare module BABYLON {
  153198. interface Scene {
  153199. /** @hidden (Backing field) */
  153200. _boundingBoxRenderer: BoundingBoxRenderer;
  153201. /** @hidden (Backing field) */
  153202. _forceShowBoundingBoxes: boolean;
  153203. /**
  153204. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153205. */
  153206. forceShowBoundingBoxes: boolean;
  153207. /**
  153208. * Gets the bounding box renderer associated with the scene
  153209. * @returns a BoundingBoxRenderer
  153210. */
  153211. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153212. }
  153213. interface AbstractMesh {
  153214. /** @hidden (Backing field) */
  153215. _showBoundingBox: boolean;
  153216. /**
  153217. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153218. */
  153219. showBoundingBox: boolean;
  153220. }
  153221. /**
  153222. * Component responsible of rendering the bounding box of the meshes in a scene.
  153223. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153224. */
  153225. export class BoundingBoxRenderer implements ISceneComponent {
  153226. /**
  153227. * The component name helpfull to identify the component in the list of scene components.
  153228. */
  153229. readonly name: string;
  153230. /**
  153231. * The scene the component belongs to.
  153232. */
  153233. scene: Scene;
  153234. /**
  153235. * Color of the bounding box lines placed in front of an object
  153236. */
  153237. frontColor: Color3;
  153238. /**
  153239. * Color of the bounding box lines placed behind an object
  153240. */
  153241. backColor: Color3;
  153242. /**
  153243. * Defines if the renderer should show the back lines or not
  153244. */
  153245. showBackLines: boolean;
  153246. /**
  153247. * Observable raised before rendering a bounding box
  153248. */
  153249. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153250. /**
  153251. * Observable raised after rendering a bounding box
  153252. */
  153253. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153254. /**
  153255. * @hidden
  153256. */
  153257. renderList: SmartArray<BoundingBox>;
  153258. private _colorShader;
  153259. private _vertexBuffers;
  153260. private _indexBuffer;
  153261. private _fillIndexBuffer;
  153262. private _fillIndexData;
  153263. /**
  153264. * Instantiates a new bounding box renderer in a scene.
  153265. * @param scene the scene the renderer renders in
  153266. */
  153267. constructor(scene: Scene);
  153268. /**
  153269. * Registers the component in a given scene
  153270. */
  153271. register(): void;
  153272. private _evaluateSubMesh;
  153273. private _activeMesh;
  153274. private _prepareRessources;
  153275. private _createIndexBuffer;
  153276. /**
  153277. * Rebuilds the elements related to this component in case of
  153278. * context lost for instance.
  153279. */
  153280. rebuild(): void;
  153281. /**
  153282. * @hidden
  153283. */
  153284. reset(): void;
  153285. /**
  153286. * Render the bounding boxes of a specific rendering group
  153287. * @param renderingGroupId defines the rendering group to render
  153288. */
  153289. render(renderingGroupId: number): void;
  153290. /**
  153291. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153292. * @param mesh Define the mesh to render the occlusion bounding box for
  153293. */
  153294. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153295. /**
  153296. * Dispose and release the resources attached to this renderer.
  153297. */
  153298. dispose(): void;
  153299. }
  153300. }
  153301. declare module BABYLON {
  153302. interface Scene {
  153303. /** @hidden (Backing field) */
  153304. _depthRenderer: {
  153305. [id: string]: DepthRenderer;
  153306. };
  153307. /**
  153308. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153309. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153310. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153311. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153312. * @returns the created depth renderer
  153313. */
  153314. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153315. /**
  153316. * Disables a depth renderer for a given camera
  153317. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153318. */
  153319. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153320. }
  153321. /**
  153322. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153323. * in several rendering techniques.
  153324. */
  153325. export class DepthRendererSceneComponent implements ISceneComponent {
  153326. /**
  153327. * The component name helpfull to identify the component in the list of scene components.
  153328. */
  153329. readonly name: string;
  153330. /**
  153331. * The scene the component belongs to.
  153332. */
  153333. scene: Scene;
  153334. /**
  153335. * Creates a new instance of the component for the given scene
  153336. * @param scene Defines the scene to register the component in
  153337. */
  153338. constructor(scene: Scene);
  153339. /**
  153340. * Registers the component in a given scene
  153341. */
  153342. register(): void;
  153343. /**
  153344. * Rebuilds the elements related to this component in case of
  153345. * context lost for instance.
  153346. */
  153347. rebuild(): void;
  153348. /**
  153349. * Disposes the component and the associated ressources
  153350. */
  153351. dispose(): void;
  153352. private _gatherRenderTargets;
  153353. private _gatherActiveCameraRenderTargets;
  153354. }
  153355. }
  153356. declare module BABYLON {
  153357. interface AbstractScene {
  153358. /** @hidden (Backing field) */
  153359. _prePassRenderer: Nullable<PrePassRenderer>;
  153360. /**
  153361. * Gets or Sets the current prepass renderer associated to the scene.
  153362. */
  153363. prePassRenderer: Nullable<PrePassRenderer>;
  153364. /**
  153365. * Enables the prepass and associates it with the scene
  153366. * @returns the PrePassRenderer
  153367. */
  153368. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153369. /**
  153370. * Disables the prepass associated with the scene
  153371. */
  153372. disablePrePassRenderer(): void;
  153373. }
  153374. /**
  153375. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153376. * in several rendering techniques.
  153377. */
  153378. export class PrePassRendererSceneComponent implements ISceneComponent {
  153379. /**
  153380. * The component name helpful to identify the component in the list of scene components.
  153381. */
  153382. readonly name: string;
  153383. /**
  153384. * The scene the component belongs to.
  153385. */
  153386. scene: Scene;
  153387. /**
  153388. * Creates a new instance of the component for the given scene
  153389. * @param scene Defines the scene to register the component in
  153390. */
  153391. constructor(scene: Scene);
  153392. /**
  153393. * Registers the component in a given scene
  153394. */
  153395. register(): void;
  153396. private _beforeCameraDraw;
  153397. private _afterCameraDraw;
  153398. private _beforeClearStage;
  153399. /**
  153400. * Rebuilds the elements related to this component in case of
  153401. * context lost for instance.
  153402. */
  153403. rebuild(): void;
  153404. /**
  153405. * Disposes the component and the associated ressources
  153406. */
  153407. dispose(): void;
  153408. }
  153409. }
  153410. declare module BABYLON {
  153411. /** @hidden */
  153412. export var fibonacci: {
  153413. name: string;
  153414. shader: string;
  153415. };
  153416. }
  153417. declare module BABYLON {
  153418. /** @hidden */
  153419. export var diffusionProfile: {
  153420. name: string;
  153421. shader: string;
  153422. };
  153423. }
  153424. declare module BABYLON {
  153425. /** @hidden */
  153426. export var subSurfaceScatteringPixelShader: {
  153427. name: string;
  153428. shader: string;
  153429. };
  153430. }
  153431. declare module BABYLON {
  153432. /**
  153433. * Sub surface scattering post process
  153434. */
  153435. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153436. /**
  153437. * Gets a string identifying the name of the class
  153438. * @returns "SubSurfaceScatteringPostProcess" string
  153439. */
  153440. getClassName(): string;
  153441. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153442. }
  153443. }
  153444. declare module BABYLON {
  153445. /**
  153446. * Contains all parameters needed for the prepass to perform
  153447. * screen space subsurface scattering
  153448. */
  153449. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153450. /** @hidden */
  153451. static _SceneComponentInitialization: (scene: Scene) => void;
  153452. private _ssDiffusionS;
  153453. private _ssFilterRadii;
  153454. private _ssDiffusionD;
  153455. /**
  153456. * Post process to attach for screen space subsurface scattering
  153457. */
  153458. postProcess: SubSurfaceScatteringPostProcess;
  153459. /**
  153460. * Diffusion profile color for subsurface scattering
  153461. */
  153462. get ssDiffusionS(): number[];
  153463. /**
  153464. * Diffusion profile max color channel value for subsurface scattering
  153465. */
  153466. get ssDiffusionD(): number[];
  153467. /**
  153468. * Diffusion profile filter radius for subsurface scattering
  153469. */
  153470. get ssFilterRadii(): number[];
  153471. /**
  153472. * Is subsurface enabled
  153473. */
  153474. enabled: boolean;
  153475. /**
  153476. * Name of the configuration
  153477. */
  153478. name: string;
  153479. /**
  153480. * Diffusion profile colors for subsurface scattering
  153481. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153482. * See ...
  153483. * Note that you can only store up to 5 of them
  153484. */
  153485. ssDiffusionProfileColors: Color3[];
  153486. /**
  153487. * Defines the ratio real world => scene units.
  153488. * Used for subsurface scattering
  153489. */
  153490. metersPerUnit: number;
  153491. /**
  153492. * Textures that should be present in the MRT for this effect to work
  153493. */
  153494. readonly texturesRequired: number[];
  153495. private _scene;
  153496. /**
  153497. * Builds a subsurface configuration object
  153498. * @param scene The scene
  153499. */
  153500. constructor(scene: Scene);
  153501. /**
  153502. * Adds a new diffusion profile.
  153503. * Useful for more realistic subsurface scattering on diverse materials.
  153504. * @param color The color of the diffusion profile. Should be the average color of the material.
  153505. * @return The index of the diffusion profile for the material subsurface configuration
  153506. */
  153507. addDiffusionProfile(color: Color3): number;
  153508. /**
  153509. * Creates the sss post process
  153510. * @return The created post process
  153511. */
  153512. createPostProcess(): SubSurfaceScatteringPostProcess;
  153513. /**
  153514. * Deletes all diffusion profiles.
  153515. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153516. */
  153517. clearAllDiffusionProfiles(): void;
  153518. /**
  153519. * Disposes this object
  153520. */
  153521. dispose(): void;
  153522. /**
  153523. * @hidden
  153524. * https://zero-radiance.github.io/post/sampling-diffusion/
  153525. *
  153526. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153527. * ------------------------------------------------------------------------------------
  153528. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153529. * PDF[r, phi, s] = r * R[r, phi, s]
  153530. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153531. * ------------------------------------------------------------------------------------
  153532. * We importance sample the color channel with the widest scattering distance.
  153533. */
  153534. getDiffusionProfileParameters(color: Color3): number;
  153535. /**
  153536. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153537. * 'u' is the random number (the value of the CDF): [0, 1).
  153538. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153539. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153540. */
  153541. private _sampleBurleyDiffusionProfile;
  153542. }
  153543. }
  153544. declare module BABYLON {
  153545. interface AbstractScene {
  153546. /** @hidden (Backing field) */
  153547. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153548. /**
  153549. * Gets or Sets the current prepass renderer associated to the scene.
  153550. */
  153551. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153552. /**
  153553. * Enables the subsurface effect for prepass
  153554. * @returns the SubSurfaceConfiguration
  153555. */
  153556. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153557. /**
  153558. * Disables the subsurface effect for prepass
  153559. */
  153560. disableSubSurfaceForPrePass(): void;
  153561. }
  153562. /**
  153563. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153564. * in several rendering techniques.
  153565. */
  153566. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153567. /**
  153568. * The component name helpful to identify the component in the list of scene components.
  153569. */
  153570. readonly name: string;
  153571. /**
  153572. * The scene the component belongs to.
  153573. */
  153574. scene: Scene;
  153575. /**
  153576. * Creates a new instance of the component for the given scene
  153577. * @param scene Defines the scene to register the component in
  153578. */
  153579. constructor(scene: Scene);
  153580. /**
  153581. * Registers the component in a given scene
  153582. */
  153583. register(): void;
  153584. /**
  153585. * Serializes the component data to the specified json object
  153586. * @param serializationObject The object to serialize to
  153587. */
  153588. serialize(serializationObject: any): void;
  153589. /**
  153590. * Adds all the elements from the container to the scene
  153591. * @param container the container holding the elements
  153592. */
  153593. addFromContainer(container: AbstractScene): void;
  153594. /**
  153595. * Removes all the elements in the container from the scene
  153596. * @param container contains the elements to remove
  153597. * @param dispose if the removed element should be disposed (default: false)
  153598. */
  153599. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153600. /**
  153601. * Rebuilds the elements related to this component in case of
  153602. * context lost for instance.
  153603. */
  153604. rebuild(): void;
  153605. /**
  153606. * Disposes the component and the associated ressources
  153607. */
  153608. dispose(): void;
  153609. }
  153610. }
  153611. declare module BABYLON {
  153612. /** @hidden */
  153613. export var outlinePixelShader: {
  153614. name: string;
  153615. shader: string;
  153616. };
  153617. }
  153618. declare module BABYLON {
  153619. /** @hidden */
  153620. export var outlineVertexShader: {
  153621. name: string;
  153622. shader: string;
  153623. };
  153624. }
  153625. declare module BABYLON {
  153626. interface Scene {
  153627. /** @hidden */
  153628. _outlineRenderer: OutlineRenderer;
  153629. /**
  153630. * Gets the outline renderer associated with the scene
  153631. * @returns a OutlineRenderer
  153632. */
  153633. getOutlineRenderer(): OutlineRenderer;
  153634. }
  153635. interface AbstractMesh {
  153636. /** @hidden (Backing field) */
  153637. _renderOutline: boolean;
  153638. /**
  153639. * Gets or sets a boolean indicating if the outline must be rendered as well
  153640. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153641. */
  153642. renderOutline: boolean;
  153643. /** @hidden (Backing field) */
  153644. _renderOverlay: boolean;
  153645. /**
  153646. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153647. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153648. */
  153649. renderOverlay: boolean;
  153650. }
  153651. /**
  153652. * This class is responsible to draw bothe outline/overlay of meshes.
  153653. * It should not be used directly but through the available method on mesh.
  153654. */
  153655. export class OutlineRenderer implements ISceneComponent {
  153656. /**
  153657. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153658. */
  153659. private static _StencilReference;
  153660. /**
  153661. * The name of the component. Each component must have a unique name.
  153662. */
  153663. name: string;
  153664. /**
  153665. * The scene the component belongs to.
  153666. */
  153667. scene: Scene;
  153668. /**
  153669. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153670. */
  153671. zOffset: number;
  153672. private _engine;
  153673. private _effect;
  153674. private _cachedDefines;
  153675. private _savedDepthWrite;
  153676. /**
  153677. * Instantiates a new outline renderer. (There could be only one per scene).
  153678. * @param scene Defines the scene it belongs to
  153679. */
  153680. constructor(scene: Scene);
  153681. /**
  153682. * Register the component to one instance of a scene.
  153683. */
  153684. register(): void;
  153685. /**
  153686. * Rebuilds the elements related to this component in case of
  153687. * context lost for instance.
  153688. */
  153689. rebuild(): void;
  153690. /**
  153691. * Disposes the component and the associated ressources.
  153692. */
  153693. dispose(): void;
  153694. /**
  153695. * Renders the outline in the canvas.
  153696. * @param subMesh Defines the sumesh to render
  153697. * @param batch Defines the batch of meshes in case of instances
  153698. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153699. */
  153700. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153701. /**
  153702. * Returns whether or not the outline renderer is ready for a given submesh.
  153703. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153704. * @param subMesh Defines the submesh to check readyness for
  153705. * @param useInstances Defines wheter wee are trying to render instances or not
  153706. * @returns true if ready otherwise false
  153707. */
  153708. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153709. private _beforeRenderingMesh;
  153710. private _afterRenderingMesh;
  153711. }
  153712. }
  153713. declare module BABYLON {
  153714. /**
  153715. * Defines the basic options interface of a Sprite Frame Source Size.
  153716. */
  153717. export interface ISpriteJSONSpriteSourceSize {
  153718. /**
  153719. * number of the original width of the Frame
  153720. */
  153721. w: number;
  153722. /**
  153723. * number of the original height of the Frame
  153724. */
  153725. h: number;
  153726. }
  153727. /**
  153728. * Defines the basic options interface of a Sprite Frame Data.
  153729. */
  153730. export interface ISpriteJSONSpriteFrameData {
  153731. /**
  153732. * number of the x offset of the Frame
  153733. */
  153734. x: number;
  153735. /**
  153736. * number of the y offset of the Frame
  153737. */
  153738. y: number;
  153739. /**
  153740. * number of the width of the Frame
  153741. */
  153742. w: number;
  153743. /**
  153744. * number of the height of the Frame
  153745. */
  153746. h: number;
  153747. }
  153748. /**
  153749. * Defines the basic options interface of a JSON Sprite.
  153750. */
  153751. export interface ISpriteJSONSprite {
  153752. /**
  153753. * string name of the Frame
  153754. */
  153755. filename: string;
  153756. /**
  153757. * ISpriteJSONSpriteFrame basic object of the frame data
  153758. */
  153759. frame: ISpriteJSONSpriteFrameData;
  153760. /**
  153761. * boolean to flag is the frame was rotated.
  153762. */
  153763. rotated: boolean;
  153764. /**
  153765. * boolean to flag is the frame was trimmed.
  153766. */
  153767. trimmed: boolean;
  153768. /**
  153769. * ISpriteJSONSpriteFrame basic object of the source data
  153770. */
  153771. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153772. /**
  153773. * ISpriteJSONSpriteFrame basic object of the source data
  153774. */
  153775. sourceSize: ISpriteJSONSpriteSourceSize;
  153776. }
  153777. /**
  153778. * Defines the basic options interface of a JSON atlas.
  153779. */
  153780. export interface ISpriteJSONAtlas {
  153781. /**
  153782. * Array of objects that contain the frame data.
  153783. */
  153784. frames: Array<ISpriteJSONSprite>;
  153785. /**
  153786. * object basic object containing the sprite meta data.
  153787. */
  153788. meta?: object;
  153789. }
  153790. }
  153791. declare module BABYLON {
  153792. /** @hidden */
  153793. export var spriteMapPixelShader: {
  153794. name: string;
  153795. shader: string;
  153796. };
  153797. }
  153798. declare module BABYLON {
  153799. /** @hidden */
  153800. export var spriteMapVertexShader: {
  153801. name: string;
  153802. shader: string;
  153803. };
  153804. }
  153805. declare module BABYLON {
  153806. /**
  153807. * Defines the basic options interface of a SpriteMap
  153808. */
  153809. export interface ISpriteMapOptions {
  153810. /**
  153811. * Vector2 of the number of cells in the grid.
  153812. */
  153813. stageSize?: Vector2;
  153814. /**
  153815. * Vector2 of the size of the output plane in World Units.
  153816. */
  153817. outputSize?: Vector2;
  153818. /**
  153819. * Vector3 of the position of the output plane in World Units.
  153820. */
  153821. outputPosition?: Vector3;
  153822. /**
  153823. * Vector3 of the rotation of the output plane.
  153824. */
  153825. outputRotation?: Vector3;
  153826. /**
  153827. * number of layers that the system will reserve in resources.
  153828. */
  153829. layerCount?: number;
  153830. /**
  153831. * number of max animation frames a single cell will reserve in resources.
  153832. */
  153833. maxAnimationFrames?: number;
  153834. /**
  153835. * number cell index of the base tile when the system compiles.
  153836. */
  153837. baseTile?: number;
  153838. /**
  153839. * boolean flip the sprite after its been repositioned by the framing data.
  153840. */
  153841. flipU?: boolean;
  153842. /**
  153843. * Vector3 scalar of the global RGB values of the SpriteMap.
  153844. */
  153845. colorMultiply?: Vector3;
  153846. }
  153847. /**
  153848. * Defines the IDisposable interface in order to be cleanable from resources.
  153849. */
  153850. export interface ISpriteMap extends IDisposable {
  153851. /**
  153852. * String name of the SpriteMap.
  153853. */
  153854. name: string;
  153855. /**
  153856. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153857. */
  153858. atlasJSON: ISpriteJSONAtlas;
  153859. /**
  153860. * Texture of the SpriteMap.
  153861. */
  153862. spriteSheet: Texture;
  153863. /**
  153864. * The parameters to initialize the SpriteMap with.
  153865. */
  153866. options: ISpriteMapOptions;
  153867. }
  153868. /**
  153869. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153870. */
  153871. export class SpriteMap implements ISpriteMap {
  153872. /** The Name of the spriteMap */
  153873. name: string;
  153874. /** The JSON file with the frame and meta data */
  153875. atlasJSON: ISpriteJSONAtlas;
  153876. /** The systems Sprite Sheet Texture */
  153877. spriteSheet: Texture;
  153878. /** Arguments passed with the Constructor */
  153879. options: ISpriteMapOptions;
  153880. /** Public Sprite Storage array, parsed from atlasJSON */
  153881. sprites: Array<ISpriteJSONSprite>;
  153882. /** Returns the Number of Sprites in the System */
  153883. get spriteCount(): number;
  153884. /** Returns the Position of Output Plane*/
  153885. get position(): Vector3;
  153886. /** Returns the Position of Output Plane*/
  153887. set position(v: Vector3);
  153888. /** Returns the Rotation of Output Plane*/
  153889. get rotation(): Vector3;
  153890. /** Returns the Rotation of Output Plane*/
  153891. set rotation(v: Vector3);
  153892. /** Sets the AnimationMap*/
  153893. get animationMap(): RawTexture;
  153894. /** Sets the AnimationMap*/
  153895. set animationMap(v: RawTexture);
  153896. /** Scene that the SpriteMap was created in */
  153897. private _scene;
  153898. /** Texture Buffer of Float32 that holds tile frame data*/
  153899. private _frameMap;
  153900. /** Texture Buffers of Float32 that holds tileMap data*/
  153901. private _tileMaps;
  153902. /** Texture Buffer of Float32 that holds Animation Data*/
  153903. private _animationMap;
  153904. /** Custom ShaderMaterial Central to the System*/
  153905. private _material;
  153906. /** Custom ShaderMaterial Central to the System*/
  153907. private _output;
  153908. /** Systems Time Ticker*/
  153909. private _time;
  153910. /**
  153911. * Creates a new SpriteMap
  153912. * @param name defines the SpriteMaps Name
  153913. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153914. * @param spriteSheet is the Texture that the Sprites are on.
  153915. * @param options a basic deployment configuration
  153916. * @param scene The Scene that the map is deployed on
  153917. */
  153918. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153919. /**
  153920. * Returns tileID location
  153921. * @returns Vector2 the cell position ID
  153922. */
  153923. getTileID(): Vector2;
  153924. /**
  153925. * Gets the UV location of the mouse over the SpriteMap.
  153926. * @returns Vector2 the UV position of the mouse interaction
  153927. */
  153928. getMousePosition(): Vector2;
  153929. /**
  153930. * Creates the "frame" texture Buffer
  153931. * -------------------------------------
  153932. * Structure of frames
  153933. * "filename": "Falling-Water-2.png",
  153934. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153935. * "rotated": true,
  153936. * "trimmed": true,
  153937. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153938. * "sourceSize": {"w":32,"h":32}
  153939. * @returns RawTexture of the frameMap
  153940. */
  153941. private _createFrameBuffer;
  153942. /**
  153943. * Creates the tileMap texture Buffer
  153944. * @param buffer normally and array of numbers, or a false to generate from scratch
  153945. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153946. * @returns RawTexture of the tileMap
  153947. */
  153948. private _createTileBuffer;
  153949. /**
  153950. * Modifies the data of the tileMaps
  153951. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153952. * @param pos is the iVector2 Coordinates of the Tile
  153953. * @param tile The SpriteIndex of the new Tile
  153954. */
  153955. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153956. /**
  153957. * Creates the animationMap texture Buffer
  153958. * @param buffer normally and array of numbers, or a false to generate from scratch
  153959. * @returns RawTexture of the animationMap
  153960. */
  153961. private _createTileAnimationBuffer;
  153962. /**
  153963. * Modifies the data of the animationMap
  153964. * @param cellID is the Index of the Sprite
  153965. * @param _frame is the target Animation frame
  153966. * @param toCell is the Target Index of the next frame of the animation
  153967. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153968. * @param speed is a global scalar of the time variable on the map.
  153969. */
  153970. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153971. /**
  153972. * Exports the .tilemaps file
  153973. */
  153974. saveTileMaps(): void;
  153975. /**
  153976. * Imports the .tilemaps file
  153977. * @param url of the .tilemaps file
  153978. */
  153979. loadTileMaps(url: string): void;
  153980. /**
  153981. * Release associated resources
  153982. */
  153983. dispose(): void;
  153984. }
  153985. }
  153986. declare module BABYLON {
  153987. /**
  153988. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153989. * @see https://doc.babylonjs.com/babylon101/sprites
  153990. */
  153991. export class SpritePackedManager extends SpriteManager {
  153992. /** defines the packed manager's name */
  153993. name: string;
  153994. /**
  153995. * Creates a new sprite manager from a packed sprite sheet
  153996. * @param name defines the manager's name
  153997. * @param imgUrl defines the sprite sheet url
  153998. * @param capacity defines the maximum allowed number of sprites
  153999. * @param scene defines the hosting scene
  154000. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154001. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154002. * @param samplingMode defines the smapling mode to use with spritesheet
  154003. * @param fromPacked set to true; do not alter
  154004. */
  154005. constructor(
  154006. /** defines the packed manager's name */
  154007. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154008. }
  154009. }
  154010. declare module BABYLON {
  154011. /**
  154012. * Defines the list of states available for a task inside a AssetsManager
  154013. */
  154014. export enum AssetTaskState {
  154015. /**
  154016. * Initialization
  154017. */
  154018. INIT = 0,
  154019. /**
  154020. * Running
  154021. */
  154022. RUNNING = 1,
  154023. /**
  154024. * Done
  154025. */
  154026. DONE = 2,
  154027. /**
  154028. * Error
  154029. */
  154030. ERROR = 3
  154031. }
  154032. /**
  154033. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154034. */
  154035. export abstract class AbstractAssetTask {
  154036. /**
  154037. * Task name
  154038. */ name: string;
  154039. /**
  154040. * Callback called when the task is successful
  154041. */
  154042. onSuccess: (task: any) => void;
  154043. /**
  154044. * Callback called when the task is not successful
  154045. */
  154046. onError: (task: any, message?: string, exception?: any) => void;
  154047. /**
  154048. * Creates a new AssetsManager
  154049. * @param name defines the name of the task
  154050. */
  154051. constructor(
  154052. /**
  154053. * Task name
  154054. */ name: string);
  154055. private _isCompleted;
  154056. private _taskState;
  154057. private _errorObject;
  154058. /**
  154059. * Get if the task is completed
  154060. */
  154061. get isCompleted(): boolean;
  154062. /**
  154063. * Gets the current state of the task
  154064. */
  154065. get taskState(): AssetTaskState;
  154066. /**
  154067. * Gets the current error object (if task is in error)
  154068. */
  154069. get errorObject(): {
  154070. message?: string;
  154071. exception?: any;
  154072. };
  154073. /**
  154074. * Internal only
  154075. * @hidden
  154076. */
  154077. _setErrorObject(message?: string, exception?: any): void;
  154078. /**
  154079. * Execute the current task
  154080. * @param scene defines the scene where you want your assets to be loaded
  154081. * @param onSuccess is a callback called when the task is successfully executed
  154082. * @param onError is a callback called if an error occurs
  154083. */
  154084. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154085. /**
  154086. * Execute the current task
  154087. * @param scene defines the scene where you want your assets to be loaded
  154088. * @param onSuccess is a callback called when the task is successfully executed
  154089. * @param onError is a callback called if an error occurs
  154090. */
  154091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154092. /**
  154093. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154094. * This can be used with failed tasks that have the reason for failure fixed.
  154095. */
  154096. reset(): void;
  154097. private onErrorCallback;
  154098. private onDoneCallback;
  154099. }
  154100. /**
  154101. * Define the interface used by progress events raised during assets loading
  154102. */
  154103. export interface IAssetsProgressEvent {
  154104. /**
  154105. * Defines the number of remaining tasks to process
  154106. */
  154107. remainingCount: number;
  154108. /**
  154109. * Defines the total number of tasks
  154110. */
  154111. totalCount: number;
  154112. /**
  154113. * Defines the task that was just processed
  154114. */
  154115. task: AbstractAssetTask;
  154116. }
  154117. /**
  154118. * Class used to share progress information about assets loading
  154119. */
  154120. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154121. /**
  154122. * Defines the number of remaining tasks to process
  154123. */
  154124. remainingCount: number;
  154125. /**
  154126. * Defines the total number of tasks
  154127. */
  154128. totalCount: number;
  154129. /**
  154130. * Defines the task that was just processed
  154131. */
  154132. task: AbstractAssetTask;
  154133. /**
  154134. * Creates a AssetsProgressEvent
  154135. * @param remainingCount defines the number of remaining tasks to process
  154136. * @param totalCount defines the total number of tasks
  154137. * @param task defines the task that was just processed
  154138. */
  154139. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154140. }
  154141. /**
  154142. * Define a task used by AssetsManager to load assets into a container
  154143. */
  154144. export class ContainerAssetTask extends AbstractAssetTask {
  154145. /**
  154146. * Defines the name of the task
  154147. */
  154148. name: string;
  154149. /**
  154150. * Defines the list of mesh's names you want to load
  154151. */
  154152. meshesNames: any;
  154153. /**
  154154. * Defines the root url to use as a base to load your meshes and associated resources
  154155. */
  154156. rootUrl: string;
  154157. /**
  154158. * Defines the filename or File of the scene to load from
  154159. */
  154160. sceneFilename: string | File;
  154161. /**
  154162. * Get the loaded asset container
  154163. */
  154164. loadedContainer: AssetContainer;
  154165. /**
  154166. * Gets the list of loaded meshes
  154167. */
  154168. loadedMeshes: Array<AbstractMesh>;
  154169. /**
  154170. * Gets the list of loaded particle systems
  154171. */
  154172. loadedParticleSystems: Array<IParticleSystem>;
  154173. /**
  154174. * Gets the list of loaded skeletons
  154175. */
  154176. loadedSkeletons: Array<Skeleton>;
  154177. /**
  154178. * Gets the list of loaded animation groups
  154179. */
  154180. loadedAnimationGroups: Array<AnimationGroup>;
  154181. /**
  154182. * Callback called when the task is successful
  154183. */
  154184. onSuccess: (task: ContainerAssetTask) => void;
  154185. /**
  154186. * Callback called when the task is successful
  154187. */
  154188. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154189. /**
  154190. * Creates a new ContainerAssetTask
  154191. * @param name defines the name of the task
  154192. * @param meshesNames defines the list of mesh's names you want to load
  154193. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154194. * @param sceneFilename defines the filename or File of the scene to load from
  154195. */
  154196. constructor(
  154197. /**
  154198. * Defines the name of the task
  154199. */
  154200. name: string,
  154201. /**
  154202. * Defines the list of mesh's names you want to load
  154203. */
  154204. meshesNames: any,
  154205. /**
  154206. * Defines the root url to use as a base to load your meshes and associated resources
  154207. */
  154208. rootUrl: string,
  154209. /**
  154210. * Defines the filename or File of the scene to load from
  154211. */
  154212. sceneFilename: string | File);
  154213. /**
  154214. * Execute the current task
  154215. * @param scene defines the scene where you want your assets to be loaded
  154216. * @param onSuccess is a callback called when the task is successfully executed
  154217. * @param onError is a callback called if an error occurs
  154218. */
  154219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154220. }
  154221. /**
  154222. * Define a task used by AssetsManager to load meshes
  154223. */
  154224. export class MeshAssetTask extends AbstractAssetTask {
  154225. /**
  154226. * Defines the name of the task
  154227. */
  154228. name: string;
  154229. /**
  154230. * Defines the list of mesh's names you want to load
  154231. */
  154232. meshesNames: any;
  154233. /**
  154234. * Defines the root url to use as a base to load your meshes and associated resources
  154235. */
  154236. rootUrl: string;
  154237. /**
  154238. * Defines the filename or File of the scene to load from
  154239. */
  154240. sceneFilename: string | File;
  154241. /**
  154242. * Gets the list of loaded meshes
  154243. */
  154244. loadedMeshes: Array<AbstractMesh>;
  154245. /**
  154246. * Gets the list of loaded particle systems
  154247. */
  154248. loadedParticleSystems: Array<IParticleSystem>;
  154249. /**
  154250. * Gets the list of loaded skeletons
  154251. */
  154252. loadedSkeletons: Array<Skeleton>;
  154253. /**
  154254. * Gets the list of loaded animation groups
  154255. */
  154256. loadedAnimationGroups: Array<AnimationGroup>;
  154257. /**
  154258. * Callback called when the task is successful
  154259. */
  154260. onSuccess: (task: MeshAssetTask) => void;
  154261. /**
  154262. * Callback called when the task is successful
  154263. */
  154264. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154265. /**
  154266. * Creates a new MeshAssetTask
  154267. * @param name defines the name of the task
  154268. * @param meshesNames defines the list of mesh's names you want to load
  154269. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154270. * @param sceneFilename defines the filename or File of the scene to load from
  154271. */
  154272. constructor(
  154273. /**
  154274. * Defines the name of the task
  154275. */
  154276. name: string,
  154277. /**
  154278. * Defines the list of mesh's names you want to load
  154279. */
  154280. meshesNames: any,
  154281. /**
  154282. * Defines the root url to use as a base to load your meshes and associated resources
  154283. */
  154284. rootUrl: string,
  154285. /**
  154286. * Defines the filename or File of the scene to load from
  154287. */
  154288. sceneFilename: string | File);
  154289. /**
  154290. * Execute the current task
  154291. * @param scene defines the scene where you want your assets to be loaded
  154292. * @param onSuccess is a callback called when the task is successfully executed
  154293. * @param onError is a callback called if an error occurs
  154294. */
  154295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154296. }
  154297. /**
  154298. * Define a task used by AssetsManager to load text content
  154299. */
  154300. export class TextFileAssetTask extends AbstractAssetTask {
  154301. /**
  154302. * Defines the name of the task
  154303. */
  154304. name: string;
  154305. /**
  154306. * Defines the location of the file to load
  154307. */
  154308. url: string;
  154309. /**
  154310. * Gets the loaded text string
  154311. */
  154312. text: string;
  154313. /**
  154314. * Callback called when the task is successful
  154315. */
  154316. onSuccess: (task: TextFileAssetTask) => void;
  154317. /**
  154318. * Callback called when the task is successful
  154319. */
  154320. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154321. /**
  154322. * Creates a new TextFileAssetTask object
  154323. * @param name defines the name of the task
  154324. * @param url defines the location of the file to load
  154325. */
  154326. constructor(
  154327. /**
  154328. * Defines the name of the task
  154329. */
  154330. name: string,
  154331. /**
  154332. * Defines the location of the file to load
  154333. */
  154334. url: string);
  154335. /**
  154336. * Execute the current task
  154337. * @param scene defines the scene where you want your assets to be loaded
  154338. * @param onSuccess is a callback called when the task is successfully executed
  154339. * @param onError is a callback called if an error occurs
  154340. */
  154341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154342. }
  154343. /**
  154344. * Define a task used by AssetsManager to load binary data
  154345. */
  154346. export class BinaryFileAssetTask extends AbstractAssetTask {
  154347. /**
  154348. * Defines the name of the task
  154349. */
  154350. name: string;
  154351. /**
  154352. * Defines the location of the file to load
  154353. */
  154354. url: string;
  154355. /**
  154356. * Gets the lodaded data (as an array buffer)
  154357. */
  154358. data: ArrayBuffer;
  154359. /**
  154360. * Callback called when the task is successful
  154361. */
  154362. onSuccess: (task: BinaryFileAssetTask) => void;
  154363. /**
  154364. * Callback called when the task is successful
  154365. */
  154366. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154367. /**
  154368. * Creates a new BinaryFileAssetTask object
  154369. * @param name defines the name of the new task
  154370. * @param url defines the location of the file to load
  154371. */
  154372. constructor(
  154373. /**
  154374. * Defines the name of the task
  154375. */
  154376. name: string,
  154377. /**
  154378. * Defines the location of the file to load
  154379. */
  154380. url: string);
  154381. /**
  154382. * Execute the current task
  154383. * @param scene defines the scene where you want your assets to be loaded
  154384. * @param onSuccess is a callback called when the task is successfully executed
  154385. * @param onError is a callback called if an error occurs
  154386. */
  154387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154388. }
  154389. /**
  154390. * Define a task used by AssetsManager to load images
  154391. */
  154392. export class ImageAssetTask extends AbstractAssetTask {
  154393. /**
  154394. * Defines the name of the task
  154395. */
  154396. name: string;
  154397. /**
  154398. * Defines the location of the image to load
  154399. */
  154400. url: string;
  154401. /**
  154402. * Gets the loaded images
  154403. */
  154404. image: HTMLImageElement;
  154405. /**
  154406. * Callback called when the task is successful
  154407. */
  154408. onSuccess: (task: ImageAssetTask) => void;
  154409. /**
  154410. * Callback called when the task is successful
  154411. */
  154412. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154413. /**
  154414. * Creates a new ImageAssetTask
  154415. * @param name defines the name of the task
  154416. * @param url defines the location of the image to load
  154417. */
  154418. constructor(
  154419. /**
  154420. * Defines the name of the task
  154421. */
  154422. name: string,
  154423. /**
  154424. * Defines the location of the image to load
  154425. */
  154426. url: string);
  154427. /**
  154428. * Execute the current task
  154429. * @param scene defines the scene where you want your assets to be loaded
  154430. * @param onSuccess is a callback called when the task is successfully executed
  154431. * @param onError is a callback called if an error occurs
  154432. */
  154433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154434. }
  154435. /**
  154436. * Defines the interface used by texture loading tasks
  154437. */
  154438. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154439. /**
  154440. * Gets the loaded texture
  154441. */
  154442. texture: TEX;
  154443. }
  154444. /**
  154445. * Define a task used by AssetsManager to load 2D textures
  154446. */
  154447. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154448. /**
  154449. * Defines the name of the task
  154450. */
  154451. name: string;
  154452. /**
  154453. * Defines the location of the file to load
  154454. */
  154455. url: string;
  154456. /**
  154457. * Defines if mipmap should not be generated (default is false)
  154458. */
  154459. noMipmap?: boolean | undefined;
  154460. /**
  154461. * Defines if texture must be inverted on Y axis (default is true)
  154462. */
  154463. invertY: boolean;
  154464. /**
  154465. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154466. */
  154467. samplingMode: number;
  154468. /**
  154469. * Gets the loaded texture
  154470. */
  154471. texture: Texture;
  154472. /**
  154473. * Callback called when the task is successful
  154474. */
  154475. onSuccess: (task: TextureAssetTask) => void;
  154476. /**
  154477. * Callback called when the task is successful
  154478. */
  154479. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154480. /**
  154481. * Creates a new TextureAssetTask object
  154482. * @param name defines the name of the task
  154483. * @param url defines the location of the file to load
  154484. * @param noMipmap defines if mipmap should not be generated (default is false)
  154485. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154486. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154487. */
  154488. constructor(
  154489. /**
  154490. * Defines the name of the task
  154491. */
  154492. name: string,
  154493. /**
  154494. * Defines the location of the file to load
  154495. */
  154496. url: string,
  154497. /**
  154498. * Defines if mipmap should not be generated (default is false)
  154499. */
  154500. noMipmap?: boolean | undefined,
  154501. /**
  154502. * Defines if texture must be inverted on Y axis (default is true)
  154503. */
  154504. invertY?: boolean,
  154505. /**
  154506. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154507. */
  154508. samplingMode?: number);
  154509. /**
  154510. * Execute the current task
  154511. * @param scene defines the scene where you want your assets to be loaded
  154512. * @param onSuccess is a callback called when the task is successfully executed
  154513. * @param onError is a callback called if an error occurs
  154514. */
  154515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154516. }
  154517. /**
  154518. * Define a task used by AssetsManager to load cube textures
  154519. */
  154520. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154521. /**
  154522. * Defines the name of the task
  154523. */
  154524. name: string;
  154525. /**
  154526. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154527. */
  154528. url: string;
  154529. /**
  154530. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154531. */
  154532. extensions?: string[] | undefined;
  154533. /**
  154534. * Defines if mipmaps should not be generated (default is false)
  154535. */
  154536. noMipmap?: boolean | undefined;
  154537. /**
  154538. * Defines the explicit list of files (undefined by default)
  154539. */
  154540. files?: string[] | undefined;
  154541. /**
  154542. * Gets the loaded texture
  154543. */
  154544. texture: CubeTexture;
  154545. /**
  154546. * Callback called when the task is successful
  154547. */
  154548. onSuccess: (task: CubeTextureAssetTask) => void;
  154549. /**
  154550. * Callback called when the task is successful
  154551. */
  154552. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154553. /**
  154554. * Creates a new CubeTextureAssetTask
  154555. * @param name defines the name of the task
  154556. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154557. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154558. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154559. * @param files defines the explicit list of files (undefined by default)
  154560. */
  154561. constructor(
  154562. /**
  154563. * Defines the name of the task
  154564. */
  154565. name: string,
  154566. /**
  154567. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154568. */
  154569. url: string,
  154570. /**
  154571. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154572. */
  154573. extensions?: string[] | undefined,
  154574. /**
  154575. * Defines if mipmaps should not be generated (default is false)
  154576. */
  154577. noMipmap?: boolean | undefined,
  154578. /**
  154579. * Defines the explicit list of files (undefined by default)
  154580. */
  154581. files?: string[] | undefined);
  154582. /**
  154583. * Execute the current task
  154584. * @param scene defines the scene where you want your assets to be loaded
  154585. * @param onSuccess is a callback called when the task is successfully executed
  154586. * @param onError is a callback called if an error occurs
  154587. */
  154588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154589. }
  154590. /**
  154591. * Define a task used by AssetsManager to load HDR cube textures
  154592. */
  154593. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154594. /**
  154595. * Defines the name of the task
  154596. */
  154597. name: string;
  154598. /**
  154599. * Defines the location of the file to load
  154600. */
  154601. url: string;
  154602. /**
  154603. * Defines the desired size (the more it increases the longer the generation will be)
  154604. */
  154605. size: number;
  154606. /**
  154607. * Defines if mipmaps should not be generated (default is false)
  154608. */
  154609. noMipmap: boolean;
  154610. /**
  154611. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154612. */
  154613. generateHarmonics: boolean;
  154614. /**
  154615. * 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)
  154616. */
  154617. gammaSpace: boolean;
  154618. /**
  154619. * Internal Use Only
  154620. */
  154621. reserved: boolean;
  154622. /**
  154623. * Gets the loaded texture
  154624. */
  154625. texture: HDRCubeTexture;
  154626. /**
  154627. * Callback called when the task is successful
  154628. */
  154629. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154630. /**
  154631. * Callback called when the task is successful
  154632. */
  154633. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154634. /**
  154635. * Creates a new HDRCubeTextureAssetTask object
  154636. * @param name defines the name of the task
  154637. * @param url defines the location of the file to load
  154638. * @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.
  154639. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154640. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154641. * @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)
  154642. * @param reserved Internal use only
  154643. */
  154644. constructor(
  154645. /**
  154646. * Defines the name of the task
  154647. */
  154648. name: string,
  154649. /**
  154650. * Defines the location of the file to load
  154651. */
  154652. url: string,
  154653. /**
  154654. * Defines the desired size (the more it increases the longer the generation will be)
  154655. */
  154656. size: number,
  154657. /**
  154658. * Defines if mipmaps should not be generated (default is false)
  154659. */
  154660. noMipmap?: boolean,
  154661. /**
  154662. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154663. */
  154664. generateHarmonics?: boolean,
  154665. /**
  154666. * 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)
  154667. */
  154668. gammaSpace?: boolean,
  154669. /**
  154670. * Internal Use Only
  154671. */
  154672. reserved?: boolean);
  154673. /**
  154674. * Execute the current task
  154675. * @param scene defines the scene where you want your assets to be loaded
  154676. * @param onSuccess is a callback called when the task is successfully executed
  154677. * @param onError is a callback called if an error occurs
  154678. */
  154679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154680. }
  154681. /**
  154682. * Define a task used by AssetsManager to load Equirectangular cube textures
  154683. */
  154684. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154685. /**
  154686. * Defines the name of the task
  154687. */
  154688. name: string;
  154689. /**
  154690. * Defines the location of the file to load
  154691. */
  154692. url: string;
  154693. /**
  154694. * Defines the desired size (the more it increases the longer the generation will be)
  154695. */
  154696. size: number;
  154697. /**
  154698. * Defines if mipmaps should not be generated (default is false)
  154699. */
  154700. noMipmap: boolean;
  154701. /**
  154702. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154703. * but the standard material would require them in Gamma space) (default is true)
  154704. */
  154705. gammaSpace: boolean;
  154706. /**
  154707. * Gets the loaded texture
  154708. */
  154709. texture: EquiRectangularCubeTexture;
  154710. /**
  154711. * Callback called when the task is successful
  154712. */
  154713. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154714. /**
  154715. * Callback called when the task is successful
  154716. */
  154717. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154718. /**
  154719. * Creates a new EquiRectangularCubeTextureAssetTask object
  154720. * @param name defines the name of the task
  154721. * @param url defines the location of the file to load
  154722. * @param size defines the desired size (the more it increases the longer the generation will be)
  154723. * If the size is omitted this implies you are using a preprocessed cubemap.
  154724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154725. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154726. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154727. * (default is true)
  154728. */
  154729. constructor(
  154730. /**
  154731. * Defines the name of the task
  154732. */
  154733. name: string,
  154734. /**
  154735. * Defines the location of the file to load
  154736. */
  154737. url: string,
  154738. /**
  154739. * Defines the desired size (the more it increases the longer the generation will be)
  154740. */
  154741. size: number,
  154742. /**
  154743. * Defines if mipmaps should not be generated (default is false)
  154744. */
  154745. noMipmap?: boolean,
  154746. /**
  154747. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154748. * but the standard material would require them in Gamma space) (default is true)
  154749. */
  154750. gammaSpace?: boolean);
  154751. /**
  154752. * Execute the current task
  154753. * @param scene defines the scene where you want your assets to be loaded
  154754. * @param onSuccess is a callback called when the task is successfully executed
  154755. * @param onError is a callback called if an error occurs
  154756. */
  154757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154758. }
  154759. /**
  154760. * This class can be used to easily import assets into a scene
  154761. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154762. */
  154763. export class AssetsManager {
  154764. private _scene;
  154765. private _isLoading;
  154766. protected _tasks: AbstractAssetTask[];
  154767. protected _waitingTasksCount: number;
  154768. protected _totalTasksCount: number;
  154769. /**
  154770. * Callback called when all tasks are processed
  154771. */
  154772. onFinish: (tasks: AbstractAssetTask[]) => void;
  154773. /**
  154774. * Callback called when a task is successful
  154775. */
  154776. onTaskSuccess: (task: AbstractAssetTask) => void;
  154777. /**
  154778. * Callback called when a task had an error
  154779. */
  154780. onTaskError: (task: AbstractAssetTask) => void;
  154781. /**
  154782. * Callback called when a task is done (whatever the result is)
  154783. */
  154784. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154785. /**
  154786. * Observable called when all tasks are processed
  154787. */
  154788. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154789. /**
  154790. * Observable called when a task had an error
  154791. */
  154792. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154793. /**
  154794. * Observable called when all tasks were executed
  154795. */
  154796. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154797. /**
  154798. * Observable called when a task is done (whatever the result is)
  154799. */
  154800. onProgressObservable: Observable<IAssetsProgressEvent>;
  154801. /**
  154802. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154803. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154804. */
  154805. useDefaultLoadingScreen: boolean;
  154806. /**
  154807. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154808. * when all assets have been downloaded.
  154809. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154810. */
  154811. autoHideLoadingUI: boolean;
  154812. /**
  154813. * Creates a new AssetsManager
  154814. * @param scene defines the scene to work on
  154815. */
  154816. constructor(scene: Scene);
  154817. /**
  154818. * Add a ContainerAssetTask to the list of active tasks
  154819. * @param taskName defines the name of the new task
  154820. * @param meshesNames defines the name of meshes to load
  154821. * @param rootUrl defines the root url to use to locate files
  154822. * @param sceneFilename defines the filename of the scene file
  154823. * @returns a new ContainerAssetTask object
  154824. */
  154825. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154826. /**
  154827. * Add a MeshAssetTask to the list of active tasks
  154828. * @param taskName defines the name of the new task
  154829. * @param meshesNames defines the name of meshes to load
  154830. * @param rootUrl defines the root url to use to locate files
  154831. * @param sceneFilename defines the filename of the scene file
  154832. * @returns a new MeshAssetTask object
  154833. */
  154834. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154835. /**
  154836. * Add a TextFileAssetTask to the list of active tasks
  154837. * @param taskName defines the name of the new task
  154838. * @param url defines the url of the file to load
  154839. * @returns a new TextFileAssetTask object
  154840. */
  154841. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154842. /**
  154843. * Add a BinaryFileAssetTask to the list of active tasks
  154844. * @param taskName defines the name of the new task
  154845. * @param url defines the url of the file to load
  154846. * @returns a new BinaryFileAssetTask object
  154847. */
  154848. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154849. /**
  154850. * Add a ImageAssetTask to the list of active tasks
  154851. * @param taskName defines the name of the new task
  154852. * @param url defines the url of the file to load
  154853. * @returns a new ImageAssetTask object
  154854. */
  154855. addImageTask(taskName: string, url: string): ImageAssetTask;
  154856. /**
  154857. * Add a TextureAssetTask to the list of active tasks
  154858. * @param taskName defines the name of the new task
  154859. * @param url defines the url of the file to load
  154860. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154861. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154862. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154863. * @returns a new TextureAssetTask object
  154864. */
  154865. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154866. /**
  154867. * Add a CubeTextureAssetTask to the list of active tasks
  154868. * @param taskName defines the name of the new task
  154869. * @param url defines the url of the file to load
  154870. * @param extensions defines the extension to use to load the cube map (can be null)
  154871. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154872. * @param files defines the list of files to load (can be null)
  154873. * @returns a new CubeTextureAssetTask object
  154874. */
  154875. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154876. /**
  154877. *
  154878. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154879. * @param taskName defines the name of the new task
  154880. * @param url defines the url of the file to load
  154881. * @param size defines the size you want for the cubemap (can be null)
  154882. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154883. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154884. * @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)
  154885. * @param reserved Internal use only
  154886. * @returns a new HDRCubeTextureAssetTask object
  154887. */
  154888. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154889. /**
  154890. *
  154891. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154892. * @param taskName defines the name of the new task
  154893. * @param url defines the url of the file to load
  154894. * @param size defines the size you want for the cubemap (can be null)
  154895. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154896. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154897. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154898. * @returns a new EquiRectangularCubeTextureAssetTask object
  154899. */
  154900. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154901. /**
  154902. * Remove a task from the assets manager.
  154903. * @param task the task to remove
  154904. */
  154905. removeTask(task: AbstractAssetTask): void;
  154906. private _decreaseWaitingTasksCount;
  154907. private _runTask;
  154908. /**
  154909. * Reset the AssetsManager and remove all tasks
  154910. * @return the current instance of the AssetsManager
  154911. */
  154912. reset(): AssetsManager;
  154913. /**
  154914. * Start the loading process
  154915. * @return the current instance of the AssetsManager
  154916. */
  154917. load(): AssetsManager;
  154918. /**
  154919. * Start the loading process as an async operation
  154920. * @return a promise returning the list of failed tasks
  154921. */
  154922. loadAsync(): Promise<void>;
  154923. }
  154924. }
  154925. declare module BABYLON {
  154926. /**
  154927. * Wrapper class for promise with external resolve and reject.
  154928. */
  154929. export class Deferred<T> {
  154930. /**
  154931. * The promise associated with this deferred object.
  154932. */
  154933. readonly promise: Promise<T>;
  154934. private _resolve;
  154935. private _reject;
  154936. /**
  154937. * The resolve method of the promise associated with this deferred object.
  154938. */
  154939. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154940. /**
  154941. * The reject method of the promise associated with this deferred object.
  154942. */
  154943. get reject(): (reason?: any) => void;
  154944. /**
  154945. * Constructor for this deferred object.
  154946. */
  154947. constructor();
  154948. }
  154949. }
  154950. declare module BABYLON {
  154951. /**
  154952. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154953. */
  154954. export class MeshExploder {
  154955. private _centerMesh;
  154956. private _meshes;
  154957. private _meshesOrigins;
  154958. private _toCenterVectors;
  154959. private _scaledDirection;
  154960. private _newPosition;
  154961. private _centerPosition;
  154962. /**
  154963. * Explodes meshes from a center mesh.
  154964. * @param meshes The meshes to explode.
  154965. * @param centerMesh The mesh to be center of explosion.
  154966. */
  154967. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154968. private _setCenterMesh;
  154969. /**
  154970. * Get class name
  154971. * @returns "MeshExploder"
  154972. */
  154973. getClassName(): string;
  154974. /**
  154975. * "Exploded meshes"
  154976. * @returns Array of meshes with the centerMesh at index 0.
  154977. */
  154978. getMeshes(): Array<Mesh>;
  154979. /**
  154980. * Explodes meshes giving a specific direction
  154981. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154982. */
  154983. explode(direction?: number): void;
  154984. }
  154985. }
  154986. declare module BABYLON {
  154987. /**
  154988. * Class used to help managing file picking and drag'n'drop
  154989. */
  154990. export class FilesInput {
  154991. /**
  154992. * List of files ready to be loaded
  154993. */
  154994. static get FilesToLoad(): {
  154995. [key: string]: File;
  154996. };
  154997. /**
  154998. * Callback called when a file is processed
  154999. */
  155000. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155001. private _engine;
  155002. private _currentScene;
  155003. private _sceneLoadedCallback;
  155004. private _progressCallback;
  155005. private _additionalRenderLoopLogicCallback;
  155006. private _textureLoadingCallback;
  155007. private _startingProcessingFilesCallback;
  155008. private _onReloadCallback;
  155009. private _errorCallback;
  155010. private _elementToMonitor;
  155011. private _sceneFileToLoad;
  155012. private _filesToLoad;
  155013. /**
  155014. * Creates a new FilesInput
  155015. * @param engine defines the rendering engine
  155016. * @param scene defines the hosting scene
  155017. * @param sceneLoadedCallback callback called when scene is loaded
  155018. * @param progressCallback callback called to track progress
  155019. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155020. * @param textureLoadingCallback callback called when a texture is loading
  155021. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155022. * @param onReloadCallback callback called when a reload is requested
  155023. * @param errorCallback callback call if an error occurs
  155024. */
  155025. 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>);
  155026. private _dragEnterHandler;
  155027. private _dragOverHandler;
  155028. private _dropHandler;
  155029. /**
  155030. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155031. * @param elementToMonitor defines the DOM element to track
  155032. */
  155033. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155034. /** Gets the current list of files to load */
  155035. get filesToLoad(): File[];
  155036. /**
  155037. * Release all associated resources
  155038. */
  155039. dispose(): void;
  155040. private renderFunction;
  155041. private drag;
  155042. private drop;
  155043. private _traverseFolder;
  155044. private _processFiles;
  155045. /**
  155046. * Load files from a drop event
  155047. * @param event defines the drop event to use as source
  155048. */
  155049. loadFiles(event: any): void;
  155050. private _processReload;
  155051. /**
  155052. * Reload the current scene from the loaded files
  155053. */
  155054. reload(): void;
  155055. }
  155056. }
  155057. declare module BABYLON {
  155058. /**
  155059. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155060. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155061. */
  155062. export class SceneOptimization {
  155063. /**
  155064. * Defines the priority of this optimization (0 by default which means first in the list)
  155065. */
  155066. priority: number;
  155067. /**
  155068. * Gets a string describing the action executed by the current optimization
  155069. * @returns description string
  155070. */
  155071. getDescription(): string;
  155072. /**
  155073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155074. * @param scene defines the current scene where to apply this optimization
  155075. * @param optimizer defines the current optimizer
  155076. * @returns true if everything that can be done was applied
  155077. */
  155078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155079. /**
  155080. * Creates the SceneOptimization object
  155081. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155082. * @param desc defines the description associated with the optimization
  155083. */
  155084. constructor(
  155085. /**
  155086. * Defines the priority of this optimization (0 by default which means first in the list)
  155087. */
  155088. priority?: number);
  155089. }
  155090. /**
  155091. * Defines an optimization used to reduce the size of render target textures
  155092. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155093. */
  155094. export class TextureOptimization extends SceneOptimization {
  155095. /**
  155096. * Defines the priority of this optimization (0 by default which means first in the list)
  155097. */
  155098. priority: number;
  155099. /**
  155100. * 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
  155101. */
  155102. maximumSize: number;
  155103. /**
  155104. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155105. */
  155106. step: number;
  155107. /**
  155108. * Gets a string describing the action executed by the current optimization
  155109. * @returns description string
  155110. */
  155111. getDescription(): string;
  155112. /**
  155113. * Creates the TextureOptimization object
  155114. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155115. * @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
  155116. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155117. */
  155118. constructor(
  155119. /**
  155120. * Defines the priority of this optimization (0 by default which means first in the list)
  155121. */
  155122. priority?: number,
  155123. /**
  155124. * 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
  155125. */
  155126. maximumSize?: number,
  155127. /**
  155128. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155129. */
  155130. step?: number);
  155131. /**
  155132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155133. * @param scene defines the current scene where to apply this optimization
  155134. * @param optimizer defines the current optimizer
  155135. * @returns true if everything that can be done was applied
  155136. */
  155137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155138. }
  155139. /**
  155140. * Defines an optimization used to increase or decrease the rendering resolution
  155141. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155142. */
  155143. export class HardwareScalingOptimization extends SceneOptimization {
  155144. /**
  155145. * Defines the priority of this optimization (0 by default which means first in the list)
  155146. */
  155147. priority: number;
  155148. /**
  155149. * Defines the maximum scale to use (2 by default)
  155150. */
  155151. maximumScale: number;
  155152. /**
  155153. * Defines the step to use between two passes (0.5 by default)
  155154. */
  155155. step: number;
  155156. private _currentScale;
  155157. private _directionOffset;
  155158. /**
  155159. * Gets a string describing the action executed by the current optimization
  155160. * @return description string
  155161. */
  155162. getDescription(): string;
  155163. /**
  155164. * Creates the HardwareScalingOptimization object
  155165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155166. * @param maximumScale defines the maximum scale to use (2 by default)
  155167. * @param step defines the step to use between two passes (0.5 by default)
  155168. */
  155169. constructor(
  155170. /**
  155171. * Defines the priority of this optimization (0 by default which means first in the list)
  155172. */
  155173. priority?: number,
  155174. /**
  155175. * Defines the maximum scale to use (2 by default)
  155176. */
  155177. maximumScale?: number,
  155178. /**
  155179. * Defines the step to use between two passes (0.5 by default)
  155180. */
  155181. step?: number);
  155182. /**
  155183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155184. * @param scene defines the current scene where to apply this optimization
  155185. * @param optimizer defines the current optimizer
  155186. * @returns true if everything that can be done was applied
  155187. */
  155188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155189. }
  155190. /**
  155191. * Defines an optimization used to remove shadows
  155192. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155193. */
  155194. export class ShadowsOptimization extends SceneOptimization {
  155195. /**
  155196. * Gets a string describing the action executed by the current optimization
  155197. * @return description string
  155198. */
  155199. getDescription(): string;
  155200. /**
  155201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155202. * @param scene defines the current scene where to apply this optimization
  155203. * @param optimizer defines the current optimizer
  155204. * @returns true if everything that can be done was applied
  155205. */
  155206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155207. }
  155208. /**
  155209. * Defines an optimization used to turn post-processes off
  155210. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155211. */
  155212. export class PostProcessesOptimization extends SceneOptimization {
  155213. /**
  155214. * Gets a string describing the action executed by the current optimization
  155215. * @return description string
  155216. */
  155217. getDescription(): string;
  155218. /**
  155219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155220. * @param scene defines the current scene where to apply this optimization
  155221. * @param optimizer defines the current optimizer
  155222. * @returns true if everything that can be done was applied
  155223. */
  155224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155225. }
  155226. /**
  155227. * Defines an optimization used to turn lens flares off
  155228. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155229. */
  155230. export class LensFlaresOptimization extends SceneOptimization {
  155231. /**
  155232. * Gets a string describing the action executed by the current optimization
  155233. * @return description string
  155234. */
  155235. getDescription(): string;
  155236. /**
  155237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155238. * @param scene defines the current scene where to apply this optimization
  155239. * @param optimizer defines the current optimizer
  155240. * @returns true if everything that can be done was applied
  155241. */
  155242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155243. }
  155244. /**
  155245. * Defines an optimization based on user defined callback.
  155246. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155247. */
  155248. export class CustomOptimization extends SceneOptimization {
  155249. /**
  155250. * Callback called to apply the custom optimization.
  155251. */
  155252. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155253. /**
  155254. * Callback called to get custom description
  155255. */
  155256. onGetDescription: () => string;
  155257. /**
  155258. * Gets a string describing the action executed by the current optimization
  155259. * @returns description string
  155260. */
  155261. getDescription(): string;
  155262. /**
  155263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155264. * @param scene defines the current scene where to apply this optimization
  155265. * @param optimizer defines the current optimizer
  155266. * @returns true if everything that can be done was applied
  155267. */
  155268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155269. }
  155270. /**
  155271. * Defines an optimization used to turn particles off
  155272. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155273. */
  155274. export class ParticlesOptimization extends SceneOptimization {
  155275. /**
  155276. * Gets a string describing the action executed by the current optimization
  155277. * @return description string
  155278. */
  155279. getDescription(): string;
  155280. /**
  155281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155282. * @param scene defines the current scene where to apply this optimization
  155283. * @param optimizer defines the current optimizer
  155284. * @returns true if everything that can be done was applied
  155285. */
  155286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155287. }
  155288. /**
  155289. * Defines an optimization used to turn render targets off
  155290. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155291. */
  155292. export class RenderTargetsOptimization extends SceneOptimization {
  155293. /**
  155294. * Gets a string describing the action executed by the current optimization
  155295. * @return description string
  155296. */
  155297. getDescription(): string;
  155298. /**
  155299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155300. * @param scene defines the current scene where to apply this optimization
  155301. * @param optimizer defines the current optimizer
  155302. * @returns true if everything that can be done was applied
  155303. */
  155304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155305. }
  155306. /**
  155307. * Defines an optimization used to merge meshes with compatible materials
  155308. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155309. */
  155310. export class MergeMeshesOptimization extends SceneOptimization {
  155311. private static _UpdateSelectionTree;
  155312. /**
  155313. * Gets or sets a boolean which defines if optimization octree has to be updated
  155314. */
  155315. static get UpdateSelectionTree(): boolean;
  155316. /**
  155317. * Gets or sets a boolean which defines if optimization octree has to be updated
  155318. */
  155319. static set UpdateSelectionTree(value: boolean);
  155320. /**
  155321. * Gets a string describing the action executed by the current optimization
  155322. * @return description string
  155323. */
  155324. getDescription(): string;
  155325. private _canBeMerged;
  155326. /**
  155327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155328. * @param scene defines the current scene where to apply this optimization
  155329. * @param optimizer defines the current optimizer
  155330. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155331. * @returns true if everything that can be done was applied
  155332. */
  155333. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155334. }
  155335. /**
  155336. * Defines a list of options used by SceneOptimizer
  155337. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155338. */
  155339. export class SceneOptimizerOptions {
  155340. /**
  155341. * Defines the target frame rate to reach (60 by default)
  155342. */
  155343. targetFrameRate: number;
  155344. /**
  155345. * Defines the interval between two checkes (2000ms by default)
  155346. */
  155347. trackerDuration: number;
  155348. /**
  155349. * Gets the list of optimizations to apply
  155350. */
  155351. optimizations: SceneOptimization[];
  155352. /**
  155353. * Creates a new list of options used by SceneOptimizer
  155354. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155355. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155356. */
  155357. constructor(
  155358. /**
  155359. * Defines the target frame rate to reach (60 by default)
  155360. */
  155361. targetFrameRate?: number,
  155362. /**
  155363. * Defines the interval between two checkes (2000ms by default)
  155364. */
  155365. trackerDuration?: number);
  155366. /**
  155367. * Add a new optimization
  155368. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155369. * @returns the current SceneOptimizerOptions
  155370. */
  155371. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155372. /**
  155373. * Add a new custom optimization
  155374. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155375. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155376. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155377. * @returns the current SceneOptimizerOptions
  155378. */
  155379. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155380. /**
  155381. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155382. * @param targetFrameRate defines the target frame rate (60 by default)
  155383. * @returns a SceneOptimizerOptions object
  155384. */
  155385. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155386. /**
  155387. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155388. * @param targetFrameRate defines the target frame rate (60 by default)
  155389. * @returns a SceneOptimizerOptions object
  155390. */
  155391. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155392. /**
  155393. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155394. * @param targetFrameRate defines the target frame rate (60 by default)
  155395. * @returns a SceneOptimizerOptions object
  155396. */
  155397. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155398. }
  155399. /**
  155400. * Class used to run optimizations in order to reach a target frame rate
  155401. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155402. */
  155403. export class SceneOptimizer implements IDisposable {
  155404. private _isRunning;
  155405. private _options;
  155406. private _scene;
  155407. private _currentPriorityLevel;
  155408. private _targetFrameRate;
  155409. private _trackerDuration;
  155410. private _currentFrameRate;
  155411. private _sceneDisposeObserver;
  155412. private _improvementMode;
  155413. /**
  155414. * Defines an observable called when the optimizer reaches the target frame rate
  155415. */
  155416. onSuccessObservable: Observable<SceneOptimizer>;
  155417. /**
  155418. * Defines an observable called when the optimizer enables an optimization
  155419. */
  155420. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155421. /**
  155422. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155423. */
  155424. onFailureObservable: Observable<SceneOptimizer>;
  155425. /**
  155426. * Gets a boolean indicating if the optimizer is in improvement mode
  155427. */
  155428. get isInImprovementMode(): boolean;
  155429. /**
  155430. * Gets the current priority level (0 at start)
  155431. */
  155432. get currentPriorityLevel(): number;
  155433. /**
  155434. * Gets the current frame rate checked by the SceneOptimizer
  155435. */
  155436. get currentFrameRate(): number;
  155437. /**
  155438. * Gets or sets the current target frame rate (60 by default)
  155439. */
  155440. get targetFrameRate(): number;
  155441. /**
  155442. * Gets or sets the current target frame rate (60 by default)
  155443. */
  155444. set targetFrameRate(value: number);
  155445. /**
  155446. * Gets or sets the current interval between two checks (every 2000ms by default)
  155447. */
  155448. get trackerDuration(): number;
  155449. /**
  155450. * Gets or sets the current interval between two checks (every 2000ms by default)
  155451. */
  155452. set trackerDuration(value: number);
  155453. /**
  155454. * Gets the list of active optimizations
  155455. */
  155456. get optimizations(): SceneOptimization[];
  155457. /**
  155458. * Creates a new SceneOptimizer
  155459. * @param scene defines the scene to work on
  155460. * @param options defines the options to use with the SceneOptimizer
  155461. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155462. * @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)
  155463. */
  155464. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155465. /**
  155466. * Stops the current optimizer
  155467. */
  155468. stop(): void;
  155469. /**
  155470. * Reset the optimizer to initial step (current priority level = 0)
  155471. */
  155472. reset(): void;
  155473. /**
  155474. * Start the optimizer. By default it will try to reach a specific framerate
  155475. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155476. */
  155477. start(): void;
  155478. private _checkCurrentState;
  155479. /**
  155480. * Release all resources
  155481. */
  155482. dispose(): void;
  155483. /**
  155484. * Helper function to create a SceneOptimizer with one single line of code
  155485. * @param scene defines the scene to work on
  155486. * @param options defines the options to use with the SceneOptimizer
  155487. * @param onSuccess defines a callback to call on success
  155488. * @param onFailure defines a callback to call on failure
  155489. * @returns the new SceneOptimizer object
  155490. */
  155491. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155492. }
  155493. }
  155494. declare module BABYLON {
  155495. /**
  155496. * Class used to serialize a scene into a string
  155497. */
  155498. export class SceneSerializer {
  155499. /**
  155500. * Clear cache used by a previous serialization
  155501. */
  155502. static ClearCache(): void;
  155503. /**
  155504. * Serialize a scene into a JSON compatible object
  155505. * @param scene defines the scene to serialize
  155506. * @returns a JSON compatible object
  155507. */
  155508. static Serialize(scene: Scene): any;
  155509. /**
  155510. * Serialize a mesh into a JSON compatible object
  155511. * @param toSerialize defines the mesh to serialize
  155512. * @param withParents defines if parents must be serialized as well
  155513. * @param withChildren defines if children must be serialized as well
  155514. * @returns a JSON compatible object
  155515. */
  155516. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155517. }
  155518. }
  155519. declare module BABYLON {
  155520. /**
  155521. * Class used to host texture specific utilities
  155522. */
  155523. export class TextureTools {
  155524. /**
  155525. * Uses the GPU to create a copy texture rescaled at a given size
  155526. * @param texture Texture to copy from
  155527. * @param width defines the desired width
  155528. * @param height defines the desired height
  155529. * @param useBilinearMode defines if bilinear mode has to be used
  155530. * @return the generated texture
  155531. */
  155532. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155533. }
  155534. }
  155535. declare module BABYLON {
  155536. /**
  155537. * This represents the different options available for the video capture.
  155538. */
  155539. export interface VideoRecorderOptions {
  155540. /** Defines the mime type of the video. */
  155541. mimeType: string;
  155542. /** Defines the FPS the video should be recorded at. */
  155543. fps: number;
  155544. /** Defines the chunk size for the recording data. */
  155545. recordChunckSize: number;
  155546. /** The audio tracks to attach to the recording. */
  155547. audioTracks?: MediaStreamTrack[];
  155548. }
  155549. /**
  155550. * This can help with recording videos from BabylonJS.
  155551. * This is based on the available WebRTC functionalities of the browser.
  155552. *
  155553. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155554. */
  155555. export class VideoRecorder {
  155556. private static readonly _defaultOptions;
  155557. /**
  155558. * Returns whether or not the VideoRecorder is available in your browser.
  155559. * @param engine Defines the Babylon Engine.
  155560. * @returns true if supported otherwise false.
  155561. */
  155562. static IsSupported(engine: Engine): boolean;
  155563. private readonly _options;
  155564. private _canvas;
  155565. private _mediaRecorder;
  155566. private _recordedChunks;
  155567. private _fileName;
  155568. private _resolve;
  155569. private _reject;
  155570. /**
  155571. * True when a recording is already in progress.
  155572. */
  155573. get isRecording(): boolean;
  155574. /**
  155575. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155576. * @param engine Defines the BabylonJS Engine you wish to record.
  155577. * @param options Defines options that can be used to customize the capture.
  155578. */
  155579. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155580. /**
  155581. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155582. */
  155583. stopRecording(): void;
  155584. /**
  155585. * Starts recording the canvas for a max duration specified in parameters.
  155586. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155587. * If null no automatic download will start and you can rely on the promise to get the data back.
  155588. * @param maxDuration Defines the maximum recording time in seconds.
  155589. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155590. * @return A promise callback at the end of the recording with the video data in Blob.
  155591. */
  155592. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155593. /**
  155594. * Releases internal resources used during the recording.
  155595. */
  155596. dispose(): void;
  155597. private _handleDataAvailable;
  155598. private _handleError;
  155599. private _handleStop;
  155600. }
  155601. }
  155602. declare module BABYLON {
  155603. /**
  155604. * Class containing a set of static utilities functions for screenshots
  155605. */
  155606. export class ScreenshotTools {
  155607. /**
  155608. * Captures a screenshot of the current rendering
  155609. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155610. * @param engine defines the rendering engine
  155611. * @param camera defines the source camera
  155612. * @param size This parameter can be set to a single number or to an object with the
  155613. * following (optional) properties: precision, width, height. If a single number is passed,
  155614. * it will be used for both width and height. If an object is passed, the screenshot size
  155615. * will be derived from the parameters. The precision property is a multiplier allowing
  155616. * rendering at a higher or lower resolution
  155617. * @param successCallback defines the callback receives a single parameter which contains the
  155618. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155619. * src parameter of an <img> to display it
  155620. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155621. * Check your browser for supported MIME types
  155622. */
  155623. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155624. /**
  155625. * Captures a screenshot of the current rendering
  155626. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155627. * @param engine defines the rendering engine
  155628. * @param camera defines the source camera
  155629. * @param size This parameter can be set to a single number or to an object with the
  155630. * following (optional) properties: precision, width, height. If a single number is passed,
  155631. * it will be used for both width and height. If an object is passed, the screenshot size
  155632. * will be derived from the parameters. The precision property is a multiplier allowing
  155633. * rendering at a higher or lower resolution
  155634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155635. * Check your browser for supported MIME types
  155636. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155637. * to the src parameter of an <img> to display it
  155638. */
  155639. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155640. /**
  155641. * Generates an image screenshot from the specified camera.
  155642. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155643. * @param engine The engine to use for rendering
  155644. * @param camera The camera to use for rendering
  155645. * @param size This parameter can be set to a single number or to an object with the
  155646. * following (optional) properties: precision, width, height. If a single number is passed,
  155647. * it will be used for both width and height. If an object is passed, the screenshot size
  155648. * will be derived from the parameters. The precision property is a multiplier allowing
  155649. * rendering at a higher or lower resolution
  155650. * @param successCallback The callback receives a single parameter which contains the
  155651. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155652. * src parameter of an <img> to display it
  155653. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155654. * Check your browser for supported MIME types
  155655. * @param samples Texture samples (default: 1)
  155656. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155657. * @param fileName A name for for the downloaded file.
  155658. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155659. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155660. */
  155661. 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;
  155662. /**
  155663. * Generates an image screenshot from the specified camera.
  155664. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155665. * @param engine The engine to use for rendering
  155666. * @param camera The camera to use for rendering
  155667. * @param size This parameter can be set to a single number or to an object with the
  155668. * following (optional) properties: precision, width, height. If a single number is passed,
  155669. * it will be used for both width and height. If an object is passed, the screenshot size
  155670. * will be derived from the parameters. The precision property is a multiplier allowing
  155671. * rendering at a higher or lower resolution
  155672. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155673. * Check your browser for supported MIME types
  155674. * @param samples Texture samples (default: 1)
  155675. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155676. * @param fileName A name for for the downloaded file.
  155677. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155678. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155679. * to the src parameter of an <img> to display it
  155680. */
  155681. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155682. /**
  155683. * Gets height and width for screenshot size
  155684. * @private
  155685. */
  155686. private static _getScreenshotSize;
  155687. }
  155688. }
  155689. declare module BABYLON {
  155690. /**
  155691. * Interface for a data buffer
  155692. */
  155693. export interface IDataBuffer {
  155694. /**
  155695. * Reads bytes from the data buffer.
  155696. * @param byteOffset The byte offset to read
  155697. * @param byteLength The byte length to read
  155698. * @returns A promise that resolves when the bytes are read
  155699. */
  155700. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155701. /**
  155702. * The byte length of the buffer.
  155703. */
  155704. readonly byteLength: number;
  155705. }
  155706. /**
  155707. * Utility class for reading from a data buffer
  155708. */
  155709. export class DataReader {
  155710. /**
  155711. * The data buffer associated with this data reader.
  155712. */
  155713. readonly buffer: IDataBuffer;
  155714. /**
  155715. * The current byte offset from the beginning of the data buffer.
  155716. */
  155717. byteOffset: number;
  155718. private _dataView;
  155719. private _dataByteOffset;
  155720. /**
  155721. * Constructor
  155722. * @param buffer The buffer to read
  155723. */
  155724. constructor(buffer: IDataBuffer);
  155725. /**
  155726. * Loads the given byte length.
  155727. * @param byteLength The byte length to load
  155728. * @returns A promise that resolves when the load is complete
  155729. */
  155730. loadAsync(byteLength: number): Promise<void>;
  155731. /**
  155732. * Read a unsigned 32-bit integer from the currently loaded data range.
  155733. * @returns The 32-bit integer read
  155734. */
  155735. readUint32(): number;
  155736. /**
  155737. * Read a byte array from the currently loaded data range.
  155738. * @param byteLength The byte length to read
  155739. * @returns The byte array read
  155740. */
  155741. readUint8Array(byteLength: number): Uint8Array;
  155742. /**
  155743. * Read a string from the currently loaded data range.
  155744. * @param byteLength The byte length to read
  155745. * @returns The string read
  155746. */
  155747. readString(byteLength: number): string;
  155748. /**
  155749. * Skips the given byte length the currently loaded data range.
  155750. * @param byteLength The byte length to skip
  155751. */
  155752. skipBytes(byteLength: number): void;
  155753. }
  155754. }
  155755. declare module BABYLON {
  155756. /**
  155757. * Class for storing data to local storage if available or in-memory storage otherwise
  155758. */
  155759. export class DataStorage {
  155760. private static _Storage;
  155761. private static _GetStorage;
  155762. /**
  155763. * Reads a string from the data storage
  155764. * @param key The key to read
  155765. * @param defaultValue The value if the key doesn't exist
  155766. * @returns The string value
  155767. */
  155768. static ReadString(key: string, defaultValue: string): string;
  155769. /**
  155770. * Writes a string to the data storage
  155771. * @param key The key to write
  155772. * @param value The value to write
  155773. */
  155774. static WriteString(key: string, value: string): void;
  155775. /**
  155776. * Reads a boolean from the data storage
  155777. * @param key The key to read
  155778. * @param defaultValue The value if the key doesn't exist
  155779. * @returns The boolean value
  155780. */
  155781. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155782. /**
  155783. * Writes a boolean to the data storage
  155784. * @param key The key to write
  155785. * @param value The value to write
  155786. */
  155787. static WriteBoolean(key: string, value: boolean): void;
  155788. /**
  155789. * Reads a number from the data storage
  155790. * @param key The key to read
  155791. * @param defaultValue The value if the key doesn't exist
  155792. * @returns The number value
  155793. */
  155794. static ReadNumber(key: string, defaultValue: number): number;
  155795. /**
  155796. * Writes a number to the data storage
  155797. * @param key The key to write
  155798. * @param value The value to write
  155799. */
  155800. static WriteNumber(key: string, value: number): void;
  155801. }
  155802. }
  155803. declare module BABYLON {
  155804. /**
  155805. * Class used to record delta files between 2 scene states
  155806. */
  155807. export class SceneRecorder {
  155808. private _trackedScene;
  155809. private _savedJSON;
  155810. /**
  155811. * Track a given scene. This means the current scene state will be considered the original state
  155812. * @param scene defines the scene to track
  155813. */
  155814. track(scene: Scene): void;
  155815. /**
  155816. * Get the delta between current state and original state
  155817. * @returns a string containing the delta
  155818. */
  155819. getDelta(): any;
  155820. private _compareArray;
  155821. private _compareObjects;
  155822. private _compareCollections;
  155823. private static GetShadowGeneratorById;
  155824. /**
  155825. * Apply a given delta to a given scene
  155826. * @param deltaJSON defines the JSON containing the delta
  155827. * @param scene defines the scene to apply the delta to
  155828. */
  155829. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155830. private static _ApplyPropertiesToEntity;
  155831. private static _ApplyDeltaForEntity;
  155832. }
  155833. }
  155834. declare module BABYLON {
  155835. /**
  155836. * A 3D trajectory consisting of an order list of vectors describing a
  155837. * path of motion through 3D space.
  155838. */
  155839. export class Trajectory {
  155840. private _points;
  155841. private readonly _segmentLength;
  155842. /**
  155843. * Serialize to JSON.
  155844. * @returns serialized JSON string
  155845. */
  155846. serialize(): string;
  155847. /**
  155848. * Deserialize from JSON.
  155849. * @param json serialized JSON string
  155850. * @returns deserialized Trajectory
  155851. */
  155852. static Deserialize(json: string): Trajectory;
  155853. /**
  155854. * Create a new empty Trajectory.
  155855. * @param segmentLength radius of discretization for Trajectory points
  155856. */
  155857. constructor(segmentLength?: number);
  155858. /**
  155859. * Get the length of the Trajectory.
  155860. * @returns length of the Trajectory
  155861. */
  155862. getLength(): number;
  155863. /**
  155864. * Append a new point to the Trajectory.
  155865. * NOTE: This implementation has many allocations.
  155866. * @param point point to append to the Trajectory
  155867. */
  155868. add(point: DeepImmutable<Vector3>): void;
  155869. /**
  155870. * Create a new Trajectory with a segment length chosen to make it
  155871. * probable that the new Trajectory will have a specified number of
  155872. * segments. This operation is imprecise.
  155873. * @param targetResolution number of segments desired
  155874. * @returns new Trajectory with approximately the requested number of segments
  155875. */
  155876. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155877. /**
  155878. * Convert Trajectory segments into tokenized representation. This
  155879. * representation is an array of numbers where each nth number is the
  155880. * index of the token which is most similar to the nth segment of the
  155881. * Trajectory.
  155882. * @param tokens list of vectors which serve as discrete tokens
  155883. * @returns list of indices of most similar token per segment
  155884. */
  155885. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155886. private static _forwardDir;
  155887. private static _inverseFromVec;
  155888. private static _upDir;
  155889. private static _fromToVec;
  155890. private static _lookMatrix;
  155891. /**
  155892. * Transform the rotation (i.e., direction) of a segment to isolate
  155893. * the relative transformation represented by the segment. This operation
  155894. * may or may not succeed due to singularities in the equations that define
  155895. * motion relativity in this context.
  155896. * @param priorVec the origin of the prior segment
  155897. * @param fromVec the origin of the current segment
  155898. * @param toVec the destination of the current segment
  155899. * @param result reference to output variable
  155900. * @returns whether or not transformation was successful
  155901. */
  155902. private static _transformSegmentDirToRef;
  155903. private static _bestMatch;
  155904. private static _score;
  155905. private static _bestScore;
  155906. /**
  155907. * Determine which token vector is most similar to the
  155908. * segment vector.
  155909. * @param segment segment vector
  155910. * @param tokens token vector list
  155911. * @returns index of the most similar token to the segment
  155912. */
  155913. private static _tokenizeSegment;
  155914. }
  155915. /**
  155916. * Class representing a set of known, named trajectories to which Trajectories can be
  155917. * added and using which Trajectories can be recognized.
  155918. */
  155919. export class TrajectoryClassifier {
  155920. private _maximumAllowableMatchCost;
  155921. private _vector3Alphabet;
  155922. private _levenshteinAlphabet;
  155923. private _nameToDescribedTrajectory;
  155924. /**
  155925. * Serialize to JSON.
  155926. * @returns JSON serialization
  155927. */
  155928. serialize(): string;
  155929. /**
  155930. * Deserialize from JSON.
  155931. * @param json JSON serialization
  155932. * @returns deserialized TrajectorySet
  155933. */
  155934. static Deserialize(json: string): TrajectoryClassifier;
  155935. /**
  155936. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155937. * VERY naive, need to be generating these things from known
  155938. * sets. Better version later, probably eliminating this one.
  155939. * @returns auto-generated TrajectorySet
  155940. */
  155941. static Generate(): TrajectoryClassifier;
  155942. private constructor();
  155943. /**
  155944. * Add a new Trajectory to the set with a given name.
  155945. * @param trajectory new Trajectory to be added
  155946. * @param classification name to which to add the Trajectory
  155947. */
  155948. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155949. /**
  155950. * Remove a known named trajectory and all Trajectories associated with it.
  155951. * @param classification name to remove
  155952. * @returns whether anything was removed
  155953. */
  155954. deleteClassification(classification: string): boolean;
  155955. /**
  155956. * Attempt to recognize a Trajectory from among all the classifications
  155957. * already known to the classifier.
  155958. * @param trajectory Trajectory to be recognized
  155959. * @returns classification of Trajectory if recognized, null otherwise
  155960. */
  155961. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155962. }
  155963. }
  155964. declare module BABYLON {
  155965. /**
  155966. * An interface for all Hit test features
  155967. */
  155968. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155969. /**
  155970. * Triggered when new babylon (transformed) hit test results are available
  155971. */
  155972. onHitTestResultObservable: Observable<T[]>;
  155973. }
  155974. /**
  155975. * Options used for hit testing
  155976. */
  155977. export interface IWebXRLegacyHitTestOptions {
  155978. /**
  155979. * Only test when user interacted with the scene. Default - hit test every frame
  155980. */
  155981. testOnPointerDownOnly?: boolean;
  155982. /**
  155983. * The node to use to transform the local results to world coordinates
  155984. */
  155985. worldParentNode?: TransformNode;
  155986. }
  155987. /**
  155988. * Interface defining the babylon result of raycasting/hit-test
  155989. */
  155990. export interface IWebXRLegacyHitResult {
  155991. /**
  155992. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155993. */
  155994. transformationMatrix: Matrix;
  155995. /**
  155996. * The native hit test result
  155997. */
  155998. xrHitResult: XRHitResult | XRHitTestResult;
  155999. }
  156000. /**
  156001. * The currently-working hit-test module.
  156002. * Hit test (or Ray-casting) is used to interact with the real world.
  156003. * For further information read here - https://github.com/immersive-web/hit-test
  156004. */
  156005. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156006. /**
  156007. * options to use when constructing this feature
  156008. */
  156009. readonly options: IWebXRLegacyHitTestOptions;
  156010. private _direction;
  156011. private _mat;
  156012. private _onSelectEnabled;
  156013. private _origin;
  156014. /**
  156015. * The module's name
  156016. */
  156017. static readonly Name: string;
  156018. /**
  156019. * The (Babylon) version of this module.
  156020. * This is an integer representing the implementation version.
  156021. * This number does not correspond to the WebXR specs version
  156022. */
  156023. static readonly Version: number;
  156024. /**
  156025. * Populated with the last native XR Hit Results
  156026. */
  156027. lastNativeXRHitResults: XRHitResult[];
  156028. /**
  156029. * Triggered when new babylon (transformed) hit test results are available
  156030. */
  156031. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156032. /**
  156033. * Creates a new instance of the (legacy version) hit test feature
  156034. * @param _xrSessionManager an instance of WebXRSessionManager
  156035. * @param options options to use when constructing this feature
  156036. */
  156037. constructor(_xrSessionManager: WebXRSessionManager,
  156038. /**
  156039. * options to use when constructing this feature
  156040. */
  156041. options?: IWebXRLegacyHitTestOptions);
  156042. /**
  156043. * execute a hit test with an XR Ray
  156044. *
  156045. * @param xrSession a native xrSession that will execute this hit test
  156046. * @param xrRay the ray (position and direction) to use for ray-casting
  156047. * @param referenceSpace native XR reference space to use for the hit-test
  156048. * @param filter filter function that will filter the results
  156049. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156050. */
  156051. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156052. /**
  156053. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156054. * @param event the (select) event to use to select with
  156055. * @param referenceSpace the reference space to use for this hit test
  156056. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156057. */
  156058. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156059. /**
  156060. * attach this feature
  156061. * Will usually be called by the features manager
  156062. *
  156063. * @returns true if successful.
  156064. */
  156065. attach(): boolean;
  156066. /**
  156067. * detach this feature.
  156068. * Will usually be called by the features manager
  156069. *
  156070. * @returns true if successful.
  156071. */
  156072. detach(): boolean;
  156073. /**
  156074. * Dispose this feature and all of the resources attached
  156075. */
  156076. dispose(): void;
  156077. protected _onXRFrame(frame: XRFrame): void;
  156078. private _onHitTestResults;
  156079. private _onSelect;
  156080. }
  156081. }
  156082. declare module BABYLON {
  156083. /**
  156084. * Options used for hit testing (version 2)
  156085. */
  156086. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156087. /**
  156088. * Do not create a permanent hit test. Will usually be used when only
  156089. * transient inputs are needed.
  156090. */
  156091. disablePermanentHitTest?: boolean;
  156092. /**
  156093. * Enable transient (for example touch-based) hit test inspections
  156094. */
  156095. enableTransientHitTest?: boolean;
  156096. /**
  156097. * Offset ray for the permanent hit test
  156098. */
  156099. offsetRay?: Vector3;
  156100. /**
  156101. * Offset ray for the transient hit test
  156102. */
  156103. transientOffsetRay?: Vector3;
  156104. /**
  156105. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156106. */
  156107. useReferenceSpace?: boolean;
  156108. /**
  156109. * Override the default entity type(s) of the hit-test result
  156110. */
  156111. entityTypes?: XRHitTestTrackableType[];
  156112. }
  156113. /**
  156114. * Interface defining the babylon result of hit-test
  156115. */
  156116. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156117. /**
  156118. * The input source that generated this hit test (if transient)
  156119. */
  156120. inputSource?: XRInputSource;
  156121. /**
  156122. * Is this a transient hit test
  156123. */
  156124. isTransient?: boolean;
  156125. /**
  156126. * Position of the hit test result
  156127. */
  156128. position: Vector3;
  156129. /**
  156130. * Rotation of the hit test result
  156131. */
  156132. rotationQuaternion: Quaternion;
  156133. /**
  156134. * The native hit test result
  156135. */
  156136. xrHitResult: XRHitTestResult;
  156137. }
  156138. /**
  156139. * The currently-working hit-test module.
  156140. * Hit test (or Ray-casting) is used to interact with the real world.
  156141. * For further information read here - https://github.com/immersive-web/hit-test
  156142. *
  156143. * Tested on chrome (mobile) 80.
  156144. */
  156145. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156146. /**
  156147. * options to use when constructing this feature
  156148. */
  156149. readonly options: IWebXRHitTestOptions;
  156150. private _tmpMat;
  156151. private _tmpPos;
  156152. private _tmpQuat;
  156153. private _transientXrHitTestSource;
  156154. private _xrHitTestSource;
  156155. private initHitTestSource;
  156156. /**
  156157. * The module's name
  156158. */
  156159. static readonly Name: string;
  156160. /**
  156161. * The (Babylon) version of this module.
  156162. * This is an integer representing the implementation version.
  156163. * This number does not correspond to the WebXR specs version
  156164. */
  156165. static readonly Version: number;
  156166. /**
  156167. * When set to true, each hit test will have its own position/rotation objects
  156168. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156169. * the developers will clone them or copy them as they see fit.
  156170. */
  156171. autoCloneTransformation: boolean;
  156172. /**
  156173. * Triggered when new babylon (transformed) hit test results are available
  156174. * Note - this will be called when results come back from the device. It can be an empty array!!
  156175. */
  156176. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156177. /**
  156178. * Use this to temporarily pause hit test checks.
  156179. */
  156180. paused: boolean;
  156181. /**
  156182. * Creates a new instance of the hit test feature
  156183. * @param _xrSessionManager an instance of WebXRSessionManager
  156184. * @param options options to use when constructing this feature
  156185. */
  156186. constructor(_xrSessionManager: WebXRSessionManager,
  156187. /**
  156188. * options to use when constructing this feature
  156189. */
  156190. options?: IWebXRHitTestOptions);
  156191. /**
  156192. * attach this feature
  156193. * Will usually be called by the features manager
  156194. *
  156195. * @returns true if successful.
  156196. */
  156197. attach(): boolean;
  156198. /**
  156199. * detach this feature.
  156200. * Will usually be called by the features manager
  156201. *
  156202. * @returns true if successful.
  156203. */
  156204. detach(): boolean;
  156205. /**
  156206. * Dispose this feature and all of the resources attached
  156207. */
  156208. dispose(): void;
  156209. protected _onXRFrame(frame: XRFrame): void;
  156210. private _processWebXRHitTestResult;
  156211. }
  156212. }
  156213. declare module BABYLON {
  156214. /**
  156215. * Configuration options of the anchor system
  156216. */
  156217. export interface IWebXRAnchorSystemOptions {
  156218. /**
  156219. * a node that will be used to convert local to world coordinates
  156220. */
  156221. worldParentNode?: TransformNode;
  156222. /**
  156223. * If set to true a reference of the created anchors will be kept until the next session starts
  156224. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156225. */
  156226. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156227. }
  156228. /**
  156229. * A babylon container for an XR Anchor
  156230. */
  156231. export interface IWebXRAnchor {
  156232. /**
  156233. * A babylon-assigned ID for this anchor
  156234. */
  156235. id: number;
  156236. /**
  156237. * Transformation matrix to apply to an object attached to this anchor
  156238. */
  156239. transformationMatrix: Matrix;
  156240. /**
  156241. * The native anchor object
  156242. */
  156243. xrAnchor: XRAnchor;
  156244. /**
  156245. * if defined, this object will be constantly updated by the anchor's position and rotation
  156246. */
  156247. attachedNode?: TransformNode;
  156248. }
  156249. /**
  156250. * An implementation of the anchor system for WebXR.
  156251. * For further information see https://github.com/immersive-web/anchors/
  156252. */
  156253. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156254. private _options;
  156255. private _lastFrameDetected;
  156256. private _trackedAnchors;
  156257. private _referenceSpaceForFrameAnchors;
  156258. private _futureAnchors;
  156259. /**
  156260. * The module's name
  156261. */
  156262. static readonly Name: string;
  156263. /**
  156264. * The (Babylon) version of this module.
  156265. * This is an integer representing the implementation version.
  156266. * This number does not correspond to the WebXR specs version
  156267. */
  156268. static readonly Version: number;
  156269. /**
  156270. * Observers registered here will be executed when a new anchor was added to the session
  156271. */
  156272. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156273. /**
  156274. * Observers registered here will be executed when an anchor was removed from the session
  156275. */
  156276. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156277. /**
  156278. * Observers registered here will be executed when an existing anchor updates
  156279. * This can execute N times every frame
  156280. */
  156281. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156282. /**
  156283. * Set the reference space to use for anchor creation, when not using a hit test.
  156284. * Will default to the session's reference space if not defined
  156285. */
  156286. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156287. /**
  156288. * constructs a new anchor system
  156289. * @param _xrSessionManager an instance of WebXRSessionManager
  156290. * @param _options configuration object for this feature
  156291. */
  156292. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156293. private _tmpVector;
  156294. private _tmpQuaternion;
  156295. private _populateTmpTransformation;
  156296. /**
  156297. * Create a new anchor point using a hit test result at a specific point in the scene
  156298. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156299. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156300. *
  156301. * @param hitTestResult The hit test result to use for this anchor creation
  156302. * @param position an optional position offset for this anchor
  156303. * @param rotationQuaternion an optional rotation offset for this anchor
  156304. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156305. */
  156306. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156307. /**
  156308. * Add a new anchor at a specific position and rotation
  156309. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156310. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156311. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156312. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156313. *
  156314. * @param position the position in which to add an anchor
  156315. * @param rotationQuaternion an optional rotation for the anchor transformation
  156316. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156317. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156318. */
  156319. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156320. /**
  156321. * detach this feature.
  156322. * Will usually be called by the features manager
  156323. *
  156324. * @returns true if successful.
  156325. */
  156326. detach(): boolean;
  156327. /**
  156328. * Dispose this feature and all of the resources attached
  156329. */
  156330. dispose(): void;
  156331. protected _onXRFrame(frame: XRFrame): void;
  156332. /**
  156333. * avoiding using Array.find for global support.
  156334. * @param xrAnchor the plane to find in the array
  156335. */
  156336. private _findIndexInAnchorArray;
  156337. private _updateAnchorWithXRFrame;
  156338. private _createAnchorAtTransformation;
  156339. }
  156340. }
  156341. declare module BABYLON {
  156342. /**
  156343. * Options used in the plane detector module
  156344. */
  156345. export interface IWebXRPlaneDetectorOptions {
  156346. /**
  156347. * The node to use to transform the local results to world coordinates
  156348. */
  156349. worldParentNode?: TransformNode;
  156350. /**
  156351. * If set to true a reference of the created planes will be kept until the next session starts
  156352. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156353. */
  156354. doNotRemovePlanesOnSessionEnded?: boolean;
  156355. }
  156356. /**
  156357. * A babylon interface for a WebXR plane.
  156358. * A Plane is actually a polygon, built from N points in space
  156359. *
  156360. * Supported in chrome 79, not supported in canary 81 ATM
  156361. */
  156362. export interface IWebXRPlane {
  156363. /**
  156364. * a babylon-assigned ID for this polygon
  156365. */
  156366. id: number;
  156367. /**
  156368. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156369. */
  156370. polygonDefinition: Array<Vector3>;
  156371. /**
  156372. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156373. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156374. */
  156375. transformationMatrix: Matrix;
  156376. /**
  156377. * the native xr-plane object
  156378. */
  156379. xrPlane: XRPlane;
  156380. }
  156381. /**
  156382. * The plane detector is used to detect planes in the real world when in AR
  156383. * For more information see https://github.com/immersive-web/real-world-geometry/
  156384. */
  156385. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156386. private _options;
  156387. private _detectedPlanes;
  156388. private _enabled;
  156389. private _lastFrameDetected;
  156390. /**
  156391. * The module's name
  156392. */
  156393. static readonly Name: string;
  156394. /**
  156395. * The (Babylon) version of this module.
  156396. * This is an integer representing the implementation version.
  156397. * This number does not correspond to the WebXR specs version
  156398. */
  156399. static readonly Version: number;
  156400. /**
  156401. * Observers registered here will be executed when a new plane was added to the session
  156402. */
  156403. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156404. /**
  156405. * Observers registered here will be executed when a plane is no longer detected in the session
  156406. */
  156407. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156408. /**
  156409. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156410. * This can execute N times every frame
  156411. */
  156412. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156413. /**
  156414. * construct a new Plane Detector
  156415. * @param _xrSessionManager an instance of xr Session manager
  156416. * @param _options configuration to use when constructing this feature
  156417. */
  156418. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156419. /**
  156420. * detach this feature.
  156421. * Will usually be called by the features manager
  156422. *
  156423. * @returns true if successful.
  156424. */
  156425. detach(): boolean;
  156426. /**
  156427. * Dispose this feature and all of the resources attached
  156428. */
  156429. dispose(): void;
  156430. protected _onXRFrame(frame: XRFrame): void;
  156431. private _init;
  156432. private _updatePlaneWithXRPlane;
  156433. /**
  156434. * avoiding using Array.find for global support.
  156435. * @param xrPlane the plane to find in the array
  156436. */
  156437. private findIndexInPlaneArray;
  156438. }
  156439. }
  156440. declare module BABYLON {
  156441. /**
  156442. * Options interface for the background remover plugin
  156443. */
  156444. export interface IWebXRBackgroundRemoverOptions {
  156445. /**
  156446. * Further background meshes to disable when entering AR
  156447. */
  156448. backgroundMeshes?: AbstractMesh[];
  156449. /**
  156450. * flags to configure the removal of the environment helper.
  156451. * If not set, the entire background will be removed. If set, flags should be set as well.
  156452. */
  156453. environmentHelperRemovalFlags?: {
  156454. /**
  156455. * Should the skybox be removed (default false)
  156456. */
  156457. skyBox?: boolean;
  156458. /**
  156459. * Should the ground be removed (default false)
  156460. */
  156461. ground?: boolean;
  156462. };
  156463. /**
  156464. * don't disable the environment helper
  156465. */
  156466. ignoreEnvironmentHelper?: boolean;
  156467. }
  156468. /**
  156469. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156470. */
  156471. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156472. /**
  156473. * read-only options to be used in this module
  156474. */
  156475. readonly options: IWebXRBackgroundRemoverOptions;
  156476. /**
  156477. * The module's name
  156478. */
  156479. static readonly Name: string;
  156480. /**
  156481. * The (Babylon) version of this module.
  156482. * This is an integer representing the implementation version.
  156483. * This number does not correspond to the WebXR specs version
  156484. */
  156485. static readonly Version: number;
  156486. /**
  156487. * registered observers will be triggered when the background state changes
  156488. */
  156489. onBackgroundStateChangedObservable: Observable<boolean>;
  156490. /**
  156491. * constructs a new background remover module
  156492. * @param _xrSessionManager the session manager for this module
  156493. * @param options read-only options to be used in this module
  156494. */
  156495. constructor(_xrSessionManager: WebXRSessionManager,
  156496. /**
  156497. * read-only options to be used in this module
  156498. */
  156499. options?: IWebXRBackgroundRemoverOptions);
  156500. /**
  156501. * attach this feature
  156502. * Will usually be called by the features manager
  156503. *
  156504. * @returns true if successful.
  156505. */
  156506. attach(): boolean;
  156507. /**
  156508. * detach this feature.
  156509. * Will usually be called by the features manager
  156510. *
  156511. * @returns true if successful.
  156512. */
  156513. detach(): boolean;
  156514. /**
  156515. * Dispose this feature and all of the resources attached
  156516. */
  156517. dispose(): void;
  156518. protected _onXRFrame(_xrFrame: XRFrame): void;
  156519. private _setBackgroundState;
  156520. }
  156521. }
  156522. declare module BABYLON {
  156523. /**
  156524. * Options for the controller physics feature
  156525. */
  156526. export class IWebXRControllerPhysicsOptions {
  156527. /**
  156528. * Should the headset get its own impostor
  156529. */
  156530. enableHeadsetImpostor?: boolean;
  156531. /**
  156532. * Optional parameters for the headset impostor
  156533. */
  156534. headsetImpostorParams?: {
  156535. /**
  156536. * The type of impostor to create. Default is sphere
  156537. */
  156538. impostorType: number;
  156539. /**
  156540. * the size of the impostor. Defaults to 10cm
  156541. */
  156542. impostorSize?: number | {
  156543. width: number;
  156544. height: number;
  156545. depth: number;
  156546. };
  156547. /**
  156548. * Friction definitions
  156549. */
  156550. friction?: number;
  156551. /**
  156552. * Restitution
  156553. */
  156554. restitution?: number;
  156555. };
  156556. /**
  156557. * The physics properties of the future impostors
  156558. */
  156559. physicsProperties?: {
  156560. /**
  156561. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156562. * Note that this requires a physics engine that supports mesh impostors!
  156563. */
  156564. useControllerMesh?: boolean;
  156565. /**
  156566. * The type of impostor to create. Default is sphere
  156567. */
  156568. impostorType?: number;
  156569. /**
  156570. * the size of the impostor. Defaults to 10cm
  156571. */
  156572. impostorSize?: number | {
  156573. width: number;
  156574. height: number;
  156575. depth: number;
  156576. };
  156577. /**
  156578. * Friction definitions
  156579. */
  156580. friction?: number;
  156581. /**
  156582. * Restitution
  156583. */
  156584. restitution?: number;
  156585. };
  156586. /**
  156587. * the xr input to use with this pointer selection
  156588. */
  156589. xrInput: WebXRInput;
  156590. }
  156591. /**
  156592. * Add physics impostor to your webxr controllers,
  156593. * including naive calculation of their linear and angular velocity
  156594. */
  156595. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156596. private readonly _options;
  156597. private _attachController;
  156598. private _controllers;
  156599. private _debugMode;
  156600. private _delta;
  156601. private _headsetImpostor?;
  156602. private _headsetMesh?;
  156603. private _lastTimestamp;
  156604. private _tmpQuaternion;
  156605. private _tmpVector;
  156606. /**
  156607. * The module's name
  156608. */
  156609. static readonly Name: string;
  156610. /**
  156611. * The (Babylon) version of this module.
  156612. * This is an integer representing the implementation version.
  156613. * This number does not correspond to the webxr specs version
  156614. */
  156615. static readonly Version: number;
  156616. /**
  156617. * Construct a new Controller Physics Feature
  156618. * @param _xrSessionManager the corresponding xr session manager
  156619. * @param _options options to create this feature with
  156620. */
  156621. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156622. /**
  156623. * @hidden
  156624. * enable debugging - will show console outputs and the impostor mesh
  156625. */
  156626. _enablePhysicsDebug(): void;
  156627. /**
  156628. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156629. * @param xrController the controller to add
  156630. */
  156631. addController(xrController: WebXRInputSource): void;
  156632. /**
  156633. * attach this feature
  156634. * Will usually be called by the features manager
  156635. *
  156636. * @returns true if successful.
  156637. */
  156638. attach(): boolean;
  156639. /**
  156640. * detach this feature.
  156641. * Will usually be called by the features manager
  156642. *
  156643. * @returns true if successful.
  156644. */
  156645. detach(): boolean;
  156646. /**
  156647. * Get the headset impostor, if enabled
  156648. * @returns the impostor
  156649. */
  156650. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156651. /**
  156652. * Get the physics impostor of a specific controller.
  156653. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156654. * @param controller the controller or the controller id of which to get the impostor
  156655. * @returns the impostor or null
  156656. */
  156657. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156658. /**
  156659. * Update the physics properties provided in the constructor
  156660. * @param newProperties the new properties object
  156661. */
  156662. setPhysicsProperties(newProperties: {
  156663. impostorType?: number;
  156664. impostorSize?: number | {
  156665. width: number;
  156666. height: number;
  156667. depth: number;
  156668. };
  156669. friction?: number;
  156670. restitution?: number;
  156671. }): void;
  156672. protected _onXRFrame(_xrFrame: any): void;
  156673. private _detachController;
  156674. }
  156675. }
  156676. declare module BABYLON {
  156677. /**
  156678. * A babylon interface for a "WebXR" feature point.
  156679. * Represents the position and confidence value of a given feature point.
  156680. */
  156681. export interface IWebXRFeaturePoint {
  156682. /**
  156683. * Represents the position of the feature point in world space.
  156684. */
  156685. position: Vector3;
  156686. /**
  156687. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156688. */
  156689. confidenceValue: number;
  156690. }
  156691. /**
  156692. * The feature point system is used to detect feature points from real world geometry.
  156693. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156694. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156695. */
  156696. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156697. private _enabled;
  156698. private _featurePointCloud;
  156699. /**
  156700. * The module's name
  156701. */
  156702. static readonly Name: string;
  156703. /**
  156704. * The (Babylon) version of this module.
  156705. * This is an integer representing the implementation version.
  156706. * This number does not correspond to the WebXR specs version
  156707. */
  156708. static readonly Version: number;
  156709. /**
  156710. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156711. * Will notify the observers about which feature points have been added.
  156712. */
  156713. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156714. /**
  156715. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156716. * Will notify the observers about which feature points have been updated.
  156717. */
  156718. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156719. /**
  156720. * The current feature point cloud maintained across frames.
  156721. */
  156722. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156723. /**
  156724. * construct the feature point system
  156725. * @param _xrSessionManager an instance of xr Session manager
  156726. */
  156727. constructor(_xrSessionManager: WebXRSessionManager);
  156728. /**
  156729. * Detach this feature.
  156730. * Will usually be called by the features manager
  156731. *
  156732. * @returns true if successful.
  156733. */
  156734. detach(): boolean;
  156735. /**
  156736. * Dispose this feature and all of the resources attached
  156737. */
  156738. dispose(): void;
  156739. /**
  156740. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156741. */
  156742. protected _onXRFrame(frame: XRFrame): void;
  156743. /**
  156744. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156745. */
  156746. private _init;
  156747. }
  156748. }
  156749. declare module BABYLON {
  156750. /**
  156751. * Configuration interface for the hand tracking feature
  156752. */
  156753. export interface IWebXRHandTrackingOptions {
  156754. /**
  156755. * The xrInput that will be used as source for new hands
  156756. */
  156757. xrInput: WebXRInput;
  156758. /**
  156759. * Configuration object for the joint meshes
  156760. */
  156761. jointMeshes?: {
  156762. /**
  156763. * Should the meshes created be invisible (defaults to false)
  156764. */
  156765. invisible?: boolean;
  156766. /**
  156767. * A source mesh to be used to create instances. Defaults to a sphere.
  156768. * This mesh will be the source for all other (25) meshes.
  156769. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156770. */
  156771. sourceMesh?: Mesh;
  156772. /**
  156773. * This function will be called after a mesh was created for a specific joint.
  156774. * Using this function you can either manipulate the instance or return a new mesh.
  156775. * When returning a new mesh the instance created before will be disposed
  156776. */
  156777. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156778. /**
  156779. * Should the source mesh stay visible. Defaults to false
  156780. */
  156781. keepOriginalVisible?: boolean;
  156782. /**
  156783. * Scale factor for all instances (defaults to 2)
  156784. */
  156785. scaleFactor?: number;
  156786. /**
  156787. * Should each instance have its own physics impostor
  156788. */
  156789. enablePhysics?: boolean;
  156790. /**
  156791. * If enabled, override default physics properties
  156792. */
  156793. physicsProps?: {
  156794. friction?: number;
  156795. restitution?: number;
  156796. impostorType?: number;
  156797. };
  156798. /**
  156799. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156800. */
  156801. handMesh?: AbstractMesh;
  156802. };
  156803. }
  156804. /**
  156805. * Parts of the hands divided to writs and finger names
  156806. */
  156807. export const enum HandPart {
  156808. /**
  156809. * HandPart - Wrist
  156810. */
  156811. WRIST = "wrist",
  156812. /**
  156813. * HandPart - The THumb
  156814. */
  156815. THUMB = "thumb",
  156816. /**
  156817. * HandPart - Index finger
  156818. */
  156819. INDEX = "index",
  156820. /**
  156821. * HandPart - Middle finger
  156822. */
  156823. MIDDLE = "middle",
  156824. /**
  156825. * HandPart - Ring finger
  156826. */
  156827. RING = "ring",
  156828. /**
  156829. * HandPart - Little finger
  156830. */
  156831. LITTLE = "little"
  156832. }
  156833. /**
  156834. * Representing a single hand (with its corresponding native XRHand object)
  156835. */
  156836. export class WebXRHand implements IDisposable {
  156837. /** the controller to which the hand correlates */
  156838. readonly xrController: WebXRInputSource;
  156839. /** the meshes to be used to track the hand joints */
  156840. readonly trackedMeshes: AbstractMesh[];
  156841. /**
  156842. * Hand-parts definition (key is HandPart)
  156843. */
  156844. handPartsDefinition: {
  156845. [key: string]: number[];
  156846. };
  156847. /**
  156848. * Populate the HandPartsDefinition object.
  156849. * This is called as a side effect since certain browsers don't have XRHand defined.
  156850. */
  156851. private generateHandPartsDefinition;
  156852. /**
  156853. * Construct a new hand object
  156854. * @param xrController the controller to which the hand correlates
  156855. * @param trackedMeshes the meshes to be used to track the hand joints
  156856. */
  156857. constructor(
  156858. /** the controller to which the hand correlates */
  156859. xrController: WebXRInputSource,
  156860. /** the meshes to be used to track the hand joints */
  156861. trackedMeshes: AbstractMesh[]);
  156862. /**
  156863. * Update this hand from the latest xr frame
  156864. * @param xrFrame xrFrame to update from
  156865. * @param referenceSpace The current viewer reference space
  156866. * @param scaleFactor optional scale factor for the meshes
  156867. */
  156868. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156869. /**
  156870. * Get meshes of part of the hand
  156871. * @param part the part of hand to get
  156872. * @returns An array of meshes that correlate to the hand part requested
  156873. */
  156874. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156875. /**
  156876. * Dispose this Hand object
  156877. */
  156878. dispose(): void;
  156879. }
  156880. /**
  156881. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156882. */
  156883. export class WebXRHandTracking extends WebXRAbstractFeature {
  156884. /**
  156885. * options to use when constructing this feature
  156886. */
  156887. readonly options: IWebXRHandTrackingOptions;
  156888. private static _idCounter;
  156889. /**
  156890. * The module's name
  156891. */
  156892. static readonly Name: string;
  156893. /**
  156894. * The (Babylon) version of this module.
  156895. * This is an integer representing the implementation version.
  156896. * This number does not correspond to the WebXR specs version
  156897. */
  156898. static readonly Version: number;
  156899. /**
  156900. * This observable will notify registered observers when a new hand object was added and initialized
  156901. */
  156902. onHandAddedObservable: Observable<WebXRHand>;
  156903. /**
  156904. * This observable will notify its observers right before the hand object is disposed
  156905. */
  156906. onHandRemovedObservable: Observable<WebXRHand>;
  156907. private _hands;
  156908. /**
  156909. * Creates a new instance of the hit test feature
  156910. * @param _xrSessionManager an instance of WebXRSessionManager
  156911. * @param options options to use when constructing this feature
  156912. */
  156913. constructor(_xrSessionManager: WebXRSessionManager,
  156914. /**
  156915. * options to use when constructing this feature
  156916. */
  156917. options: IWebXRHandTrackingOptions);
  156918. /**
  156919. * Check if the needed objects are defined.
  156920. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156921. */
  156922. isCompatible(): boolean;
  156923. /**
  156924. * attach this feature
  156925. * Will usually be called by the features manager
  156926. *
  156927. * @returns true if successful.
  156928. */
  156929. attach(): boolean;
  156930. /**
  156931. * detach this feature.
  156932. * Will usually be called by the features manager
  156933. *
  156934. * @returns true if successful.
  156935. */
  156936. detach(): boolean;
  156937. /**
  156938. * Dispose this feature and all of the resources attached
  156939. */
  156940. dispose(): void;
  156941. /**
  156942. * Get the hand object according to the controller id
  156943. * @param controllerId the controller id to which we want to get the hand
  156944. * @returns null if not found or the WebXRHand object if found
  156945. */
  156946. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156947. /**
  156948. * Get a hand object according to the requested handedness
  156949. * @param handedness the handedness to request
  156950. * @returns null if not found or the WebXRHand object if found
  156951. */
  156952. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156953. protected _onXRFrame(_xrFrame: XRFrame): void;
  156954. private _attachHand;
  156955. private _detachHand;
  156956. }
  156957. }
  156958. declare module BABYLON {
  156959. /**
  156960. * The motion controller class for all microsoft mixed reality controllers
  156961. */
  156962. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156963. protected readonly _mapping: {
  156964. defaultButton: {
  156965. valueNodeName: string;
  156966. unpressedNodeName: string;
  156967. pressedNodeName: string;
  156968. };
  156969. defaultAxis: {
  156970. valueNodeName: string;
  156971. minNodeName: string;
  156972. maxNodeName: string;
  156973. };
  156974. buttons: {
  156975. "xr-standard-trigger": {
  156976. rootNodeName: string;
  156977. componentProperty: string;
  156978. states: string[];
  156979. };
  156980. "xr-standard-squeeze": {
  156981. rootNodeName: string;
  156982. componentProperty: string;
  156983. states: string[];
  156984. };
  156985. "xr-standard-touchpad": {
  156986. rootNodeName: string;
  156987. labelAnchorNodeName: string;
  156988. touchPointNodeName: string;
  156989. };
  156990. "xr-standard-thumbstick": {
  156991. rootNodeName: string;
  156992. componentProperty: string;
  156993. states: string[];
  156994. };
  156995. };
  156996. axes: {
  156997. "xr-standard-touchpad": {
  156998. "x-axis": {
  156999. rootNodeName: string;
  157000. };
  157001. "y-axis": {
  157002. rootNodeName: string;
  157003. };
  157004. };
  157005. "xr-standard-thumbstick": {
  157006. "x-axis": {
  157007. rootNodeName: string;
  157008. };
  157009. "y-axis": {
  157010. rootNodeName: string;
  157011. };
  157012. };
  157013. };
  157014. };
  157015. /**
  157016. * The base url used to load the left and right controller models
  157017. */
  157018. static MODEL_BASE_URL: string;
  157019. /**
  157020. * The name of the left controller model file
  157021. */
  157022. static MODEL_LEFT_FILENAME: string;
  157023. /**
  157024. * The name of the right controller model file
  157025. */
  157026. static MODEL_RIGHT_FILENAME: string;
  157027. profileId: string;
  157028. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157029. protected _getFilenameAndPath(): {
  157030. filename: string;
  157031. path: string;
  157032. };
  157033. protected _getModelLoadingConstraints(): boolean;
  157034. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157035. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157036. protected _updateModel(): void;
  157037. }
  157038. }
  157039. declare module BABYLON {
  157040. /**
  157041. * The motion controller class for oculus touch (quest, rift).
  157042. * This class supports legacy mapping as well the standard xr mapping
  157043. */
  157044. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157045. private _forceLegacyControllers;
  157046. private _modelRootNode;
  157047. /**
  157048. * The base url used to load the left and right controller models
  157049. */
  157050. static MODEL_BASE_URL: string;
  157051. /**
  157052. * The name of the left controller model file
  157053. */
  157054. static MODEL_LEFT_FILENAME: string;
  157055. /**
  157056. * The name of the right controller model file
  157057. */
  157058. static MODEL_RIGHT_FILENAME: string;
  157059. /**
  157060. * Base Url for the Quest controller model.
  157061. */
  157062. static QUEST_MODEL_BASE_URL: string;
  157063. profileId: string;
  157064. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157065. protected _getFilenameAndPath(): {
  157066. filename: string;
  157067. path: string;
  157068. };
  157069. protected _getModelLoadingConstraints(): boolean;
  157070. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157071. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157072. protected _updateModel(): void;
  157073. /**
  157074. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157075. * between the touch and touch 2.
  157076. */
  157077. private _isQuest;
  157078. }
  157079. }
  157080. declare module BABYLON {
  157081. /**
  157082. * The motion controller class for the standard HTC-Vive controllers
  157083. */
  157084. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157085. private _modelRootNode;
  157086. /**
  157087. * The base url used to load the left and right controller models
  157088. */
  157089. static MODEL_BASE_URL: string;
  157090. /**
  157091. * File name for the controller model.
  157092. */
  157093. static MODEL_FILENAME: string;
  157094. profileId: string;
  157095. /**
  157096. * Create a new Vive motion controller object
  157097. * @param scene the scene to use to create this controller
  157098. * @param gamepadObject the corresponding gamepad object
  157099. * @param handedness the handedness of the controller
  157100. */
  157101. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157102. protected _getFilenameAndPath(): {
  157103. filename: string;
  157104. path: string;
  157105. };
  157106. protected _getModelLoadingConstraints(): boolean;
  157107. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157108. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157109. protected _updateModel(): void;
  157110. }
  157111. }
  157112. declare module BABYLON {
  157113. /**
  157114. * A cursor which tracks a point on a path
  157115. */
  157116. export class PathCursor {
  157117. private path;
  157118. /**
  157119. * Stores path cursor callbacks for when an onchange event is triggered
  157120. */
  157121. private _onchange;
  157122. /**
  157123. * The value of the path cursor
  157124. */
  157125. value: number;
  157126. /**
  157127. * The animation array of the path cursor
  157128. */
  157129. animations: Animation[];
  157130. /**
  157131. * Initializes the path cursor
  157132. * @param path The path to track
  157133. */
  157134. constructor(path: Path2);
  157135. /**
  157136. * Gets the cursor point on the path
  157137. * @returns A point on the path cursor at the cursor location
  157138. */
  157139. getPoint(): Vector3;
  157140. /**
  157141. * Moves the cursor ahead by the step amount
  157142. * @param step The amount to move the cursor forward
  157143. * @returns This path cursor
  157144. */
  157145. moveAhead(step?: number): PathCursor;
  157146. /**
  157147. * Moves the cursor behind by the step amount
  157148. * @param step The amount to move the cursor back
  157149. * @returns This path cursor
  157150. */
  157151. moveBack(step?: number): PathCursor;
  157152. /**
  157153. * Moves the cursor by the step amount
  157154. * If the step amount is greater than one, an exception is thrown
  157155. * @param step The amount to move the cursor
  157156. * @returns This path cursor
  157157. */
  157158. move(step: number): PathCursor;
  157159. /**
  157160. * Ensures that the value is limited between zero and one
  157161. * @returns This path cursor
  157162. */
  157163. private ensureLimits;
  157164. /**
  157165. * Runs onchange callbacks on change (used by the animation engine)
  157166. * @returns This path cursor
  157167. */
  157168. private raiseOnChange;
  157169. /**
  157170. * Executes a function on change
  157171. * @param f A path cursor onchange callback
  157172. * @returns This path cursor
  157173. */
  157174. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157175. }
  157176. }
  157177. declare module BABYLON {
  157178. /** @hidden */
  157179. export var blurPixelShader: {
  157180. name: string;
  157181. shader: string;
  157182. };
  157183. }
  157184. declare module BABYLON {
  157185. /** @hidden */
  157186. export var pointCloudVertexDeclaration: {
  157187. name: string;
  157188. shader: string;
  157189. };
  157190. }
  157191. // Mixins
  157192. interface Window {
  157193. mozIndexedDB: IDBFactory;
  157194. webkitIndexedDB: IDBFactory;
  157195. msIndexedDB: IDBFactory;
  157196. webkitURL: typeof URL;
  157197. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157198. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157199. WebGLRenderingContext: WebGLRenderingContext;
  157200. MSGesture: MSGesture;
  157201. CANNON: any;
  157202. AudioContext: AudioContext;
  157203. webkitAudioContext: AudioContext;
  157204. PointerEvent: any;
  157205. Math: Math;
  157206. Uint8Array: Uint8ArrayConstructor;
  157207. Float32Array: Float32ArrayConstructor;
  157208. mozURL: typeof URL;
  157209. msURL: typeof URL;
  157210. VRFrameData: any; // WebVR, from specs 1.1
  157211. DracoDecoderModule: any;
  157212. setImmediate(handler: (...args: any[]) => void): number;
  157213. }
  157214. interface HTMLCanvasElement {
  157215. requestPointerLock(): void;
  157216. msRequestPointerLock?(): void;
  157217. mozRequestPointerLock?(): void;
  157218. webkitRequestPointerLock?(): void;
  157219. /** Track wether a record is in progress */
  157220. isRecording: boolean;
  157221. /** Capture Stream method defined by some browsers */
  157222. captureStream(fps?: number): MediaStream;
  157223. }
  157224. interface CanvasRenderingContext2D {
  157225. msImageSmoothingEnabled: boolean;
  157226. }
  157227. interface MouseEvent {
  157228. mozMovementX: number;
  157229. mozMovementY: number;
  157230. webkitMovementX: number;
  157231. webkitMovementY: number;
  157232. msMovementX: number;
  157233. msMovementY: number;
  157234. }
  157235. interface Navigator {
  157236. mozGetVRDevices: (any: any) => any;
  157237. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157238. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157239. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157240. webkitGetGamepads(): Gamepad[];
  157241. msGetGamepads(): Gamepad[];
  157242. webkitGamepads(): Gamepad[];
  157243. }
  157244. interface HTMLVideoElement {
  157245. mozSrcObject: any;
  157246. }
  157247. interface Math {
  157248. fround(x: number): number;
  157249. imul(a: number, b: number): number;
  157250. }
  157251. interface WebGLRenderingContext {
  157252. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157253. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157254. vertexAttribDivisor(index: number, divisor: number): void;
  157255. createVertexArray(): any;
  157256. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157257. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157258. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157259. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157260. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157261. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157262. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157263. // Queries
  157264. createQuery(): WebGLQuery;
  157265. deleteQuery(query: WebGLQuery): void;
  157266. beginQuery(target: number, query: WebGLQuery): void;
  157267. endQuery(target: number): void;
  157268. getQueryParameter(query: WebGLQuery, pname: number): any;
  157269. getQuery(target: number, pname: number): any;
  157270. MAX_SAMPLES: number;
  157271. RGBA8: number;
  157272. READ_FRAMEBUFFER: number;
  157273. DRAW_FRAMEBUFFER: number;
  157274. UNIFORM_BUFFER: number;
  157275. HALF_FLOAT_OES: number;
  157276. RGBA16F: number;
  157277. RGBA32F: number;
  157278. R32F: number;
  157279. RG32F: number;
  157280. RGB32F: number;
  157281. R16F: number;
  157282. RG16F: number;
  157283. RGB16F: number;
  157284. RED: number;
  157285. RG: number;
  157286. R8: number;
  157287. RG8: number;
  157288. UNSIGNED_INT_24_8: number;
  157289. DEPTH24_STENCIL8: number;
  157290. MIN: number;
  157291. MAX: number;
  157292. /* Multiple Render Targets */
  157293. drawBuffers(buffers: number[]): void;
  157294. readBuffer(src: number): void;
  157295. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157296. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157297. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157298. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157299. // Occlusion Query
  157300. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157301. ANY_SAMPLES_PASSED: number;
  157302. QUERY_RESULT_AVAILABLE: number;
  157303. QUERY_RESULT: number;
  157304. }
  157305. interface WebGLProgram {
  157306. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157307. }
  157308. interface EXT_disjoint_timer_query {
  157309. QUERY_COUNTER_BITS_EXT: number;
  157310. TIME_ELAPSED_EXT: number;
  157311. TIMESTAMP_EXT: number;
  157312. GPU_DISJOINT_EXT: number;
  157313. QUERY_RESULT_EXT: number;
  157314. QUERY_RESULT_AVAILABLE_EXT: number;
  157315. queryCounterEXT(query: WebGLQuery, target: number): void;
  157316. createQueryEXT(): WebGLQuery;
  157317. beginQueryEXT(target: number, query: WebGLQuery): void;
  157318. endQueryEXT(target: number): void;
  157319. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157320. deleteQueryEXT(query: WebGLQuery): void;
  157321. }
  157322. interface WebGLUniformLocation {
  157323. _currentState: any;
  157324. }
  157325. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157326. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157327. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157328. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157329. interface WebGLRenderingContext {
  157330. readonly RASTERIZER_DISCARD: number;
  157331. readonly DEPTH_COMPONENT24: number;
  157332. readonly TEXTURE_3D: number;
  157333. readonly TEXTURE_2D_ARRAY: number;
  157334. readonly TEXTURE_COMPARE_FUNC: number;
  157335. readonly TEXTURE_COMPARE_MODE: number;
  157336. readonly COMPARE_REF_TO_TEXTURE: number;
  157337. readonly TEXTURE_WRAP_R: number;
  157338. readonly HALF_FLOAT: number;
  157339. readonly RGB8: number;
  157340. readonly RED_INTEGER: number;
  157341. readonly RG_INTEGER: number;
  157342. readonly RGB_INTEGER: number;
  157343. readonly RGBA_INTEGER: number;
  157344. readonly R8_SNORM: number;
  157345. readonly RG8_SNORM: number;
  157346. readonly RGB8_SNORM: number;
  157347. readonly RGBA8_SNORM: number;
  157348. readonly R8I: number;
  157349. readonly RG8I: number;
  157350. readonly RGB8I: number;
  157351. readonly RGBA8I: number;
  157352. readonly R8UI: number;
  157353. readonly RG8UI: number;
  157354. readonly RGB8UI: number;
  157355. readonly RGBA8UI: number;
  157356. readonly R16I: number;
  157357. readonly RG16I: number;
  157358. readonly RGB16I: number;
  157359. readonly RGBA16I: number;
  157360. readonly R16UI: number;
  157361. readonly RG16UI: number;
  157362. readonly RGB16UI: number;
  157363. readonly RGBA16UI: number;
  157364. readonly R32I: number;
  157365. readonly RG32I: number;
  157366. readonly RGB32I: number;
  157367. readonly RGBA32I: number;
  157368. readonly R32UI: number;
  157369. readonly RG32UI: number;
  157370. readonly RGB32UI: number;
  157371. readonly RGBA32UI: number;
  157372. readonly RGB10_A2UI: number;
  157373. readonly R11F_G11F_B10F: number;
  157374. readonly RGB9_E5: number;
  157375. readonly RGB10_A2: number;
  157376. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157377. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157378. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157379. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157380. readonly DEPTH_COMPONENT32F: number;
  157381. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157382. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157383. 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;
  157384. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157385. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157386. readonly TRANSFORM_FEEDBACK: number;
  157387. readonly INTERLEAVED_ATTRIBS: number;
  157388. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157389. createTransformFeedback(): WebGLTransformFeedback;
  157390. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157391. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157392. beginTransformFeedback(primitiveMode: number): void;
  157393. endTransformFeedback(): void;
  157394. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157395. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157396. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157397. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157398. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157399. }
  157400. interface ImageBitmap {
  157401. readonly width: number;
  157402. readonly height: number;
  157403. close(): void;
  157404. }
  157405. interface WebGLQuery extends WebGLObject {
  157406. }
  157407. declare var WebGLQuery: {
  157408. prototype: WebGLQuery;
  157409. new(): WebGLQuery;
  157410. };
  157411. interface WebGLSampler extends WebGLObject {
  157412. }
  157413. declare var WebGLSampler: {
  157414. prototype: WebGLSampler;
  157415. new(): WebGLSampler;
  157416. };
  157417. interface WebGLSync extends WebGLObject {
  157418. }
  157419. declare var WebGLSync: {
  157420. prototype: WebGLSync;
  157421. new(): WebGLSync;
  157422. };
  157423. interface WebGLTransformFeedback extends WebGLObject {
  157424. }
  157425. declare var WebGLTransformFeedback: {
  157426. prototype: WebGLTransformFeedback;
  157427. new(): WebGLTransformFeedback;
  157428. };
  157429. interface WebGLVertexArrayObject extends WebGLObject {
  157430. }
  157431. declare var WebGLVertexArrayObject: {
  157432. prototype: WebGLVertexArrayObject;
  157433. new(): WebGLVertexArrayObject;
  157434. };
  157435. // Type definitions for WebVR API
  157436. // Project: https://w3c.github.io/webvr/
  157437. // Definitions by: six a <https://github.com/lostfictions>
  157438. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157439. interface VRDisplay extends EventTarget {
  157440. /**
  157441. * Dictionary of capabilities describing the VRDisplay.
  157442. */
  157443. readonly capabilities: VRDisplayCapabilities;
  157444. /**
  157445. * z-depth defining the far plane of the eye view frustum
  157446. * enables mapping of values in the render target depth
  157447. * attachment to scene coordinates. Initially set to 10000.0.
  157448. */
  157449. depthFar: number;
  157450. /**
  157451. * z-depth defining the near plane of the eye view frustum
  157452. * enables mapping of values in the render target depth
  157453. * attachment to scene coordinates. Initially set to 0.01.
  157454. */
  157455. depthNear: number;
  157456. /**
  157457. * An identifier for this distinct VRDisplay. Used as an
  157458. * association point in the Gamepad API.
  157459. */
  157460. readonly displayId: number;
  157461. /**
  157462. * A display name, a user-readable name identifying it.
  157463. */
  157464. readonly displayName: string;
  157465. readonly isConnected: boolean;
  157466. readonly isPresenting: boolean;
  157467. /**
  157468. * If this VRDisplay supports room-scale experiences, the optional
  157469. * stage attribute contains details on the room-scale parameters.
  157470. */
  157471. readonly stageParameters: VRStageParameters | null;
  157472. /**
  157473. * Passing the value returned by `requestAnimationFrame` to
  157474. * `cancelAnimationFrame` will unregister the callback.
  157475. * @param handle Define the hanle of the request to cancel
  157476. */
  157477. cancelAnimationFrame(handle: number): void;
  157478. /**
  157479. * Stops presenting to the VRDisplay.
  157480. * @returns a promise to know when it stopped
  157481. */
  157482. exitPresent(): Promise<void>;
  157483. /**
  157484. * Return the current VREyeParameters for the given eye.
  157485. * @param whichEye Define the eye we want the parameter for
  157486. * @returns the eye parameters
  157487. */
  157488. getEyeParameters(whichEye: string): VREyeParameters;
  157489. /**
  157490. * Populates the passed VRFrameData with the information required to render
  157491. * the current frame.
  157492. * @param frameData Define the data structure to populate
  157493. * @returns true if ok otherwise false
  157494. */
  157495. getFrameData(frameData: VRFrameData): boolean;
  157496. /**
  157497. * Get the layers currently being presented.
  157498. * @returns the list of VR layers
  157499. */
  157500. getLayers(): VRLayer[];
  157501. /**
  157502. * Return a VRPose containing the future predicted pose of the VRDisplay
  157503. * when the current frame will be presented. The value returned will not
  157504. * change until JavaScript has returned control to the browser.
  157505. *
  157506. * The VRPose will contain the position, orientation, velocity,
  157507. * and acceleration of each of these properties.
  157508. * @returns the pose object
  157509. */
  157510. getPose(): VRPose;
  157511. /**
  157512. * Return the current instantaneous pose of the VRDisplay, with no
  157513. * prediction applied.
  157514. * @returns the current instantaneous pose
  157515. */
  157516. getImmediatePose(): VRPose;
  157517. /**
  157518. * The callback passed to `requestAnimationFrame` will be called
  157519. * any time a new frame should be rendered. When the VRDisplay is
  157520. * presenting the callback will be called at the native refresh
  157521. * rate of the HMD. When not presenting this function acts
  157522. * identically to how window.requestAnimationFrame acts. Content should
  157523. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157524. * asynchronously from other displays and at differing refresh rates.
  157525. * @param callback Define the eaction to run next frame
  157526. * @returns the request handle it
  157527. */
  157528. requestAnimationFrame(callback: FrameRequestCallback): number;
  157529. /**
  157530. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157531. * Repeat calls while already presenting will update the VRLayers being displayed.
  157532. * @param layers Define the list of layer to present
  157533. * @returns a promise to know when the request has been fulfilled
  157534. */
  157535. requestPresent(layers: VRLayer[]): Promise<void>;
  157536. /**
  157537. * Reset the pose for this display, treating its current position and
  157538. * orientation as the "origin/zero" values. VRPose.position,
  157539. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157540. * updated when calling resetPose(). This should be called in only
  157541. * sitting-space experiences.
  157542. */
  157543. resetPose(): void;
  157544. /**
  157545. * The VRLayer provided to the VRDisplay will be captured and presented
  157546. * in the HMD. Calling this function has the same effect on the source
  157547. * canvas as any other operation that uses its source image, and canvases
  157548. * created without preserveDrawingBuffer set to true will be cleared.
  157549. * @param pose Define the pose to submit
  157550. */
  157551. submitFrame(pose?: VRPose): void;
  157552. }
  157553. declare var VRDisplay: {
  157554. prototype: VRDisplay;
  157555. new(): VRDisplay;
  157556. };
  157557. interface VRLayer {
  157558. leftBounds?: number[] | Float32Array | null;
  157559. rightBounds?: number[] | Float32Array | null;
  157560. source?: HTMLCanvasElement | null;
  157561. }
  157562. interface VRDisplayCapabilities {
  157563. readonly canPresent: boolean;
  157564. readonly hasExternalDisplay: boolean;
  157565. readonly hasOrientation: boolean;
  157566. readonly hasPosition: boolean;
  157567. readonly maxLayers: number;
  157568. }
  157569. interface VREyeParameters {
  157570. /** @deprecated */
  157571. readonly fieldOfView: VRFieldOfView;
  157572. readonly offset: Float32Array;
  157573. readonly renderHeight: number;
  157574. readonly renderWidth: number;
  157575. }
  157576. interface VRFieldOfView {
  157577. readonly downDegrees: number;
  157578. readonly leftDegrees: number;
  157579. readonly rightDegrees: number;
  157580. readonly upDegrees: number;
  157581. }
  157582. interface VRFrameData {
  157583. readonly leftProjectionMatrix: Float32Array;
  157584. readonly leftViewMatrix: Float32Array;
  157585. readonly pose: VRPose;
  157586. readonly rightProjectionMatrix: Float32Array;
  157587. readonly rightViewMatrix: Float32Array;
  157588. readonly timestamp: number;
  157589. }
  157590. interface VRPose {
  157591. readonly angularAcceleration: Float32Array | null;
  157592. readonly angularVelocity: Float32Array | null;
  157593. readonly linearAcceleration: Float32Array | null;
  157594. readonly linearVelocity: Float32Array | null;
  157595. readonly orientation: Float32Array | null;
  157596. readonly position: Float32Array | null;
  157597. readonly timestamp: number;
  157598. }
  157599. interface VRStageParameters {
  157600. sittingToStandingTransform?: Float32Array;
  157601. sizeX?: number;
  157602. sizeY?: number;
  157603. }
  157604. interface Navigator {
  157605. getVRDisplays(): Promise<VRDisplay[]>;
  157606. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157607. }
  157608. interface Window {
  157609. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157610. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157611. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157612. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157613. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157614. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157615. }
  157616. interface Gamepad {
  157617. readonly displayId: number;
  157618. }
  157619. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157620. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157621. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157622. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157623. type XRHandedness = "none" | "left" | "right";
  157624. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157625. type XREye = "none" | "left" | "right";
  157626. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157627. interface XRSpace extends EventTarget {}
  157628. interface XRRenderState {
  157629. depthNear?: number;
  157630. depthFar?: number;
  157631. inlineVerticalFieldOfView?: number;
  157632. baseLayer?: XRWebGLLayer;
  157633. }
  157634. interface XRInputSource {
  157635. handedness: XRHandedness;
  157636. targetRayMode: XRTargetRayMode;
  157637. targetRaySpace: XRSpace;
  157638. gripSpace: XRSpace | undefined;
  157639. gamepad: Gamepad | undefined;
  157640. profiles: Array<string>;
  157641. hand: XRHand | undefined;
  157642. }
  157643. interface XRSessionInit {
  157644. optionalFeatures?: string[];
  157645. requiredFeatures?: string[];
  157646. }
  157647. interface XRSession {
  157648. addEventListener: Function;
  157649. removeEventListener: Function;
  157650. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157651. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157652. requestAnimationFrame: Function;
  157653. end(): Promise<void>;
  157654. renderState: XRRenderState;
  157655. inputSources: Array<XRInputSource>;
  157656. // hit test
  157657. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157658. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157659. // legacy AR hit test
  157660. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157661. // legacy plane detection
  157662. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157663. }
  157664. interface XRReferenceSpace extends XRSpace {
  157665. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157666. onreset: any;
  157667. }
  157668. type XRPlaneSet = Set<XRPlane>;
  157669. type XRAnchorSet = Set<XRAnchor>;
  157670. interface XRFrame {
  157671. session: XRSession;
  157672. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157673. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157674. // AR
  157675. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157676. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157677. // Anchors
  157678. trackedAnchors?: XRAnchorSet;
  157679. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157680. // Planes
  157681. worldInformation: {
  157682. detectedPlanes?: XRPlaneSet;
  157683. };
  157684. // Hand tracking
  157685. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157686. }
  157687. interface XRViewerPose extends XRPose {
  157688. views: Array<XRView>;
  157689. }
  157690. interface XRPose {
  157691. transform: XRRigidTransform;
  157692. emulatedPosition: boolean;
  157693. }
  157694. interface XRWebGLLayerOptions {
  157695. antialias?: boolean;
  157696. depth?: boolean;
  157697. stencil?: boolean;
  157698. alpha?: boolean;
  157699. multiview?: boolean;
  157700. framebufferScaleFactor?: number;
  157701. }
  157702. declare var XRWebGLLayer: {
  157703. prototype: XRWebGLLayer;
  157704. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157705. };
  157706. interface XRWebGLLayer {
  157707. framebuffer: WebGLFramebuffer;
  157708. framebufferWidth: number;
  157709. framebufferHeight: number;
  157710. getViewport: Function;
  157711. }
  157712. declare class XRRigidTransform {
  157713. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157714. position: DOMPointReadOnly;
  157715. orientation: DOMPointReadOnly;
  157716. matrix: Float32Array;
  157717. inverse: XRRigidTransform;
  157718. }
  157719. interface XRView {
  157720. eye: XREye;
  157721. projectionMatrix: Float32Array;
  157722. transform: XRRigidTransform;
  157723. }
  157724. interface XRInputSourceChangeEvent {
  157725. session: XRSession;
  157726. removed: Array<XRInputSource>;
  157727. added: Array<XRInputSource>;
  157728. }
  157729. interface XRInputSourceEvent extends Event {
  157730. readonly frame: XRFrame;
  157731. readonly inputSource: XRInputSource;
  157732. }
  157733. // Experimental(er) features
  157734. declare class XRRay {
  157735. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157736. origin: DOMPointReadOnly;
  157737. direction: DOMPointReadOnly;
  157738. matrix: Float32Array;
  157739. }
  157740. declare enum XRHitTestTrackableType {
  157741. "point",
  157742. "plane",
  157743. "mesh",
  157744. }
  157745. interface XRHitResult {
  157746. hitMatrix: Float32Array;
  157747. }
  157748. interface XRTransientInputHitTestResult {
  157749. readonly inputSource: XRInputSource;
  157750. readonly results: Array<XRHitTestResult>;
  157751. }
  157752. interface XRHitTestResult {
  157753. getPose(baseSpace: XRSpace): XRPose | undefined;
  157754. // When anchor system is enabled
  157755. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157756. }
  157757. interface XRHitTestSource {
  157758. cancel(): void;
  157759. }
  157760. interface XRTransientInputHitTestSource {
  157761. cancel(): void;
  157762. }
  157763. interface XRHitTestOptionsInit {
  157764. space: XRSpace;
  157765. entityTypes?: Array<XRHitTestTrackableType>;
  157766. offsetRay?: XRRay;
  157767. }
  157768. interface XRTransientInputHitTestOptionsInit {
  157769. profile: string;
  157770. entityTypes?: Array<XRHitTestTrackableType>;
  157771. offsetRay?: XRRay;
  157772. }
  157773. interface XRAnchor {
  157774. anchorSpace: XRSpace;
  157775. delete(): void;
  157776. }
  157777. interface XRPlane {
  157778. orientation: "Horizontal" | "Vertical";
  157779. planeSpace: XRSpace;
  157780. polygon: Array<DOMPointReadOnly>;
  157781. lastChangedTime: number;
  157782. }
  157783. interface XRJointSpace extends XRSpace {}
  157784. interface XRJointPose extends XRPose {
  157785. radius: number | undefined;
  157786. }
  157787. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157788. readonly length: number;
  157789. [index: number]: XRJointSpace;
  157790. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157791. readonly WRIST: number;
  157792. readonly THUMB_METACARPAL: number;
  157793. readonly THUMB_PHALANX_PROXIMAL: number;
  157794. readonly THUMB_PHALANX_DISTAL: number;
  157795. readonly THUMB_PHALANX_TIP: number;
  157796. readonly INDEX_METACARPAL: number;
  157797. readonly INDEX_PHALANX_PROXIMAL: number;
  157798. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157799. readonly INDEX_PHALANX_DISTAL: number;
  157800. readonly INDEX_PHALANX_TIP: number;
  157801. readonly MIDDLE_METACARPAL: number;
  157802. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157803. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157804. readonly MIDDLE_PHALANX_DISTAL: number;
  157805. readonly MIDDLE_PHALANX_TIP: number;
  157806. readonly RING_METACARPAL: number;
  157807. readonly RING_PHALANX_PROXIMAL: number;
  157808. readonly RING_PHALANX_INTERMEDIATE: number;
  157809. readonly RING_PHALANX_DISTAL: number;
  157810. readonly RING_PHALANX_TIP: number;
  157811. readonly LITTLE_METACARPAL: number;
  157812. readonly LITTLE_PHALANX_PROXIMAL: number;
  157813. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157814. readonly LITTLE_PHALANX_DISTAL: number;
  157815. readonly LITTLE_PHALANX_TIP: number;
  157816. }
  157817. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157818. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157819. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157820. interface XRSession {
  157821. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157822. }
  157823. interface XRFrame {
  157824. featurePointCloud? : Array<number>;
  157825. }